API reference

am_helpers

class molsoft.am_helpers.BackendUser(ip='172.17.228.204', port=31010, timeout=45.0)

TCP client to connect to the backend.

is_idle()

Check if the backend is idle.

Returns:

status – Whether the backend is idle.

Return type:

bool

send(msg)

Send a command message to the backend.

Parameters:

msg (str) – Message to send out.

Returns:

status – If the command got successfully passed it returns True, otherwise False.

Return type:

bool

class molsoft.am_helpers.SignalHandler

Handle unix signals sent to the program.

class molsoft.am_helpers.TCCUser(ip='localhost', port='65444', timeout=45.0)

TCP client to connect to TCC.

send(msg)

Send a command message to TCC.

Parameters:

msg (str) – Message to send out.

Returns:

status – If the command got successfully passed it returns True, otherwise False.

Return type:

bool

molsoft.am_helpers.can_be_observed(ra, dec, start_utc, tobs)

Check if a given source is up from the given start time for all the requested observation time.

Parameters:
  • ra (str) – RA J2000 in hh:mm:ss notation.

  • dec (str) – DEC J2000 in hh:mm:ss notation.

  • start_utc (ephem.Date object) – Start UTC.

  • tobs (float) – Requested observation time in seconds.

Returns:

can_be_observed – Whether the source is up from the given start time and for all tobs.

Return type:

bool

molsoft.am_helpers.exit_cleanly(err=None)

Exit the automatic mode cleanly. In case of errors make sure that the telescope is safe.

molsoft.am_helpers.get_backend_config(config, obs_type, name, ra, dec)

Determine the backend config based on the requested observation type.

Parameters:
  • config (str) – Observing config mode.

  • obs_type (str) – Either stationary, transiting or tracking mode.

  • name (str) – Name of object.

  • ra (str) – RA of object to observe in equatorial J2000 hh:mm:ss format.

  • dec (str) – DEC of object to observe in equatorial J2000 hh:mm:ss format.

Returns:

backend_config – Config dictionary for backend.

Return type:

dict

Raises:
  • NotImplementedError – If request config is not implemented.

  • RuntimeError – On invalid configs.

molsoft.am_helpers.get_backend_status()

Query status of the backend.

molsoft.am_helpers.get_md_ns_tilt(ra, dec, date=45167.023935185185)

Compute NS and MD tilt for a given source at RA and DEC.

Parameters:
  • ra (str) – RA in hh:mm:ss notation.

  • dec (str) – DEC in hh:mm:ss notation.

  • date (ephem.Date object (optional, default=now)) – Current date.

Returns:

  • md_tilt (float) – MD tilt in degrees.

  • ns_tilt (float) – NS tilt in degrees.

  • is_up (bool) – True if the source is up else false.

molsoft.am_helpers.get_slew_time(md1, ns1, md2, ns2)

Calculate the slew time between two positions.

Returns:

t – Slewtime in seconds between the two positions.

Return type:

str

molsoft.am_helpers.get_status()

Get telescope tracking status for TCC3 via TCP socket.

Returns:

status – Tracking status of the telescope, or None if no connection to TCC3 could be made.

Return type:

numpy rec or None

molsoft.am_helpers.get_tcc_status()

Query status of TCC.

molsoft.am_helpers.get_transit(ra, dec)

Calculate next transit time for a source at RA and DEC.

Parameters:
  • ra (str) – RA in hh:mm:ss notation.

  • dec (str) – DEC in hh:mm:ss notation.

Returns:

  • rising – Rising UTC.

  • transit – Transit UTC.

  • setting – Setting UTC.

molsoft.am_helpers.is_on_source(movement_state, ns_md_off, is_pulsar=False)

Check if the telescope is on source.

Parameters:
  • movement_state (numpy rec) – Slew speed and state of each arm.

  • ns_md_off (dict) – Pointing offsets for both arms.

  • is_pulsar (bool (optional, default=False)) – Be less conservative with pulsars and report on_source already when it is within half-power point of primary beam.

Returns:

  • on_source (bool or None) – Whether the telescope is on source. None if telescope status from TCC is unknown.

  • slew_time (float or None) – Expected slew time to source. None if telescope status from TCC is unknown.

molsoft.am_helpers.park_telescope(movement_state, ns_md_off)

Park the telescope.

