def build_coeff_tables(): """ Use the latest throughput values to build Table 2. Requires LSST stack installed and syseng_throughputs setup """ from calcM5 import calcM5 import bandpassUtils as bu from lsst.utils import getPackageDir defaultDirs = bu.setDefaultDirs( rootDir=getPackageDir('syseng_throughputs')) addLosses = True atmosphere = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='atmos_10_aerosol.dat') hardware, system = bu.buildHardwareAndSystem(defaultDirs, addLosses, atmosphereOverride=atmosphere) m5_vals = calcM5(hardware, system, atmosphere, title='', return_t2_values=True) np.savez('m5_vals.npz', m5_vals=m5_vals)
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()
fwhm_eff = 1.16 * np.sqrt(fwhm_system**2 + 1.04 * fwhm_atmo**2) # Translate to FWHMgeom. fwhm_geom = 0.822 * fwhm_eff + 0.052 return fwhm_eff, fwhm_geom if __name__ == '__main__': # Set the directories for each component. # Note that this sets the detector to be the 'generic detector' (minimum of each vendor). defaultDirs = bu.setDefaultDirs(rootDir = '..') # To use a particular vendor, uncomment one of the following lines or edit as necessary. # defaultDirs['detector'] = 'vendor1' # defaultDirs['detector'] = 'vendor2' # Add losses to each component? addLosses = True # Build the system and hardware throughput curves (without aerosols, with X=1.0). #atmosphere = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='atmos_10.dat') #hardware, system = bu.buildHardwareAndSystem(defaultDirs, addLosses, atmosphereOverride=atmosphere) #m5 = calcM5(hardware, system, atmosphere, title='') atmosphere = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='atmos_10_aerosol.dat') hardware, system = bu.buildHardwareAndSystem(defaultDirs, addLosses, atmosphereOverride=atmosphere) m5 = calcM5(hardware, system, atmosphere, title='') plt.show()
if title == "Vendor combo": title = "" plt.title("System total response curves %s" % (title)) plt.savefig("../plots/system+sky" + title + ".png", format="png", dpi=600) return m5 if __name__ == "__main__": defaultDirs = bu.setDefaultDirs(rootDir="..") addLosses = True hardware = {} system = {} m5 = {} atmosphere = bu.readAtmosphere(defaultDirs["atmosphere"], atmosFile="atmos_10_aerosol.dat") hardware["combo"], system["combo"] = bu.buildHardwareAndSystem(defaultDirs, atmosphereOverride=atmosphere) m5["combo"] = calcM5(hardware["combo"], system["combo"], atmosphere, title="combo") genericDetector = defaultDirs["detector"] for det in [1, 2]: defaultDirs["detector"] = os.path.join(genericDetector, "vendor%d" % det) hardware[det], system[det] = bu.buildHardwareAndSystem(defaultDirs, atmosphereOverride=atmosphere) m5[det] = calcM5(hardware[det], system[det], atmosphere, title="vendor%d" % (det)) # Show what these look like (print m5 limits on throughput curves) plt.figure() for f in filterlist: for det in [1, 2]: if det == 1: linestyle = ":" spacer = " "
# total_[ugrizy].dat # hardware_[ugrizy].dat # Read the data needed from the syseng_throughput repo. defaultDirs = bu.setDefaultDirs() addLosses = True detector = bu.buildDetector(defaultDirs['detector'], addLosses) filters = bu.buildFilters(defaultDirs['filters'], addLosses) lens1 = bu.buildLens(defaultDirs['lens1'], addLosses) lens2 = bu.buildLens(defaultDirs['lens2'], addLosses) lens3 = bu.buildLens(defaultDirs['lens3'], addLosses) m1 = bu.buildMirror(defaultDirs['mirror1'], addLosses) m2 = bu.buildMirror(defaultDirs['mirror2'], addLosses) m3 = bu.buildMirror(defaultDirs['mirror3'], addLosses) atmos_std = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='pachonModtranAtm_12_aerosol.dat') atmos_10 = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='atmos_10_aerosol.dat') darksky = Sed() darksky.readSED_flambda(os.path.join(defaultDirs['atmosphere'], 'darksky.dat')) hardware, system = bu.buildHardwareAndSystem(defaultDirs, addLosses=addLosses, atmosphereOverride=atmos_std) # Write the data to disk. outDir = 'baseline' if not os.path.isdir(outDir): os.makedirs(outDir) shutil.copy('../README.md', os.path.join(outDir, 'README.md'))
bu.plotBandpasses(atmodict) return atmosphere_aerosol if __name__ == '__main__': parser = argparse.ArgumentParser( description= 'Add a standard aerosol component to an atmosphere without aerosols') parser.add_argument('atmosphereFile', type=str, default=None, help='The atmosphere file to add aerosols to.') parser.add_argument('airmass', type=float, default=None, help='The airmass of the atmosphere file.') args = parser.parse_args() atmosDir, atmosFile = os.path.split(args.atmosphereFile) defaultDirs = bu.setDefaultDirs() atmosphere = bu.readAtmosphere(atmosDir, atmosFile) atmosphere_aerosol = addAerosol(atmosphere, args.airmass) outfile = atmosphere.bandpassname.replace('.dat', '') + '_aerosol.dat' atmosphere_aerosol.writeThroughput(outfile, print_header='Added aerosol component') plt.show()
# total_[ugrizy].dat # hardware_[ugrizy].dat # Read the data needed from the syseng_throughput repo. defaultDirs = bu.setDefaultDirs() addLosses = True detector = bu.buildDetector(defaultDirs['detector'], addLosses) filters = bu.buildFilters(defaultDirs['filters'], addLosses) lens1 = bu.buildLens(defaultDirs['lens1'], addLosses) lens2 = bu.buildLens(defaultDirs['lens2'], addLosses) lens3 = bu.buildLens(defaultDirs['lens3'], addLosses) m1 = bu.buildMirror(defaultDirs['mirror1'], addLosses) m2 = bu.buildMirror(defaultDirs['mirror2'], addLosses) m3 = bu.buildMirror(defaultDirs['mirror3'], addLosses) atmos_std = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='pachonModtranAtm_12_aerosol.dat') atmos_10 = bu.readAtmosphere(defaultDirs['atmosphere'], atmosFile='atmos_10_aerosol.dat') darksky = Sed() darksky.readSED_flambda(os.path.join(defaultDirs['atmosphere'], 'darksky.dat')) hardware, system = bu.buildHardwareAndSystem(defaultDirs, addLosses=addLosses, atmosphereOverride=atmos_std) # Write the data to disk. outDir = 'baseline' if not os.path.isdir(outDir): os.makedirs(outDir) version = subprocess.check_output(['git', 'describe']).strip() sha1 = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip() print "version", version, "sha1", sha1 versioninfo = '# Version %s\n'%(version) versioninfo += '# sha1 %s\n' %(sha1)
tau = tau0 * np.power((wavelen0/atmosphere.wavelen), alpha) # Generate new atmosphere bandpass with aerosols. atmosphere_aerosol = Bandpass() atmosphere_aerosol.setBandpass(wavelen = atmosphere.wavelen, sb = atmosphere.sb * np.exp(-tau*X)) if plotAtmosphere: # Plot for a check: atmodict = {'Original atmosphere':atmosphere, 'With aerosols': atmosphere_aerosol} bu.plotBandpasses(atmodict) return atmosphere_aerosol if __name__=='__main__': parser = argparse.ArgumentParser(description='Add a standard aerosol component to an atmosphere without aerosols') parser.add_argument('atmosphereFile', type=str, default=None, help='The atmosphere file to add aerosols to.') parser.add_argument('airmass', type=float, default=None, help='The airmass of the atmosphere file.') args = parser.parse_args() atmosDir, atmosFile = os.path.split(args.atmosphereFile) defaultDirs = bu.setDefaultDirs() atmosphere = bu.readAtmosphere(atmosDir, atmosFile) atmosphere_aerosol = addAerosol(atmosphere, args.airmass) outfile = atmosphere.bandpassname.replace('.dat', '') + '_aerosol.dat' atmosphere_aerosol.writeThroughput(outfile, print_header='Added aerosol component') plt.show()
bu.plotBandpasses(oldfilters, newfig=False, linestyle=':', title='Compare filters') # Put the individual filter bandpasses straight into 'throughputs', for easier use below. for f in filters: throughputs[f] = filters[f] # Build and compare the mirror curves, for mirrors 1/2/3. for mirror in ('mirror1', 'mirror2', 'mirror3'): throughputs[mirror] = bu.buildMirror(defaultDirs[mirror], addLosses) mfile = ('../intermediateFiles/components/telescope/' + mirror[0] + mirror[-1] + 'Throughput.dat') comparison.readThroughput(mfile) plotDict = {'New %s' %(mirror):throughputs[mirror], 'Old %s' %(mirror):comparison} bu.plotBandpasses(plotDict, title='Compare %s' %(mirror)) # Read the atmosphere file. throughputs['atmosphere'] = bu.readAtmosphere(defaultDirs['atmosphere']) # Plot all components. bu.plotBandpasses(throughputs, title='All components') # Combine components by hand. Compare to combination returned from bandpassUtils. core_sb = (throughputs['detector'].sb * throughputs['lens1'].sb * throughputs['lens2'].sb * throughputs['lens3'].sb * throughputs['mirror1'].sb * throughputs['mirror2'].sb * throughputs['mirror3'].sb) hardware = {} system = {} for f in filters: hardware[f] = Bandpass() system[f] = Bandpass() wavelen = filters[f].wavelen hw_sb = core_sb * filters[f].sb
throughputs[f] = filters[f] # Build and compare the mirror curves, for mirrors 1/2/3. for mirror in ('mirror1', 'mirror2', 'mirror3'): throughputs[mirror] = bu.buildMirror(defaultDirs[mirror], addLosses) mfile = ('../intermediateFiles/components/telescope/' + mirror[0] + mirror[-1] + 'Throughput.dat') comparison.readThroughput(mfile) plotDict = { 'New %s' % (mirror): throughputs[mirror], 'Old %s' % (mirror): comparison } bu.plotBandpasses(plotDict, title='Compare %s' % (mirror)) # Read the atmosphere file. throughputs['atmosphere'] = bu.readAtmosphere(defaultDirs['atmosphere']) # Plot all components. bu.plotBandpasses(throughputs, title='All components') # Combine components by hand. Compare to combination returned from bandpassUtils. core_sb = (throughputs['detector'].sb * throughputs['lens1'].sb * throughputs['lens2'].sb * throughputs['lens3'].sb * throughputs['mirror1'].sb * throughputs['mirror2'].sb * throughputs['mirror3'].sb) hardware = {} system = {} for f in filters: hardware[f] = Bandpass() system[f] = Bandpass() wavelen = filters[f].wavelen