ekaterinailin / AltaiPony

Find flares in Kepler and TESS light curves. Notebooks for quickstart inside.
https://altaipony.readthedocs.io
MIT License
26 stars 10 forks source link

savgol detrending failure #80

Open jlvansaders opened 1 year ago

jlvansaders commented 1 year ago

I'm trying to get altaipony up and running on my machine, and I seem to be having a lot of issues with the savgol detrending. I have checked that all of my packages are present and within the versions listed in requirements.txt. I have verified that the lightcurve downloaded from MAST actually contains data that looks reasonable. I am following the TESS lightcurve flare tutorial, and this is where I hit trouble (probably something silly on my part!) I'm running into the same issue regardless of target:

flc = from_mast("TIC 1539914", mission="TESS", exptime=120)
/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
1% (197/17337) of the cadences will be ignored due to the quality mask (quality_bitmask=175).
1% (197/17337) of the cadences will be ignored due to the quality mask (quality_bitmask=175).
0% (52/17395) of the cadences will be ignored due to the quality mask (quality_bitmask=175).
0% (52/17395) of the cadences will be ignored due to the quality mask (quality_bitmask=175).

flcd = flc[1].detrend("savgol")
/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
  and should_run_async(code)
Traceback (most recent call last):

  File "<ipython-input-54-903704850a60>", line 1, in <module>
    flcd = flc[1].detrend("savgol")

  File "/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/altaipony/flarelc.py", line 342, in detrend
    new_lc =  detrend_savgol(new_lc, **kwargs)

  File "/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/altaipony/altai.py", line 261, in detrend_savgol
    ok = np.where(sigma_clip(lc.flux.value[le:ri], **kwargs))[0] + le

  File "/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/altaipony/utils.py", line 167, in sigma_clip
    med, sig = medsig(a[mask])

  File "/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/altaipony/utils.py", line 108, in medsig
    med = np.median(a[l])

  File "<__array_function__ internals>", line 200, in median

  File "/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/astropy/utils/masked/core.py", line 830, in __array_function__
    dispatched_result = dispatched_function(*args, **kwargs)

  File "/Users/jvansaders/opt/anaconda3/envs/isochrones/lib/python3.8/site-packages/astropy/utils/masked/function_helpers.py", line 580, in median
    r, k = np.lib.function_base._ureduce(

TypeError: iteration over a 0-d array
jlvansaders commented 1 year ago

Found a fix: needs a np.array() around the lc object in 261 with lightkurve v5