Parameters:
  • movement_state (dict) – States the NS/MD movement state of telescope. The keys are {ns_east, ns_west, md_east, md_west}.

  • ns_md_off (dict) – The NS, MD pointing offsets for each arm.

molsoft.am_helpers.parse_cfg(cfg_file, tags=None)

Return config file with given tags as dictionary.

Parameters:
  • cfg_file (str) – full directory to config file

  • tags (list) – list of tags to search the cgf_file

Returns:

config_dict – dictionary with keys given in tags, and values extracted from cfg_file. If one tag doesn’t exist, value corresponded will be None, else value is of type str, or list if multiple values exist for same key.

Return type:

dict

molsoft.am_helpers.parse_status(raw_data)

Parse the tracking status returned from TCC.

Parameters:

raw_data (str) – Raw data as returned from anasi.

Returns:

status – Tracking status of the telescope.

Return type:

numpy rec

molsoft.am_helpers.point(x, y, movement_state, ns_md_off, tracking, coord_system='equatorial')

Point at RA and DEC using J2000 and hh:mm:ss notation.

Parameters:
  • x (str) – Horizontal pointing position, normally RA.

  • y (str) – Vertial pointing position, normally DEC.

  • movement_state (numpy rec) – Either auto, slow or disable for each arm.

  • ns_md_off (dict) – Dictionary with keyvalues {ns_east_offset, ns_west_offset, md_east_offset, md_west_offset} representing the pointing offsets that are sent to anansi.

  • tracking (str) – Either on or off. It determines if the requested field should actively be tracked.

  • coord_system (str (optional, default="equatorial")) – Coordinate system that x and y are specified in. Default is equatorial.

Raises:

RuntimeError – If tracking status is unknown.

molsoft.am_helpers.posn_on_source(ra, dec, movement_state, ns_md_off)

Move to source but do not start the backend.

Parameters:
  • ra (str) – RA in J2000 equatorial coordinates in hh:mm:ss notation.

  • dec (str) – DEC in J2000 equatorial coordinates in hh:mm:ss notation.

molsoft.am_helpers.run_schedule(schedule, debug, move_telescope, movement_state, ns_md_off=None)

This is the main loop that processes a schedule.

Parameters:
  • schedule (list) – The schedule to run.

  • debug (bool) – Test the operation of the function in debug mode.

  • move_telescope (bool) – Determines whether the telescope should be moved.

  • movement_state (dict) – States the NS/MD movement state of telescope. The keys are {ns_east, ns_west, md_east, md_west}.

  • ns_md_off (dict (optional, default=None)) – The NS, MD pointing offsets for each arm.

molsoft.am_helpers.sanity_check(line, movement_state)

Check if a given schedule line can be processed at the current time. Check: 1) Source is up for at least tslew + tobs.

Returns:

line_works – Return True if all is good, otherwise False.

Return type:

bool

molsoft.am_helpers.start_backend(config, obs_type, name, ra, dec, tobs)

Start the backend.

molsoft.am_helpers.start_backend_thresh(config, obs_type, name, ra, dec, thresh, tmin, tmax)

Start the backend for a tied-array beam threshold observation.

Raises:

RuntimeError – On invalid parameters.

molsoft.am_helpers.stop_backend(force=False)

Stop the backend.

Parameters:

force (bool (optional, default=False)) – Whether the backend should be stopped at all costs, without exiting cleanly.

molsoft.am_helpers.stop_tracking(force=False)

Stop tracking.

Parameters:

force (bool (optional, default=False)) – Whether tracking should be stopped at all costs, without exiting cleanly.

molsoft.am_helpers.test_connections(move_telescope)

Test connectivity to the backend, TCC and so on.

Parameters:

move_telescope (bool) – Determines whether the telescope should currently move or not.

Raises:

RuntimeError – If not connection can be established to TCC or the backend.

molsoft.am_helpers.track_source(ra, dec, movement_state, is_pulsar, ns_md_off)

Track source but do not start backend.

Parameters:
  • ra (str) – RA in J2000 equatorial coordinates in hh:mm:ss notation.

  • dec (str) – DEC in J2000 equatorial coordinates in hh:mm:ss notation.

molsoft.am_helpers.wait_lst(end_lst)

Wait until a given LST.

molsoft.am_helpers.wait_sec(seconds)

Wait for a given amount of seconds.

molsoft.am_helpers.wait_transit(jname, offset)

Wait for the transit of a given pulsar.

