Coverage for python/lsst/sims/maf/slicers/userPointsSlicer.py : 10%

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
1import numpy as np
2from lsst.sims.maf.plots.spatialPlotters import BaseSkyMap, BaseHistogram
3from .baseSpatialSlicer import BaseSpatialSlicer
5__all__ = ['UserPointsSlicer']
8class UserPointsSlicer(BaseSpatialSlicer):
9 """A spatial slicer that evaluates pointings overlapping user-provided list of points.
11 Parameters
12 ----------
13 ra : list or numpy.ndarray
14 User-selected RA points, in degrees. Stored internally in radians.
15 dec : list or numpy.ndarray
16 User-selected Dec points, in degrees. Stored internally in radians.
17 lonCol : str, optional
18 Name of the longitude (RA equivalent) column to use from the input data.
19 Default fieldRA
20 latCol : str, optional
21 Name of the latitude (Dec equivalent) column to use from the input data.
22 Default fieldDec
23 latLonDeg : bool, optional
24 Flag indicating whether the lon and lat values will be in degrees (True) or radians (False).
25 Default True (appropriate for opsim v4).
26 verbose : boolean, optional
27 Flag to indicate whether or not to write additional information to stdout during runtime.
28 Default True.
29 badval : float, optional
30 Bad value flag, relevant for plotting. Default -666.
31 leafsize : int, optional
32 Leafsize value for kdtree. Default 100.
33 radius : float, optional
34 Radius for matching in the kdtree. Equivalent to the radius of the FOV. Degrees.
35 Default 1.75.
36 useCamera : boolean, optional
37 Flag to indicate whether to use the LSST camera footprint or not.
38 Default False.
39 rotSkyPosColName : str, optional
40 Name of the rotSkyPos column in the input data. Only used if useCamera is True.
41 Describes the orientation of the camera orientation compared to the sky.
42 Default rotSkyPos.
43 mjdColName : str, optional
44 Name of the exposure time column. Only used if useCamera is True.
45 Default observationStartMJD.
46 chipNames : array-like, optional
47 List of chips to accept, if useCamera is True. This lets users turn 'on' only a subset of chips.
48 Default 'all' - this uses all chips in the camera.
49 """
50 def __init__(self, ra, dec, lonCol='fieldRA', latCol='fieldDec', latLonDeg=True, verbose=True,
51 badval=-666, leafsize=100, radius=1.75,
52 useCamera=False, rotSkyPosColName='rotSkyPos', mjdColName='observationStartMJD',
53 chipNames='all'):
54 super(UserPointsSlicer, self).__init__(lonCol=lonCol, latCol=latCol, latLonDeg=latLonDeg,
55 verbose=verbose,
56 badval=badval, radius=radius, leafsize=leafsize,
57 useCamera=useCamera, rotSkyPosColName=rotSkyPosColName,
58 mjdColName=mjdColName, chipNames=chipNames)
59 # check that ra and dec are iterable, if not, they are probably naked numbers, wrap in list
60 if not hasattr(ra, '__iter__'):
61 ra = [ra]
62 if not hasattr(dec, '__iter__'):
63 dec = [dec]
64 if len(ra) != len(dec):
65 raise ValueError('RA and Dec must be the same length')
66 ra = np.radians(ra)
67 dec = np.radians(dec)
68 self.slicePoints['sid'] = np.arange(np.size(ra))
69 self.slicePoints['ra'] = np.array(ra)
70 self.slicePoints['dec'] = np.array(dec)
71 self.nslice = np.size(ra)
72 self.shape = self.nslice
73 self.spatialExtent = [0, self.nslice - 1]
74 self.slicer_init = {'ra': ra,
75 'dec': dec,
76 'lonCol': lonCol,
77 'latCol': latCol,
78 'radius': radius}
79 self.plotFuncs = [BaseSkyMap, BaseHistogram]
81 def __eq__(self, otherSlicer):
82 """Evaluate if two slicers are equivalent."""
83 result = False
84 # check the slicePoints
85 for key in otherSlicer.slicePoints:
86 if key in self.slicePoints.keys():
87 if not np.all(otherSlicer.slicePoints[key] == self.slicePoints[key]):
88 return False
89 else:
90 return False
91 if isinstance(otherSlicer, UserPointsSlicer):
92 if otherSlicer.nslice == self.nslice:
93 if np.all(otherSlicer.slicePoints['ra'] == self.slicePoints['ra']) \
94 and np.all(otherSlicer.slicePoints['dec'] == self.slicePoints['dec']):
95 if (otherSlicer.lonCol == self.lonCol and otherSlicer.latCol == self.latCol):
96 if otherSlicer.radius == self.radius:
97 if otherSlicer.useCamera == self.useCamera:
98 if otherSlicer.chipsToUse == self.chipsToUse:
99 if otherSlicer.rotSkyPosColName == self.rotSkyPosColName:
100 if np.all(otherSlicer.shape == self.shape):
102 result = True
103 return result