Coverage for python/lsst/sims/catUtils/exampleCatalogDefinitions/phoSimCatalogExamples.py : 93%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Instance Catalog""" PhoSimAstrometryGalaxies, PhoSimAstrometrySSM, FrozenSNCat)
"PhoSimCatalogPoint", "PhoSimCatalogZPoint", "PhoSimCatalogSN", "PhoSimCatalogSersic2D", "PhoSimCatalogSSM", "PhoSimSpecMap", "DefaultPhoSimHeaderMap", 'DefaultPhoSimInstanceCatalogCols']
dirDict={'(^lte)': 'starSED/phoSimMLT'})
# This is a dict of transformations mapping from data in OpSim to header # values expected by PhoSim. The dict is keyed on the names of PhoSim # parameters. The values of the dict are either straight values, in which # case those values are written to the PhoSim InstanceCatalog header, or tuples # containing the name of the OpSim column which should be use to calculate # the PhoSim parameter and any transformation needed to go from OpSim # units to PhoSim units. # # PhoSim header parameters are documented here # https://bitbucket.org/phosim/phosim_release/wiki/Instance%20Catalog # # OpSim columns are documented here # https://www.lsst.org/scientists/simulations/opsim/summary-table-column-descriptions-v335
'obshistid': ('obsHistID', None), 'moonra': ('moonRA', np.degrees), 'moondec': ('moonDec', np.degrees), 'moonphase': ('moonPhase', None), 'moonalt': ('moonAlt', np.degrees), 'dist2moon': ('dist2Moon', np.degrees), 'sunalt': ('sunAlt', np.degrees), 'seeing': ('rawSeeing', None), 'vistime': ('visitExpTime', lambda x: x + 3.0), 'nsnap': 2, 'seed': ('obsHistID', None)}
# This variable contains all of the columns in a phosim Instance Catalog # Can be used to reconstruct the information encoded in a phosim instance # Catalog , 'MAG_NORM', 'SED_NAME', 'REDSHIFT'\ , 'GAMMA1', 'GAMMA2', 'MU', 'DELTA_RA'\ , 'DELTA_DEC', 'SOURCE_TYPE'\ , 'source_pars', 'DUST_REST_NAME'\ , 'dust_pars_1a', 'dust_pars_1b'\ , 'DUST_LAB_NAME', 'dust_pars_2a'\ , 'dust_pars_2b')
""" Find the value of a PhoSim header parameter given a PhoSimHeaderMap, and an ObservationMetaData
@param [in] param is the name of the header parameter desired.
@param [in] phosim_header_map is a phoSimHeaderMap dict
@param [in] obs is an ObservationMetaData
@param [out] returns the value of the PhoSim header parameter """
""" Write the data contained in an ObservationMetaData as a header in a PhoSim InstanceCatalog.
obs is the ObservationMetaData
file_handle points to the catalog being written. """
"a phoSimHeaderMap in your call to write_catalog().\n" "\n" "A phoSimHeaderMap is a dict that maps between columns stored in the " "OpSim database from which an ObservationMetaData was created and " "header parameters expected by PhoSim. The dict is keyed on the names of PhoSim " "parameters. The values of the dict are either straight values, in which " "case those values are written to the PhoSim InstanceCatalog header, or tuples " "containing the name of the OpSim column which should be use to calculate " "the PhoSim parameter and any transformation needed to go from OpSim " "units to PhoSim units (the transform is 'None' if no transform is needed).\n" "\n" "To add a phoSimHeaderMap, simple assign it to the 'phoSimHeaderMap' " "member variable of your catalog with (for instance):\n" "\n" "myCat.phoSimHeaderMap = my_phosim_header_map\n" "\n" "Before calling write_catalog()\n" "\n" "The header parameters expected by PhoSim can be found at\n" "\n" "https://bitbucket.org/phosim/phosim_release/wiki/Instance%20Catalog\n" "\n" "The contents of the OpSim database's Summary table can be found at\n" "\n" "https://www.lsst.org/scientists/simulations/opsim/summary-table-column-descriptions-v335\n" "\n" "If you do not wish to use any of these columns, you can just pass in an empty " "dict. If you want to use a pre-made mapping, use the DefaultPhoSimHeaderMap " "imported from lsst.sims.catUtils.exampleCatalogDefinitions\n" "\n" "Note: do not specify ra, dec, alt, az, mjd, filter, or rotSkyPos in your " "phoSimHeaderMap. These are handled directly by the ObservationMetaData " "to ensure self-consistency.\n" "\n" "For reference, the OpSim columns you can choose to map (i.e. those contained " "in your ObservationMetaData) are:\n\n" + raw_opsim_contents + "\n(Even if your ObservationMetaData contains no extra OpSim Columns " "you may wish to consider adding default PhoSim parameters through " "the phoSimHeaderMap)")
# PhoSim wants the MJD at the middle of the visit (i.e. between the two exposures # in our two-snap model). OpSim gives the MJD at the start of the visit. # below we calculate the change in MJD necessary to transform the OpSim value # into the PhoSim value delta_t = 0.5*vistime else:
{'u': 0, 'g': 1, 'r': 2, 'i': 3, 'z': 4, 'y': 5}[obs.bandpass])
# sort the header map keys so that PhoSim headers generated with the same # map always have parameters in the same order.
elif isinstance(val, int): file_handle.write('%s %ld\n' % (name, val)) else: file_handle.write('%s %s\n' % (name, str(val)))
def get_prefix(self):
def get_sedFilepath(self): for k in self.column_by_name('sedFilename')])
def get_spatialmodel(self):
def get_phoSimMagNorm(self): """ This getter returns the magnitude normalization expected by PhoSim (the magnitude at 500 nm).
To account for variability, the getter adds the delta_lsst_x column from the Variability mixin where 'x' is the bandpass defined by self.observation_metadata.bandpass (assuming that self.observation_metadata.bandpass is not list-like; if it is list-like, then no variability is added to the magNorm value).
Redshift is currently ignored. That may or may not be appropriate. This requires further investigation into the behavior of PhoSim. """
else:
'redshift', 'gamma1', 'gamma2', 'kappa', 'raOffset', 'decOffset', 'spatialmodel', 'internalExtinctionModel', 'galacticExtinctionModel', 'galacticAv', 'galacticRv']
('kappa', 0., float), ('raOffset', 0., float), ('decOffset', 0., float), ('galacticExtinctionModel', 'CCM', (str, 3)), ('galacticRv', 3.1, float), ('internalExtinctionModel', 'none', (str, 4))]
'redshift', 'gamma1', 'gamma2', 'kappa', 'raOffset', 'decOffset', 'spatialmodel', 'internalExtinctionModel', 'galacticExtinctionModel', 'galacticAv', 'galacticRv']
('raOffset', 0., float), ('decOffset', 0., float), ('spatialmodel', 'ZPOINT', (str, 6)), ('galacticExtinctionModel', 'CCM', (str, 3)), ('galacticAv', 0.1, float), ('galacticRv', 3.1, float), ('internalExtinctionModel', 'none', (str, 4))]
""" Mixin for PhoSim Instance Catalogs in PhoSim """
return self.column_by_name('TsedFilepath')
return self.column_by_name('magNorm')
'redshift', 'gamma1', 'gamma2', 'kappa', 'raOffset', 'decOffset', 'spatialmodel', 'majorAxis', 'minorAxis', 'positionAngle', 'sindex', 'internalExtinctionModel', 'internalAv', 'internalRv', 'galacticExtinctionModel', 'galacticAv', 'galacticRv',]
('raOffset', 0., float), ('decOffset', 0., float), ('galacticAv', 0.1, float), ('galacticRv', 3.1, float), ('galacticExtinctionModel', 'CCM', (str, 3)), ('internalExtinctionModel', 'CCM', (str, 3)), ('internalAv', 0., float), ('internalRv', 3.1, float)]
'majorAxis': arcsecFromRadians, 'minorAxis': arcsecFromRadians}
def get_phoSimCoordinates(self): """Getter for RA, Dec coordinates expected by PhoSim.
These are observed RA, Dec coordinates with the effects of nutation, aberration, and precession subtracted out by the PhosimInputBase._dePrecess() method. This preserves the relative effects of nutation, aberration, and precession while re-aligning the catalog with the boresite RA, Dec so that astrometric solutions make sense."""
epoch=self.db_obj.epoch)
'redshift', 'gamma1', 'gamma2', 'kappa', 'raOffset', 'decOffset', 'spatialmodel', 'internalExtinctionModel', 'galacticExtinctionModel']
('kappa', 0., float), ('raOffset', 0., float), ('decOffset', 0., float), ('galacticExtinctionModel', 'none', (str, 4)), ('internalExtinctionModel', 'none', (str, 4))]
|