history

Module for processing the past history of observations from OB database or user inputted file. Used to populate the past.csv file for the optimization.

class astroq.history.StarHistory(name, date_last_observed, total_n_exposures, total_n_visits, total_n_unique_nights, total_open_shutter_time, n_obs_on_nights, n_visits_on_nights, exposure_start_times)

Bases: tuple

_asdict()

Return a new dict which maps field names to their values.

_field_defaults = {}
_fields = ('name', 'date_last_observed', 'total_n_exposures', 'total_n_visits', 'total_n_unique_nights', 'total_open_shutter_time', 'n_obs_on_nights', 'n_visits_on_nights', 'exposure_start_times')
classmethod _make(iterable)

Make a new StarHistory object from a sequence or iterable

_replace(**kwds)

Return a new StarHistory object replacing specified fields with new values

count(value, /)

Return number of occurrences of value.

date_last_observed

Alias for field number 1

exposure_start_times

Alias for field number 8

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

n_obs_on_nights

Alias for field number 6

n_visits_on_nights

Alias for field number 7

name

Alias for field number 0

total_n_exposures

Alias for field number 2

total_n_unique_nights

Alias for field number 4

total_n_visits

Alias for field number 3

total_open_shutter_time

Alias for field number 5

astroq.history._exposure_ut_column(df)[source]
astroq.history._local_datetime_from_ut(t_ut, utc_offset_hours)[source]

Apply fixed offset (local = UT + utc_offset_hours as implemented elsewhere).

astroq.history._make_observer(observatory_string)[source]

Observer for sunset; None if site lookup fails.

astroq.history._night_of_key_from_cell(night_of_val)[source]

YYYY-MM-DD from CSV NightOf (date-only or YYYY-MM-DDTHH:MM…).

astroq.history.local_time_str_from_ut(exposure_start_str, utc_offset_hours)[source]

Wall-clock local string from UT exposure start (matches process_star_history formatting).

astroq.history.night_of_date_from_sunset(t_ut, observer, utc_offset_hours)[source]

Local civil calendar date (YYYY-MM-DD) of the observing night: the local date of the most recent sunset at the observatory before this exposure (in UTC time order). Falls back to local-noon night boundary if sunset cannot be computed.

astroq.history.process_star_history(filename, utc_offset_hours=-10, observatory=None)[source]

Process the past.csv file to return a dict of star histories.

Parameters:
  • filename (str) – the path to the past.csv file

  • utc_offset_hours (float) – hours difference local minus UT (negative = local behind UT, e.g. -10 for HST). Pass SemesterPlanner’s value from config [global] UTCoffset.

  • observatory (str, optional) – site name for NightOf sunset logic (matches prep / config).

Returns:

a dictionary of star histories where keys are ‘id’, values are objects with attributes: date_last_observed, total_n_exposures, total_n_visits, total_n_unique_nights, total_open_shutter_time

Return type:

result (dict)

astroq.history.write_OB_histories_to_csv(histories, utc_offset_hours=-10, observatory=None)[source]

Prepare dataframe of past history for writing to CSV.

Parameters:
  • histories (json) – the OB histories in json format

  • utc_offset_hours (float) – local minus UT from config [global] UTCoffset.

  • observatory (str, optional) – site name for astroplan (e.g. config global observatory).

Returns:

the OB histories in dataframe format

Return type:

df (pandas DataFrame)