Parameters:
  • jname (str) – J2000 name of the pulsar.

  • offset (float) – The offset is given in seconds and can be negative (earlier) or positve (later) compared with the transit time.

molsoft.am_helpers.wait_utc(end_utc)

Wait until a given UTC.

molsoft.am_helpers.wind_stow(maintenance=False)

Send the telescope to wind stow position.

Parameters:

maintenance (bool (optional, default=False)) – If True send the telescope to maintenance position instead.

automatic_mode

automatic_mode_client

class molsoft.automatic_mode_client.SignalHandler

Handle unix signals sent to the program.

molsoft.automatic_mode_client.xml_parse(response_DS)

Parse the XML message.

automatic_mode_server

class molsoft.automatic_mode_server.ThreadedTCPRequestHandler(request, client_address, server)

A server side code for communicating with dynamic scheduler and am_client.

handle()

Handle a TCP connection. This is the main function.

class molsoft.automatic_mode_server.ThreadedTCPServer(server_address, RequestHandlerClass, queue1)
molsoft.automatic_mode_server.request_pulsars(ds_config)

Request new pulsars from the scheduler.

Parameters:

ds_config (tuple) – Tuple containing (hostname, port) of the scheduler.

molsoft.automatic_mode_server.worker(pulsars, ds_config, debug, move_telescope, movement_state)

A worker thread.

coord_helpers

molsoft.coord_helpers.compute_tilt_grid(tadpole=False)

Compute the NS, EW tilt grid for Molonglo.

Parameters:

tadpole (bool) – Determine whether a finer grid for Tadpole should be generated.

Returns:

tilt_grid – NS, EW tilt grid as numpy record.

Return type:

numpy rec

molsoft.coord_helpers.compute_trail_grid(t_targets)

Compute a trail movement grid for each target with a given DEC.

Parameters:

t_targets (numpy rec) – Numpy record of target sources.

Returns:

total – Trail grid for all targets.

Return type:

numpy rec

molsoft.coord_helpers.gen_coordinate_list(filename)

Generate coordinate list of all pulsars from psrcat.

molsoft.coord_helpers.get_coordinate_list()

Get the pulsar coordinate list from psrcat.

molsoft.coord_helpers.get_lst(utc)

Compute the LST at Molonglo that corresponds to the given utc.

Parameters:

utc (str) – UTC date string.

Returns:

LST at Molonglo.

Return type:

lst

molsoft.coord_helpers.get_md_ns_tilt(ra, dec, date=45167.023935185185)

Compute NS and MD tilt for a given source at RA and DEC.

Parameters:
  • ra (str) – RA in hh:mm:ss notation.

  • dec (str) – DEC in hh:mm:ss notation.

  • date (ephem object) – The requested date as ephem object.

Returns:

  • md_tilt (float) – MD tilt in degrees.

  • ns_tilt (float) – NS tilt in degrees.

  • is_up (bool) – Returns whether the source is up at Molonglo.

molsoft.coord_helpers.get_ra_dec(jname)

Get the RA and DEC of a pulsar from psrcat.

Parameters:

jname (str) – J2000 name of a pulsar.

Returns:

  • ra (str) – RA in hh:mm:ss notation.

  • ra (str) – DEC in hh:mm:ss notation.

molsoft.coord_helpers.get_ra_dec_list(coord_list, name)

Get the RA and DEC (J2000) for a given pulsar with Jname. It works by looking it up in a coordinate list generated from psrcat.

Parameters:
  • coord_list (numpy rec) – Coordinate list generated from psrcat.

  • name (str) – J2000 name of pulsar.

Returns:

  • ra (str) – RA in hh:mm:ss notation.

  • dec (str) – DEC in hh:mm:ss notation.

molsoft.coord_helpers.parse_coordinate_list(filename)

Parse pulsar coordinate list output by psrcat.

molsoft.coord_helpers.update_target_tilt(targets, utc)

Update the MD and NS tilt of the targets for the given UTC time stamp.

Parameters:
  • targets (numpy rec) – Targets record.

  • utc – UTC time stamp.

Returns:

targets – Targets numpy record with updated tilts.

Return type:

numpy rec

molsoft.coord_helpers.update_target_tilt_grid(targets, grid, utc, interp='linear')

Update the MD and NS tilt of the targets for the given UTC time stamp. This function uses a lookup grid for speed. This assumes that both targets and grid are sorted by name and that the names are equal.

