Пример #1
0
def calcEffWavelen(hardware, title, throughputDir=None):
    photParams = PhotometricParameters()
    lsstDefaults = LSSTdefaults()
    atmos = {}
    stdAtmoFile = os.path.join(os.getenv('SYSENG_THROUGHPUTS_DIR'),
                               'siteProperties/pachonModtranAtm_12.dat')
    atmos['std'] = Bandpass()
    atmos['std'].readThroughput(stdAtmoFile)
    multiAtmos = False
    if throughputDir is None:
        throughputDir = os.getenv('THROUGHPUTS_DIR')
    if throughputDir is not None:
        multiAtmos = True
        Xarr = np.arange(1.0, 2.55, 0.1)
        for X in Xarr:
            atmos['%.1f' % X] = Bandpass()
            atmos['%.1f' % X].readThroughput(
                os.path.join(throughputDir,
                             'atmos/atmos_%d.dat' % (int(X * 10))))

    atmoskeys = sorted(atmos.keys())
    print title
    print '    %s' % ('    '.join(atmoskeys))
    system = Bandpass()
    effsb = {}
    for f in ['u', 'g', 'r', 'i', 'z', 'y']:
        writestring = '%s ' % f
        for k in atmoskeys:
            system.wavelen, system.sb = hardware[f].multiplyThroughputs(
                atmos[k].wavelen, atmos[k].sb)
            effphi, effsb[k] = system.calcEffWavelen()
            writestring += '%.2f ' % (effsb[k])
        print writestring
def calcEffWavelen(hardware, title, throughputDir=None):
    photParams = PhotometricParameters()
    lsstDefaults = LSSTdefaults()
    atmos = {}
    stdAtmoFile = os.path.join(os.getenv('SYSENG_THROUGHPUTS_DIR'), 'siteProperties/pachonModtranAtm_12.dat')
    atmos['std'] = Bandpass()
    atmos['std'].readThroughput(stdAtmoFile)
    multiAtmos = False
    if throughputDir is None:
        throughputDir = os.getenv('THROUGHPUTS_DIR')
    if throughputDir is not None:
        multiAtmos = True
        Xarr = np.arange(1.0, 2.55, 0.1)
        for X in Xarr:
            atmos['%.1f' %X] = Bandpass()
            atmos['%.1f' %X].readThroughput(os.path.join(throughputDir,
                                                         'atmos/atmos_%d.dat' %(int(X*10))))

    atmoskeys = sorted(atmos.keys())
    print title
    print '    %s' %('    '.join(atmoskeys))
    system = Bandpass()
    effsb = {}
    for f in ['u', 'g', 'r', 'i', 'z', 'y']:
        writestring = '%s ' %f
        for k in atmoskeys:
            system.wavelen, system.sb = hardware[f].multiplyThroughputs(atmos[k].wavelen, atmos[k].sb)
            effphi, effsb[k] = system.calcEffWavelen()
            writestring += '%.2f ' %(effsb[k])
        print writestring
Пример #3
0
    def Load_Atmosphere(self, airmass=1.2):

        self.airmass = airmass
        if self.airmass > 0.:
            atmosphere = Bandpass()

            #official atmospheric simulation
            if not self.libradtran:
                path_atmos = os.path.join(self.atmosDir,
                                          'atmos_%d.dat' % (self.airmass * 10))
                if os.path.exists(path_atmos):
                    atmosphere.readThroughput(
                        os.path.join(self.atmosDir,
                                     'atmos_%d.dat' % (self.airmass * 10)))
                else:
                    atmosphere.readThroughput(
                        os.path.join(self.atmosDir, 'atmos.dat'))
                self.atmos = Bandpass(wavelen=atmosphere.wavelen,
                                      sb=atmosphere.sb)
            else:  # with libradtran
                path, thefile = ProcessSimulationaer(airmass, atm_pwv,
                                                     atm_ozone, atm_wl0,
                                                     atm_aer)
                #path,thefile=ProcessSimulation(am,pwv,ozone)
                atmdata = np.loadtxt(os.path.join(path, thefile))
                wl = atmdata[:, 0]
                atm = atmdata[:, 1]
                func = interp1d(wl, atm, kind='linear')
                transm = func(WL)
                atmosphere.wavelen = WL
                atmosphere.sb = transm
                self.atmos = Bandpass(wavelen=WL, sb=transm)

            for f in self.filterlist:
                wavelen, sb = self.lsst_system[f].multiplyThroughputs(
                    atmosphere.wavelen, atmosphere.sb)
                self.lsst_atmos[f] = Bandpass(wavelen=wavelen, sb=sb)

            if self.aerosol:
                atmosphere_aero = Bandpass()
                atmosphere_aero.readThroughput(
                    os.path.join(self.atmosDir,
                                 'atmos_%d_aerosol.dat' % (self.airmass * 10)))
                self.atmos_aerosol = Bandpass(wavelen=atmosphere_aero.wavelen,
                                              sb=atmosphere_aero.sb)

                for f in self.filterlist:
                    wavelen, sb = self.lsst_system[f].multiplyThroughputs(
                        atmosphere_aero.wavelen, atmosphere_aero.sb)
                    self.lsst_atmos_aerosol[f] = Bandpass(wavelen=wavelen,
                                                          sb=sb)
        else:
            for f in self.filterlist:
                self.lsst_atmos[f] = self.lsst_system[f]
                self.lsst_atmos_aerosol[f] = self.lsst_system[f]
