endaq.batch

class endaq.batch.GetDataBuilder(*, preferred_chs=[], accel_highpass_cutoff, accel_start_time=None, accel_end_time=None, accel_start_margin=None, accel_end_margin=None)

The main interface for the calculations.

This object has two types of functions:

  • configuration functions - these determine what calculations will be performed on IDE recordings, and pass in any requisite parameters for said calculations. This includes the following functions:

    • add_psd

    • add_pvss

    • add_metrics

    • add_peaks

    • add_vc_curves

  • execution functions - these functions take recording files as parameters, perform the configured calculations on the data therein, and return the calculated data as pandas objects.

    This includes the functions _get_data & aggregate_data, which operates on one & multiple file(s), respectively.

A typical use case will look something like this:

filenames = [...]

calc_output = (
    GetDataBuilder(accel_highpass_cutoff=1)
    .add_psd(freq_bin_width=1)
    .add_pvss(init_freq=1, bins_per_octave=12)
    .add_metrics()
    .add_peaks(margin_len=100)
    .add_vc_curves(init_freq=1, bins_per_octave=3)
    .aggregate_data(filenames)
)
file_data = calc_output.dataframes
Parameters
  • preferred_chs – a sequence of channels; each channel listed is prioritized over others of the same type of physical measurement (e.g., acceleration, temperature, pressure, etc.)

  • accel_highpass_cutoff – the cutoff frequency used when pre-filtering acceleration data

  • accel_start_time – the relative timestamp before which to reject recording data; cannot be used in conjunction with accel_start_margin

  • accel_end_time – the relative timestamp after which to reject recording data; cannot be used in conjunction with accel_end_margin

  • accel_start_margin – the number of samples before which to reject recording data; cannot be used in conjunction with accel_start_time

  • accel_end_margin – the numper of samples after which to reject recording data; cannot be used in conjunction with accel_end_time

add_metrics()

Add broad channel metrics to the calculation queue.

add_peaks(*, margin_len)

Add windows about the acceleration’s peak value to the calculation queue.

Parameters

margin_len – the number of samples on each side of a peak to include in the windows

add_psd(*, freq_bin_width=None, freq_start_octave=None, bins_per_octave=None, window='hanning')

Add the acceleration PSD to the calculation queue.

Parameters
  • freq_bin_width – the desired spacing between adjacent PSD samples; a default is provided only if bins_per_octave is used, otherwise this parameter is required

  • freq_start_octave – the first frequency to use in octave-spacing; this is only used if bins_per_octave is set

  • bins_per_octave – the number of frequency bins per octave in a log-spaced PSD; if not set, the PSD will be linearly-spaced as specified by freq_bin_width

  • window – the window type used in the PSD calculation; see the documentation for scipy.signal.welch for details

add_pvss(*, init_freq, bins_per_octave)

Add the acceleration PVSS (Pseudo Velocity Shock Spectrum) to the calculation queue.

Parameters
  • init_freq – the first frequency sample in the spectrum

  • bins_per_octave – the number of samples per frequency octave

add_vc_curves(*, init_freq, bins_per_octave)

Add Vibration Criteria (VC) Curves to the calculation queue.

Parameters
  • init_freq – the first frequency

  • bins_per_octave – the number of samples per frequency octave

aggregate_data(filenames)

Compile configured data from the given files into a dataframe.

Parameters

filenames – a sequence of paths of recording files to process

class endaq.batch.calc.OutputStruct(data)

A data wrapper class with methods for common export operations.

Objects of this class are generated by GetDataBuilder.aggregate_data. This class is not intended be instantiated manually.

to_csv_folder(folder_path)

Write data to a folder as CSV’s.

Parameters

folder_path – the output directory path for .CSV files

to_html_plots(folder_path=None, show=False)

Generate plots in HTML.

Parameters
  • folder_path – the output directory for saving .HTML plots; if None (default), plots are not saved

  • show – whether to open plots after generation; defaults to False