Parameters:
  • targets (numpy rec) – The target sources.

  • grid (numpy rec) – The trail lookup grid for all target sources.

  • utc (str) – The requested UTC.

  • interp (str (optional)) – Interpolation strategy to use. Default is linear interpolation to the current LST.

Returns:

targets – Targets record with updated tilts.

Return type:

numpy rec

db_helpers

molsoft.db_helpers.dtype_add_fields(dtype1, dtype2)

Add fields in dtype2 to dtype1.

Parameters:
  • dtype1 (dtype) – First dtype object.

  • dtype2 (dtype) – Second dtype object.

Returns:

r – Combined dtype object.

Return type:

dtype

molsoft.db_helpers.get_fluxes(filename='/home/docs/strategy.db')

Get the fluxes from the database.

Parameters:

filename (str) – Filename of database.

Returns:

data – Flux densities of sources from database.

Return type:

numpy rec

molsoft.db_helpers.get_obs_strategy(filename='/home/docs/strategy.db')

Parse the observing strategy.

Parameters:

filename (str) – Filename of database.

Returns:

data – Observation strategy from database.

Return type:

numpy rec

molsoft.db_helpers.get_observations(filename='/home/docs/schedule/dirtydb/dirtydb.db')

Load all the observations from the database.

Parameters:

filename (str) – Filename of database.

Returns:

data – Data as a numpy record.

Return type:

numpy rec

molsoft.db_helpers.init_db(filename)

Initialize observations database.

Parameters:

filename (str) – Filename of database.

molsoft.db_helpers.insert_into_db(data, table, filename)

Insert data into database.

Parameters:
  • data (numpy rec) – Data to add into database.

  • table (str) – Name of table into which the data should be inserted.

  • filename (str) – Filename of the database.

molsoft.db_helpers.obs_strat_to_schedule(t_data)

Convert the output from the observation strategy into a schedule file for automatic_mode.

Parameters:

t_data – Output from observation strategy.

Returns:

schedule – List of SchedItems.

Return type:

list

frog

molsoft.frog.get_md_ns_object(name, up_only=True)

Compute NS and MD of various objects (Sun, Moon, etc.).

Parameters:
  • name (str) – Name of object.

  • up_only (bool (optional)) – Get tilts only for objects that are currently up.

Returns:

  • md_tilt (float or None) – MD tilt in degrees. Returns None if object is not up.

  • ns_tilt (float or None) – NS tilt in degrees. Returns None if object is not up.

Raises:

NotImplementedError – If object is not implemented.

molsoft.frog.get_status(status_ip, status_port)

Get telescope tracking status for TCC3 via TCP socket.

Parameters:
  • status_ip (str) – IP of the status reporting process.

  • status_port (int) – Status port.

Returns:

status – This returns the telescope status of None if no connection to TCC3 could be made.

Return type:

numpy rec or None

molsoft.frog.get_targets(schedule)

Get targets from schedule.

molsoft.frog.load_frb_data(filename)

Load the FRB data from file.

Parameters:

filename (str) – Filename of file with FRB data.

Returns:

data – FRB data.

Return type:

numpy rec

molsoft.frog.load_psr_data(filename)

Load the pulsar data from file. The input file is a list of jnames.

Parameters:

filename (str) – Filename of file with PSR data.

Returns:

data – PSR data.

Return type:

numpy rec

molsoft.frog.load_qso_data(filename)

Load the quasar calibrator data from file.

Parameters:

filename (str) – Filename of file with QSO data.

Returns:

data – QSO data.

Return type:

numpy rec

molsoft.frog.parse_status(raw_data)

Parse the tracking status returned from TCC.

Parameters:

raw_data (str) – The raw data transmitted from the status port.

Returns:

status – Status of the telescope. This returns None if the status of the arms could not be determined.

Return type:

numpy rec or None

molsoft.frog.plot_status(fig, data, tilt_grid, tilt_grid_tad, targets, psrs, psrs_tad, qsos, frbs, daemon=False, mode='frog')

Plot the telescope status.

molsoft.frog.signal_handler(signum, frame)

Handle unix signals sent to the program.

make_schedule

molsoft.make_schedule.get_last_observed(data, source_name)

Determine when a source was last observed.

Parameters:
  • data (numpy rec) – Data from the observation database.

  • source_name (str) – Name of the source.