Пример #4
0
def read_filtersonly(shift_perc=None):
    # read the filter throughput curves only (called from read_hardware as well)
    # apply a shift of +shift_perc/100 * eff_wavelength to the wavelengths of the filter.
    filterdir = os.getenv("LSST_THROUGHPUTS_DEFAULT")
    filters = {}
    for f in filterlist:
        filters[f] = Bandpass()
        filters[f].readThroughput(os.path.join(filterdir, "filter_" + f + ".dat"))
        effwavelenphi, effwavelensb = filters[f].calcEffWavelen()
        if shift_perc != None:
            shift = effwavelensb * shift_perc/100.0
            print f, shift
            filters[f].wavelen = filters[f].wavelen + shift
            filters[f].resampleBandpass()
    return filters
Пример #5
0
def read_hardware(shift_perc=None):
    # read system (hardware) transmission, return dictionary of system hardware (keyed to filter)
    filterdir = os.getenv("LSST_THROUGHPUTS_DEFAULT")
    hardware = ("detector.dat", "m1.dat", "m2.dat", "m3.dat", "lens1.dat", "lens2.dat", "lens3.dat")
    # Read in the standard components, but potentially shift the filter by shift_perc percent.
    filters = read_filtersonly(shift_perc=shift_perc)
    sys = {}
    for f in filterlist:
        sys[f] = Bandpass()
        # put together the standard component list
        tlist = []
        for t in hardware:
            tlist.append(os.path.join(filterdir, t))
        # read in the standard components, combine into sys
        sys[f].readThroughputList(tlist)
        # multiply by the filter throughput for final hardware throughput (no atmosphere)
        sys[f].wavelen, sys[f].sb = sys[f].multiplyThroughputs(filters[f].wavelen, filters[f].sb)
    return sys
Пример #6
0
    def Set_Atmosphere(self, airmass, wavelenatm, transmatm):

        self.airmass = airmass
        if self.airmass > 0.:
            atmosphere = Bandpass()

            # interpolation
            func = interp1d(wavelenatm, transmatm, kind='linear')
            transm = func(WL)

            atmosphere.wavelen = WL
            atmosphere.sb = transm
            self.atmos = Bandpass(wavelen=WL, sb=transm)

            # loop on filters to update effective throughput
            for f in self.filterlist:
                wavelen, sb = self.lsst_system[f].multiplyThroughputs(
                    atmosphere.wavelen, atmosphere.sb)
                self.lsst_atmos[f] = Bandpass(wavelen=wavelen, sb=sb)
    plt.ylim(0, 1)
    plt.xlim(300, 1100)
    plt.xlabel('Wavelength (nm)')
    plt.ylabel('Fractional Throughput Response')
    plt.title('System total response curves %s' %(title))
    return m5


if __name__ == '__main__':

    # Set the directories for each component.
    # Note that this sets the detector to be the 'generic detector' (minimum of each vendor).
    throughputDir = os.getenv('LSST_THROUGHPUTS_DEFAULT')
    defaultDirs = bu.setDefaultDirs()

    # Build the system and hardware throughput curves (without aerosols, with X=1.0).
    atmosphere = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='atmos_10_aerosol.dat')
    hardware = {}
    system = {}
    for f in ['u', 'g', 'r', 'i', 'z', 'y']:
        hardware[f] = Bandpass()
        system[f] = Bandpass()
        hardware[f].readThroughputList(componentList=['detector.dat', 'filter_'+f+'.dat','lens1.dat', 'lens2.dat', 'lens3.dat', 'm1.dat', 'm2.dat', 'm3.dat'],
                                       rootDir=throughputDir)
        system[f].wavelen, system[f].sb = hardware[f].multiplyThroughputs(atmosphere.wavelen, atmosphere.sb)

    m5 = calcM5(hardware, system, atmosphere, title='')


    plt.show()
    plt.title('System total response curves %s' % (title))
    return m5


if __name__ == '__main__':

    # Set the directories for each component.
    # Note that this sets the detector to be the 'generic detector' (minimum of each vendor).
    throughputDir = os.getenv('LSST_THROUGHPUTS_DEFAULT')
    defaultDirs = bu.setDefaultDirs()

    # Build the system and hardware throughput curves (without aerosols, with X=1.0).
    atmosphere = bu.readAtmosphere(defaultDirs['atmosphere'],
                                   atmosFile='atmos_10_aerosol.dat')
    hardware = {}
    system = {}
    for f in ['u', 'g', 'r', 'i', 'z', 'y']:
        hardware[f] = Bandpass()
        system[f] = Bandpass()
        hardware[f].readThroughputList(componentList=[
            'detector.dat', 'filter_' + f + '.dat', 'lens1.dat', 'lens2.dat',
            'lens3.dat', 'm1.dat', 'm2.dat', 'm3.dat'
        ],
                                       rootDir=throughputDir)
        system[f].wavelen, system[f].sb = hardware[f].multiplyThroughputs(
            atmosphere.wavelen, atmosphere.sb)

    m5 = calcM5(hardware, system, atmosphere, title='')

    plt.show()