myimagelib.corrLib.compute_energy_density

myimagelib.corrLib.compute_energy_density(pivData, d=8.25, MPP=0.33)

Compute kinetic energy density in k space from piv data. The unit of the return value is [velocity] * [length], where [velocity] is the unit of pivData, and [length] is the unit of sample_spacing parameter. Note, the default value of sampling_spacing does not have any significance. It is just the most convenient value for my first application, and should be set with caution when a different magnification and PIV are used.

Parameters
  • pivData – 2D piv data, DataFrame of x, y, u, v

  • d – sample spacing, in unit of microns

  • MPP – microns per pixel

Returns

kinetic energy field in wavenumber (k) space

Test

>>> pivData = pd.read_csv(r'E:\moreData\08032020\piv_imseq\01\3370-3371.csv')
>>> compute_energy_density(pivData)

Edit

11020202

Add parameter sample_spacing, the distance between adjacent velocity (or data in general. The spacing is used to rescale the DFT so that it has a unit of [velocity] * [length]. In numpy.fft, the standard fft function is defined as

\[A_k = \sum\limits^{n-1}_{m=0} a_m \exp \left[ -2\pi i \frac{mk}{n} \right]\]

The unit of this Fourier Transform \(A_k\) is clearly the same as \(a_m\). In order to get unit [velocity] * [length], and to make transform result consistent at different data density, I introduce sample_spacing \(d\) as a modifier of the DFT. After this modification, the energy spectrum computed at various step size (of PIV) should give quantitatively similar results.

11042020

Replace the (* sample_spacing * sample_spacing) after v_fft with ( / row / col). This overwrites the edit I did on 11022020.

11112020

removed ( / row / col), add the area constant in energy_spectrum() function. Details can be found here

11302020
  • Convert unit of velocity, add optional arg MPP (microns per pixel);

  • Add * d * d to both velocity FFT’s to account for the missing length in default FFT algorithm;

  • The energy spectrum calculated by this function shows a factor of ~3 difference when comparing int E(k) dk with v**2.sum()/2