Returns:

age – Time since the last observation of an object and now as timedelta object. If the object was never observed, return None.

Return type:

timedelta or None

molsoft.make_schedule.limit_observation_time(schedule, hours)

Limit the schedule to X hours of observation time. It ensures that the schedule tobs will always be less than X hours.

Parameters:
  • schedule – Schedule file.

  • hours (float) – Number of hours of tobs.

molsoft.make_schedule.output_schedule_file(schedule)

Output the schedule file to disk.

Parameters:

schedule (list) – List of SchedItems.

molsoft.make_schedule.signal_handler(signum, frame)

Handle unix signals sent to the program.

molsoft.make_schedule.sort_schedule(schedule, offset)

Sort the schedule to be applicable for the current LST. Sort it by increasing RA after the current LST.

Parameters:
  • schedule (list) – List of SchedItem.

  • offset (float) – Offset in hours to the current LST.

Returns:

Sorted schedule.

Return type:

schedule

schedule_helpers

class molsoft.schedule_helpers.SchedItem

A schedule item that encapsulates all the necessary data to process an observation.

make_schedule()

Output the current object as schedule line.

Returns:

line – Schedule line that fully represents the SchedItem.

Return type:

str

molsoft.schedule_helpers.calculate_times(schedule)

Calculate times and statistics for the current schedule.

Parameters:

schedule (list) – List of SchedItems.

molsoft.schedule_helpers.get_schedule_grammar()

Return the grammar in the schedule file.

Returns:

grammar – Grammar in the schedule file.

Return type:

str

molsoft.schedule_helpers.load_schedule(filename)

Load schedule from file.

Parameters:

filename (str) – Filename of the schedule file to load.

Returns:

schedule – List of SchedItems.

Return type:

list

Raises:

RuntimeError – If schedule file does not exist or cannot be parsed.

molsoft.schedule_helpers.parse_schedule(total)

Parse the schedule and check it for errors.

Parameters:

total (list) – List of str are schedule lines.

Returns:

schedule – Schedule that is a list of SchedItems.

Return type:

list

Raises:

RuntimeError – If the schedule line could not be parsed.

molsoft.schedule_helpers.split_max_tobs(schedule, max_tobs)

Split very long observation into multiple chunks.

Parameters:
  • schedule (list) – List of SchedItems.

  • max_tobs (float) – Maximum observing time given in seconds.

Returns:

schedule – List of SchedItem that is split into multiple chunks that are less than max_tobs.

Return type:

list

Raises:

RuntimeError – If the split failed.

molsoft.schedule_helpers.test_schedule_file(filename)

Test the schedule file for errors.

Parameters:

filename (str) – Filename of schedule file to process.

Raises:

RuntimeError – If errors occurred.

scheduler

class molsoft.scheduler.ThreadedTCPRequestHandler(request, client_address, server)

A server side code for communicating with automatic_mode.

handle()

Handle the TCP connection. This is the main processing function.

class molsoft.scheduler.ThreadedTCPServer(server_address, RequestHandlerClass, bind_and_activate=True)
molsoft.scheduler.append_paths(total, t_data)

Append path or score data onto an existing numpy record. Increment the path_nr appropriately.

molsoft.scheduler.combine_paths(t_data)

Combine paths into a single data structure. Increment the path_nr appropriately.

molsoft.scheduler.compute_paths(targets, trail_grid, start_position, start_utc, nr_paths)

Compute a number of paths. The path_nr keyword identifies each individual path.

Parameters:
  • targets (numpy rec) – Targets record.

  • trail_grid (numpy rec) – Trail lookup table for each target.

  • start_position (numpy rec) – Start pointing position of the telescope.

  • start_utc – UTC timestamp of the start.

  • nr_paths (int) – Total number of paths generated.

Returns:

total – Record of all the paths.

Return type:

numpy rec

molsoft.scheduler.compute_rise_set(t_trail_grid)

Add the is_up status and compute the rise and set LST for each target.

molsoft.scheduler.gen_path(targets, trail_grid, start_position, start_utc=45167.02395833333)

Generate a path through the target cloud for a start position and and start utc.

Parameters:
  • targets (numpy rec) – Targets record.

  • trail_grid (numpy rec) – Pre-computed trail grid for each target.

  • start_position (numpy rec) – MD, NS value of start position.

  • start_utc (ephem.Date object (optional, default=now)) – UTC of start of the path generation.

