BaseSlicer¶
- class rubin_sim.maf.slicers.BaseSlicer(verbose=True, badval=-666)¶
Bases:
object
Base class for all slicers: sets required methods and implements common functionality.
After first construction, the slicer should be ready for setup_slicer to define slice_points, which will let the slicer ‘slice’ data and generate plots. After init after a restore: everything necessary for using slicer for plotting or saving/restoring metric data should be present (although slicer does not need to be able to slice data again and generally will not be able to).
- Parameters:
- verbose: `bool`, optional
True/False flag to send extra output to screen. Default True.
- badval: int or float, optional
The value the Slicer uses to fill masked metric data values Default -666.
Attributes Summary
Methods Summary
Return the slice_point metadata, for all slice points.
output_json
(metric_values[, metric_name, ...])Send metric data to JSON streaming API, along with a little bit of metadata.
read_backwards_compatible
(restored, infilename)Read pre v1.0 metric files.
read_data
(infilename)Read metric data from disk, along with the info to rebuild the slicer (minus new slicing capability).
setup_slicer
(sim_data[, maps])Set up Slicer for data slicing.
write_data
(outfilename, metric_values[, ...])Save metric values along with the information required to re-build the slicer.
Attributes Documentation
- registry = {'BlockIntervalSlicer': <class 'rubin_sim.maf.slicers.time_interval_slicers.BlockIntervalSlicer'>, 'HealpixComCamSlicer': <class 'rubin_sim.maf.slicers.healpix_comcam_slicer.HealpixComCamSlicer'>, 'HealpixSDSSSlicer': <class 'rubin_sim.maf.slicers.healpix_sdss_slicer.HealpixSDSSSlicer'>, 'HealpixSlicer': <class 'rubin_sim.maf.slicers.healpix_slicer.HealpixSlicer'>, 'HealpixSubsetSlicer': <class 'rubin_sim.maf.slicers.healpix_subset_slicer.HealpixSubsetSlicer'>, 'HourglassSlicer': <class 'rubin_sim.maf.slicers.hourglass_slicer.HourglassSlicer'>, 'MoObjSlicer': <class 'rubin_sim.maf.slicers.mo_slicer.MoObjSlicer'>, 'MovieSlicer': <class 'rubin_sim.maf.slicers.movie_slicer.MovieSlicer'>, 'NDSlicer': <class 'rubin_sim.maf.slicers.nd_slicer.NDSlicer'>, 'OneDSlicer': <class 'rubin_sim.maf.slicers.one_d_slicer.OneDSlicer'>, 'TimeIntervalSlicer': <class 'rubin_sim.maf.slicers.time_interval_slicers.TimeIntervalSlicer'>, 'UniSlicer': <class 'rubin_sim.maf.slicers.uni_slicer.UniSlicer'>, 'UserPointsSlicer': <class 'rubin_sim.maf.slicers.user_points_slicer.UserPointsSlicer'>, 'VisitIntervalSlicer': <class 'rubin_sim.maf.slicers.time_interval_slicers.VisitIntervalSlicer'>}¶
Methods Documentation
- get_slice_points()¶
Return the slice_point metadata, for all slice points.
- output_json(metric_values, metric_name='', sim_data_name='', info_label='', plot_dict=None)¶
Send metric data to JSON streaming API, along with a little bit of metadata.
This method will only work for metrics where the metricDtype is float or int, as JSON will not interpret more complex data properly. These values can’t be plotted anyway though.
- Parameters:
- metric_valuesnp.ma.MaskedArray or np.ndarray
The metric values.
- metric_namestr, optional
The name of the metric. Default ‘’.
- sim_data_namestr, optional
The name of the simulated data source. Default ‘’.
- info_labelstr, optional
Some additional information about this metric and how it was calculated. Default ‘’.
- plot_dictdict, optional.
The plot_dict for this metric bundle. Default None.
- Returns:
- StringIO
StringIO object containing a header dictionary with metric_name/metadata/sim_data_name/slicer_name, and plot labels from plot_dict, and metric values/data for plot. if oneDSlicer, the data is [ [bin_left_edge, value], [bin_left_edge, value]..]. if a spatial slicer, the data is [ [lon, lat, value], [lon, lat, value] ..].
- read_backwards_compatible(restored, infilename)¶
Read pre v1.0 metric files.
- read_data(infilename)¶
Read metric data from disk, along with the info to rebuild the slicer (minus new slicing capability).
- Parameters:
- infilename: str
The filename containing the metric data.
- Returns:
- np.ma.MaskedArray, rubin_sim.maf.slicer, dict
MetricValues stored in data file, the slicer basis for those metric values, and a dictionary containing header information (run_name, metadata, etc.).
- setup_slicer(sim_data, maps=None)¶
Set up Slicer for data slicing.
Set up internal parameters necessary for slicer to slice data and generates indexes on sim_data. Also sets _slice_sim_data for a particular slicer.
- Parameters:
- sim_datanp.recarray
The simulated data to be sliced.
- mapslist of rubin_sim.maf.maps objects, optional.
Maps to apply at each slice_point, to add to the slice_point metadata. Default None.
- write_data(outfilename, metric_values, metric_name='', sim_data_name='', constraint=None, info_label='', plot_dict=None, display_dict=None)¶
Save metric values along with the information required to re-build the slicer.
- Parameters:
- outfilename
str
The output file name.
- metric_values
np.ma.MaskedArray
ornp.ndarray
The metric values to save to disk.
- outfilename