Coverage for python/lsst/sims/catUtils/matchSED/matchUtils.py : 86%

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
# -*- coding: utf-8 -*- Created on Wed Feb 25 14:07:03 2015
@author: Bryce Kalmbach """
""" This class is designed to provide methods that will be useful to both selectStarSED and selectGalaxySED. """
redshift = None, filtRange = None):
""" This will find the magNorm value that gives the closest match to the magnitudes of the object using the matched SED. Uses scipy.optimize.leastsq to find the values of fluxNorm that minimizes the function: ((flux_obs - (fluxNorm*flux_model))/flux_error)**2.
@param [in] objectMags are the magnitude values for the object with extinction matching that of the SED object. In the normal case using the selectSED routines above it will be dereddened mags.
@param [in] sedObj is an Sed class instance that is set with the wavelength and flux of the matched SED
@param [in] bandpassDict is a BandpassDict class instance with the Bandpasses set to those for the magnitudes given for the catalog object
@param [in] mag_error are provided error values for magnitudes in objectMags. If none provided then this defaults to 1.0. This should be an array of the same length as objectMags.
@param [in] redshift is the redshift of the object if the magnitude is observed
@param [in] filtRange is a selected range of filters specified by their indices in the bandpassList to match up against. Used when missing data in some magnitude bands.
@param [out] bestMagNorm is the magnitude normalization for the given magnitudes and SED """
else:
""" This will calculate a set of colors from a list of SED objects when there is no need to redshift the SEDs.
@param [in] sedList is the set of spectral objects from the models SEDs provided by loaders in rgStar or rgGalaxy. NOTE: Since this uses photometryBase.manyMagCalc_list the SED objects will be changed.
@param [in] bandpassDict is a BandpassDict class instance with the Bandpasses set to those for the magnitudes given for the catalog object
@param [in] makeCopy indicates whether or not to operate on copies of the SED objects in sedList since this method will change the wavelength grid.
@param [out] modelColors is the set of colors in the Bandpasses provided for the given sedList. """
else:
""" This will correct for extinction effects in a set of catalog Magnitudes.
@param [in] ebvVals is a list of ebv Values from calculateEBV in ebv.py or given by user that correspond to the same set of objects as the set of magnitudes.
@param [in] catMags is an array of the magnitudes of the catalog objects.
@param [in] extCoeffs is a list of the coefficients which should come from Schlafly and Finkbeiner (2011) (ApJ, 737, 103) for the same filters and in the same order as the catalog mags.
@param [out] deRedMags is the array of corrected magnitudes. """
""" This class provides loading routines for the star SEDs currently in sims_sed_library. To load one's own SED library, the user can subclass this and add their own loader following the format of those included here. """
""" @param [in] sEDDir is a place to specify a different path to a directory that follows the same directory structure as SIMS_SED_LIBRARY. If not specified, this will attempt to default to the SIMS_SED_LIBRARY.
@param [in] kuruczDir is a place to specify a different path to kurucz SED files than the files in the LSST sims_sed_library. If set to None it will default to the LSST library. Will probably be most useful for those who want to use loadGalfast without downloading the entire LSST sims_sed_library which contains much more than just the star SEDs.
@param [in] mltDir is the same as kuruczPath except that it specifies a directory for the mlt SEDs
@param [in] wdDir is the same as the previous two except that it specifies a path to an alternate white dwarf SED directory. """ #Use SpecMap to pull the directory locations
except: self.sEDDir = None else: self.sEDDir = sEDDir
""" By default will load all seds in kurucz directory. The user can also define a subset of what's in the directory and load only those SEDs instead. Will skip over extraneous files in sed folder.
@param [in] subset is the list of the subset of files wanted if one doesn't want all files in the kurucz directory.
@param [out] sedList is the set of model SED spectra objects to be passed onto the matching routines. """
try: self.kuruczDir = str(self.sEDDir + '/' + self.specMapDict['kurucz'] + '/') except: raise ValueError(str('self.kuruczDir is None. ' + 'Add path to kurucz directory.'))
else:
else:
except: continue
""" By default will load all seds in mlt directory. The user can also define a subset of what's in the directory and load only those SEDs instead. Will skip over extraneous files in sed folder.
@param [in] subset is the list of the subset of files wanted if one doesn't want all files in the mlt directory.
@param [out] sedList is the set of model SED spectra objects to be passed onto the matching routines. """
try: self.mltDir = str(self.sEDDir + '/' + self.specMapDict['mlt'] + '/') except: raise ValueError(str('self.mltDir is None. ' + 'Add path to mlt directory.'))
else:
except: continue
""" By default will load all seds in wd directory. The user can also define a subset of what's in the directory and load only those SEDs instead. Will skip over extraneous files in sed folder.
@param [in] subset is the list of the subset of files wanted if one doesn't want all files in the kurucz directory.
@param [out] sedListH is the set of model SED spectra objects for Hydrogen WDs to be passed onto the matching routines.
@param [out] sedListHE is the set of model SED spectra objects for Helium WDs to be passed onto the matching routines. """
try: self.wdDir = str(self.sEDDir + '/' + self.specMapDict['wd'] + '/') except: raise ValueError(str('self.wdDir is None. ' + 'Add path to wddirectory.'))
else:
else:
except: continue
""" This class provides loading routines for the galaxy SEDs currently in sims_sed_library. To load one's own SED library, the user can subclass this and add their own loader following the format of those included here. """
""" @param [in] galDir is the directory where the galaxy SEDs are stored """ # Use SpecMap to pull in directory's location in LSST Stack specMap = SpecMap() specFileStart = 'Exp' #Start of sample BC03 name in sims_sed_library for key, val in sorted(specMap.subdir_map.items()): if re.match(key, specFileStart): galSpecDir = str(val) self.galDir = str(lsst.utils.getPackageDir('sims_sed_library') + '/' + galSpecDir) else:
""" This loads the Bruzual and Charlot SEDs that are currently in the SIMS_SED_LIBRARY. If the user wants to use different SEDs another loading method can be created and used in place of this.
@param [in] subset is the list of the subset of files in the galDir that the user can specify if using all the SEDs in the directory is not desired.
@param [out] sedList is the set of model SED spectra objects to be passed onto the matching routines. """
raise ValueError('self.galDir is None. Add path to galaxy directory.')
else:
#Final form is z/zSun
except: continue
|