zero.data module

Data representation and manipulation

class zero.data.BaseFunction(sources=None, sinks=None, series=None, plot_options=None)[source]

Bases: object

Base function container.

A function represents data between one or many sources and sinks. These can be any type descending from BaseElement, though concrete subclasses may implement additional type constraints.

Functions are designed to allow mathematical operations, such as multiplication by scalars or other functions. Concrete subclasses may implement additional constraints on allowed operations.

Parameters
  • sources, sinks (list of BaseElement, optional) – The function’s sources and sinks. Defaults to empty lists.

  • series (Series, optional) – The function’s data.

  • plot_options (dict, optional) – Plot options, passed to matplotlib.pyplot.plot().

abstract draw(*axes)[source]
equivalent(other)[source]

Checks if the specified function has equivalent sources, sinks, labels and data.

property frequencies
property label
meta_data()[source]

Meta data used to provide a hash and check for meta equivalence.

meta_equivalent(other)[source]

Checks if the specified function has equivalent sources, sinks, and labels.

This does not check for data equality.

abstract series_equivalent(other)[source]

Checks if the specified function has an equivalent series to this one.

class zero.data.MultiNoiseDensity(sources=None, series=None, constituents=None, label=None, **kwargs)[source]

Bases: zero.data.NoiseDensityBase

Set of noise data series from multiple sources to a single sink

property noise_names
class zero.data.NoiseDensity(source=None, **kwargs)[source]

Bases: zero.data.SingleSourceFunction, zero.data.NoiseDensityBase

Noise data series

property element_type
property noise_name
property noise_type
class zero.data.NoiseDensityBase(sink=None, **kwargs)[source]

Bases: zero.data.SingleSinkFunction

Function with a single noise spectral density.

draw(*axes, label_suffix=None)[source]
series_equivalent(other)[source]

Checks if the specified function has an equivalent series to this one.

property spectral_density
class zero.data.Reference(frequencies, data, label=None, unit=None, **kwargs)[source]

Bases: zero.data.BaseFunction

property sink_unit
class zero.data.ReferenceNoise(frequencies, data, label=None, unit=None, **kwargs)[source]

Bases: zero.data.Reference, zero.data.NoiseDensity

class zero.data.ReferenceResponse(frequencies, data, label=None, unit=None, **kwargs)[source]

Bases: zero.data.Reference, zero.data.Response

class zero.data.Response(source=None, **kwargs)[source]

Bases: zero.data.SingleSourceFunction, zero.data.SingleSinkFunction

Data set representing a response at a sink from a source.

property complex_magnitude
property db_magnitude

Magnitude scaled in units of decibel.

The response is power scaled such that the response is \(20 \log_{10} \left| x \right|\) where \(x\) is the complex response provided by complex_magnitude.

draw(*axes, **kwargs)[source]
inverse()[source]

Inverse response.

property magnitude

Absolute magnitude.

property phase

Phase in degrees.

series_equivalent(other)[source]

Checks if the specified function has an equivalent series to this one.

property unit_str
class zero.data.Series(x, y)[source]

Bases: object

Data series

classmethod from_mag_phase(x, magnitude, phase=None, mag_scale=None, phase_scale=None)[source]

Create Series from magnitude and phase data.

Parameters
  • x (np.array) – The x vector.

  • magnitude (np.array) – The magnitude. This magnitude’s scaling is determined by mag_scale.

  • phase (np.array, optional) – The phase. If None, the magnitude is assumed to have zero phase.

  • mag_scale (str, optional) – The magnitude scale. Defaults to absolute.

  • phase_scale (str, optional) – The phase scale. Defaults to degrees.

Returns

Series – The series containing the data.

Raises

ValueError – If the specified magnitude or phase scale is unrecognised.

classmethod from_re_im(x, re, im)[source]

Create Series from real and imaginary parts.

Parameters
  • x (np.array) – The x vector.

  • magnitude (np.array) – The magnitude. This magnitude’s scaling is determined by mag_scale.

  • phase (np.array) – The phase.

  • magnitude_scale (str, optional) – The magnitude scale. Defaults to absolute.

  • phase_scale (str, optional) – The phase scale. Defaults to radians.

Returns

Series – The series containing the data.

Raises

ValueError – If either the real or imaginary part is complex.

inverse()[source]
class zero.data.SingleSinkFunction(sink=None, **kwargs)[source]

Bases: zero.data.BaseFunction

Data set containing data for a single sink.

property sink
property sink_unit
class zero.data.SingleSourceFunction(source=None, **kwargs)[source]

Bases: zero.data.BaseFunction

Data set containing data for a single source.

property source
property source_unit
zero.data.argmax_difference(vector_a, vector_b)[source]

Finds the maximum relative difference in percent between vector_a and vector_b

Returns index of maximum relative difference as well as its value.

zero.data.frequencies_match(vector_a, vector_b)[source]
zero.data.spectra_match(vector_a, vector_b)[source]
zero.data.vectors_match(vector_a, vector_b)[source]