How to use the photutils.MMMBackground function in photutils

To help you get started, we’ve selected a few photutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github afeinstein20 / eleanor / make_postcards.py View on Github external
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)
github afeinstein20 / eleanor / eleanor / targetdata.py View on Github external
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)
github afeinstein20 / eleanor / eleanor / postcard.py View on Github external
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