MeasurementBase¶
-
class
lsst.validate.base.MeasurementBase[source]¶ Bases:
lsst.validate.base.QuantityAttributeMixin,lsst.validate.base.jsonmixin.JsonSerializationMixin,lsst.validate.base.datummixin.DatumAttributeMixinBase class for Measurement classes.
This class isn’t instantiated directly. Instead, developers should subclass
MeasurementBaseto create measurement classes for each metric being measured.Subclasses must (at least) implement the following attributes:
metric(set to aMetricinstance).spec_name(if applicable).filter_name(if applicable).
Subclasses are also responsible for assiging the measurement’s value to the
quantityattribute (as anastropy.units.Quantity).See also
The Creating measurement classes page shows how to create measurement classes using
MeasurementBase.Attributes Summary
blobsdictof blobs attached to this measurement instance.datumRepresentation of this measurement as a Datum.extrasdictcontaining all measurement by-products (called extras) thatfilter_nameName of the optical filter for the observations this measurement was made from. identifierUnique UUID4-based identifier for this measurement ( str).jsonA dictthat can be serialized as semantic SQUASH JSON.labelName of the Metricassociated with this measurement (str).latex_unitUnits as a LaTeX string, wrapped in $.metricMetricthat this measurement is associated to.parametersdictcontaining all input parameters used by this measurement.quantityValue of the datum ( astropy.units.Quantity,str,bool,None).spec_nameName of the specification level (e.g., ‘design,’ ‘minimum,’ ‘stretch’) that this measurement represents. unitRead-only astropy.units.Unitof thequantity.unit_strRead-only astropy.units.Unit-compatiblestrindicating units ofquantity.Methods Summary
check_spec(name)Check this measurement against a Specificationlevel, of theMetric.from_json(json_data[, blobs_json])Construct a measurement from a JSON dataset. jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. register_extra(extra_key[, quantity, unit, ...])Register a measurement extra—a by-product of a metric measurement. register_parameter(param_key[, quantity, ...])Register a measurement input parameter attribute. write_json(filepath)Write JSON to a file. Attributes Documentation
-
extras= None¶ dictcontaining all measurement by-products (called extras) that have been registered for serialization.Extras are
Datuminstances. Values of extras can also be accessed and updated as instance attributes named after the extra.
-
filter_name= None¶ Name of the optical filter for the observations this measurement was made from.
Noneif a measurement is not filter-dependent.
-
latex_unit¶ Units as a LaTeX string, wrapped in
$.
-
parameters= None¶ dictcontaining all input parameters used by this measurement. Parameters areDatuminstances. Parameter values can be accessed and updated as instance attributes named after the parameter.
-
quantity¶ Value of the datum (
astropy.units.Quantity,str,bool,None).
-
spec_name= None¶ Name of the specification level (e.g., ‘design,’ ‘minimum,’ ‘stretch’) that this measurement represents.
Noneif this measurement applies to all specification levels.
-
unit¶ Read-only
astropy.units.Unitof thequantity.
-
unit_str¶ Read-only
astropy.units.Unit-compatiblestrindicating units ofquantity.
Methods Documentation
-
check_spec(name)[source]¶ Check this measurement against a
Specificationlevel, of theMetric.Parameters: name :
strSpecificationlevel name.Returns: passed :
boolTrueif the measurement meets theSpecificationlevel,Falseotherwise.Notes
Internally this method retrieves the
Specificationobject, filtering first by thename, but also by this object’sfilter_nameattribute if specifications are filter-dependent.
-
classmethod
from_json(json_data, blobs_json=None)[source]¶ Construct a measurement from a JSON dataset.
Parameters: json_data :
dictMeasurement JSON object.
blobs_json :
listJSON serialization of blobs. This is the
blobsobject produced byJob.json.Returns: measurement :
MeasurementBase-typeMeasurement from JSON.
-
jsonify_dict(d)¶ Recursively build JSON-renderable objects on all values in a dict.
Parameters: d :
dictDictionary ito convert into a JSON-serializable object. Values are recursively JSON-ified.
Returns: json_dict :
dictDictionary that can be serialized to JSON.
Examples
Subclasses can use this method to prepare output in their
json-method implementation. For example:def json(self): return JsonSerializationMixin.jsonify_dict({ 'value': self.value, })
-
register_extra(extra_key, quantity=None, unit=None, label=None, description=None, datum=None)[source]¶ Register a measurement extra—a by-product of a metric measurement.
The value of the extra can either be set at registration time (see
quantityargument), or later by setting the object’s attribute namedextra_key.The value of an extra can always be accessed through the object’s attribute named after
extra_key.Extras are stored as
Datumobjects, which can be accessed through theparametersattributedict.Parameters: extra_key :
strName of the extra; used as the key in the
extrasattribute of this object.quantity :
astropy.units.Quantity,str, orboolValue of the extra.
label :
str, optionalLabel suitable for plot axes (without units). By default the
extra_keyis used as thelabel. Setting this label argument overrides both of these.description :
str, optionalExtended description.
datum :
Datum, optionalIf a
Datumis provided, its value, label and description will be used unless overriden by other arguments toregister_extra.
-
register_parameter(param_key, quantity=None, label=None, description=None, datum=None)[source]¶ Register a measurement input parameter attribute.
The value of the parameter can either be set at registration time (see
quantityargument), or later by setting the object’s attribute namedparam_key.The value of a parameter can always be accessed through the object’s attribute named after the provided
param_key.Parameters are stored as
Datumobjects, which can be accessed through theparametersattributedict.Parameters: param_key :
strName of the parameter; used as the key in the
parametersattribute of this object.quantity :
astropy.units.Quantity,strorbool.Value of the parameter.
label :
str, optionalLabel suitable for plot axes (without units). By default the
param_keyis used as thelabel. Setting thislabelargument overrides that default.description :
str, optionalExtended description of the parameter.
datum :
Datum, optionalIf a
Datumis provided, its quantity, label and description are be used unless overriden by other arguments to this method.