Coverage for python/lsst/sims/catUtils/dust/EBV.py : 94%

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
""" 1D interpolation on a grid"""
'''Class for describing a map of EBV
Images are read in from a fits file and assume a ZEA projection '''
""" read a fits file containing the ebv data"""
# read WCS information
# read projection information
""" convert long, lat angles to pixel x y
input angles are in radians but the conversion assumes radians
@param [in] gLon galactic longitude in radians
@param [in] gLat galactic latitude in radians
@param [out] x is the x pixel coordinate
@param [out] y is the y pixel coordinate
"""
# use the SFD approach to define xy pixel positions # ROTATION - Equn (4) - degenerate case else: # Assume it's an NGP projection ... theta = gLat*rad2deg phi = gLon*rad2deg + 180.0 + self.lonpole - self.crval1
# Put phi in the range [0,360) degrees
# FORWARD MAP PROJECTION - Equn (26)
# Equns (10), (11)
# SCALE FROM PHYSICAL UNITS - Equn (3) after inverting the matrix
""" Calculate EBV with option for interpolation
@param [in] glon galactic longitude in radians
@param [in] galactic latitude in radians
@param [out] ebvVal the scalar value of EBV extinction
"""
# calculate pixel values
# find the indices of the pixels bounding the point of interest
# interpolate the EBV value at the point of interest by interpolating # first in x and then in y
else:
x, y = self.xyFromSky(gLong, gLat) ix = int(x + 0.5) iy = int(y + 0.5)
return ix, iy
""" This class will give users access to calculateEbv oustide of the framework of a catalog.
To find the value of EBV at a point on the sky, create an instance of this object, and then call calculateEbv passing the coordinates of interest as kwargs
e.g.
ebvObject = EBVbase() ebvValue = ebvObject.calculateEbv(galacticCoordinates = myGalacticCoordinates)
or
ebvValue = ebvObject.calculateEbv(equatorialCoordinates = myEquatorialCoordinates)
where myGalacticCoordinates is a 2-d numpy array where the first row is galactic longitude and the second row is galactic latitude.
myEquatorialCoordinates is a 2-d numpy array where the first row is RA and the second row is dec
All coordinates are in radians
You can also specify dust maps in the northern and southern galactic hemispheres, but there are default values that the code will automatically load (see the class variables below).
The information regarding where the dust maps are located is stored in member variables ebvDataDir, ebvMapNorthName, ebvMapSouthName
The actual dust maps (when loaded) are stored in ebvMapNorth and ebvMapSouth """
# these variables will tell the mixin where to get the dust maps
# A dict to hold every open instance of an EBVmap. # Since this is being declared outside of the constructor, # it will be a class member, which means that, every time # an EBVmap is added to the cache, all EBVBase instances will # know about it.
# the set_xxxx routines below will allow the user to point elsewhere for the dust maps """ This allows the user to pick a new northern SFD map file """ self.ebvMapNorthName = word
""" This allows the user to pick a new southern SFD map file """ self.ebvMapSouthName = word
# these routines will load the dust maps for the galactic north and south hemispheres """ Load the EBV map specified by file_name. If that map has already been loaded, just return the map stored in self._ebv_map_cache. If it must be loaded, store it in the cache. """
""" This will load the northern SFD map """
""" This will load the southern SFD map """
interp=False): """ For an array of Gal long, lat calculate E(B-V)
@param [in] galacticCoordinates is a numpy.array; the first row is galactic longitude, the second row is galactic latitude in radians
@param [in] equatorialCoordinates is a numpy.array; the first row is RA, the second row is Dec in radians
@param [in] northMap the northern dust map
@param [in] southMap the southern dust map
@param [in] interp is a boolean determining whether or not to interpolate the EBV value
@param [out] ebv is a list of EBV values for all of the gLon, gLat pairs
"""
# raise an error if the coordinates are specified in both systems "equatorialCoordinates in calculateEbv")
# convert (ra,dec) into gLon, gLat
# raise an error if you did not specify ra or dec
equatorialCoordinates[1, :]))
# identify (by index) which points are in the galactic northern hemisphere # and which points are in the galactic southern hemisphere # taken from # http://stackoverflow.com/questions/4578590/python-equivalent-of-filter-getting-two-output-lists-i-e-partition-of-a-list enumerate(galacticCoordinates[1, :]), ([], []))
|