Пример #1
0
def read_stdatmo(override_filename=None):
    # read the standard atmosphere bandpass file, precomputed by MODTRAN & DaveBurke.
    # this is closely equivalent to atmos_12.dat
    atmosdir = os.getenv("LSST_THROUGHPUTS_ATMOS")
    atmos_bp = Bandpass()
    if override_filename == None:
        atmos_bp.readThroughput(os.path.join(atmosdir, "atmos_std.dat"))
    else:
        atmos_bp.readThroughput(os.path.join(atmosdir, override_filename))
    return atmos_bp
Пример #2
0
def read_stdatmo(override_filename = None):
    # read the standard atmosphere bandpass file, precomputed by MODTRAN & DaveBurke.
    # this is closely equivalent to atmos_12.dat
    atmosdir = os.getenv("LSST_THROUGHPUTS_ATMOS")
    atmos_bp = Bandpass()
    if override_filename == None:
        atmos_bp.readThroughput(os.path.join(atmosdir, "atmos_std.dat"))
    else:
        atmos_bp.readThroughput(os.path.join(atmosdir, override_filename))
    return atmos_bp
 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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
def read_wvfiles():
    tt = os.listdir('.')
    files = []
    for t in tt:
        if t.startswith('am') & t.endswith('.plt'):
            files.append(t)
    print files
    atms = {}
    wvs = []
    for f in files:
        wv = f[9:12]
        print wv, f
        wvs.append(wv)
        atms[wv] = Bandpass()
        atms[wv].readThroughput(f, wavelen_step=0.1)
    std = Bandpass()
    std.readThroughput(
        os.path.join(os.getenv('LSST_THROUGHPUTS_ATMOS'), 'atmos_12.dat'))
    #std.readThroughput('atmos_85143574.dat', wavelen_step=.1)

    # calculate effect of absorption ..
    condition = ((atms[wvs[0]].wavelen >= 850) &
                 (atms[wvs[0]].wavelen <= 1100))
    abs = {}
    for w in wvs:
        abs[w] = (1 - atms[w].sb[condition]).sum() * 0.1
        print w, abs[w]

    # check with a plot
    max = len(wvs) - 1
    pylab.figure()
    for w in [wvs[0], wvs[max]]:
        pylab.plot(atms[w].wavelen, atms[w].sb, label=w)
    pylab.plot(std.wavelen, std.sb, 'k-', label='std')
    pylab.legend(loc='lower right')
    pylab.xlabel('Wavelength')
    pylab.ylabel('Transmission')
    pylab.xlim(900, 1000)
    pylab.figure()
    for w in [wvs[0], wvs[max]]:
        pylab.plot(atms[w].wavelen, atms[w].sb, label=w)
    pylab.plot(std.wavelen, std.sb, 'k-', label='std')
    pylab.legend(loc='lower right')
    pylab.xlabel('Wavelength')
    pylab.ylabel('Transmission')
    #pylab.show()

    return atms, wvs, std
Пример #8
0
def read_wvfiles():
    tt = os.listdir('.')
    files = []
    for t in tt:
        if t.startswith('am') & t.endswith('.plt'):
            files.append(t)
    print files
    atms = {}
    wvs = []
    for f in files:
        wv = f[9:12]
        print wv, f
        wvs.append(wv)
        atms[wv] = Bandpass()
        atms[wv].readThroughput(f, wavelen_step=0.1)
    std = Bandpass()
    std.readThroughput(os.path.join(os.getenv('LSST_THROUGHPUTS_ATMOS'), 'atmos_12.dat'))
    #std.readThroughput('atmos_85143574.dat', wavelen_step=.1)

    # calculate effect of absorption ..
    condition = ((atms[wvs[0]].wavelen >= 850) & (atms[wvs[0]].wavelen <= 1100))
    abs = {}
    for w in wvs:
        abs[w] = (1-atms[w].sb[condition]).sum() * 0.1
        print w, abs[w]

    # check with a plot
    max = len(wvs)-1
    pylab.figure()
    for w in [wvs[0], wvs[max]]:
        pylab.plot(atms[w].wavelen, atms[w].sb, label=w)
    pylab.plot(std.wavelen, std.sb, 'k-', label='std')
    pylab.legend(loc='lower right')
    pylab.xlabel('Wavelength')
    pylab.ylabel('Transmission')
    pylab.xlim(900, 1000)
    pylab.figure()
    for w in [wvs[0], wvs[max]]:
        pylab.plot(atms[w].wavelen, atms[w].sb, label=w)
    pylab.plot(std.wavelen, std.sb, 'k-', label='std')
    pylab.legend(loc='lower right')
    pylab.xlabel('Wavelength')
    pylab.ylabel('Transmission')
    #pylab.show()

    return atms, wvs, std
