ObservationGroup#
- class astro_metadata_translator.ObservationGroup(members, translator_class=None, pedantic=None)#
Bases:
MutableSequence[ObservationInfo]A collection of
ObservationInfoheaders.- Parameters:
members (iterable of
ObservationInfoordict-like) –ObservationInfoto seed the group membership. Ifdict-like values are used they will be passed to theObservationInfoconstructor.translator_class (
MetadataTranslator-class, optional) – If any of the members is not anObservationInfo, translator class to pass to theObservationInfoconstructor. IfNonethe translation class will be determined automatically.pedantic (
bool, optional) – If any of the members is not anObservationInfo, passed to theObservationInfoconstructor to control whether a failed translation is fatal or not.Noneindicates that theObservationInfoconstructor default should be used.
Methods Summary
extremes()Return the oldest observation in the group and the newest.
from_simple(simple)Convert simplified form back to
ObservationGroup.insert(index, value)S.insert(index, value) -- insert value before index
model_dump_json(**kwargs)Serialize to JSON using Pydantic-compatible semantics.
model_validate_json(json_data, **kwargs)Deserialize from JSON using Pydantic-compatible semantics.
newest()Return the newest observation in the group.
oldest()Return the oldest observation in the group.
property_values(property)Return a set of values associated with the specified property.
reverse()S.reverse() -- reverse IN PLACE
sort([key, reverse])Convert the group to simplified form.
Methods Documentation
- extremes()#
Return the oldest observation in the group and the newest.
If there is only one member of the group, the newest and oldest can be the same observation.
- Return type:
- Returns:
oldest (
ObservationInfo) – Oldest observation.newest (
ObservationInfo) – Newest observation.
- classmethod from_simple(simple)#
Convert simplified form back to
ObservationGroup.- Parameters:
- Returns:
group – Reconstructed group.
- Return type:
- insert(index, value)#
S.insert(index, value) – insert value before index
- Parameters:
index (
int)value (
ObservationInfo|MutableMapping[str,Any])
- Return type:
- model_dump_json(**kwargs)#
Serialize to JSON using Pydantic-compatible semantics.
- Parameters:
**kwargs (
Any) – Parameters passed topydantic.BaseModel.model_dump_json.- Returns:
json_data – JSON string representing the model.
- Return type:
- classmethod model_validate_json(json_data, **kwargs)#
Deserialize from JSON using Pydantic-compatible semantics.
- Parameters:
json_data (
str|bytes|bytearray) – JSON representation of the model.**kwargs (
Any) – Parameters passed topydantic.BaseModel.model_validate_json.
- Returns:
group – Model constructed from the JSON.
- Return type:
- newest()#
Return the newest observation in the group.
- Returns:
newest – The newest
ObservationInfoin theObservationGroup.- Return type:
- oldest()#
Return the oldest observation in the group.
- Returns:
oldest – The oldest
ObservationInfoin theObservationGroup.- Return type:
- property_values(property)#
Return a set of values associated with the specified property.
- Parameters:
property (
str) – Property of anObservationInfo.- Returns:
values – All the distinct values for that property within this group.
- Return type:
- sort(key=None, reverse=False)#
- to_simple()#
Convert the group to simplified form.
- Returns:
simple – Simple form is a list containing the simplified dict form of each
ObservationInfo.- Return type: