layup.convert
Attributes
Functions
Get the output column names and types for the converted data. |
|
|
Apply the appropriate conversion function to the data |
|
Convert a structured numpy array to a different orbital format with support for parallel processing. |
|
Convert an orbit file from one format to another with support for parallel processing. |
Module Contents
- ORBIT_FIT_COLS = [('csq', 'f8'), ('ndof', 'i4'), ('niter', 'i4'), ('method', 'O'), ('flag', 'i4')][source]
- get_output_column_names_and_types(primary_id_column_name, has_covariance, extra_cols_to_keep)[source]
Get the output column names and types for the converted data.
- Parameters:
primary_id_column_name (str) – The name of the column in the data that contains the primary ID of the object.
has_covariance (bool) – Whether the data has covariance information.
extra_cols_to_keep (list) – List of tuples containing extra column names and dtypes to keep in the output data.
- Returns:
A tuple containing two elements: - A dictionary mapping orbit formats to the required column names for that format. - A list of default column dtypes for the output data.
- Return type:
tuple
- _apply_convert(data, convert_to, cache_dir=None, primary_id_column_name=None, extra_cols_to_keep=[])[source]
Apply the appropriate conversion function to the data
- Parameters:
data (numpy structured array) – The data to convert.
convert_to (str) – The orbital format to convert the data to. Must be one of: “BCART”, “BCART_EQ”, “BCOM”, “BKEP”, “CART”, “COM”, “KEP”
cache_dir (str, optional) – The base directory for downloaded files.
primary_id_column_name (str, optional) – The name of the column in the data that contains the primary ID of the object.
extra_cols_to_keep (list, optional) – List of tuples containing extra column names and dtypes to keep in the output data.
- Returns:
data – The converted data
- Return type:
numpy structured array
- convert(data, convert_to, num_workers=1, cache_dir=None, primary_id_column_name='ObjID', extra_cols_to_keep=[])[source]
Convert a structured numpy array to a different orbital format with support for parallel processing.
- Parameters:
data (numpy structured array) – The data to convert.
convert_to (str) – The format to convert the data to. Must be one of: “BCART_EQ”, “BCOM”, “BKEP”, “CART”, “COM”, “KEP”
num_workers (int, optional (default=1)) – The number of workers to use for parallel processing.
cache_dir (str, optional) – The base directory for downloaded files.
primary_id_column_name (str, optional (default="ObjID")) – The name of the column in the data that contains the primary ID of the object.
extra_cols_to_keep (list, optional) – List of tuples containing additional column names and dtypes to keep in the output data.
- Returns:
data – The converted data
- Return type:
numpy structured array
- convert_cli(input: str, output_file_stem: str, convert_to: Literal['BCART', 'BCART_EQ', 'BCOM', 'BKEP', 'CART', 'COM', 'KEP'], file_format: Literal['csv', 'hdf5'] = 'csv', chunk_size: int = 10000, num_workers: int = -1, cli_args: dict = None)[source]
Convert an orbit file from one format to another with support for parallel processing.
Note that the output file will be written in the caller’s current working directory.
- Parameters:
input (str) – The path to the input file.
output_file_stem (str) – The stem of the output file.
convert_to (str) – The format to convert the input file to. Must be one of: “BCART”, “BCART_EQ”, “BCOM”, “BKEP”, “CART”, “COM”, “KEP”
file_format (str, optional (default="csv")) – The format of the output file. Must be one of: “csv”, “hdf5”
chunk_size (int, optional (default=10_000)) – The number of rows to read in at a time.
num_workers (int, optional (default=-1)) – The number of workers to use for parallel processing of the individual chunk. If -1, the number of workers will be set to the number of CPUs on the system.
cli_args (argparse, optional (default=None)) – The argparse object that was created when running from the CLI.