Пример #9
0
def read_hardware():
    # read system (hardware) transmission)
    filterdir = os.getenv("LSST_THROUGHPUTS_DEFAULT")
    hardware = ("detector.dat", "m1.dat", "m2.dat", "m3.dat", "lens1.dat",
                "lens2.dat", "lens3.dat")
    sys_std = {}
    # Read in all the standard components
    for f in filterlist:
        sys_std[f] = Bandpass()
        tlist = []
        for t in hardware:
            tlist.append(os.path.join(filterdir, t))
        tlist.append(os.path.join(filterdir, "filter_" + f + ".dat"))
        sys_std[f].readThroughputList(tlist)
    sys_edge = {}
    # Read in the standard components, except shift the filter by 1% of the central wavelength near the edge
    for f in filterlist:
        sys_edge[f] = Bandpass()
        tlist = []
        for t in hardware:
            tlist.append(os.path.join(filterdir, t))
        sys_edge[f].readThroughputList(tlist)
        tmpfilter = Bandpass()
        tmpfilter.readThroughput(
            os.path.join(filterdir, "filter_" + f + ".dat"))
        effwavelenphi, effwavelensb = tmpfilter.calcEffWavelen()
        shift = effwavelensb * 0.01
        tmpfilter.wavelen = tmpfilter.wavelen + shift
        tmpfilter.resampleBandpass()
        sys_edge[f].wavelen, sys_edge[f].sb = sys_edge[f].multiplyThroughputs(
            tmpfilter.wavelen, tmpfilter.sb)
    for f in filterlist:
        junk, effwavelen = sys_std[f].calcEffWavelen()
        junk, effwavelen_edge = sys_edge[f].calcEffWavelen()
        print f, effwavelen, effwavelen_edge, effwavelen / effwavelen_edge
    return sys_std, sys_edge
Пример #10
0
tests = 2

for i in range(tests):
    t = time.time()
    print("Generating atmosphere for a test case:")
    print(paramList[i])

    # Write modtran input cards
    m.writeModtranCards(paramList[i], 'tmp')

    # Run modtran on this file.
    m.runModtran('tmp')

    dt, t = dtime(t)
    print("Generating atmosphere took %f seconds." % (dt))

    # Read the atmosphere back in and plot to screen.
    atm = Bandpass()
    #    atm.readThroughput('tmp.psc', wavelen_min=800, wavelen_max=1300, wavelen_step=0.001)
    atm.readThroughput('tmp.psc',
                       wavelen_min=300,
                       wavelen_max=1100,
                       wavelen_step=0.1)
    pylab.plot(atm.wavelen, atm.sb, 'b-')
    pylab.xlabel('Wavelength (nm)')
    pylab.ylabel('Atmospheric Transmission')

    m.cleanModtran('tmp')

pylab.show()
Пример #11
0
def read_stdatmo():
    atmosdir = "."
    atmos_bp = Bandpass()
    atmos_bp.readThroughput(os.path.join(atmosdir, "atmos_std.dat"))
    return atmos_bp
Пример #12
0
for i in range(tests):
    t = time.time()
    print "Generating atmosphere for a test case:"
    print paramList[i]
    
    # Write modtran input cards
    m.writeModtranCards(paramList[i], 'tmp')

    # Run modtran on this file.
    m.runModtran('tmp')
    
    dt, t = dtime(t)
    print "Generating atmosphere took %f seconds." %(dt)

    # Read the atmosphere back in and plot to screen. 
    atm = Bandpass()
#    atm.readThroughput('tmp.psc', wavelen_min=800, wavelen_max=1300, wavelen_step=0.001)
    atm.readThroughput('tmp.psc', wavelen_min=300, wavelen_max=1100, wavelen_step=0.1)
    pylab.plot(atm.wavelen, atm.sb, 'b-')
    pylab.xlabel('Wavelength (nm)')
    pylab.ylabel('Atmospheric Transmission')
    
    m.cleanModtran('tmp')


pylab.show()




Пример #13
0
    fnu = sed.fnu
    if sed.needResample(wavelen=wavelen, wavelen_match=bp.wavelen):
        wavelen, fnu = sed.resampleSED(wavelen, fnu, wavelen_match=bp.wavelen)
    return np.sum(fnu * bp.phi)

if __name__ == "__main__":
    pickleFile = "calculateSedDcr3.pickle"
    if not os.path.isfile(pickleFile):
        catDir = os.environ["CAT_SHARE_DATA"]
        filtDir = os.environ["LSST_THROUGHPUTS_BASELINE"]
        uBand  = Bandpass()
        gBand  = Bandpass()
        rBand  = Bandpass()
        iBand  = Bandpass()
        zBand  = Bandpass()
        uBand.readThroughput(os.path.join(filtDir, "total_u.dat"))
        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"))
        uBand.sbTophi()
        gBand.sbTophi()
        rBand.sbTophi()
        iBand.sbTophi()
        zBand.sbTophi()
    
        seen = []
        for line in open(sys.argv[1]).readlines()[1:]:
            sed, mag, nsed = line.split()

            # These seem to have funky colors
Пример #14
0
    
def integrate(sed, bp):
    wavelen = sed.wavelen
    fnu = sed.fnu
    if sed.needResample(wavelen=wavelen, wavelen_match=bp.wavelen):
        wavelen, fnu = sed.resampleSED(wavelen, fnu, wavelen_match=bp.wavelen)
    return np.sum(fnu * bp.phi)

if __name__ == "__main__":
    import multiprocessing
    pool = multiprocessing.Pool(multiprocessing.cpu_count()-2)
    
    filtDir = os.environ["LSST_THROUGHPUTS_BASELINE"]
    gBand  = Bandpass()
    rBand  = Bandpass()
    gBand.readThroughput(os.path.join(filtDir, "total_g.dat"))
    rBand.readThroughput(os.path.join(filtDir, "total_r.dat"))
    gBand.sbTophi()
    rBand.sbTophi()
    
    catDir = os.environ["CAT_SHARE_DATA"]
    
    args = []
    for line in open(sys.argv[1]).readlines()[1:]:
        sed, mag, nsed = line.split()
        mag = float(mag) 
        if mag < 16 or mag > 25:
            continue
        args.append((line, gBand, rBand, catDir))

    results = pool.map(doit, args)