spectrum
A module containing the spectrum functions of the VACF analysis.
The functions in this module port the legacy ft.f Fourier
transformation tool (ftvac ver. 2.0) of the thh_tools
collection. The auto-correlation function is optionally multiplied
with a one-sided apodization window, mirrored into an even extension
and transformed with a discrete cosine sum. All legacy conventions are
replicated exactly - see the notes of vacf_spectrum() for the
historical quirks that are kept for backwards compatibility.
Summary
Functions:
Calculates the one-sided legacy apodization window. |
|
Calculates the legacy cosine-transform spectrum of a correlation function. |
Reference
- apodization_window(
- n_points: PositiveInt,
- time_step: PositiveReal,
- window_function: str = 'none',
- window_param: PositiveReal = 4.0,
- window_start: PositiveReal = 0.0,
- window_stop: PositiveReal = 1000.0,
Calculates the one-sided legacy apodization window.
The window replicates the legacy
ft.fwindow functions exactly. With the start indexwinsind = nint(window_start / time_step)and the end indexwineind = nint(window_stop / time_step)the window factor of the one-based pointiis one fori <= winsind, zero fori > wineindand otherwise:exponential:exp(-window_param * time_step * (i - 1 - winsind))hann:(1 - cos(pi * (wineind - i) / (wineind - winsind))) / 2blackman:0.42 + 0.5 * cos(pi * (i - 1 - winsind) / wineind) + 0.08 * cos(2 * pi * (i - 1 - winsind) / wineind)
Note that the legacy
hannandblackmanformulas are non-standard: thehannwindow is mirrored (it rises from the end of the window range) and theblackmandenominators arewineindinstead of the window width. Both quirks are replicated deliberately.- Parameters:
n_points (PositiveInt) – The number of points of the correlation function.
time_step (PositiveReal) – The time step between two points of the correlation function.
window_function (str, optional) – The window function, one of
none,exponential,hannandblackman, by defaultnone(all factors are one).window_param (PositiveReal, optional) – The exponential decay coefficient
aof theexponentialwindowexp(-a * t), by default 4.0.window_start (PositiveReal, optional) – The time at which the window starts to decay, by default 0.0.
window_stop (PositiveReal, optional) – The time at which the window becomes zero, by default 1000.0.
- Returns:
The window factors for all points.
- Return type:
- Raises:
- vacf_spectrum(
- time: Np1DNumberArray,
- correlation: Np1DNumberArray,
- ftsize: PositiveInt = 2000,
- window_function: str = 'none',
- window_param: PositiveReal = 4.0,
- window_start: PositiveReal = 0.0,
- window_stop: PositiveReal = 1000.0,
Calculates the legacy cosine-transform spectrum of a correlation function.
The (optionally apodized) correlation function is zero-padded to
ftsizepoints and mirrored into an even extension of length2 * ftsize - 1centered at indexftsize. The spectrum is the discrete cosine sumspectrum(l) = |0.5 * sum_k cd(k) * cos(2 * pi * l * (k - ftsize) / (2 * ftsize - 1))|for
l = 1..ftsize, which is evaluated here via the equivalent real part of the FFT of the circularly shifted even extension.Notes
The frequency axis replicates the historical calibration of the legacy
ft.ftool: the wavenumber spacing is calculated with a period of2 * (ftsize - 1)points although the underlying even extension has2 * ftsize - 1points. This slight frequency-axis mismatch is kept deliberately so that spectra remain comparable with the historical results. The time step is taken from the first two entries of the time axis and is assumed to be constant, and the last spectrum point duplicates its predecessor (a legacy consequence of evaluating the cosine sum atl = ftsize).- Parameters:
time (Np1DNumberArray) – The equidistant time axis of the correlation function in ps.
correlation (Np1DNumberArray) – The correlation function values.
ftsize (PositiveInt, optional) – The Fourier transform point size, by default 2000. The correlation function is zero-padded (or truncated) to this size.
window_function (str, optional) – The apodization window, one of
none,exponential,hannandblackman, by defaultnone. Seeapodization_window().window_param (PositiveReal, optional) – The exponential window decay coefficient, by default 4.0.
window_start (PositiveReal, optional) – The window start time, by default 0.0.
window_stop (PositiveReal, optional) – The window stop time, by default 1000.0.
- Returns:
wavenumbers (Np1DNumberArray) – The wavenumbers in cm^-1 for the indices
1..ftsize.amplitudes (Np1DNumberArray) – The spectrum amplitudes.
windowed_correlation (Np1DNumberArray) – The correlation function after applying the apodization window (equal to the input for the
nonewindow).
- Raises:
VACFError – If less than two points are given, the time axis and the correlation function have different lengths or ftsize is smaller than two.
- WINDOW_FUNCTIONS = ('none', 'exponential', 'hann', 'blackman')
The window functions supported by
apodization_window().