afeinstein20 / eleanor

A tool for light curve extraction from the TESS FFIs.
MIT License
92 stars 39 forks source link

multi_sector() finding multiple instances of same sector - sector doesn't work as a result. #250

Closed ojhall94 closed 2 years ago

ojhall94 commented 2 years ago

I'm having an issue where I'm using eleanor.multi_sectors() to search for a star using Gaia coordinates. The star is observed in sectors 16 and 17, but the function returns two entries for sector 16, and breaks as a result. Trying to download sector 16 using eleanor.Source() fails with the same error message, but downloading sector 7 using `eleanor.Source() works fine.

Any ideas? :)

I'm using Python 3.8.11 and eleanor version 2.0.3 from this repository.

import eleanor
from astropy.coordinates import SkyCoord
import astropy.units as u

c = SkyCoord(ra = 325.689078, dec=54.038285, unit=(u.deg, u.deg))
star = eleanor.multi_sectors(coords=c, sectors='all')
datum = eleanor.TargetData(star[1])

Found star in Sector(s) 16 16 17
WARNING: NoResultsWarning: Query returned no results. [astroquery.mast.discovery_portal]
No eleanor postcard has been made for your target (yet). Using TessCut instead.
No eleanor postcard has been made for your target (yet). Using TessCut instead.
No eleanor postcard has been made for your target (yet). Using TessCut instead.

datum = eleanor.TargetData(star[1])
WARNING: Input data contains invalid values (NaNs or infs), which were automatically clipped. [astropy.stats.sigma_clipping]
WARNING: Input data contains invalid values (NaNs or infs), which were automatically clipped. [astropy.stats.sigma_clipping]
/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/numpy/lib/nanfunctions.py:1113: RuntimeWarning: Mean of empty slice
  return np.nanmean(a, axis, out=out, keepdims=keepdims)
/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/numpy/lib/nanfunctions.py:1113: RuntimeWarning: Mean of empty slice
  return np.nanmean(a, axis, out=out, keepdims=keepdims)
/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/numpy/lib/nanfunctions.py:1113: RuntimeWarning: Mean of empty slice
  return np.nanmean(a, axis, out=out, keepdims=keepdims)
/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/numpy/lib/nanfunctions.py:1113: RuntimeWarning: Mean of empty slice
  return np.nanmean(a, axis, out=out, keepdims=keepdims)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/qh/nrsz4hq94kg510wh1srt1x0ry2q37w/T/ipykernel_29011/847810929.py in <module>
----> 1 datum = eleanor.TargetData(star[1])

/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/eleanor-2.0.3-py3.8.egg/eleanor/targetdata.py in __init__(self, source, height, width, save_postcard, do_pca, do_psf, bkg_size, aperture_mode, cal_cadences, try_load, regressors, language)
    229                 self.create_apertures(self.tpf.shape[1], self.tpf.shape[2])
    230 
--> 231                 self.get_lightcurve()
    232 
    233                 if do_pca == True:

/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/eleanor-2.0.3-py3.8.egg/eleanor/targetdata.py in get_lightcurve(self, aperture)
    641             q = self.quality == 0
    642 
--> 643             tpf_stds[a] = get_flattened_sigma(all_corr_lc_tpf_sub[a][q][self.cal_cadences[0]:self.cal_cadences[1]])
    644             pc_stds[a] = get_flattened_sigma(all_corr_lc_pc_sub[a][q][self.cal_cadences[0]:self.cal_cadences[1]])
    645 

/Users/Anaconda/anaconda3/envs/michael/lib/python3.8/site-packages/eleanor-2.0.3-py3.8.egg/eleanor/targetdata.py in get_flattened_sigma(y, maxiter, window_size, nsigma)
   1688 def get_flattened_sigma(y, maxiter=100, window_size=51, nsigma=4):
   1689     y = np.copy(y[np.isfinite(y)], order="C")
-> 1690     y[:] /= savgol_filter(y, window_size, 2)
   1691     y[:] -= np.mean(y)
   1692     sig = np.std(y)

~/.local/lib/python3.8/site-packages/scipy/signal/_savitzky_golay.py in savgol_filter(x, window_length, polyorder, deriv, delta, axis, mode, cval)
    337     if mode == "interp":
    338         if window_length > x.size:
--> 339             raise ValueError("If mode is 'interp', window_length must be less "
    340                              "than or equal to the size of x.")
    341 

ValueError: If mode is 'interp', window_length must be less than or equal to the size of x.
ojhall94 commented 2 years ago

Turns out this was fixed between version 2.0.3, which was installed on my virtual environment, and 2.0.5 (which I updated in the wrong environment). Woops! Sorry :)