io
Module for the building and writing of reports for human readability and debugging of schedule solution.
- astroq.io.build_fullness_report(semester_planner, round_info)[source]
Determine how full the schedule is: slots available, slots scheduled, and slots required
- Parameters:
semester_planner (obj) – a SemesterPlanner object from splan.py
round_info (str) – information about the optimization round (e.g. Round1, Round2)
- Returns:
None
- astroq.io.compute_program_statistics(semester_planner, schedule_df)[source]
Compute awarded, requested, and scheduled statistics per program.
- Parameters:
semester_planner (obj) – a SemesterPlanner object from splan.py
schedule_df (DataFrame) – DataFrame containing scheduled observations
- Returns:
- Dictionary keyed by program name, with values containing:
awarded_nights, awarded_hours, awarded_slots
past_nights, past_hours, past_slots
requested_nights, requested_hours, requested_slots
scheduled_nights, scheduled_hours, scheduled_slots
fullness1 ((scheduled+past)/requested %)
fullness2 ((scheduled+past)/awarded %)
- Return type:
dict
- astroq.io.format_kpf_row(row, obs_time, first_available, last_available, current_day, filler_flag=False, extra=False)[source]
Format request data in the specific way needed for the script (relates to the Keck “Magiq” software’s data ingestion requirements).
- Parameters:
row (dataframe) – a single row from the requests sheet dataframe
obs_time (str) – the timestamp of the night to begin the exposure according to the TTP. In format HH:MM in HST timezone
first_available (str) – the timestamp of the night where the star is first accessible. In format HH:MM in HST timezone.
last_available (str) – the timestamp of the night where the star is last accessible. In format HH:MM in HST timezone.
filler_flag (boolean) – True of the target was added in the bonus round
extra (boolean) – is this an “extra” target
- Returns:
the properly formatted string to be included in the script file
- Return type:
line (str)
- astroq.io.pm_correcter(ra, dec, pmra, pmdec, current_day, equinox='2000')[source]
Update a star’s coordinates due to proper motion.
- Parameters:
ra (float) – RA in degrees
dec (float) – Dec in degrees
pmra (float) – proper motion in RA (mas/yr), including cos(Dec)
pmdec (float) – proper motion in Dec (mas/yr)
equinox (str) – original epoch (e.g. ‘2000.0’)
current_day (str) – date to which to propagate (e.g. ‘2025-04-30’)
- Returns:
updated coordinates as strings
- Return type:
formatted_ra (str), formatted_dec (str)
- astroq.io.serialize_schedule(Yrds, semester_planner)[source]
Turns the ragged matrix of the Gurobi solution Yrds into a human readable solution by filling in the slots where a star’s exposure is started.
- Parameters:
Yrds (array) – the Gurobi solution with keys of (unique_id, day, slot) and values 1 or 0.
semester_planner (obj) – a SemesterPlanner object from splan.py
- Returns:
None
- astroq.io.write_starlist(frame, solution_frame, night_start_time, extras, filler_stars, current_day, outputdir, version='nominal')[source]
Generate the nightly script in the correct format.
- Parameters:
frame (dataframe) – the request.csv in dataframe format for just the targets that were selected to be observed tonight
solution_frame (dataframe) – the solution attribute from the TTP model.plotly object
night_start_time (astropy time object) – Beginning of observing interval
extras (array) – starnames of “extra” stars (those not fit into the script)
filler_stars (array) – star names of the stars added in the bonus round
current_day (str) – today’s date in format YYYY-MM-DD
outputdir (str) – the directory to save the script file
version (str) – a tag for thescript (e.g. nominal, slowdown, backups, etc)
- Returns:
None