ErichZimmer / OpenPIV-Python-cxx

OpenPIV Python accelerated by c++
GNU General Public License v3.0
1 stars 2 forks source link

Add correlation based correction algorithm #5

Open ErichZimmer opened 2 years ago

ErichZimmer commented 2 years ago

See details here:

Hart, D. PIV error correction. Experiments in Fluids 29, 13–22 (2000). https://doi.org/10.1007/s003480050421

ErichZimmer commented 2 years ago

Basically, a new grid generator has to be created so that rows of interrogation windows are processed. This allows for a low performance hit and a very robust correlation algorithm that had much needed success on an in-house PIV system using improper seeding methods (a 400W fog machine).

ErichZimmer commented 2 years ago

Maybe add repeated correlation like PIVlab?

ErichZimmer commented 1 year ago

I performed a very quick evaluation of the correlation based correction algorithm based on Hart (not repeated correlation like PIVlab, so there is only a slight performance hit) and found very promising results with great stability when using linear correlation. However, the current implementation of linear correlation is ~2.8 times slower than circular correlation (still ~2.25 times faster than OpenPIV-Python's linear correlation). Circular correlation provided small improvements when using correlation based correlation with an average increase in accuracy of 15% (compared to up to 310% with linear correlation and correlation based correction). On average, the correlation based correction algorithm is ~11% slower. Further testing will be done when I get time.

ErichZimmer commented 1 year ago

Here is a quick and dirty test on Gaussian white noise. Note: values are off by one decimal place; e.g., 0.25 --> 0.025. scc_vs_ecc

Simple benchmark. Each method was ran 50 times. Correlation Method Correlation Correction Threads Time milliseconds (ms)
Circular False 4 91.2 ms +/- 7.54 ms
Linear False 4 249 ms +/- 29.5 ms
Circular True 4 104 ms +/- 3.7 ms
Linear True 4 282 ms +/- 19.4 ms

I got somewhat different results from my preliminary tests, but the reason why is lost due do not saving the notebook session.

ErichZimmer commented 1 year ago

@alexlib Should we implement something like this in OpenPIV-Python? Perhaps, like this?

def correlation_correction(corr: np.float64) --> np.float64:
    ...
alexlib commented 1 year ago

What do you mean? static typing with mypy?

ErichZimmer commented 1 year ago

Perhaps, we should implement a correlation based correction based on the works by Hart. The template function example I added followed PEP 484 with type hints.

alexlib commented 1 year ago

I do not know this algorithm. if you have a good experience with it, yes please, lets add it.