ObservationGroup¶
- class astro_metadata_translator.ObservationGroup(members: Iterable[ObservationInfo | MutableMapping[str, Any]], translator_class: type[MetadataTranslator] | None = None, pedantic: bool | None = None)¶
Bases:
MutableSequence
A collection of
ObservationInfo
headers.- Parameters:
- membersiterable of
ObservationInfo
ordict
-like ObservationInfo
to seed the group membership. Ifdict
-like values are used they will be passed to theObservationInfo
constructor.- translator_class
MetadataTranslator
-class, optional If any of the members is not an
ObservationInfo
, translator class to pass to theObservationInfo
constructor. IfNone
the translation class will be determined automatically.- pedantic
bool
, optional If any of the members is not an
ObservationInfo
, passed to theObservationInfo
constructor to control whether a failed translation is fatal or not.None
indicates that theObservationInfo
constructor default should be used.
- membersiterable of
Methods Summary
append
(value)S.append(value) -- append value to the end of the sequence
clear
()count
(value)extend
(values)S.extend(iterable) -- extend sequence by appending elements from the iterable
extremes
()Return the oldest observation in the group and the newest.
from_simple
(simple)Convert simplified form back to
ObservationGroup
.index
(value, [start, [stop]])Raises ValueError if the value is not present.
insert
(index, value)S.insert(index, value) -- insert value before index
newest
()Return the newest observation in the group.
oldest
()Return the oldest observation in the group.
pop
([index])Raise IndexError if list is empty or index is out of range.
property_values
(property)Return a set of values associated with the specified property.
remove
(value)S.remove(value) -- remove first occurrence of value.
reverse
()S.reverse() -- reverse IN PLACE
sort
([key, reverse])Convert the group to simplified form.
Methods Documentation
- append(value)¶
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S ¶
- count(value) integer -- return number of occurrences of value ¶
- extend(values)¶
S.extend(iterable) – extend sequence by appending elements from the iterable
- extremes() tuple[astro_metadata_translator.observationInfo.ObservationInfo, astro_metadata_translator.observationInfo.ObservationInfo] ¶
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.
- Returns:
- oldest
ObservationInfo
Oldest observation.
- newest
ObservationInfo
Newest observation.
- oldest
- classmethod from_simple(simple: list[dict[str, Any]]) ObservationGroup ¶
Convert simplified form back to
ObservationGroup
.- Parameters:
- Returns:
- group
ObservationGroup
Reconstructed group.
- group
- index(value[, start[, stop]]) integer -- return first index of value. ¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(index: int, value: ObservationInfo | MutableMapping[str, Any]) None ¶
S.insert(index, value) – insert value before index
- newest() ObservationInfo ¶
Return the newest observation in the group.
- Returns:
- newest
ObservationInfo
The newest
ObservationInfo
in theObservationGroup
.
- newest
- oldest() ObservationInfo ¶
Return the oldest observation in the group.
- Returns:
- oldest
ObservationInfo
The oldest
ObservationInfo
in theObservationGroup
.
- oldest
- pop([index]) item -- remove and return item at index (default last). ¶
Raise IndexError if list is empty or index is out of range.
- property_values(property: str) set[Any] ¶
Return a set of values associated with the specified property.
- Parameters:
- property
str
Property of an
ObservationInfo
.
- property
- Returns:
- values
set
All the distinct values for that property within this group.
- values
- remove(value)¶
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- to_simple() list[collections.abc.MutableMapping[str, Any]] ¶
Convert the group to simplified form.
- Returns:
- simple
list
ofdict
Simple form is a list containing the simplified dict form of each
ObservationInfo
.
- simple