grd349 / PBjam

A repo for our peak baggin code and tips on jam
MIT License
17 stars 6 forks source link

Example in documentation not working, maybe because of Lightkurve 2? #260

Closed warrickball closed 3 years ago

warrickball commented 3 years ago

I just tried peak bagging a star and started getting errors, so I thought I'd take a step back and at least try the quick-start example in the documentation:

import pbjam as pb
sess = pb.session(ID='KIC4448777',
                  numax=(220.0, 3.0),
                  dnu=(16.97, 0.05),
                  teff=(4750, 250),
                  bp_rp=(1.34, 0.1),
                  path = '.')
sess(norders = 7, make_plots=True)

This fails with the output:

WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
/home/wball/pypi/PBjam/pbjam/session.py:736: LightkurveDeprecationWarning: The search_lightcurvefile function is deprecated and may be removed in a future version.
        Use search_lightcurve() instead.
  search = lk.search_lightcurvefile(ID, cadence=lkwargs['cadence'],
Traceback (most recent call last):
  File "/home/wball/try/pbjam/boieng.py", line 4, in <module>
    sess = pb.session(ID='KIC4448777',
  File "/home/wball/pypi/PBjam/pbjam/session.py", line 574, in __init__
    vardf.at[i, 'timeseries'] = _lc_to_lk(vardf.loc[i, 'ID'], 
  File "/home/wball/pypi/PBjam/pbjam/session.py", line 349, in _lc_to_lk
    tsOut = _query_lightkurve(ID, download_dir, use_cached, lkwargs)
  File "/home/wball/pypi/PBjam/pbjam/session.py", line 194, in _query_lightkurve
    lc = _load_fits(fitsFiles, lkwargs['mission'])
  File "/home/wball/pypi/PBjam/pbjam/session.py", line 675, in _load_fits
    lccol = lk.collections.LightCurveFileCollection(lcs)
AttributeError: module 'lightkurve.collections' has no attribute 'LightCurveFileCollection'

My guess is this is an issue with Lightkurve 2. For some specific versions, I'm using

I'll open issues for the other things if they persist after I can resolve this.

nielsenmb commented 3 years ago

Looks like it, I just upgraded to lightkurve 2 and things broke. I'll see if I can fix it and make a PR with a few other bug fixes.

warrickball commented 3 years ago

I just pulled master and tried running the same script again. This time I get:

WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
Traceback (most recent call last):
  File "/home/wball/try/pbjam/boeing.py", line 4, in <module>
    sess = pb.session(ID='KIC4448777',
  File "/home/wball/pypi/PBjam/pbjam/session.py", line 577, in __init__
    if any(np.isnan(vardf['exptime'])) and any((vardf['timeseries'])) and any(vardf['spectrum']):
  File "/home/wball/.local/lib/python3.9/site-packages/pandas/core/generic.py", line 1933, in __array_ufunc__
    return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
  File "/home/wball/.local/lib/python3.9/site-packages/pandas/core/arraylike.py", line 274, in array_ufunc
    result = getattr(ufunc, method)(*inputs, **kwargs)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

At least it doesn't look like a Lightkurve 2 issue anymore...

nielsenmb commented 3 years ago

I think we were a bit hasty with the PR. It's because you didn't set an exptime on the session init, and the default setting for exptime is None which throws an error in np.isnan().

Of course if you're supplying a time series manually you shouldn't need to set an exptime, so I'm not entirely sure what the best solution is.

On Thu, 20 May 2021 at 17:19, Warrick Ball @.***> wrote:

I just pulled master and tried running the same script again. This time I get:

WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions. Traceback (most recent call last): File "/home/wball/try/pbjam/boeing.py", line 4, in sess = pb.session(ID='KIC4448777', File "/home/wball/pypi/PBjam/pbjam/session.py", line 577, in init if any(np.isnan(vardf['exptime'])) and any((vardf['timeseries'])) and any(vardf['spectrum']): File "/home/wball/.local/lib/python3.9/site-packages/pandas/core/generic.py", line 1933, in __array_ufunc__ return arraylike.array_ufunc(self, ufunc, method, *inputs, *kwargs) File "/home/wball/.local/lib/python3.9/site-packages/pandas/core/arraylike.py", line 274, in array_ufunc result = getattr(ufunc, method)(inputs, **kwargs) TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

At least it doesn't look like a Lightkurve 2 issue anymore...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/grd349/PBjam/issues/260#issuecomment-845262813, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEJWO37GWJPUBV3DVAUICO3TOUZAPANCNFSM435JKXWQ .

warrickball commented 3 years ago

Gotcha. I just had a look at the quickstart example, which is how this started, and saw that it's been updated to include the exptime argument. As you say, that now works, so my issue ("quickstart example doesn't work") is resolved.