Пример #1
0
def get_photometric_error(mag, band, run=None, gamma=None, coadd=True):
    """
    Calculate the photometric error
    
    Returns
    -------
    The magnitude error in mag.
    """
    bandpass_dir = '../throughputs/baseline'  # hardcoded for my own system; not necessary for desc-stack
    LSST_BandPass = BandpassDict.loadTotalBandpassesFromFiles(
        bandpassDir=bandpass_dir)
    bandpass_obj = LSST_BandPass[band]
    phot_params_obj = PhotometricParameters()

    # 5-sigma depth
    if coadd:
        m5 = dict(zip(list('ugrizy'), [26.1, 27.4, 27.5, 26.8, 26.1, 24.9]))
    else:
        # single visit (2 x 15s), for point sources
        # from Ivezic et al 2018
        m5 = dict(
            zip(list('ugrizy'), [23, 78, 24.81, 24.35, 23.92, 23.34, 22.45]))
    # Override if run is provided, meaning it's DC2
    if run == '1.2i':
        m5 = dict(zip(list('ugrizy'), [25.7, 25.7, 25.7, 25.7, 25.7, 25.7
                                       ]))  #FIXME: only r correct for Run 1.2i

    mag_err, gamma = calcMagError_m5(mag, bandpass_obj, m5[band],
                                     phot_params_obj, gamma)
    return mag_err
def convert_params_to_depths(params):
    ### Convert the number of visits in each band to 5sigma magnitude depths
    # params = [ [vu,vg,vr,vi,vz,vy], years]

    visits = params[0]
    years = params[1]
    print 'visits = ', visits
    print 'years = ', years

    filter_list = ['u', 'g', 'r', 'i', 'z', 'y']
    filter_file = "/Users/melissagraham/Science/LSST/photoz_experiments/filters/LSSTcosmosJDEM.filt"
    filters = OrderedDict({})
    for filt in filter_list:
        filters[filt] = importBandpass(filter_file, filt)
    gamma = [0.037, 0.038, 0.039, 0.039, 0.04, 0.04]  #Sam Schmidt
    photParams = PhotometricParameters()

    # m5sig_10year     = np.asarray( (26.1,27.4,27.5,26.8,26.1,24.9), dtype='float' )
    m5sig_1vis_lmags = np.asarray((23.9, 25.0, 24.7, 24.0, 23.3, 22.1),
                                  dtype='float')

    m5 = np.zeros(6, dtype='float')
    for f, filt in enumerate(filter_list):
        if visits[f] > 0:
            m5[f] = m5sig_1vis_lmags[f] + (1.25 *
                                           np.log10(visits[f] * years / 10.0))
        if visits[f] <= 0: m5[f] = float('NaN')
    # print 'm5: ',m5

    return m5
Пример #3
0
    def catsimBandFluxError(self, time, bandpassobject, m5,
                            fluxinMaggies=None,
                            magnitude=None,
                            photParams=None):
        """
        return the flux uncertainty in the bandpass in units 'maggies'
        (the flux the AB magnitude reference spectrum would have in the
        same band.) for a source of given brightness. The source brightness
        may be calculated, but the need for calculation is overridden by a
        provided flux in bandpass (in units of maggies) which itself may be
        overridden by a provided magnitude. If the provided/calculated flux
        is 0. or negative the magnitude calculated is taken to be 200.0 rather
        than a np.nan.


        Parameters
        ----------
        time: mandatory, float
            MJD at which band fluxes are evaluated
        bandpassobject: mandatory, `lsst.sims.photUtils.BandPass` object
            A particular bandpass which is an instantiation of one of
            (u, g, r, i, z, y)
        m5 : float, mandatory
            fiveSigma Depth for the sky observation
        photParams : instance of `sims.photUtils.PhotometricParameters`, defaults to `None` 
            describes the hardware parameters of the Observing system
        magnitude : float, defaults to None
            AB magnitude of source in bandpass.
        fluxinMaggies : float, defaults to None
            flux in Maggies for source in bandpass
        Returns
        -------
        float

        Examples
        --------
        .. note: If there is an unphysical value of sed the fluxinMaggies might
        be `np.nan`. The magnitude calculated from this is calculated using `noNan`
         and is therefore 200.0 rather than `np.nan`. 
        """
        if fluxinMaggies is None:
            fluxinMaggies = self.catsimBandFlux(time=time,
                                                bandpassobject=bandpassobject)
        if magnitude is None:
            mag = self.catsimBandMag(time=time, fluxinMaggies=fluxinMaggies,
                                     bandpassobject=bandpassobject, noNan=True)
        else:
            mag = magnitude

        # recalculate fluxinMaggies as the previous one might have been `np.nan`
        # the noise is contaminated if this is `np.nan`
        fluxinMaggies = 10.0**(-0.4 * mag)

        if photParams is None:
            photParams = PhotometricParameters()

        SNR, gamma = calcSNR_m5(magnitude=mag, bandpass=bandpassobject,
                                m5=m5, photParams=photParams)
        return fluxinMaggies / SNR
Пример #4
0
    def catsimBandMagError(self, time, bandpassobject, m5, photParams=None,
                           magnitude=None):
        """
        return the 68 percent uncertainty on the magnitude in the bandpass

        Parameters
        ----------
        time: mandatory, float
            MJD at which band fluxes are evaluated
        bandpassobject: mandatory, `lsst.sims.photUtils.BandPass` object
            A particular bandpass which is an instantiation of one of
            (u, g, r, i, z, y)
        m5 :
        photParams :
        magnitude :

        Returns
        -------
        float

        Examples
        --------
        .. note: If there is an unphysical value of sed in
        the wavelength range, it produces a flux of  `np.nan`
        """

        if magnitude is None:
            mag = self.catsimBandMag(time=time,
                                     bandpassobject=bandpassobject,
                                     noNan=True)
        else:
            mag = magnitude

        bandpass = bandpassobject

        if photParams is None:
            photParams = PhotometricParameters()

        magerr = calcMagError_m5(magnitude=mag,
                                 bandpass=bandpassobject,
                                 m5=m5,
                                 photParams=photParams)
        return magerr[0]
Пример #5
0
    def setUp(self):
        """
        Setup tests
        SN_blank: A SNObject with no MW extinction
        """

        mydir = get_config_dir()
        print('===============================')
        print('===============================')
        print(mydir)
        print('===============================')
        print('===============================')
        # A range of wavelengths in Ang
        self.wave = np.arange(3000., 12000., 50.)
        # Equivalent wavelenths in nm
        self.wavenm = self.wave / 10.
        # Time to be used as Peak
        self.mjdobs = 571190

        # Check that we can set up a SED
        # with no extinction
        self.SN_blank = SNObject()
        self.SN_blank.setCoords(ra=30., dec=-60.)
        self.SN_blank.set(z=0.96, t0=571181, x1=2.66, c=0.353, x0=1.796e-6)
        self.SN_blank.set_MWebv(0.)

        self.SN_extincted = SNObject(ra=30., dec=-60.)
        self.SN_extincted.set(z=0.96,
                              t0=571181,
                              x1=2.66,
                              c=0.353,
                              x0=1.796112e-06)

        self.SNCosmoModel = self.SN_extincted.equivalentSNCosmoModel()
        self.rectify_photParams = PhotometricParameters()
        self.lsstBandPass = BandpassDict.loadTotalBandpassesFromFiles()
        self.SNCosmoBP = sncosmo.Bandpass(wave=self.lsstBandPass['r'].wavelen,
                                          trans=self.lsstBandPass['r'].sb,
                                          wave_unit=astropy.units.Unit('nm'),
                                          name='lsst_r')