PIVPy graphics tutorial

[2]:
import xarray as xr
import numpy as np
from pivpy import io, pivpy, graphics
import matplotlib.pyplot as plt
[3]:
## Let's create a sample dataset
[4]:
df = io.create_sample_dataset()
df
[4]:
<xarray.Dataset>
Dimensions:  (t: 5, x: 8, y: 5)
Coordinates:
  * x        (x) float64 32.0 45.71 59.43 73.14 86.86 100.6 114.3 128.0
  * y        (y) float64 16.0 44.0 72.0 100.0 128.0
  * t        (t) int64 0 1 2 3 4
Data variables:
    u        (x, y, t) float64 1.0 1.0 1.0 1.0 1.0 2.75 ... 8.0 8.0 8.0 8.0 8.0
    v        (x, y, t) float64 -0.1917 0.4701 -0.3205 ... 0.8455 0.5244 0.3326
    chc      (x, y, t) float64 1.0 1.0 1.0 1.0 1.0 1.0 ... 1.0 1.0 1.0 1.0 1.0
Attributes:
    variables:  ['x', 'y', 'u', 'v']
    units:      ['pix', 'pix', 'pix/dt', 'pix/dt']
    dt:         1.0
    files:      
[5]:
plt.figure(figsize=(10,10))
graphics.quiver(df.piv.average,arrScale=3,streamlines=True);
_images/tutorial_4_0.png
[6]:
plt.figure(figsize=(10,10))
# plot quiver of the first frame (t[0]), selected by .isel and apply quiver()
df.isel(t=0).piv.quiver(arrScale=7,streamlines=True)
[6]:
(<Figure size 720x720 with 1 Axes>,
 <AxesSubplot:xlabel='x(pix)', ylabel='y (pix)'>)
_images/tutorial_5_1.png
[26]:
fig,ax = graphics.contour_plot(df.isel(t=-1),colbar='vertical')
fig.set_size_inches(6,6)
ax.set_xlabel('$x$ (pix)',fontsize=16);
_images/tutorial_6_0.png
[ ]: