Coverage for python/lsst/sims/maf/metrics/snCadenceMetric.py : 12%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Metric to estimate the redshift limit for faint supernovae (x1,color) = (-2.0,0.2)
Parameters ---------- list : str, opt Name of the columns used to estimate the metric coadd : bool, opt to make "coaddition" per night (uses snStacker) Default True lim_sn : class, opt Reference data used to estimate redshift values (interpolation) """
mjdCol='observationStartMJD', RaCol='fieldRA', DecCol='fieldDec', filterCol='filter', m5Col='fiveSigmaDepth', exptimeCol='visitExposureTime', nightCol='night', obsidCol='observationId', nexpCol='numExposures', vistimeCol='visitTime', coadd=True, lim_sn=None, **kwargs):
self.mjdCol = mjdCol self.m5Col = m5Col self.filterCol = filterCol self.RaCol = RaCol self.DecCol = DecCol self.exptimeCol = exptimeCol self.seasonCol = 'season' self.nightCol = nightCol self.obsidCol = obsidCol self.nexpCol = nexpCol self.vistimeCol = vistimeCol
cols = [self.nightCol, self.m5Col, self.filterCol, self.mjdCol, self.obsidCol, self.nexpCol, self.vistimeCol, self.exptimeCol, self.seasonCol] if coadd: cols += ['coadd']
super(SNcadenceMetric, self).__init__( col=cols, metricName=metricName, **kwargs)
self.filterNames = np.array(['u', 'g', 'r', 'i', 'z', 'y'])
self.lim_sn = lim_sn
# Cut down to only include filters in correct wave range.
goodFilters = np.in1d(dataSlice['filter'], self.filterNames) dataSlice = dataSlice[goodFilters] if dataSlice.size == 0: return None dataSlice.sort(order=self.mjdCol)
r = [] fieldRA = np.mean(dataSlice[self.RaCol]) fieldDec = np.mean(dataSlice[self.DecCol]) band = np.unique(dataSlice[self.filterCol])[0]
sel = dataSlice bins = np.arange(np.floor(sel[self.mjdCol].min()), np.ceil( sel[self.mjdCol].max()), 1.) c, b = np.histogram(sel[self.mjdCol], bins=bins) if c.mean() < 1.e-8: cadence = 0. else: cadence = 1. / c.mean() # time_diff = sel[self.mjdCol][1:]-sel[self.mjdCol][:-1] r.append((fieldRA, fieldDec, band, np.mean(sel[self.m5Col]), cadence))
res = np.rec.fromrecords( r, names=['fieldRA', 'fieldDec', 'band', 'm5_mean', 'cadence_mean'])
zref = self.lim_sn.Interp_griddata(res)
return zref |