Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, time=None, flux=None, flux_err=None,
flux_unit=u.Unit('electron/second'), time_format='bkjd', time_scale='tdb',
centroid_col=None, centroid_row=None, quality=None, quality_bitmask=None,
channel=None, campaign=None, quarter=None, mission=None,
cadenceno=None, targetid=None, ra=None, dec=None, label=None, meta=None):
super(KeplerLightCurve, self).__init__(time=time, flux=flux, flux_err=flux_err, flux_unit=flux_unit,
time_format=time_format, time_scale=time_scale,
targetid=targetid, label=label, meta=meta)
self.centroid_col = self._validate_array(centroid_col, name='centroid_col')
self.centroid_row = self._validate_array(centroid_row, name='centroid_row')
self.quality = self._validate_array(quality, name='quality')
self.cadenceno = self._validate_array(cadenceno, name='cadenceno')
self.quality_bitmask = quality_bitmask
self.channel = channel
self.campaign = campaign
self.quarter = quarter
self.mission = mission
self.ra = ra
self.dec = dec
def prf_lightcurve(self, **kwargs):
lc = self.extract_prf_photometry(**kwargs).lightcurves[0]
keys = {'quality': self.quality,
'channel': self.channel,
'campaign': self.campaign,
'quarter': self.quarter,
'mission': self.mission,
'cadenceno': self.cadenceno,
'ra': self.ra,
'dec': self.dec,
'targetid': self.targetid}
return KeplerLightCurve(time=self.time,
flux=lc.flux,
**keys)
flux, flux_err, centroid_col, centroid_row = \
self._aperture_photometry(aperture_mask=aperture_mask,
centroid_method=centroid_method)
keys = {'centroid_col': centroid_col,
'centroid_row': centroid_row,
'quality': self.quality,
'channel': self.channel,
'campaign': self.campaign,
'quarter': self.quarter,
'mission': self.mission,
'cadenceno': self.cadenceno,
'ra': self.ra,
'dec': self.dec,
'label': self.header['OBJECT'],
'targetid': self.targetid}
return KeplerLightCurve(time=self.time,
flux=flux,
flux_err=flux_err,
**keys)
centroid_col = np.repeat(np.NaN, self.quality_mask.sum())
centroid_row = np.repeat(np.NaN, self.quality_mask.sum())
if flux_type in self._flux_types():
# We did not import lightcurve at the top to prevent circular imports
from .lightcurve import KeplerLightCurve
f = self.hdu[1].data[flux_type][self.quality_mask]
fe = self.hdu[1].data[flux_type + "_ERR"][self.quality_mask]
if flux_type == 'SAP_FLUX':
f /= self.hdu[1].header.get('FLFRCSAP', 1)
fe /= self.hdu[1].header.get('FLFRCSAP', 1)
f /= self.hdu[1].header.get('CROWDSAP', 1)
fe /= self.hdu[1].header.get('CROWDSAP', 1)
return KeplerLightCurve(
time=self.hdu[1].data['TIME'][self.quality_mask],
time_format='bkjd',
time_scale='tdb',
flux=f,
flux_err=fe,
centroid_col=centroid_col,
centroid_row=centroid_row,
quality=self._get_quality()[self.quality_mask],
quality_bitmask=self.quality_bitmask,
channel=self.channel,
campaign=self.campaign,
quarter=self.quarter,
mission=self.mission,
cadenceno=self.cadenceno,
targetid=self.targetid,
label=self.get_keyword('OBJECT'),
def lc(self, value):
# this enables `lc` to be either a string
# or an object from KeplerLightCurveFile
if isinstance(value, str):
self._lc = KeplerLightCurveFile(value).PDCSAP_FLUX
elif isinstance(value, KeplerLightCurveFile):
self._lc = value.SAP_FLUX
elif isinstance(value, KeplerLightCurve):
self._lc = value
else:
raise ValueError("lc must be either a string, a KeplerLightCurve or a"
" KeplerLightCurveFile instance, got {}.".format(value))
aperture_mask = self._parse_aperture_mask(aperture_mask)
# Ignore warnings related to zero or negative errors
with warnings.catch_warnings():
warnings.simplefilter("ignore", RuntimeWarning)
flux_bkg_err = np.nansum(self.flux_bkg_err[:, aperture_mask]**2, axis=1)**0.5
keys = {'quality': self.quality,
'channel': self.channel,
'campaign': self.campaign,
'quarter': self.quarter,
'mission': self.mission,
'cadenceno': self.cadenceno,
'ra': self.ra,
'dec': self.dec,
'label': self.header['OBJECT'],
'targetid': self.targetid}
return KeplerLightCurve(time=self.time,
flux=np.nansum(self.flux_bkg[:, aperture_mask], axis=1),
flux_err=flux_bkg_err,
**keys)
def lc(self, value):
# this enables `lc` to be either a string
# or an object from KeplerLightCurveFile
if isinstance(value, str):
self._lc = KeplerLightCurveFile(value).PDCSAP_FLUX
elif isinstance(value, KeplerLightCurveFile):
self._lc = value.SAP_FLUX
elif isinstance(value, KeplerLightCurve):
self._lc = value
else:
raise ValueError("lc must be either a string, a KeplerLightCurve or a"
" KeplerLightCurveFile instance, got {}.".format(value))