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

error in the notebook named "04_TESS_Light_Curves_With_Flares.ipynb" while injecting the fake flare #76

Open Sudip-Pramanik opened 1 year ago

Sudip-Pramanik commented 1 year ago

flcd, fakeflc = flcd.sample_flare_recovery(inject_before_detrending=True, mode="savgol",iterations=50, fakefreq=1, ampl=[1e-4, 0.5], dur=[.001/6., 0.1/6.])

When I used the above code I get that following error :

0%| |/home/sudip/anaconda3/lib/python3.9/site-packages/altaipony-2.0.1-py3.9.egg/altaipony/fakeflares.py:105: RuntimeWarning: overflow encountered in exp

Detrending fake LC:

/home/sudip/anaconda3/lib/python3.9/site-packages/numpy/lib/nanfunctions.py:1216: RuntimeWarning: Mean of empty slice return np.nanmean(a, axis, out=out, keepdims=keepdims)

ValueError Traceback (most recent call last) Input In [18], in <cell line: 1>() ----> 1 flcd, fakeflc = flcd.sample_flare_recovery(inject_before_detrending=True, mode="savgol",iterations=50, fakefreq=1, ampl=[1e-4, 0.5], dur=[.001/6., 0.1/6.])

File ~/anaconda3/lib/python3.9/site-packages/altaipony-2.0.1-py3.9.egg/altaipony/flarelc.py:519, in FlareLightCurve.sample_flare_recovery(self, iterations, inject_before_detrending, mode, func, save_lc_to_file, folder, fakefreq, save, path, detrend_kwargs, kwargs) 517 if inject_before_detrending == True: 518 LOG.info('\nDetrending fake LC:\n') --> 519 fake_lc = fake_lc.detrend(mode, func=func, detrend_kwargs) 521 fake_lc = fake_lc.find_flares(fake=True) 522 recs = fake_lc.flares

File ~/anaconda3/lib/python3.9/site-packages/altaipony-2.0.1-py3.9.egg/altaipony/flarelc.py:342, in FlareLightCurve.detrend(self, mode, save, path, de_niter, max_sigma, func, kwargs) 339 if mode == "savgol": 341 new_lc = copy.deepcopy(self) --> 342 new_lc = detrend_savgol(new_lc, kwargs) 343 if save == True: 344 new_lc.to_fits(path)

File ~/anaconda3/lib/python3.9/site-packages/altaipony-2.0.1-py3.9.egg/altaipony/altai.py:282, in detrend_savgol(lc, window_length, pad, printwl, **kwargs) 280 if printwl: 281 print(f"window length: {wl}") --> 282 flux_model_i = savgol_filter(flux, wl, 3, mode='nearest') 284 flux_diff = flux - flux_model_i + np.nanmean(flux_model_i) 285 lc.detrended_flux[ok] = flux_diff

File ~/anaconda3/lib/python3.9/site-packages/scipy/signal/_savitzky_golay.py:335, in savgol_filter(x, window_length, polyorder, deriv, delta, axis, mode, cval) 332 if x.dtype != np.float64 and x.dtype != np.float32: 333 x = x.astype(np.float64) --> 335 coeffs = savgol_coeffs(window_length, polyorder, deriv=deriv, delta=delta) 337 if mode == "interp": 338 if window_length > x.size:

File ~/anaconda3/lib/python3.9/site-packages/scipy/signal/_savitzky_golay.py:108, in savgol_coeffs(window_length, polyorder, deriv, delta, pos, use) 105 pos = halflen 107 if not (0 <= pos < window_length): --> 108 raise ValueError("pos must be nonnegative and less than " 109 "window_length.") 111 if use not in ['conv', 'dot']: 112 raise ValueError("use must be 'conv' or 'dot'")

ValueError: pos must be nonnegative and less than window_length.