Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 0398cdc

Browse files
committed
Fixed documentation for baseSlicer.
1 parent 2e9d0da commit 0398cdc

File tree

1 file changed

+45
-15
lines changed

1 file changed

+45
-15
lines changed

python/lsst/sims/maf/slicers/baseSlicer.py

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ class BaseSlicer(object):
4848
saving/restoring metric data should be present (although slicer does not need to be able to
4949
slice data again and generally will not be able to).
5050
51-
The sliceMetric has a 'memo-ize' functionality that can save previous indexes & return
52-
metric data value calculated for same set of previous indexes, if desired.
53-
CacheSize = 0 effectively turns this off, otherwise cacheSize should be set by the slicer.
54-
(Most useful for healpix slicer, where many healpixels may have same set of LSST visits).
55-
5651
Parameters
5752
----------
5853
verbose: boolean, optional
@@ -102,6 +97,13 @@ def setupSlicer(self, simData, maps=None):
10297
10398
Set up internal parameters necessary for slicer to slice data and generates indexes on simData.
10499
Also sets _sliceSimData for a particular slicer.
100+
101+
Parameters
102+
-----------
103+
simData : np.recarray
104+
The simulated data to be sliced.
105+
maps : list of lsst.sims.maf.maps objects, optional.
106+
Maps to apply at each slicePoint, to add to the slicePoint metadata. Default None.
105107
"""
106108
# Typically args will be simData, but opsimFieldSlicer also uses fieldData.
107109
raise NotImplementedError()
@@ -169,8 +171,12 @@ def writeData(self, outfilename, metricValues, metricName='',
169171
"""
170172
Save metric values along with the information required to re-build the slicer.
171173
172-
outfilename: the output file
173-
metricValues: the metric values to save to disk
174+
Parameters
175+
-----------
176+
outfilename : str
177+
The output file name.
178+
metricValues : np.ma.MaskedArray or np.ndarray
179+
The metric values to save to disk.
174180
"""
175181
header = {}
176182
header['metricName']=metricName
@@ -210,14 +216,29 @@ def outputJSON(self, metricValues, metricName='',
210216
"""
211217
Send metric data to JSON streaming API, along with a little bit of metadata.
212218
213-
Output is
214-
header dictionary with 'metricName/metadata/simDataName/slicerName' and plot labels from plotDict (if provided).
215-
then data for plot:
216-
if oneDSlicer, it's [ [bin_left_edge, value], [bin_left_edge, value]..].
217-
if a spatial slicer, it's [ [lon, lat, value], [lon, lat, value] ..].
218-
219-
This method will only work for non-complex metrics (i.e. metrics where the metric value is a float or int),
219+
This method will only work for metrics where the metricDtype is float or int,
220220
as JSON will not interpret more complex data properly. These values can't be plotted anyway though.
221+
222+
Parameters
223+
-----------
224+
metricValues : np.ma.MaskedArray or np.ndarray
225+
The metric values.
226+
metricName : str, optional
227+
The name of the metric. Default ''.
228+
simDataName : str, optional
229+
The name of the simulated data source. Default ''.
230+
metadata : str, optional
231+
The metadata about this metric. Default ''.
232+
plotDict : dict, optional.
233+
The plotDict for this metric bundle. Default None.
234+
235+
Returns
236+
--------
237+
StringIO
238+
StringIO object containing a header dictionary with metricName/metadata/simDataName/slicerName,
239+
and plot labels from plotDict, and metric values/data for plot.
240+
if oneDSlicer, the data is [ [bin_left_edge, value], [bin_left_edge, value]..].
241+
if a spatial slicer, the data is [ [lon, lat, value], [lon, lat, value] ..].
221242
"""
222243
# Bail if this is not a good data type for JSON.
223244
if not (metricValues.dtype == 'float') or (metricValues.dtype == 'int'):
@@ -309,7 +330,16 @@ def readData(self, infilename):
309330
"""
310331
Read metric data from disk, along with the info to rebuild the slicer (minus new slicing capability).
311332
312-
infilename: the filename containing the metric data.
333+
Parameters
334+
-----------
335+
infilename: str
336+
The filename containing the metric data.
337+
338+
Returns
339+
-------
340+
np.ma.MaskedArray, lsst.sims.maf.slicer, dict
341+
MetricValues stored in data file, the slicer basis for those metric values, and a dictionary
342+
containing header information (runName, metadata, etc.).
313343
"""
314344
import lsst.sims.maf.slicers as slicers
315345
restored = np.load(infilename)

0 commit comments

Comments
 (0)