tqt_nmr.experimental package

Submodules

tqt_nmr.experimental.adaptive_fft module

find_time_range(freqs, times, stft, iterations=2, search_range=(1500, 2400))

Uses Short Time Fourier Transformation (STFT) to find a time range of strong a frequency presence.

Parameters:
  • freqs (array) – Frequencies space (calculated by STFT).

  • times (array) – Time points space (calculated by STFT).

  • stft (array) – Complex grid values of the STFT (calculated by STFT).

  • iterations (int) – How many iterations of STD outlier-filtering to apply for strong signal isolation.

  • search_range (Tuple[float, float]) – Lower and upper bounds of the search range along the frequencies axis.

Return type:

Tuple[float, float]

Returns:

Lower and upper limits of the range of strong signal (subset of the time points).

adaptive_fft(times, values, iterations=2, search_range=(1500, 2400), envelope_width=300, stft_step=1000, stft_overlap=100)

Implements an experimental adaptive FFT algorithm.

Algorithm:
  1. Finds a timeframe of the dominant frequency in the search_range;

  2. Cuts it out as a signal frame;

  3. Calculates an upper envelope of the signal frame via a rolling max window;

  4. Adaptively normalizes the signal frame by dividing it by its envelope;

  5. Calculates a real-valued FFT.

Parameters:
  • times (array) – Time points of the signal.

  • values (array) – The signal values.

  • iterations (int) – See find_time_range(…) doc.

  • search_range (Tuple[float, float]) – See find_time_range(…) doc.

  • envelope_width (int) – Width of the rolling max window.

  • stft_step (int) – See scipy.signal.stft(…) ‘nperseg’ argument.

  • stft_overlap (int) – See scipy.signal.stft(…) ‘noverlap’ argument.

Return type:

Tuple[array, array]

Returns:

Frequencies and the corresponding (complex) values of the FFT calculated.

tqt_nmr.experimental.experimental_fft module

fft(time, signal)
Return type:

tuple[ndarray, ndarray]

Parameters:
  • time (ndarray)

  • signal (ndarray)

tqt_nmr.experimental.utils module

rolling_func(data, window, func, axis=1)
Parameters:
  • data (ndarray)

  • window (int)

  • func (Callable)

  • axis (int)

max_rolling(data, window, axis=1)
Parameters:
  • data (ndarray)

  • window (int)

  • axis (int)

phase_align(reference, target, roi_idx, res=1, fast=False)

Cross-correlate data within region of interest at a precision of 1/res if data is cross-correlated at native resolution (i.e. res=1) this function can only achieve integer precision.

Parameters:
  • reference (ndarray) – signal that won’t be shifted

  • target (ndarray) – signal to be shifted to reference

  • roi_idx (Tuple[int, int]) – region of interest to compute chi-squared

  • res (int) – factor to increase resolution of data via linear interpolation

  • fast (bool) – Cuts the algorithm is set

Returns:

offset between target and reference signal

Return type:

shift (float)

highres(y, kind='cubic', res=100)

Interpolate data onto a higher resolution grid by a factor of res

Parameters:
  • y (1d array/list) – signal to be interpolated

  • kind (str) – order of interpolation (see docs for scipy.interpolate.interp1d)

  • res (int) – factor to increase resolution of data via linear interpolation

Returns:

offset between target and reference signal

Return type:

shift (float)

Module contents