tiskitpy.ResponseFunctions

class tiskitpy.ResponseFunctions(sdf, in_id, out_ids=None, noise_channel='output', n_to_reject=3, min_freq=None, max_freq=None, quiet=False, show_progress=False, noise_chan=None)

Bases: object

Class of Frequency Response Functions for a given input channel.

From Bendat & Piersol, chapter 6. The frequency response function is the relation between coherent parts of the signal: if the measured input \(x(t) = u(t) + m(t)\) and the measured output \(y(t) = v(t) + n(t)\), where \(u(t)\) and \(v(t)\) are coherent and \(m(t)\) and \(n(t)\) are not, then the frequency response function \(H(f)\) is such that \(v(t) = H(f)*u(t)\). As to spectra, \(G_vv(f) = abs(H(f))^2 * G_uu(f)\)

The input and output channel_ids should be tikitpy_ids (seed_codes + cleaned_sequence info)

_ds (

class: XArray.dataset): container for response functions and attributes

Parameters:
  • sdf (SpectralDensity) – Spectral density functions objet

  • in_id (str) – input channel id. Can use Unix wildcards (‘*’, ‘?’) but will return error if more than one string matches

  • out_ids (list of str) – output channel ids (None => all but in_id)

  • noise_channel (str) – ‘input’, ‘output’, ‘equal’, ‘unknown’

  • n_to_reject (int) – number of neighboring frequencies for which the coherence must be above the 95% significance level in order to calculate frequency response function (other values are set to 0, n_to_reject=0 means use all frequencies)

  • min_freq (float or None) – Return zero for frequencies below this value

  • max_freq (float or None) – Return zero for frequencies above this value

  • quiet (bool) – don’t warn if creating a test object

  • show_progress (bool) – plot response functions and coherences

coh_signif(prob=0.95)

Return coherence significance level

Parameters:

prob (float) – significance level (between 0 and 1)

coherence(output_channel_id, zero_as_none=False, verbose=False)

Return coherence for the given output channel

coherence is real valued gamma_xy^2, defined by Bendat & Piersol (1986), Appendix B

Parameters:
  • output_channel_id (str) – output channel id

  • zero_as_none (bool) – return non-calculated values as Nones instead of zeros

copy()
corrector(output_channel_id, zero_as_none=False)

Return coherent channel correction factor for the given output channel

Parameters:
  • output_channel_id (str) – output channel id

  • zero_as_none (bool) – return non-calculated values as Nones instead of zeros

corrector_wrt_counts(output_channel_id, zero_as_none=False)

Return frequency response function with respect to raw data counts

Parameters:
  • output_channel_id (str) – output channel id

  • zero_as_none (bool) – return non-calculated values as Nones instead of zeros

deepcopy()
property freqs

Frequency response function frequencies

property input_channel_id
property input_clean_sequence
property input_units

Frequency response function input channel units

instrument_response(output_channel_id, zero_as_none=False)

Return (output_channel_instr_response/input_channel_instr_response)

Divide count-based response function by this to get unit-based Multiply unit-based response function by this to get count-based

Parameters:
  • output_channel_id (str) – output channel id

  • zero_as_none (bool) – NOT USED!

Returns:

numpy.ndarray`

property n_windows

Number of time series data windows used

noise_channel(output_channel_id)

Return the channel assumed to have incoherent noise

Parameters:

output_channel_id (str) – the channel to use

Returns:

The channel (‘input’, ‘output’, ‘equal’, or ‘unknown’)

Return type:

str

property noise_channels

Names of the noise channel for each rf

property output_channel_ids
output_units(output_channel_id)

Frequency response function output channel units

plot(errorbars=True, grid=False, show=True, title=None, outfile=None)

Plot frequency response functions

Parameters:
  • errorbars (bool) – plot error bars

  • grid (bool or str) – False, True, ‘major’, ‘minor’, or ‘both’

  • show (bool) – show on the screen

  • title (str) – replace overall title

  • outfile (str) – save figure to this filename

Returns:

array of axis pairs (amplitude, phase)

Return type:

(numpy.ndarray)

plot_one(in_id, out_id, fig=None, fig_grid=(1, 1), plot_spot=(0, 0), errorbars=True, label=None, title=None, show_xlabel=True, show_ylabel=True, grid=False)

Plot one frequency response function

Parameters:
  • in_id (str) – input channel id

  • out_id (str) – output channel id

  • ( (fig) – class: ~matplotlib.figure.Figure): figure to plot on, if None this method will plot on the current figure or create a new figure.

  • fig_grid (tuple) – this plot sits in a grid of this many (rows, columns)

  • plot_spot (tuple) – put this plot at this (row, column) of the figure grid

  • errorbars (bool) – plot as vertical error bars

  • label (str) – string to put in legend

  • title (str) – string to put in title

  • show_xlabel (bool) – put an xlabel on this subplot

  • show_ylabel (bool) – put a y label on this subplot

  • grid (bool or str) – False, True, ‘major’, ‘minor’, or ‘both’

Returns:

frequency response function amplitude plot frequency response function phase plot

Return type:

tuple

uncert_mult(output_channel_id)

Return uncertainty as a fraction of the frequency response function

Parameters:

output_channel (str) – channel to return uncertainty for

uncertainty(out_id)

Return frequency response function uncertainty

Parameters:

out_id (str) – channel to return uncertainty for

uncertainty_wrt_counts(out_id)

Return frequency response function uncertainty with respect to counts

value(output_channel_id, zero_as_none=False, verbose=False)

Return frequency response function for the given output channel

Parameters:
  • output_channel_id (str) – output channel id

  • zero_as_none (bool) – return non-calculated values as Nones instead of zeros

value_wrt_counts(output_channel_id, zero_as_none=False)

Return frequency response function with respect to raw data counts

Parameters:
  • output_channel_id (str) – output channel name

  • zero_as_none (bool) – return non-calculated values as Nones instead of zeros