Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def bkg(flux, sigma=2.5):
# Returns background for a single cadence. Default sigma=2.5
sigma_clip = SigmaClip(sigma=sigma)
bkg = MMMBackground(sigma_clip=sigma_clip)
return bkg.calc_background(flux)
If `tpf`, will use data from the target pixel file only to estimate and remove the background.
If `postcard`, will use data from the entire postcard region to estimate and remove the background.
sigma : float
The standard deviation cut used to determine which pixels are representative of the background in each cadence.
"""
time = self.time
if self.source_info.tc == True:
flux = self.bkg_tpf
else:
flux = self.tpf
tpf_flux_bkg = []
sigma_clip = SigmaClip(sigma=sigma)
bkg = MMMBackground(sigma_clip=sigma_clip)
for i in range(len(time)):
bkg_value = bkg.calc_background(flux[i])
tpf_flux_bkg.append(bkg_value)
if self.source_info.tc == True:
self.tpf_flux_bkg = np.array(tpf_flux_bkg)
else:
return np.array(tpf_flux_bkg)
def bkg(self):
sigma_clip = SigmaClip(sigma=3.)
bkg = MMMBackground(sigma_clip=sigma_clip)
b = bkg.calc_background(self.flux, axis=(1,2))
return b