fairdm.core.measurement.models#
Models for measurements and their related descriptions, dates and identifiers.
Module Contents#
Classes#
Where a measurement is for a viewer, and whose location that is. |
|
A record of a specific observation or calculation made on a sample. |
|
Refuse a |
|
Typed free-text description of a measurement. |
|
Typed date on a measurement. |
|
Typed external identifier of a measurement. |
API#
- class EffectiveLocation#
Bases:
typing.NamedTupleWhere a measurement is for a viewer, and whose location that is.
Attributes: point: The point, in SRID 4326. elevation: Metres above mean sea level, or None. uncertainty: Metres, or None. source:
"own"for the measurement’s own location,"sample"for its sample’s.- point: django.contrib.gis.geos.Point#
None
- elevation: float | None#
None
- uncertainty: float | None#
None
- source: str#
None
- class Measurement(*args, **kwargs)#
Bases:
fairdm.core.abstract.BasePolymorphicModelA record of a specific observation or calculation made on a sample.
A polymorphic model: domain-specific measurement types inherit from this base. Subclasses should define
valueand optionallyuncertaintyfields forget_value()andprint_value()to work.Attributes: CONTRIBUTOR_ROLES: The roles a contributor can hold on a measurement. DESCRIPTION_TYPES: The description types a measurement can carry. DATE_TYPES: The date types a measurement can carry. objects: The manager, with the
MeasurementQuerySethelpers. dataset: The dataset this measurement belongs to. uuid: Unique short identifier with anmprefix. contributors: Generic relation to contributor records. sample: The sample on which the measurement was made. local_id: The creator’s own identifier for the measurement within its dataset. location: The point where the measurement was made, in WGS 84. location_elevation: Metres above mean sea level. location_uncertainty: Metres within which the true place lies.Initialization
- CONTRIBUTOR_ROLES#
None
- DESCRIPTION_TYPES#
None
- DATE_TYPES#
None
- objects#
‘(…)’
- dataset#
‘ForeignKey(…)’
- uuid#
‘ShortUUIDField(…)’
- contributors#
‘GenericRelation(…)’
- sample#
‘ForeignKey(…)’
- local_id#
‘CharField(…)’
- location#
‘PointField(…)’
- location_elevation#
‘FloatField(…)’
- location_uncertainty#
‘FloatField(…)’
- class Meta#
- verbose_name#
‘_(…)’
- verbose_name_plural#
‘_(…)’
- ordering#
[‘-modified’]
‘measurements’
- indexes#
None
- constraints#
‘location_constraints(…)’
- permissions#
None
- clean()#
Refuse a bare
Measurement, and a change of dataset that leaves nobody to manage it.
- type_of()#
Return the base Measurement class for polymorphic queries.
- get_value()#
Return the measurement value, with its uncertainty when there is one.
A type is not obliged to nominate a pint quantity for
value, so uncertainty arithmetic is only attempted where the value supports it.Returns: The value with its
plus_minusuncertainty applied when both exist, the plain value otherwise, or the name when the class defines novalue(the base class).
- print_value()#
Return the value and its uncertainty as a string for a person.
Delegates to the framework’s quantity formatter, which renders a pint
Measurementas “value ± error unit”, rather than building a string by hand.Returns: The formatted value.
- effective_location_for(user=None)#
Return where the measurement is for a viewer: its own location, else its sample’s.
The sample’s is used only where the viewer may open the sample, by the same rule as
MeasurementQuerySet.with_effective_location.Args: user: The viewer, or
Nonefor a visitor who is not signed in.Returns: An
EffectiveLocationnaming the point, its elevation and uncertainty and whose location it is, orNonewhen the viewer has none to be shown.
- get_absolute_url()#
Return the URL of the measurement’s own detail page.
- get_template_name()#
Return the card templates to try for this measurement, in order of preference.
Returns: The template paths.
- class VocabularyGuardedSave#
Refuse a
typeoutside the record’s own collection, even on a direct save.A concept field checks its collection only in
full_clean(), which a manager’screate()and a baresave()never call. Subclasses setVOCABULARY_NOUNfor the error message.Attributes: VOCABULARY_NOUN: The noun in “‘x’ is not a valid Measurement
type.” - VOCABULARY_NOUN = <Multiline-String>#
- save(*args, **kwargs)#
Refuse a
typethat is not in the collection, then save.
- class MeasurementDescription(*args, **kwargs)#
Bases:
fairdm.core.measurement.models.VocabularyGuardedSave,fairdm.core.abstract.AbstractDescriptionTyped free-text description of a measurement.
Initialization
- VOCABULARY_NOUN#
‘description’
- type#
‘ConceptField(…)’
‘ForeignKey(…)’
- class MeasurementDate(*args, **kwargs)#
Bases:
fairdm.core.measurement.models.VocabularyGuardedSave,fairdm.core.abstract.AbstractDateTyped date on a measurement.
Initialization
- VOCABULARY_NOUN#
‘date’
- type#
‘ConceptField(…)’
‘ForeignKey(…)’
- class MeasurementIdentifier(*args, **kwargs)#
Bases:
fairdm.core.measurement.models.VocabularyGuardedSave,fairdm.core.abstract.AbstractIdentifierTyped external identifier of a measurement.
Drawn from the measurement identifier collection rather than the unscoped vocabulary, so a member added for another record type (such as IGSN for samples) cannot leak in here.
Initialization
- VOCABULARY_NOUN#
‘identifier’
- type#
‘ConceptField(…)’
‘ForeignKey(…)’