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 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
Exemple #3
0
 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()
Exemple #4
0
 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()
 def calcMagNorm(self, spec, mag, redshift, filter='i'):
   """Calculate the SED normalization given a spectrum, redshift, and
   reference magnitude.  ***This assumes not host redenning.***
   """
   #Setup the filters
   imsimband = Bandpass()
   imsimband.imsimBandpass()
   #setup the sed
   sed = Sed()
   sed.readSED_flambda(os.path.join(self.spath,spec))
   #need the rest frame spectrum for calculating the mag norm since
   #the normalization is applied in the rest frame
   sed_orig = deepcopy(sed)
   #Redshift the spectrum
   sed.redshiftSED(redshift, dimming=True)
   #Calculate the normalization using the reference magnitude
   fluxNorm = sed.calcFluxNorm(mag, self.bands[filter])
   sed_orig.multiplyFluxNorm(fluxNorm)
   #Calculate the normalization in units of magnitudes
   magNorm = sed_orig.calcMag(imsimband)
   return magNorm, fluxNorm
 def calcMagNorm(self, spec, mag, redshift, filter='i'):
     """Calculate the SED normalization given a spectrum, redshift, and
 reference magnitude.  ***This assumes not host redenning.***
 """
     #Setup the filters
     imsimband = Bandpass()
     imsimband.imsimBandpass()
     #setup the sed
     sed = Sed()
     sed.readSED_flambda(os.path.join(self.spath, spec))
     #need the rest frame spectrum for calculating the mag norm since
     #the normalization is applied in the rest frame
     sed_orig = deepcopy(sed)
     #Redshift the spectrum
     sed.redshiftSED(redshift, dimming=True)
     #Calculate the normalization using the reference magnitude
     fluxNorm = sed.calcFluxNorm(mag, self.bands[filter])
     sed_orig.multiplyFluxNorm(fluxNorm)
     #Calculate the normalization in units of magnitudes
     magNorm = sed_orig.calcMag(imsimband)
     return magNorm, fluxNorm