sorcha.readers.EphemerisReader

Classes

EphemerisDataReader

A class to read in ephemeris from an external ephemeris file.

Functions

read_full_ephemeris_table(filename, inputformat)

A helper function for testing that reads and returns an entire ephemeris table.

Module Contents

class EphemerisDataReader(filename, inputformat, **kwargs)[source]

Bases: sorcha.readers.ObjectDataReader.ObjectDataReader

A class to read in ephemeris from an external ephemeris file.

Instead of subclassing the various readers (CSV, HDF5, etc.) individually, this class instantiates one of those classes in an internal reader attribute. As such all reading, validation, etc. is passed off to the reader object this object owns. While this adds a level of indirection, it allows us to support a cross product of N file types from M ephemeris generators with M + N readers instead of M * N.

reader = None[source]
get_reader_info()[source]

Return a string identifying the current reader name and input information (for logging and output).

Returns:

The reader information.

Return type:

string

_read_rows_internal(block_start=0, block_size=None, **kwargs)[source]

Reads in a set number of rows from the input.

Parameters:
  • block_start (int, optional) -- The 0-indexed row number from which to start reading the data. For example in a CSV file block_start=2 would skip the first two lines after the header and return data starting on row=2. Default =0

  • block_size (int, optional) -- the number of rows to read in. Use block_size=None to read in all available data. Default = None

  • **kwargs (dictionary, optional) -- Extra arguments

Returns:

res_df -- dataframe of the object data.

Return type:

Pandas dataframe

_read_objects_internal(obj_ids, **kwargs)[source]

Read in a chunk of data corresponding to all rows for a given set of object IDs.

Parameters:
  • obj_ids (list) -- A list of object IDs to use.

  • **kwargs (dictionary, optional) -- Extra arguments

Returns:

res_df -- The dataframe for the object data.

Return type:

pandas dataframe

_process_and_validate_input_table(input_table, **kwargs)[source]

Perform any input-specific processing and validation on the input table. Modifies the input dataframe in place.

Parameters:
  • input_table (Pandas dataframe) -- A loaded table.

  • **kwargs (dictionary, optional) -- Extra arguments

Returns:

input_table -- Returns the input dataframe modified in-place.

Return type:

Pandas dataframe

Notes

The base implementation includes filtering that is common to most input types. Subclasses should call super.process_and_validate() to ensure that the ancestor’s validation is also applied.

read_full_ephemeris_table(filename, inputformat)[source]

A helper function for testing that reads and returns an entire ephemeris table.

Parameters:
  • filename (string) -- location/name of the data file.

  • inputformat (string) -- format of input file ("whitespace"/"comma"/"csv"/"h5"/"hdf5").

Returns:

res_df -- dataframe of the object data.

Return type:

pandas dataframe