Returns:

path – Path through the target cloud.

Return type:

numpy rec

molsoft.scheduler.gen_schedule(pulsar, utc)

Returns a list of schedule lines

Parameters:
  • pulsar (numpy rec) – Pulsar to process.

  • utc (str) – UTC in format YYYY-MM-DD-HH:MM:SS.

Returns:

sched – Schedule file.

Return type:

list

molsoft.scheduler.get_best_path(s_score)

Select the optimum path based on different scores.

Parameters:

s_score (numpy rec) – Score record.

Returns:

best – Path_nr of the best path or None if no best path was found.

Return type:

int or None

molsoft.scheduler.get_best_source_transit(targets)

Determine the best source for transit mode.

Parameters:

targets (numpy rec) – Targets record.

Returns:

best_source – Best source to observe.

Return type:

numpy rec

molsoft.scheduler.get_best_sources(targets, nr)

Return the sources with the best scores at the moment that have not been observed yet.

Parameters:
  • targets (numpy rec) – Targets record.

  • nr (int) – Number of sources to return.

Returns:

best_sources – Record of number nr best sources.

Return type:

numpy rec

molsoft.scheduler.get_can_be_done(targets, utc, transit)

Determine if the targets can be done. That means that they are up for all slewtime + tobs.

Parameters:
  • targets (numpy rec) – Targets record.

  • utc – UTC timestamp.

  • transit (bool) – Determines if the telescope operates as a transit intrument.

Returns:

can_be_done – Boolean array that determines whether each target can be observed.

Return type:

numpy arr

molsoft.scheduler.get_dwell_weights(t_targets, utc)

Compute the dwell weights, which are mainly used for meridian transit observations.

Parameters:
  • t_targets (numpy rec) – Targets record.

  • utc – UTC timestamp.

Returns:

weights – Dwell weights for each target.

Return type:

numpy arr

molsoft.scheduler.get_scores_paths(total, output_stats=False)

Compute the total scores for each path.

Parameters:
  • total (numpy rec) – Total record of paths.

  • output_stats (bool (optional, default=False)) – Determines whether statistics are output.

Returns:

score – List of scores that reference the paths record via the keyword path_nr.

Return type:

list

molsoft.scheduler.get_targets()

Get the targets for the scheduler from the observation strategy.

Returns:

data – Targets for the scheduler.

Return type:

numpy rec

Raises:

RuntimeError – If something goes wrong.

molsoft.scheduler.get_time_to_transit(ra, utc, slewtime, tobs)

Return time to transit.

Parameters:
  • ra – RA of object.

  • utc – UTC timestamp.

  • slewtime (float) – Slewtime to target from current position in seconds.

  • tobs (float) – Observing time in seconds.

Returns:

tdiff – Time to transit in seconds.

Return type:

float

molsoft.scheduler.get_tobs(snr_wanted, flux, delta, tsky, fraction=1.0)

Compute the observation time required to reach a certain S/N for a given pulsar.

Parameters:
  • snr_wanted (float) – S/N that is requested.

  • flux (float) – Pulse-average flux density of pulsar given in mJy.

  • delta (float) – Duty cycle of the pulsar.

  • tsky (float) – Sky temperature at the pulsar’s location given in K.

  • fraction (float (optional, default=1.0)) – Fraction of sensitivity of the maximum sensitivity.

Returns:

tobs – Required observation time to reach the requested S/N given in seconds.

Return type:

float

molsoft.scheduler.get_weight_cadence(t_data, utc)

Compute the weight for the required cadence.

Parameters:
  • t_data (numpy rec) – Target data record.

  • utc – UTC timestamp.

Returns:

weights – Cadence weight for each target.

Return type:

numpy arr

molsoft.scheduler.plot_skyview(fig, tilt_grid, t_targets, position, best_sources, utc, path=None)

Plot the targets in a skyview.

molsoft.scheduler.pool_compute_paths(args)

Run the compute_path function by a pool of worker processes.

molsoft.scheduler.run_dynamic()

Run the processing for dynamic mode.

molsoft.scheduler.run_genpaths(targets, trail_grid, position, utc, npath, output_stats)

Run the processing for genpaths mode.

molsoft.scheduler.run_plotlive(targets, tilt_grid, trail_grid, position, utc, npath, output_stats, show_best)

