data_processing_utilities

Attributes

AU_M

AU_KM

logger

Classes

FakeSorchaArgs

LayupObservatory

A wrapper around Sorcha's Observatory class to provide additional functionality for Layup.

Functions

process_data(data, n_workers, func, **kwargs)

Process a structured numpy array in parallel for a given function and keyword arguments

process_data_by_id(data, n_workers, func, ...)

Process a structured numpy array in parallel for a given function and

get_cov_columns()

Get the covariance columns that are expected in the structured numpy array

has_cov_columns(data)

Check if the data has the expected covariance columns.

parse_cov(orbit_row[, flatten])

Parse the covariance matrix from a structured numpy array representing our

parse_fit_result(fit_result_row[, orbit_colm_flag, ...])

Parse the initial guess data from a structured numpy array representing our

create_chunks(reader, chunk_size)

For a given reader create a list of lists of object ids such that the total

layup_furnish_spiceypy(cache_dir)

A simple wrapper to furnish spiceypy kernels.

get_format(data)

Get the orbit parameter format for this data.

skyplane_cov_to_radec_cov(ra, dec, cov_xx, cov_xy, cov_yy)

Transforms the sky plane covariance matrix into

Module Contents

AU_M = 149597870700[source]
AU_KM = 149597870.7[source]
logger[source]
process_data(data, n_workers, func, **kwargs)[source]

Process a structured numpy array in parallel for a given function and keyword arguments

Parameters:
  • data (numpy structured array) – The data to process.

  • n_workers (int) – The number of workers to use for parallel processing.

  • func (function) – The function to apply to each block of data within parallel.

  • **kwargs (dictionary) – Extra arguments to pass to the function.

Returns:

res – The processed data concatenated from each function result

Return type:

numpy structured array

process_data_by_id(data, n_workers, func, primary_id_column_name, **kwargs)[source]

Process a structured numpy array in parallel for a given function and keyword arguments. Instead of distributing the data across all available workers it is expected that the data will contain a primary id column. The data will be split by the unique values in the primary id column and each block of data will be processed in parallel.

Parameters:
  • data (numpy structured array) – The data to process. Expected to contain a primary id column.

  • n_workers (int) – The number of workers to use for parallel processing.

  • func (function) – The function to apply to each block of data within parallel.

  • **kwargs (dictionary) – Extra arguments to pass to the function.

Returns:

res – The processed data concatenated from each function result

Return type:

numpy structured array

get_cov_columns()[source]

Get the covariance columns that are expected in the structured numpy array representing our orbit fit output result.

Columns are a flattened version of the covariance matrix, which is a 6x6 matrix where the first first row and first 6 items are:

[cov_00, cov_01, cov_02, cov_03, cov_04, cov_05]

and the last row and last 6 items of the flattened matrix are: [cov_50, cov_51, cov_52, cov_53, cov_54, cov_55]

Returns:

cov_columns – The covariance columns in the data.

Return type:

list[str]

has_cov_columns(data)[source]

Check if the data has the expected covariance columns.

Parameters:

data (numpy structured array) – The data to check.

Returns:

True if the data has covariance columns, False otherwise.

Return type:

bool

parse_cov(orbit_row, flatten=False)[source]

Parse the covariance matrix from a structured numpy array representing our orbit fit output result.

Parameters:
  • orbit_row (numpy structured array) – The row of the structured array representing an orbit.

  • flatten (bool, optional) – If True, return a flattened covariance matrix. If False, return a 6x6 covariance matrix. Default is False.

Returns:

cov – The parsed covariance matrix.

Return type:

numpy array

parse_fit_result(fit_result_row, orbit_colm_flag=True, orbit_para=['x', 'y', 'z', 'xdot', 'ydot', 'zdot'])[source]

Parse the initial guess data from a structured numpy array representing our orbit fit output result.

Parameters:

fit_result_row (numpy structured array) – The row of the structured array representing the orbit fit result.

Returns:

res – The parsed fit result.

Return type:

FitResult

create_chunks(reader, chunk_size)[source]

For a given reader create a list of lists of object ids such that the total number of entries in the file for all object ids in a given list, will be less than the chunk size.

Parameters:
  • reader (ObjectDataReader) – The file reader object for the input file

  • chunk_size (int) – The maximum number of rows to be included in a single list of ids

Returns:

chunks – A list of lists of object ids that can be passed to the reader’s read_objects method.

Return type:

list[list[ObjIds]]

class FakeSorchaArgs(cache_dir=None)[source]
ar_data_file_path = None[source]
layup_furnish_spiceypy(cache_dir)[source]

A simple wrapper to furnish spiceypy kernels.

class LayupObservatory(cache_dir=None)[source]

Bases: sorcha.ephemeris.simulation_parsing.Observatory

A wrapper around Sorcha’s Observatory class to provide additional functionality for Layup.

cached_obs[source]
create_obscode_cache_key(obscode, et)[source]

Create a cache key for the observatory coordinates.

Parameters:
  • obscode (str) – The observatory code.

  • et (float) – The ephemeris time.

Returns:

The cache key for the observatory coordinates.

Return type:

str

populate_observatory(obscode, et, data)[source]

Populate the observatory coordinates for a given observatory code and ephemeris time and provide the key that can be used to access the coordinates for the observatory in the cache at the given epoch. This is used to generalize the case where the observatory does not have a fixed position and the coordinates are provided in the data.

Parameters:
  • obscode (str) – The observatory code.

  • et (float) – The ephemeris time.

  • data (numpy structured array) – A row of the structured array of the orbit data to process.

Returns:

obscode_cache_key – The cache key for the observatory coordinates at the given epoch.

Return type:

str

obscodes_to_barycentric(data)[source]

Takes a structured array of observations and returns the barycentric positions and velocites of the observatories.

This assumes that data must have a column ‘et’ representing the ephemeris time of each observation in TDB.

Parameters:

data (numpy structured array) – The data to process.

Returns:

res – Representing the barycentric positions and velocities of the observatories in the data (x,y,z,vx,vy,vz).

Return type:

numpy structured array

get_format(data)[source]

Get the orbit parameter format for this data.

Parameters:

data (numpy structured array) – The data to check.

Returns:

The format of the data.

Return type:

str

skyplane_cov_to_radec_cov(ra, dec, cov_xx, cov_xy, cov_yy)[source]

Transforms the sky plane covariance matrix into an on-sky covariance matrix (error ellipse)

Code adapted from B&K routines

Parameters:
  • ra (numpy array) – right ascension of the observation (deg)

  • dec (numpy array) – declination of the observation (deg)

  • cov_xx (numpy array) – (x,x) entry of the sky plane cov matrix (radians)

  • cov_xy (numpy array) – (x,y) entry of the sky plane cov matrix (radians)

  • cov_yy (numpy array) – (y,y) entry of the sky plane cov matrix (radians)

Returns:

  • numpy array – semi-major axis of the error ellipse (arcsec)

  • numpy array – semi-minor axis of the error ellipse (arcsec)

  • numpy array – position angle of the error ellipse (degrees)