orsopy.fileio.orso

Implementation of the top level class for the ORSO header.

class orsopy.fileio.orso.Orso(data_source, reduction, columns, data_set=None, **user_data)[source]

Bases: Header

The Orso object collects the necessary metadata.

Parameters:
  • data_source (DataSource) – Information about the origin and ownership of the raw data.

  • reduction (Reduction) – Details of the data reduction that has been performed. The content of this section should contain enough information to rerun the reduction.

  • columns (List[Union[Column, ErrorColumn]]) – Information about the columns of data that will be contained in the file.

  • data_set (Union[int, str, None]) – An identifier for the data set, i.e. if there is more than one data set in the object.

data_source: DataSource
reduction: Reduction
columns: List[Union[Column, ErrorColumn]]
data_set: Union[int, str, None] = None
classmethod empty()[source]

Create an empty instance of the ORSO header with all non-optional attributes as None.

Return type:

Orso

Returns:

Empty Orso class, within minimum required columns

property user_data
column_header()[source]

An information string that explains what each of the columns in a dataset corresponds to.

Return type:

str

Returns:

Explanatory string.

from_difference(other_dict)[source]

Constructs another Orso instance from self, and a dict containing updated header information.

Parameters:

other_dict (dict) – Contains updated header information.

Return type:

Orso

Returns:

A new Orso object constructed from self, and the updated header information.

to_difference(other)[source]

A dictionary containing the difference in header information between two Orso objects.

Parameters:

other (Orso) – Other header to diff with.

Return type:

dict

Returns:

Dictionary of the header information difference.

to_dict()[source]

Adds the user data to the returned dictionary.

comment: Optional[str] = None
class orsopy.fileio.orso.OrsoDataset(info, data)[source]

Bases: object

Parameters:
  • info (Orso) – The header information for the reflectivity measurement

  • data (Any) – The numerical data associated with the reflectivity measurement. The data has shape (npnts, ncols).

Raises:

ValueError – When ncols != len(self.info.columns).

info: Orso
data: Any
header()[source]

The header string for the ORSO file.

Return type:

str

Returns:

Header string.

diff_header(other)[source]

Return a header string that only contains changes to other OrsoDataset ensure that data_set is the first entry.

Parameters:

other (OrsoDataset) – Other OrsoDataset to compare against.

Return type:

str

Returns:

Header string with only changes.

save(fname)[source]

Save the OrsoDataset.

Parameters:

fname (Union[TextIO, str]) – The file name to save to.

orsopy.fileio.orso.save_orso(datasets, fname, comment=None, data_separator='')[source]

Saves an ORSO file. Each of the datasets must have a unique OrsoDataset.info.data_set attribute. If that attribute is not set, it is given an integer value corresponding to it’s position in the list.

Parameters:
  • datasets (List[OrsoDataset]) – List of OrsoDataset to save into the Orso file.

  • fname (Union[TextIO, str]) – The file name to save to.

  • comment (Optional[str]) – Comment to write at the top of Orso file.

  • data_separator (str) – Optinal string of newline characters to separate multiple datasets.

Raises:

ValueError – If the OrsoDataset.info.data_set values are not unique.

Return type:

None

orsopy.fileio.orso.load_orso(fname)[source]
Parameters:

fname (Union[TextIO, str]) – The Orso file to load.

Return type:

List[OrsoDataset]

Returns:

OrsoDataset objects for each dataset contained within the ORT file.