orsopy.fileio.base

Implementation of the base classes for the ORSO header.

orsopy.fileio.base.orsodataclass(cls)[source]
exception orsopy.fileio.base.ORSOResolveError[source]

Bases: ValueError

class orsopy.fileio.base.Header[source]

Bases: object

The super class for all of the items in the orso module.

property user_data
classmethod empty()[source]

Create an empty instance of this item containing all non-option attributes as None.

Return type:

Header

Returns:

Empty class.

static asdict(header)[source]

Static method for to_dict().

Parameters:

header (Header) – Object to convert to dictionary.

Return type:

dict

Returns:

Dictionary result.

to_dict()[source]

Produces a clean dictionary of the Header object, removing any optional attributes with the value None.

Return type:

dict

Returns:

Cleaned dictionary.

to_yaml()[source]

Return the yaml string for the Header item

Return type:

str

Returns:

Yaml string

yaml_representer(dumper)[source]
yaml_representer_compact(dumper)[source]
class orsopy.fileio.base.OrsoDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]

Bases: SafeDumper

represent_data(data)[source]
class orsopy.fileio.base.ErrorValue(error_value, error_type=None, value_is=None, distribution=None, comment=None, **user_kwds)[source]

Bases: Header

Information about errors on a value.

error_value: float
error_type: Optional[Literal['uncertainty', 'resolution']] = None
value_is: Optional[Literal['sigma', 'FWHM']] = None
distribution: Optional[Literal['gaussian', 'triangular', 'uniform', 'lorentzian']] = None
yaml_representer(dumper)
property sigma

Return value converted to standard deviation.

The conversion factors can be found in common statistics and experimental physics text books or derived manually solving the variance definition integral. (e.g. Dekking, Michel (2005). A modern introduction to probability and statistics : understanding why and how. Springer, London, UK:) Values and some references available on Wikipedia, too.

comment: Optional[str] = None
class orsopy.fileio.base.Value(magnitude, unit=None, error=None, comment=None, **user_kwds)[source]

Bases: Header

A value or list of values with an optional unit.

magnitude: float
unit: Optional[str] = None
error: Optional[ErrorValue] = None
yaml_representer(dumper)
as_unit(output_unit)[source]

Returns the value as converted to the given unit.

comment: Optional[str] = None
class orsopy.fileio.base.ComplexValue(real, imag=None, unit=None, error=None, comment=None, **user_kwds)[source]

Bases: Header

A value or list of values with an optional unit.

real: float
imag: Optional[float] = None
unit: Optional[str] = None
error: Optional[ErrorValue] = None
yaml_representer(dumper)
as_unit(output_unit)[source]

Returns the complex value as converted to the given unit.

comment: Optional[str] = None
class orsopy.fileio.base.ValueRange(min, max, unit=None, comment=None, **user_kwds)[source]

Bases: Header

A range or list of ranges with mins, maxs, and an optional unit.

min: float
max: float
unit: Optional[str] = None
yaml_representer(dumper)
as_unit(output_unit)[source]

Returns a (min, max) tuple of values as converted to the given unit.

comment: Optional[str] = None
class orsopy.fileio.base.ValueVector(x, y, z, unit=None, error=None, comment=None, **user_kwds)[source]

Bases: Header

A vector or list of vectors with an optional unit. For vectors relating to the sample, such as polarisation, the follow definitions are used.

Parameters:
  • x (float) – is defined as parallel to the radiation beam, positive going with the beam direction.

  • y (float) – is defined from the other two based on the right hand rule.

  • z (float) – is defined as normal to the sample surface, positive direction in scattering direction.

  • unit (Optional[str]) – SI unit string.

x: float
y: float
z: float
unit: Optional[str] = None
error: Optional[ErrorValue] = None
yaml_representer(dumper)
as_unit(output_unit)[source]

Returns a (x, y, z) tuple of values as converted to the given unit.

comment: Optional[str] = None
class orsopy.fileio.base.Person(name, affiliation, contact=None, comment=None, **user_kwds)[source]

Bases: Header

Information about a person, including name, affilation(s), and contact information.

name: str
affiliation: str
contact: Optional[str] = None
comment: Optional[str] = None
class orsopy.fileio.base.Column(name, unit=None, physical_quantity=None, comment=None, **user_kwds)[source]

Bases: Header

Information about a data column.

name: str
unit: Optional[str] = None
physical_quantity: Optional[str] = None
yaml_representer(dumper)
comment: Optional[str] = None
class orsopy.fileio.base.ErrorColumn(error_of, error_type=None, value_is=None, distribution=None, comment=None, **user_kwds)[source]

Bases: Header

Information about a data column.

error_of: str
error_type: Optional[Literal['uncertainty', 'resolution']] = None
value_is: Optional[Literal['sigma', 'FWHM']] = None
distribution: Optional[Literal['gaussian', 'triangular', 'uniform', 'lorentzian']] = None
yaml_representer(dumper)
property name

A convenience property to allow programs to get a valid name attribute for any column.

property to_sigma

The multiplicative factor needed to convert a FWHM to sigma.

The conversion factors can be found in common statistics and experimental physics text books or derived manually solving the variance definition integral. (e.g. Dekking, Michel (2005). A modern introduction to probability and statistics : understanding why and how. Springer, London, UK:) Values and some references available on Wikipedia, too.

comment: Optional[str] = None
class orsopy.fileio.base.File(file, timestamp=None, comment=None, **user_kwds)[source]

Bases: Header

A file with file path and a last modified timestamp.

file: str
timestamp: Optional[datetime] = None
comment: Optional[str] = None
exception orsopy.fileio.base.NotOrsoCompatibleFileError[source]

Bases: ValueError