Run the processing for plotlive mode.

molsoft.scheduler.run_plotpaths(targets, tilt_grid, trail_grid, position, utc, npath)

Run the processing for plotpaths mode.

molsoft.scheduler.run_showtrails(targets, tilt_grid, trail_grid, position, utc)

Run the processing for showtrails mode.

molsoft.scheduler.save_schedule_file(sched, fname)

Save schedule file to disk.

Parameters:
  • sched (list of str) – Schedule file.

  • fname (str) – Name of schedule file.

molsoft.scheduler.set_rise_set(targets, grid)

Set the rise and set LST for each target from the trail grid.

molsoft.scheduler.show_best_path(fig, path)

Show the best path in a window.

molsoft.scheduler.show_path(fig, tilt_grid, trail_grid, t_targets, p_path)

Show a path in skyview.

molsoft.scheduler.update_last_observed(targets)

Update the last_observed times for each target. If a source was never observed, set its last_observed to 1 year in the past.

molsoft.scheduler.update_neighbours(targets)

Compute how many sources are neighbours withing a distance of X deg around each source. diameter is in degrees around a source. Use a circle here.

Parameters:

targets (numpy rec) – Targets record.

Returns:

targets – Updated targets record.

Return type:

numpy rec

molsoft.scheduler.update_target_distance(targets, position)

Update the distance of each target from the current position.

Parameters:
  • targets (numpy rec) – Targets record.

  • position (numpy rec) – Current pointing position of the telescope in MD, NS space.

Returns:

targets – Updated targets record.

Return type:

numpy rec

molsoft.scheduler.update_target_score(targets, trail_grid, position, utc, use_neighbours=False)

Update the score for each target based on various criteria.

Parameters:
  • targets (numpy rec) – Targets record.

  • trail_grid (numpy rec) – Pre-computed trail grid of each target source.

  • position (numpy rec) – Current pointing position of the telescope.

  • use_neighbours (bool (optional, default=False)) – Recompute the next neighbour density weights.

Returns:

targets – Targets record with updated weights.

Return type:

numpy rec

molsoft.scheduler.update_target_slewtime(targets, transit)

Update the slew time to each target from the current position.

Parameters:
  • targets (numpy rec) – Targets record.

  • transit (bool) – Determines if the telescope should slew in NS only.

Returns:

targets – Updated targets record.

Return type:

numpy rec

molsoft.scheduler.worker(task_queue, result_queue)

A worker process.

sentinel

molsoft.sentinel.local_time_to_utc(time)

Convert local time to UTC.

Parameters:

time (ephem.Date object) – Local time.

Returns:

utc – Local time converted to UTC.

Return type:

ephem.Date object

molsoft.sentinel.park_telescope()

Slew to park position.

molsoft.sentinel.shutdown_observing_system()

Shutdown the observing system.

molsoft.sentinel.signal_handler(signum, frame)

Handle unix signals sent to the program.

molsoft.sentinel.stop_observation()

Stop the current automatic_mode process. Stop telescope tracking, backend etc.

snr_extractor_client

molsoft.snr_extractor_client.get_snr_in_x_min(snr0, t0, t=1200)

Extrapolate the SNR from SNR0 at t0 to a time t.

Parameters:
  • snr0 (float) – SNR at t0.

  • t0 (float) – Observation time t0 in seconds.

  • t (float (optional)) – Observation time t in seconds. Default is 20 min.

Returns:

snr – SNR at time t.

Return type:

float

molsoft.snr_extractor_client.get_snr_status()

Connect to SNR extractor server and get status.

Returns:

status – Status of current observation. If an error occurs return None.

Return type:

numpy rec or None

molsoft.snr_extractor_client.parse_xml(raw_data)

Parse the XML message and determine the status of the observation.

Parameters:
  • raw_data (str) – Raw status data.

  • status (numpy rec) – Status of observation.

molsoft.snr_extractor_client.plot_snr(fig, data)

Plot the SNR evolution.

molsoft.snr_extractor_client.set_threshold(mode, thresh)

Send the SNR or ToA threshold to the snr extractor server.

Parameters:
  • mode (str) – Determines if SNR or ToA threshold is set.

  • thresh (float) – Threshold to set.

Returns:

worked – Whether the command was passed successfully.

Return type:

bool

molsoft.snr_extractor_client.signal_handler(signum, frame)

