ch_util.holography

Holography observation tables.

This module defines the tables:

and the constants:

  • QUALITY_GOOD

  • QUALITY_OFFSOURCE

  • ONSOURCE_DIST_TO_FLAG

Classes

HolographyObservation(*args, **kwargs)

A peewee model for the holographic observations.

HolographySource(*args, **kwargs)

A peewee model for the Holography sources.

class ch_util.holography.HolographyObservation(*args, **kwargs)[source]

Bases: base_model

A peewee model for the holographic observations.

source

The source that we were observing.

Type:

foreign key

start_time, finish_time

Start and end times of the source observation (as UNIX times).

Type:

float

notes

Any free form notes about the observation.

Type:

str

DoesNotExist

alias of HolographyObservationDoesNotExist

classmethod create_from_ant_logs(logs, verbose=False, onsource_dist=0.1, notes=None, quality_flag=0, **kwargs)[source]

Read John Galt Telescope log files and create an entry in the holography database corresponding to the exact times on source

Parameters:
  • logs (list of strings) – log file archives (.zip files) to pass to parse_ant_logs()

  • onsource_dist (float (default: 0.1)) – maximum angular distance at which to consider the Galt Telescope on source (in degrees)

Return type:

none

classmethod create_from_dict(dict, notes=None, start_tol=60.0, dryrun=True, replace_dup=False, verbose=False)[source]

Create a holography database entry from a dictionary

This routine checks for duplicates and overwrites duplicates if and only if replace_dup = True

Parameters:

dict (dict) –

srcHolographySource

A HolographySource object for the source

start_time

Start time as a Skyfield Time object

finish_time

Finish time as a Skyfield Time object

classmethod create_from_post_reports(logs, start_tol=60.0, dryrun=True, replace_dup=False, verbose=True, notes=None)[source]

Create holography database entry from .POST_REPORT log files generated by the nsched controller for the Galt Telescope.

Parameters:
  • logs (string) – list of paths to archives. Filenames should be, eg, 01DEC17_1814.zip. Must be only one period in the filename, separating the extension.

  • start_tol (float (optional; default: 60.)) – Tolerance (in seconds) around which to search for duplicate operations.

  • dryrun (boolean (optional; default: True)) – Dry run only; do not add entries to database

  • replace_dup (boolean (optional; default: False)) – Delete existing duplicate entries and replace. Only has effect if dry_run == False

  • notes (string or list of strings (optional; default: None)) – notes to be added. If a string, the same note will be added to all observations. If a list of strings (must be same length as logs), each element of the list will be added to the corresponding database entry. Nota bene: the text “Added by create_from_post_reports” with the current date and time will also be included in the notes database entry.

Example

from ch_util import holography as hl import glob

obs = hl.HolographyObservation logs = glob.glob(‘/path/to/logs/JUN18.zip’) obs_list, dup_obs_list, missing = obs.create_from_post_reports(logs, dryrun=False)

classmethod from_lst(source, start_day, start_lst, duration_lst, quality_flag=0, notes=None)[source]

Method to initialize a HolographyObservation from a start day, start LST, and a stop day, stop LST.

Parameters:
  • source (HolographySource) – An instance of HolographySource.

  • start_day (string) – Of format YYYMMDD-ABT, ABT can be one of (UTC, PST, PDT)

  • start_lst (float) – Hours and fraction of hours on a scale from 0-24.

  • duration (float) – Hours and fraction of hours on a scale from 0-24.

  • quality_flag (int, default : 0) – Flag for poor quality data. Good data is zero. Sets a bitmask in the HolographyObservation instance.

  • notes (string, optional) – Any notes on this observation.

classmethod parse_ant_logs(logs, return_post_report_params=False)[source]

Unzip and parse .ANT log file output by nsched for John Galt Telescope observations

Parameters:

logs (list of strings) –

.ZIP filenames. Each .ZIP archive should include a .ANT file and a .POST_REPORT file. This method unzips the archive, uses parse_post_report to read the .POST_REPORT file and extract the CHIME sidereal day corresponding to the DRAO sidereal day, and then reads the lines in the .ANT file to obtain the pointing history of the Galt Telescope during this observation.

(The DRAO sidereal day is days since the clock in Ev Sheehan’s office at DRAO was reset. This clock is typically only reset every few years, but it does not correspond to any defined date, so the date must be figured out from the .POST_REPORT file, which reports both the DRAO sidereal day and the UTC date and time.

Known reset dates: 2017-11-21, 2019-3-10)

Returns:

  • if output_params == False

    ant_data: A dictionary consisting of lists containing the LST,

    hour angle, RA, and dec (all as Skyfield Angle objects), CHIME sidereal day, and DRAO sidereal day.

  • if output_params == True – output_params: dictionary returned by parse_post_report and ant_data: described above

  • Files

  • —–

  • the .ANT and .POST_REPORT files in the input .zip archive are

  • extracted into /tmp/26mlog/<loginname>/

classmethod parse_post_report(post_report_file)[source]

read a .POST_REPORT file from the nsched program which controls the John Galt Telescope and extract the source name, estimated start time, DRAO sidereal day, commanded duration, and estimated finish time

Parameters:

post_report_file (str) – path to the .POST_REPORT file to read

Returns:

output_params

output_params[‘src’]HolographySource object or string

If the source is a known source in the holography database, return the HolographySource object. If not, return the name of the source as a string

output_params[‘SID’]int

DRAO sidereal day at the beginning of the observation

output_params[‘start_time’]skyfield time object

UTC time at the beginning of the observation

output_params[‘DURATION’]float

Commanded duration of the observation in sidereal hours

output_params[‘finish_time’]skyfield time object

Calculated UTC time at the end of the observation Calculated as start_time + duration * ephemeris.SIDEREAL_S

Return type:

dictionary

class ch_util.holography.HolographySource(*args, **kwargs)[source]

Bases: base_model

A peewee model for the Holography sources.

name

Unique name for the source. Be careful to avoid duplicates.

Type:

str

ra, dec

ICRS co-ordinates of the source.

Type:

float

DoesNotExist

alias of HolographySourceDoesNotExist