lstpressure.lstcalendar

class lstpressure.lstcalendar.LSTCalendar(start: str | datetime, end: str | datetime | None = None, observations: list[Observation] = [], latitude: str | float | None = '-30:42:39.8', longitude: str | float | None = '21:26:38.0', provider: LocationProviderType | None = None)

Calendar tailored for LST (Local Sidereal Time) related interval lookups.

Attributes

startstr | datetime

The beginning of the date range for the calendar.

endOptional[str | datetime]

The conclusion of the date range for the calendar. Defaults to None.

latitudefloat

The geographic latitude in decimal degrees. Defaults to 0.

longitudefloat

The geographic longitude in decimal degrees. Defaults to 0.

interval_indexLSTIndex

An index to manage intervals efficiently.

observations_indexLSTIndex

An index to manage observations efficiently.

dateslist[LSTCalendarDate]

A list containing dates and corresponding sun statistics within the range.

Methods

__init__(start, end, latitude=0, longitude=0, observations=[])

Initialize the LSTCalendar object.

__enter__()

Enter context management.

__exit__(exc_type, exc_val, exc_tb)

Exit context management.

load_observations(observations: list[Observation]) -> LSTCalendar

Load a list of observations and insert their intervals into the observation index.

observables(observations: Optional[list[Observation]] = None) -> list[Observable]

Retrieve observable observations for the dates maintained by this calendar.

property dates: list[LSTCalendarDate]

Property to retrieve the list of dates.

Returns

list[LSTCalendarDate]

A list containing dates and corresponding sun statistics within the range.

property interval_index: LSTIndex

Property to retrieve the interval index.

Returns

LSTIndex

An index to manage intervals efficiently.

load_observations(observations: list[Observation]) Self

Load a list of observations, set the calendar attribute for each observation, and insert their intervals into the observation index.

Observations must have unique IDs.

Parameters

observationslist[Observation]

A list of observation instances.

Returns

LSTCalendar

The LSTCalendar object.

observables(observations: list[Observation] | None = None) list[Observable]

Retrieve observable observations for the dates maintained by this calendar.

This method processes a list of dates within the calendar and aggregates their observable observations into observation windows. If a list of observations is provided, it replaces the current observations of the calendar with the new list.

Parameters

observationsOptional[list[Observation]], optional

A list of Observation objects to process, which is optional. If provided, it overwrites any existing observations in the calendar.

Raises

TypeError

If no observations have been loaded into the calendar and none are provided.

Returns

list[Observable]

A list of aggregated observation windows, each representing observable observations for a specific date in the calendar.

Example usage:

calendar = Calendar()
calendar.load_dates(dates)
try:
    observation_windows = calendar.observable_observations()
except TypeError as e:
    print(e)
property observations: list[Dict[str, LSTInterval | Observation]]

Property to retrieve the list of observations.

Returns

list[Dict[str, LSTInterval | Observation]]

A list of observations.

property observations_index: LSTIndex

Property to retrieve the observations index.

Returns

LSTIndex

An index to manage observations efficiently.

class lstpressure.lstcalendar.LSTCalendarDate(dt, cal, provider: LocationProviderType | None = None)
c = 0

Represents a date within the LSTCalendar.

Parameters

dtdate

The date for which LSTCalendarDate is instantiated.

calLSTCalendar

The parent LSTCalendar object that manages this date.

Attributes

dtdate

The date for which LSTCalendarDate is instantiated.

tomorrow_dtdate

The date following the current date.

sunSun

An object representing sun statistics for the current date.

tomorrow_sunSun

An object representing sun statistics for the following date.

calendarLSTCalendar

The parent LSTCalendar object that manages this date.

intervalslist[LSTInterval]

A list of LSTInterval objects associated with this date.

Methods

observables() -> list[Observable]

Retrieve observable observations for this date.

to_yyyymmdd() -> str

Convert the date to a string in the ‘YYYYMMDD’ format.

observables() list[Observable]

Retrieve observable observations for this date.

Returns

list[Observable]

A list of observable observations for this date.

to_yyyymmdd() str

Convert the date to a string in the ‘YYYYMMDD’ format.

Returns

str

The date in ‘YYYYMMDD’ format.