Example #1
0
 def setUpClass(self):
     # Locate the dynamic version of the example Galacticus HDF5 files
     DATA = GalacticusData()
     self.snapshotFile = DATA.searchDynamic("galacticus.snapshotExample.hdf5")
     self.lightconeFile = DATA.searchDynamic("galacticus.lightconeExample.hdf5")
     self.removeSnapshotExample = False
     self.removeLightconeExample = False
     # If the file does not exist, create a copy from the static version.
     if self.snapshotFile is None:
         self.snapshotFile = DATA.dynamic+"/examples/galacticus.snapshotExample.hdf5"
         self.removeSnapshotExample = True
         if not os.path.exists(DATA.dynamic+"/examples"):
             os.makedirs(DATA.dynamic+"/examples")
         copyfile(DATA.static+"/examples/galacticus.snapshotExample.hdf5",self.snapshotFile)
     if self.lightconeFile is None:
         self.lightconeFile = DATA.dynamic+"/examples/galacticus.lightconeExample.hdf5"
         self.removeLightconeExample = True
         if not os.path.exists(DATA.dynamic+"/examples"):
             os.makedirs(DATA.dynamic+"/examples")
         copyfile(DATA.static+"/examples/galacticus.lightconeExample.hdf5",self.lightconeFile)
     # Initialize the Redshift class.
     SGALS = Galaxies(GH5Obj=GalacticusHDF5(self.snapshotFile,'r'))
     self.SZ = Redshift(SGALS)
     LGALS = Galaxies(GH5Obj=GalacticusHDF5(self.lightconeFile,'r'))
     self.LZ = Redshift(LGALS)
     return
Example #2
0
 def setUpClass(self):
     DATA = GalacticusData()
     self.snapshotFile = DATA.searchDynamic(
         "galacticus.snapshotExample.hdf5")
     self.lightconeFile = DATA.searchDynamic(
         "galacticus.lightconeExample.hdf5")
     self.removeSnapshotExample = False
     self.removeLightconeExample = False
     # If the file does not exist, create a copy from the static version.
     if self.snapshotFile is None:
         self.snapshotFile = DATA.dynamic + "/examples/galacticus.snapshotExample.hdf5"
         self.removeSnapshotExample = True
         if not os.path.exists(DATA.dynamic + "/examples"):
             os.makedirs(DATA.dynamic + "/examples")
         copyfile(DATA.static + "/examples/galacticus.snapshotExample.hdf5",
                  self.snapshotFile)
     if self.lightconeFile is None:
         self.lightconeFile = DATA.dynamic + "/examples/galacticus.lightconeExample.hdf5"
         self.removeLightconeExample = True
         if not os.path.exists(DATA.dynamic + "/examples"):
             os.makedirs(DATA.dynamic + "/examples")
         copyfile(
             DATA.static + "/examples/galacticus.lightconeExample.hdf5",
             self.lightconeFile)
     # Initialize the Totals class.
     GH5 = GalacticusHDF5(self.lightconeFile, 'r')
     GALS = Galaxies(GH5Obj=GH5)
     self.LINES = EmissionLineFlux(GALS)
     return
Example #3
0
 def setUpClass(self):
     # Locate the dynamic version of the galacticus.snapshotExample.hdf5 file.
     DATA = GalacticusData()
     self.snapshotFile = DATA.searchDynamic("galacticus.snapshotExample.hdf5")
     self.removeExample = False
     # If the file does not exist, create a copy from the static version.
     if self.snapshotFile is None:
         self.snapshotFile = DATA.dynamic+"/examples/galacticus.snapshotExample.hdf5"
         self.removeExample = True
         if not os.path.exists(DATA.dynamic+"/examples"):
             os.makedirs(DATA.dynamic+"/examples")
         copyfile(DATA.static+"/examples/galacticus.snapshotExample.hdf5",self.snapshotFile)
     # Initialize the Inclination class.
     GH5 = GalacticusHDF5(self.snapshotFile,'r')
     GALS = Galaxies(GH5Obj=GH5)
     self.INC = Inclination(GALS)
     return
# Initialize CloudyTable class
CLOUDY = CloudyTable()
# List all available emission lines
emlines = CLOUDY.listAvailableLines()

# Get the file name from the command line.
if ( len(sys.argv) != 2 ):
    sys.exit("Usage: addEmissionLines.py <galacticusModelFile>")
galacticusFileName = sys.argv[1]

print("Adding luminosities for emission lines: "+", ".join(emlines))

# We simply compute the emission lines for each output of the Galacticus output file.
model          = GalacticusHDF5(galacticusFileName,'r+')
galaxies       = Galaxies(model)

for redshift in model.availableRedshifts():
    print("Processing output at z="+str(redshift))
    # Check that this output contains galaxies
    numberGalaxies = model.countGalaxiesAtRedshift(redshift)
    # If output does not contain any galaxies then skip this output
    if numberGalaxies == 0:
        continue
    # Get redshift string
    zStr = model.getRedshiftString(redshift) # e.g. z1.0000
    # Build a list of emission line luminosities.    
    propertyNames = ["totalLineLuminosity:"+name+":observed:"+zStr for name in emlines]
    for propertyName in propertyNames:
        print("   Computing emission line luminosity: "+propertyName)
        property = galaxies.retrieveProperty(propertyName,redshift)