def uncMagCalc(redshift, tempGalwav, tempGalfla, multiFlux=None, finish=None): tempName = Sed(wavelen=tempGalwav, flambda=tempGalfla) if multiFlux is not None: tempName.multiplyFluxNorm(multiFlux) if finish is not None: tempName.redshiftSED(redshift, dimming=True) tempName.resampleSED(wavelen_min=300, wavelen_max=1200, wavelen_step=wavelen_step) tempName.flambdaTofnu() return tempName
def getSpecNorms(self, sedfile, mag, filtstr): band = Bandpass() band.readThroughput(os.path.join(self.tpath, "total_%s.dat"%(filtstr))) imsimband = Bandpass() imsimband.imsimBandpass() sed = Sed() sed.readSED_flambda(self.spath+"/"+sedfile) fluxNorm = sed.calcFluxNorm(mag, band) sed.multiplyFluxNorm(fluxNorm) magNorm = sed.calcMag(imsimband) return magNorm, fluxNorm
def calcLSSTMags(self, sedfile, fluxnorm): sed = Sed() sed.readSED_flambda(self.spath+"/"+sedfile) sed.multiplyFluxNorm(fluxnorm) mags = [] for filtstr in ('u', 'g', 'r', 'i', 'z', 'y'): band = Bandpass() band.readThroughput(os.path.join(self.tpath, "total_%s.dat"%(filtstr))) imsimband = Bandpass() imsimband.imsimBandpass() mags.append(sed.calcMag(band)) return mags
def getSpecNorms(self, sedfile, mag, filtstr): band = Bandpass() band.readThroughput( os.path.join(self.tpath, "total_%s.dat" % (filtstr))) imsimband = Bandpass() imsimband.imsimBandpass() sed = Sed() sed.readSED_flambda(self.spath + "/" + sedfile) fluxNorm = sed.calcFluxNorm(mag, band) sed.multiplyFluxNorm(fluxNorm) magNorm = sed.calcMag(imsimband) return magNorm, fluxNorm
def calcLSSTMags(self, spec, fluxnorm, redshift): """Calculate the magnitude of the source given a flux normalization in the standard LSST bands. ***This does not take into account host extinction. """ #Get default sed and filter locations #setup and redshift the spectrum sed = Sed() sed.readSED_flambda(os.path.join(self.spath,spec)) sed.multiplyFluxNorm(fluxnorm) sed.redshiftSED(redshift, dimming=True) sed.resampleSED(wavelen_match=self.bands[self.indmap['0']].wavelen) sed.flambdaTofnu() return sed.manyMagCalc(self.phiarr, self.wavelen_step)
def calcLSSTMags(self, sedfile, fluxnorm): sed = Sed() sed.readSED_flambda(self.spath + "/" + sedfile) sed.multiplyFluxNorm(fluxnorm) mags = [] for filtstr in ('u', 'g', 'r', 'i', 'z', 'y'): band = Bandpass() band.readThroughput( os.path.join(self.tpath, "total_%s.dat" % (filtstr))) imsimband = Bandpass() imsimband.imsimBandpass() mags.append(sed.calcMag(band)) return mags
def calcLSSTMags(self, spec, fluxnorm, redshift): """Calculate the magnitude of the source given a flux normalization in the standard LSST bands. ***This does not take into account host extinction. """ #Get default sed and filter locations #setup and redshift the spectrum sed = Sed() sed.readSED_flambda(os.path.join(self.spath, spec)) sed.multiplyFluxNorm(fluxnorm) sed.redshiftSED(redshift, dimming=True) sed.resampleSED(wavelen_match=self.bands[self.indmap['0']].wavelen) sed.flambdaTofnu() return sed.manyMagCalc(self.phiarr, self.wavelen_step)
def mkGalPhot(self): ifh = open(self.mfile) lnum = 0 k = None for l in ifh: flds = l.rstrip().split() if l.startswith("Opsim_filter"): self.filter = self.filtmap[int(flds[1])] k = self.filter ifh.close() ifh = open(self.tfile) for l in ifh: flds = l.rstrip().split() if not flds[0] == "object": continue otype = flds[12] if otype != "sersic2D": continue id = float(flds[1]) if not self.centdata.has_key(id): continue magNorm = float(flds[4]) spec = flds[5] redshift = float(flds[6]) ind = float(flds[16]) mwav = float(flds[21]) av = float(flds[18]) sed = Sed() sed.readSED_flambda(self.spath+"/"+spec) a_int, b_int = sed.setupCCMab() self.outdata['id'].append(id) if lnum > self.donum and self.donum is not None: break if lnum%10000 == 0: print id fluxNorm = sed.calcFluxNorm(magNorm, self.imsimband) sed.multiplyFluxNorm(fluxNorm/(1+redshift)) sed.addCCMDust(a_int, b_int, A_v=av) sed.redshiftSED(redshift, dimming=False) a_mw, b_mw = sed.setupCCMab() sed.addCCMDust(a_mw, b_mw, A_v=mwav) line = {'flux':None, 'mag':None} mag = sed.calcMag(self.bands[k]) flux = sed.calcADU(self.bands[k], gain=1.0) line['mag'] = mag line['flux'] = flux self.outdata[k].append(line) lnum += 1 ifh.close()
def mkStarPhot(self): ifh = open(self.mfile) lnum = 0 k = None for l in ifh: flds = l.rstrip().split() if l.startswith("Opsim_filter"): self.filter = self.filtmap[int(flds[1])] k = self.filter ifh.close() ifh = open(self.tfile) for l in ifh: flds = l.rstrip().split() if not flds[0] == "object": continue otype = flds[12] if otype != "point": continue id = float(flds[1]) if not self.centdata.has_key(id): continue magNorm = float(flds[4]) spec = flds[5] av = float(flds[14]) sed = Sed() self.outdata['id'].append(id) if re.search("kurucz", spec): sed.readSED_flambda(self.spath+"/"+spec) else: sed.readSED_flambda(self.spath+"/"+spec) fluxNorm = sed.calcFluxNorm(magNorm, self.imsimband) sed.multiplyFluxNorm(fluxNorm) a, b = sed.setupCCMab() sed.addCCMDust(a, b, A_v=av) line = {'flux':None, 'mag':None} mag = sed.calcMag(self.bands[k]) flux = sed.calcADU(self.bands[k], gain=1.) line['mag'] = mag line['flux'] = flux self.outdata[k].append(line) lnum += 1 ifh.close()