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:
HeaderThe 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
-
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:
- Returns:
Empty Orso class, within minimum required columns
- 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
Orsoinstance from self, and a dict containing updated header information.
- to_difference(other)[source]
A dictionary containing the difference in header information between two
Orsoobjects.- Parameters:
other (
Orso) – Other header to diff with.- Return type:
dict- Returns:
Dictionary of the header information difference.
-
comment:
Optional[str] = None
- class orsopy.fileio.orso.OrsoDataset(info, data)[source]
Bases:
object- Parameters:
info (
Orso) – The header information for the reflectivity measurementdata (
Union[ndarray,Sequence[ndarray],Sequence[Sequence]]) – The numerical data associated with the reflectivity measurement. The data has shape(npnts, ncols).
- Raises:
ValueError – When
ncols != len(self.info.columns).
-
data:
Union[ndarray,Sequence[ndarray],Sequence[Sequence]]
- diff_header(other)[source]
Return a header string that only contains changes to other
OrsoDatasetensure that data_set is the first entry.- Parameters:
other (
OrsoDataset) – OtherOrsoDatasetto 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_setattribute. 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) – Optional string of newline characters to separate multiple datasets.
- Raises:
ValueError – If the
OrsoDataset.info.data_setvalues 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:
OrsoDatasetobjects for each dataset contained within the ORT file.
- orsopy.fileio.orso.load_nexus(fname)[source]
- Return type:
List[OrsoDataset]