Get started with OpenPIV in 5 minutes! This guide will help you install and run your first PIV analysis.
1
Install OpenPIV
Choose your preferred installation method:
pip install openpiv
Requires Python 3.8 or higher
conda install -c conda-forge openpiv
Recommended for scientific Python users
2
Get Sample PIV Images
Download example images or use your own PIV image pairs:
from openpiv import tools
frame_a, frame_b = tools.imread('exp1_001_a.bmp'), tools.imread('exp1_001_b.bmp')
Sample Data: You can download test images from the OpenPIV GitHub repository
3
Run Your First Analysis
Use this simple script to perform PIV analysis:
import openpiv.tools
import openpiv.process
import openpiv.scaling
# Load images
frame_a = openpiv.tools.imread('exp1_001_a.bmp')
frame_b = openpiv.tools.imread('exp1_001_b.bmp')
# Run PIV analysis
u, v, sig2noise = openpiv.process.extended_search_area_piv(
frame_a, frame_b,
window_size=32,
overlap=16,
dt=0.02,
search_area_size=64
)
# Scale to physical units (example: 1 pixel = 0.1 mm, dt = 0.02 s)
x, y, u, v = openpiv.scaling.uniform(
u, v,
scaling_factor=0.1/0.02 # 5 mm/s per pixel/frame
)
# Save results
openpiv.tools.save(x, y, u, v, 'output.txt')
print('PIV analysis complete! Results saved to output.txt')
4
Visualize Your Results
Create beautiful velocity field plots:
import matplotlib.pyplot as plt
import openpiv.tools
# Load results
x, y, u, v = openpiv.tools.load('output.txt')
# Create quiver plot
fig, ax = plt.subplots(figsize=(10, 8))
ax.quiver(x, y, u, v, scale=50)
ax.set_xlabel('X [mm]')
ax.set_ylabel('Y [mm]')
ax.set_title('PIV Velocity Field')
plt.savefig('velocity_field.png', dpi=150)
plt.show()
Try OpenPIV Online
No installation required! Test OpenPIV in your browser.
Troubleshooting
Try installing in user mode:
Or use a virtual environment:
pip install --user openpiv
Or use a virtual environment:
python -m venv myenv
Make sure you're using the correct Python environment. Check with:
python -m pip show openpiv
Try adjusting parameters:
- Increase
window_sizefor larger displacements - Increase
search_area_sizeif particles move far between frames - Adjust
overlapfor better spatial resolution - Check image quality and particle seeding density