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 or dict-like

ObservationInfo to seed the group membership. If dict-like values are used they will be passed to the ObservationInfo constructor.

translator_classMetadataTranslator-class, optional

If any of the members is not an ObservationInfo, translator class to pass to the ObservationInfo constructor. If None the translation class will be determined automatically.

pedanticbool, optional

If any of the members is not an ObservationInfo, passed to the ObservationInfo constructor to control whether a failed translation is fatal or not. None indicates that the ObservationInfo constructor default should be used.

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])

to_simple()

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:
oldestObservationInfo

Oldest observation.

newestObservationInfo

Newest observation.

classmethod from_simple(simple: list[dict[str, Any]]) ObservationGroup

Convert simplified form back to ObservationGroup.

Parameters:
simplelist of dict

Object returned by to_simple.

Returns:
groupObservationGroup

Reconstructed 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:
newestObservationInfo

The newest ObservationInfo in the ObservationGroup.

oldest() ObservationInfo

Return the oldest observation in the group.

Returns:
oldestObservationInfo

The oldest ObservationInfo in the ObservationGroup.

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:
propertystr

Property of an ObservationInfo.

Returns:
valuesset

All the distinct values for that property within this group.

remove(value)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse() None

S.reverse() – reverse IN PLACE

sort(key: Callable | None = None, reverse: bool = False) None
to_simple() list[collections.abc.MutableMapping[str, Any]]

Convert the group to simplified form.

Returns:
simplelist of dict

Simple form is a list containing the simplified dict form of each ObservationInfo.