Coverage for python/lsst/sims/maf/slicers/baseSpatialSlicer.py : 96%

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
# The base class for all spatial slicers. # Slicers are 'data slicers' at heart; spatial slicers slice data by RA/Dec and # return the relevant indices in the simData to the metric. # The primary things added here are the methods to slice the data (for any spatial slicer) # as this uses a KD-tree built on spatial (RA/Dec type) indexes.
# For the footprint generation and conversion between galactic/equatorial coordinates.
"""Base spatial slicer object, contains additional functionality for spatial slicing, including setting up and traversing a kdtree containing the simulated data points.
Parameters ---------- lonCol : str, optional Name of the longitude (RA equivalent) column to use from the input data. Default fieldRA latCol : str, optional Name of the latitude (Dec equivalent) column to use from the input data. Default fieldDec latLonDeg : boolean, optional Flag indicating whether lat and lon values from input data are in degrees (True) or radians (False). Default True. verbose : boolean, optional Flag to indicate whether or not to write additional information to stdout during runtime. Default True. badval : float, optional Bad value flag, relevant for plotting. Default -666. leafsize : int, optional Leafsize value for kdtree. Default 100. radius : float, optional Radius for matching in the kdtree. Equivalent to the radius of the FOV. Degrees. Default 1.75. useCamera : boolean, optional Flag to indicate whether to use the LSST camera footprint or not. Default False. rotSkyPosColName : str, optional Name of the rotSkyPos column in the input data. Only used if useCamera is True. Describes the orientation of the camera orientation compared to the sky. Default rotSkyPos. mjdColName : str, optional Name of the exposure time column. Only used if useCamera is True. Default observationStartMJD. chipNames : array-like, optional List of chips to accept, if useCamera is True. This lets users turn 'on' only a subset of chips. Default 'all' - this uses all chips in the camera. """ verbose=True, badval=-666, leafsize=100, radius=1.75, useCamera=False, rotSkyPosColName='rotSkyPos', mjdColName='observationStartMJD', chipNames='all'): 'radius': radius, 'badval': badval, 'useCamera': useCamera} # RA and Dec are required slicePoint info for any spatial slicer. Slicepoint RA/Dec are in radians.
"""Use simData[self.lonCol] and simData[self.latCol] (in radians) to set up KDTree.
Parameters ----------- simData : numpy.recarray The simulated data, including the location of each pointing. maps : list of lsst.sims.maf.maps objects, optional List of maps (such as dust extinction) that will run to build up additional metadata at each slicePoint. This additional metadata is available to metrics via the slicePoint dictionary. Default None. """ 'Should probably set useCache=False in slicer.') else: np.radians(simData[self.latCol]), self.leafsize) else:
def _sliceSimData(islice): """Return indexes for relevant opsim data at slicepoint (slicepoint=lonCol/latCol value .. usually ra/dec)."""
# Build dict for slicePoint info else: self.slicePoints['dec'][islice]) # Query against tree.
# Loop through all the slicePoint keys. If the first dimension of slicepoint[key] has # the same shape as the slicer, assume it is information per slicepoint. # Otherwise, pass the whole slicePoint[key] information. Useful for stellar LF maps # where we want to pass only the relevant LF and the bins that go with it. else: else:
"""If we want to include the camera chip gaps, etc"""
"""Loop over each pointing and find which sky points are observed """ # Now to make a list of lists for looking up the relevant observations at each slicepoint # Make a kdtree for the _slicepoints_ # Using scipy 0.16 or later
# Loop over each unique pointing position lat = np.radians(simData[self.latCol]) lon = np.radians(simData[self.lonCol]) else: simData[self.rotSkyPosColName], simData[self.mjdColName]): # Find healpixels inside the FoV pointingDec=np.degrees(dec), rotSkyPos=np.degrees(rotSkyPos), mjd=mjd)
self.slicePoints['dec'][hpIndices], epoch=self.epoch, camera=self.camera, obs_metadata=obs_metadata) # If we are using only a subset of chips # Find the healpixels that fell on a chip for this pointing
"Created lookup table after checking for chip gaps."
"""Build KD tree on simDataRA/Dec using utility function from mafUtils.
simDataRA, simDataDec = RA and Dec values (in radians). leafsize = the number of Ra/Dec pointings in each leaf node.""" simDataDec, leafsize)
"""Set radius (in degrees) for kdtree search using utility function from mafUtils.""" |