Ejemplo n.º 1
0
    def __call__(self, band, t, extrap=False):
        self.template.mktemplate(self.parameters[self.stype])
        t = t - self.Tmax
        rband = self.parent.restbands[band]

        # Now build the lc model
        temp, etemp, mask = self.template.eval(rband,
                                               t,
                                               self.parent.z,
                                               gen=self.gen,
                                               extrap=extrap)
        K, mask2 = self.kcorr(band, t)
        temp = temp + K

        # Apply reddening correction:
        # Figure out the reddening law
        if self.do_Robs:
            self.Robs[band] = kcorr.R_obs(band,
                                          self.parent.z,
                                          t,
                                          self.EBVhost,
                                          self.parent.EBVgal,
                                          self.Rv_host[self.calibration],
                                          self.parent.Rv_gal,
                                          self.parent.k_version,
                                          redlaw=self.parent.redlaw)
            temp = temp + self.Robs[band] * (self.EBVhost + self.parent.EBVgal)
        else:
            # Apply Robs*EBVgal:
            R = self.MWR(band, t)
            temp = temp + self.Robs[
                band] * self.EBVhost + R * self.parent.EBVgal
        temp = temp + self.DM + self.MMax(rband, self.calibration)

        return temp, etemp, mask * mask2
Ejemplo n.º 2
0
    def systematics(self, calibration=1, include_Ho=False):
        '''Returns the systematic errors in the paramters as a dictionary.  
	  If no estimate is available, return None for that paramter.'''
        systs = dict.fromkeys(self.parameters.keys())
        # DM contains systematics for Ho, plus average of calibration
        #	 uncertainties
        syst_DM = []
        weights = []
        for band in self._fbands:
            rb = self.parent.restbands[band]
            # make a call to get the weights
            mod, err, mask = self.__call__(band, self.parent.data[band].MJD)
            weights.append(sum(where(mask, power(err, -2), 0)))
            if self.stype in ['st']:
                dst = self.st - 1.0
            else:
                dst = self.dm15 - 1.1
            Robs = kcorr.R_obs(band,
                               self.parent.z,
                               0,
                               self.EBVhost,
                               self.parent.EBVgal,
                               self.Rv_host[calibration],
                               self.parent.Rv_gal,
                               self.parent.k_version,
                               redlaw=self.parent.redlaw)
            dRobs = Robs * self.eRv_host[calibration] / self.Rv_host[
                calibration]
            syst_DM.append(power(dst*self.eb[calibration][rb],2)+\
               power(self.EBVhost*dRobs, 2)+\
               power(self.ea[calibration][rb], 2)+\
						#power(2.17*velerr/(3e5*self.parent.z),2) +\
               power(self.sigSN[calibration][rb],2))
        syst_DM = array(syst_DM)
        weights = array(weights)
        systs['DM'] = sum(weights * syst_DM) / sum(weights)
        if include_Ho:
            systs['DM'] += power(2.17 * 0.1, 2)  # assume 10% error in Ho
        systs['DM'] = sqrt(systs['DM'])
        systs['EBVhost'] = 0.06
        if self.stype == 'dm15':
            systs['dm15'] = 0.06
        else:
            systs['st'] = 0.03
        systs['Tmax'] = 0.34
        return (systs)
Ejemplo n.º 3
0
    def setup(self):
        # check to see if we have more than one filter when solving for EBV
        if 'EBVhost' not in self.args:
            if len(self._fbands) < 2:
                raise RuntimeError, "Error:	 to solve for EBVhost, you need to fit more than one filter"

        self.calibration = self.args.get('calibration', 0)
        self.gen = 2

        for band in self._fbands:
            self.Robs[band] = kcorr.R_obs(band,
                                          self.parent.z,
                                          0,
                                          0.01,
                                          0,
                                          self.Rv_host[self.calibration],
                                          self.parent.Rv_gal,
                                          self.parent.k_version,
                                          redlaw=self.parent.redlaw)
Ejemplo n.º 4
0
    def setup(self):
        if 'EBVhost' not in self.args:
            if len(self._fbands) < 2:
                raise RuntimeError, "Error:	 to solve for EBVhost, you need to fit more than one filter"

        self.calibration = self.args.get('calibration', 6)
        self.gen = self.args.get('gen', 2)
        for band in self._fbands:
            #cal = self.args.get('cal',6)
            cal = self.calibration
            self.Robs[band] = kcorr.R_obs(band,
                                          self.parent.z,
                                          0,
                                          0.01,
                                          0,
                                          self.Rv_host[cal],
                                          self.parent.Rv_gal,
                                          self.parent.k_version,
                                          redlaw=self.parent.redlaw)
Ejemplo n.º 5
0
 def get_max(self, bands, restframe=0, deredden=0):
     Tmaxs = []
     Mmaxs = []
     eMmaxs = []
     rbands = []
     self.template.mktemplate(self.parameters[self.stype])
     for band in bands:
         rband = self.parent.restbands[band]
         # find where the template truly peaks:
         x0 = brent(lambda x: self.template.eval(rband, x, gen=self.gen)[0],
                    brack=(0., 5.))
         Tmaxs.append(x0 + self.Tmax)
         mmax = self.DM + self.MMax(rband, self.calibration)
         if not restframe and band in self.parent.ks_tck:
             # add the K-correction
             mmax = mmax + scipy.interpolate.splev(Tmaxs[-1],
                                                   self.parent.ks_tck[band])
         if not deredden:
             if self.do_Robs:
                 Robs = kcorr.R_obs(band,
                                    self.parent.z,
                                    x0,
                                    self.EBVhost,
                                    self.parent.EBVgal,
                                    self.Rv_host[self.calibration],
                                    self.parent.Rv_gal,
                                    'H3',
                                    redlaw=self.parent.redlaw)
                 mmax = mmax + Robs * (self.EBVhost + self.parent.EBVgal)
             else:
                 # Apply Robs*EBVgal:
                 if band in self.parent.Robs:
                     if type(self.parent.Robs[band]) is type(()):
                         R = scipy.interpolate.splev(
                             Tmaxs[-1], self.parent.Robs[band])
                     else:
                         R = self.parent.Robs[band]
                 else:
                     EBV = max(self.parent.EBVgal, 0.01)
                     R = kcorr.R_obs(band,
                                     self.parent.z,
                                     0,
                                     0,
                                     EBV,
                                     self.Rv_host[self.calibration],
                                     self.parent.Rv_gal,
                                     self.parent.k_version,
                                     redlaw=self.parent.redlaw)
                 EBV = max(self.EBVhost, 0.01)
                 Robs = kcorr.R_obs(band,
                                    self.parent.z,
                                    0,
                                    EBV,
                                    0,
                                    self.Rv_host[self.calibration],
                                    self.parent.Rv_gal,
                                    self.parent.k_version,
                                    redlaw=self.parent.redlaw)
                 mmax = mmax + Robs * self.EBVhost + R * self.parent.EBVgal
         Mmaxs.append(mmax)
         eMmaxs.append(self.errors['DM'])
         rbands.append(rband)
     return (Tmaxs, Mmaxs, eMmaxs, rbands)