Base Data Model

Standard models for RV data

class rvdata.core.models.base.RVDataModel

Bases: object

The base class for all RV data models.

Warning

This class (RVDataModel) should not be used directly. Based on the data level of your .fits file, used the appropriate level specific data model.

This is the base model for all data models. Level specific data inherit from this class, so any attribute and method listed here applies to all data models.

extensions

A dictionary of extensions. This maps extension name to their FITS data type, e.g. PrimaryHDU, ImageHDU, BinTableHDU.

Type:

dict

headers

A dictionary of headers of each extension (HDU). This stores all header information from the FITS file as a dictionary with extension name as the keys and the header content as the values. Headers are stored as OrderedDict types.

Type:

dict

data

A dictionary of data of each extension (HDU). This stores all extension data from the FITS file as a dictionary with extension name as the keys and the data content as the values. Data type is translated from the FITS type to an appropriate Python data type by core.model.definitions.FITS_TYPE_MAP.

Type:

dict

receipt
A table that records the history of this data. The receipt keeps track of the data process history, so that the information stored by this instance can be reproduced from the original data. It is structured as a pandas.DataFrame table, with each row as an entry. Anything that modifies the content of a data product are expected to also write to the receipt. Three string inputs from the primitive are required: name, any relevant parameters, and a status. The receipt will also automatically fill in additional information, such as the time of execution, code release version, current branch, ect. It is not recommended to modify the receipt Dataframe directly. Use the provided methods to make any adjustments, such as:
>>> from core.models.level1 import RV1
>>> data = RV1()
>>> data.receipt_add_entry('primitive1', 'param1', 'PASS')
Type:

pandas.DataFrame

create_extension(ext_name: str, ext_type: str, header=None, data=None)

Create a new empty extension

Parameters:
  • ext_name (str) – name of extension, will be forced uppercase

  • ext_type – FITS data type as string (e.g. BinTableHDU)

  • header (OrderedDict) – optional header to initialize extension header

  • data – optional data to initialize extension data

del_extension(ext_name)

Delete an existing extension

Parameters:

ext_name (str) – extension name

classmethod from_fits(fn, instrument=None, **kwargs)

Create a data instance from a file

This method implys the read method for reading the file. Refer to it for more detail. It is assumed that the input FITS file is in RVData standard format

Parameters:
  • fn (str) – file path (relative to the repository)

  • instrument (str) – name of instrument. None implies FITS file is in EPRV standard format.

Returns:

the data instance containing the file content

Return type:

cls (data model class)

read(fn, instrument=None, overwrite=False, **kwargs)

Read the content of a RVData standard .fits file and populate this data structure.

Parameters:
  • fn (str) – file path (relative to the repository)

  • instrument (str) – instrument name. None implies FITS file is in EPRV standard format.

  • overwrite (bool) – if this instance is not empty, specifies whether to overwrite

Raises:

IOError – when a invalid file is presented

Note

This is not a @classmethod so initialization is required before calling this function

receipt_add_entry(module, status)

Add an entry to the receipt

Parameters:
  • module (str) – Name of the module making this entry

  • status (str) – status to be recorded

receipt_info()

Print the short version of the receipt

Parameters:

receipt_name (string) – name of the receipt

set_data(ext_name, data)

Set extension data

Parameters:
  • ext_name (str) – name of extension, will be forced uppercase

  • data – data to set extension data

set_header(ext_name, header)

Set extension header

Parameters:
  • ext_name (str) – name of extension, will be forced uppercase

  • header (OrderedDict) – header to set extension header

to_fits(fn)

Collect the content of this instance into a monolithic FITS file

Parameters:

fn (str) – file path

Note

Can only write to KPF formatted FITS