Handle unix signals sent to the program.

snr_extractor_server

class molsoft.snr_extractor_server.Observation(basedir, filename)

A class for the current observation.

check_finished()

Check if the observation is finished.

Returns:

finished – Whether the observation is finished.

Return type:

bool

estimate_snr(lock)

Estimate the S/N of this observation. This is the main loop.

Parameters:

lock – The threading lock object.

set_snr_threshold(lock, threshold)

Set the S/N threshold.

Parameters:
  • lock – The threading lock object.

  • threshold (float) – The new threshold.

class molsoft.snr_extractor_server.ThreadedTCPRequestHandler(request, client_address, server)

A threaded TCP request handler.

class molsoft.snr_extractor_server.ThreadedTCPServer(server_address, RequestHandlerClass, lock, observation)

A threaded TCP Server.

molsoft.snr_extractor_server.db_worker(db_filename, basedir, first_run)

A database worker thread.

molsoft.snr_extractor_server.gen_xml(obs)

Generate observation status as XML message.

molsoft.snr_extractor_server.get_current_observation(basedir)

Return the current observation.

Parameters:

basedir (str) – The base directory to operate in.

Returns:

current_file – Filename of the current observation. The current observation is the newest one that is not finished yet.

Return type:

str

molsoft.snr_extractor_server.get_info(filename)

Compute the current S/N ratio of an archive and extract various other information from it.

molsoft.snr_extractor_server.get_obs_info(filename)

Get some basic info about the observation.

Parameters:

filename (str) – The filename of the observation.

Returns:

data – Basic info about observation.

Return type:

numpy rec

molsoft.snr_extractor_server.get_snr_in_x_min(snr0, t0, t=1200)

Extrapolate the SNR from SNR0 at t0 to a time t.

Parameters:
  • snr0 (float) – SNR at t0.

  • t0 (float) – Observation time t0 in seconds.

  • t (float (optional)) – Observation time t in seconds. Default is 20 min.

Returns:

snr – SNR at time t.

Return type:

float

molsoft.snr_extractor_server.get_snr_status(data, threshold)

Determine if the S/N is stable and trustworthy. Check if the S/N was above the threshold for at least a minute and at least 3 subintegrations.

Parameters:
  • data (numpy rec) – The observation data.

  • threshold (float) – The S/N threshold.

Returns:

status – Stable str if stable, otherwise None.

Return type:

str or None

molsoft.snr_extractor_server.get_std_profile(jname)

Get the filename of the standard profile for the given pulsar.

Parameters:

jname (str) – J2000 name of the pulsar.

Returns:

std_profile – Filename of the standard profile for the given pulsar.

Return type:

str

Raises:

RuntimeError – If there is no standard profile for the given pulsar.

molsoft.snr_extractor_server.get_toa_error(data)

Compute the ToA error for the current observation.

Parameters:

data (numpy rec) – The observation data.

Returns:

toa_err – ToA error of the current observation or None if not possible to extract.

Return type:

float or None

molsoft.snr_extractor_server.get_toa_status(data, threshold)

Check if the improvement in ToA error (dtoa) was below the threshold for at least a minute and at least 3 subintegrations.

Parameters:
  • data (numpy rec) – The observation data.

  • threshold (float) – The delta ToA threshold.

Returns:

status – Stable str if stable, otherwise None.

Return type:

str or None

molsoft.snr_extractor_server.running_mean(data, n)

Compute a running mean over the data with window size n.

molsoft.snr_extractor_server.snr_worker(lock, observation)

A S/N worker thread.

molsoft.snr_extractor_server.update_dirty_db(filename, basedir, first_run)

Update the dirty db with observation data.

Parameters:
  • filename (str) – Filename of the database.

  • basedir (str) – Base directory to search for observations in.

  • first_run (bool) – Determines if old_results are checked as well.

molsoft.snr_extractor_server.update_rmean_snr(data)

Update the running mean S/N in the data.

molsoft.snr_extractor_server.use_gaussian_baseline_estimator(restore=False)

Adjust PSRCHIVE to use the Gaussian baseline estimator (GaussianBaseline) instead of the default one (BaselineWindow), as it is much better at estimating the baseline correctly for accurate flux density measurements.

We do this by setting the corresponding option in ~/.psrchive.cfg

Parameters:

restore (bool (optional, default=False)) – If true, restore the backup of the original config file.

software_status