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 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, 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 doit(args): sed = args if sed.startswith("bergeron"): pref = "wDs" suff = ".gz" elif sed.startswith("k"): pref = "kurucz" suff = ".gz" elif sed.startswith("burrows") or sed.startswith("L") or sed.startswith("l") or sed.startswith("m"): pref = "mlt" suff = ".gz" star = Sed() star.readSED_flambda(os.path.join(catDir, "SEDs/starSED/%s/%s%s" % (pref, sed, suff))) star.flambdaTofnu() # Resample array elements wavelen = star.wavelen fnu = star.fnu wavelenu, fnuu = star.resampleSED(wavelen, fnu, wavelen_match=uBand.wavelen) waveleng, fnug = star.resampleSED(wavelen, fnu, wavelen_match=gBand.wavelen) wavelenr, fnur = star.resampleSED(wavelen, fnu, wavelen_match=rBand.wavelen) waveleni, fnui = star.resampleSED(wavelen, fnu, wavelen_match=iBand.wavelen) wavelenz, fnuz = star.resampleSED(wavelen, fnu, wavelen_match=zBand.wavelen) fluxu = fnuu * uBand.phi fluxg = fnug * gBand.phi fluxr = fnur * rBand.phi fluxi = fnui * iBand.phi fluxz = fnuz * zBand.phi fluxes = [fluxu, fluxg, fluxr, fluxi, fluxz] nflux = 5 colors = [] for i in range(5): for j in range(i+1, 5): color = -2.5 * np.log10( np.sum(fluxes[i]) / np.sum(fluxes[j]) ) colors.append(color) refrac = [] for zd in zds: # Find R ru = getOffset(wavelenu, fluxu, zd) rg = getOffset(waveleng, fluxg, zd) rr = getOffset(wavelenr, fluxr, zd) ri = getOffset(waveleni, fluxi, zd) rz = getOffset(wavelenz, fluxz, zd) refrac.append((zd, ru, rg, rr, ri, rz)) return sed, colors, refrac
def doit(args): line, gBand, rBand, catDir = args sed, mag, nsed = line.split() nsed = int(nsed) if sed.startswith("bergeron"): pref = "wDs" suff = ".gz" elif sed.startswith("k"): pref = "kurucz" suff = ".gz" elif sed.startswith("burrows") or sed.startswith("L") or sed.startswith("l") or sed.startswith("m"): pref = "mlt" suff = ".gz" star = Sed() star.readSED_flambda(os.path.join(catDir, "SEDs/starSED/%s/%s%s" % (pref, sed, suff))) star.flambdaTofnu() gflux = integrate(star, gBand) rflux = integrate(star, rBand) color = -2.5 * np.log10(gflux/rflux) #if int(color*100)==45: # print sed, nsed return sed, color, nsed
def doit(args): sed, gmag, nsed = args if sed.startswith("bergeron"): pref = "wDs" suff = ".gz" elif sed.startswith("k"): pref = "kurucz" suff = ".gz" elif sed.startswith("burrows") or sed.startswith("L") or sed.startswith("l") or sed.startswith("m"): pref = "mlt" suff = ".gz" star = Sed() star.readSED_flambda(os.path.join(catDir, "SEDs/starSED/%s/%s%s" % (pref, sed, suff))) star.flambdaTofnu() Mg = np.empty((len(dairmasses), len(dthetas))) Mr = np.empty((len(dairmasses), len(dthetas))) Mi = np.empty((len(dairmasses), len(dthetas))) Mz = np.empty((len(dairmasses), len(dthetas))) # Resample array elements wavelen = star.wavelen fnu = star.fnu waveleng, fnug = star.resampleSED(wavelen, fnu, wavelen_match=gBand.wavelen) wavelenr, fnur = star.resampleSED(wavelen, fnu, wavelen_match=rBand.wavelen) waveleni, fnui = star.resampleSED(wavelen, fnu, wavelen_match=iBand.wavelen) wavelenz, fnuz = star.resampleSED(wavelen, fnu, wavelen_match=zBand.wavelen) fluxg = fnug * gBand.phi fluxr = fnur * rBand.phi fluxi = fnui * iBand.phi fluxz = fnuz * zBand.phi gr = -2.5 * np.log10( np.sum(fluxg) / np.sum(fluxr) ) gi = -2.5 * np.log10( np.sum(fluxg) / np.sum(fluxi) ) gz = -2.5 * np.log10( np.sum(fluxg) / np.sum(fluxz) ) rmag = gmag - gr imag = gmag - gi zmag = gmag - gz # Find DCR at airmass zd1 dg1 = getOffset(waveleng, fluxg, zd1) - refOffset["g"][int(zd1)] dr1 = getOffset(wavelenr, fluxr, zd1) - refOffset["r"][int(zd1)] di1 = getOffset(waveleni, fluxi, zd1) - refOffset["i"][int(zd1)] dz1 = getOffset(wavelenz, fluxz, zd1) - refOffset["z"][int(zd1)] for ia, dairmass in enumerate(dairmasses): # Find DCR at other zds zd2 = np.arccos(1./(airmass1 + dairmass)) * 180/np.pi dg2 = getOffset(waveleng, fluxg, zd2) - refOffset["g"][int(zd2)] dr2 = getOffset(wavelenr, fluxr, zd2) - refOffset["r"][int(zd2)] di2 = getOffset(waveleni, fluxi, zd2) - refOffset["i"][int(zd2)] dz2 = getOffset(wavelenz, fluxz, zd2) - refOffset["z"][int(zd2)] for it, dtheta in enumerate(dthetas): #print ia, it, (airmass1 + dairmass), zd1, zd2, dtheta, dg1, dg2 Mg[ia, it] = np.sqrt(dg1**2 + dg2**2 - 2 * dg1 * dg2 * np.cos(dtheta * np.pi / 180)) Mr[ia, it] = np.sqrt(dr1**2 + dr2**2 - 2 * dr1 * dr2 * np.cos(dtheta * np.pi / 180)) Mi[ia, it] = np.sqrt(di1**2 + di2**2 - 2 * di1 * di2 * np.cos(dtheta * np.pi / 180)) Mz[ia, it] = np.sqrt(dz1**2 + dz2**2 - 2 * dz1 * dz2 * np.cos(dtheta * np.pi / 180)) #print Mg #print Mr if (gmag<16) or (gmag>25): Mg *= 0 ng = 0 else: ng = nsed if (rmag<16) or (rmag>24.7): Mr *= 0 nr = 0 else: nr = nsed if (imag<16) or (imag>24): Mi *= 0 ni = 0 else: ni = nsed if (zmag<16) or (zmag>23.3): Mz *= 0 nz = 0 else: nz = nsed return Mg, Mr, Mi, Mz, ng, nr, ni, nz
gBand = Bandpass() rBand = Bandpass() iBand = Bandpass() zBand = Bandpass() gBand.readThroughput(os.path.join(filtDir, "total_g.dat")) rBand.readThroughput(os.path.join(filtDir, "total_r.dat")) iBand.readThroughput(os.path.join(filtDir, "total_i.dat")) zBand.readThroughput(os.path.join(filtDir, "total_z.dat")) gBand.sbTophi() rBand.sbTophi() iBand.sbTophi() zBand.sbTophi() ref = Sed() ref.readSED_flambda(os.path.join(catDir, "SEDs/starSED/kurucz/%s"%(sedName))) ref.flambdaTofnu() wavelen = ref.wavelen fnu = ref.fnu waveleng, fnug = ref.resampleSED(wavelen, fnu, wavelen_match=gBand.wavelen) wavelenr, fnur = ref.resampleSED(wavelen, fnu, wavelen_match=rBand.wavelen) waveleni, fnui = ref.resampleSED(wavelen, fnu, wavelen_match=iBand.wavelen) wavelenz, fnuz = ref.resampleSED(wavelen, fnu, wavelen_match=zBand.wavelen) fluxg = fnug * gBand.phi fluxr = fnur * rBand.phi fluxi = fnui * iBand.phi fluxz = fnuz * zBand.phi refOffset = {} refOffset["r"] = {} refOffset["g"] = {} refOffset["i"] = {}