dpivsoft.SyIm¶
- dpivsoft.SyIm.Analytic_Syntetic(dirSave, Name, saveData=True, randTransform=False)[source]¶
Generates a pair of imnages where the trazers particles moves accordly to an analytical flow velocity field. The parameters of the generated images are defined on the class Synt_Img (see class Synt_Img for more info).
- dpivsoft.SyIm.Custom_Syntetic(xx, yy, uu, vv, scale, dirSave, Name, dt, limits=None, randTransform=False)[source]¶
Generates a pair of syntetic images where the trazers particles move accordly a custom velocity field loaded from a numpy array.
The numpy array must be saved in colums as: | x | y | u | v |
- dpivsoft.SyIm.random_transformation(x, y, u, v)[source]¶
Apply a random symmetry operation to a velocity field for data augmentation.
One of 8 equally likely outcomes (transpose and/or sign flips, including the identity). For isotropic turbulence each outcome is an equally valid realization, so this multiplies the effective dataset size 8x. Requires square images (transpose mixes the axes).
- Parameters:
x (2d np.ndarray) – Grid coordinates (returned unchanged).
y (2d np.ndarray) – Grid coordinates (returned unchanged).
u (2d np.ndarray) – Velocity components to transform.
v (2d np.ndarray) – Velocity components to transform.
- Returns:
x, y, u, v – The (possibly transposed / sign-flipped) field.
- Return type:
2d np.ndarray
- dpivsoft.SyIm.Velocity_Profile()[source]¶
Build the analytical velocity field used to advect the tracers.
The profile is selected by
Synt_Img.vel_profileand evaluated on the pixel grid: ‘Constant’, ‘Couette’, ‘Poiseuille’, ‘Vortex’ (Lamb-Oseen-like) or ‘Frequency’ (sinusoidal shear). Exits if the profile name is unknown.- Returns:
xv, yv (2d np.ndarray) – Pixel-coordinate meshgrid.
u, v (2d np.ndarray) – Velocity components on that grid.
- dpivsoft.SyIm.Gen_trazers()[source]¶
Randomly sample the brightness and diameter of the tracer particles.
Both are drawn from triangular distributions centred on the class means (
Shine_m,D_m) with half-widthsd_Shine/d_D, one value per particle.- Returns:
trazers_shine (1d np.ndarray) – Peak brightness of each particle.
trazers_D (1d np.ndarray) – Diameter of each particle (pixels).
- dpivsoft.SyIm.Img_Generation(u, v, xv, yv, trazers_shine, trazers_D)[source]¶
Render the synthetic image pair from a velocity field and tracers.
Particles are seeded at random subpixel positions for the first image, then advected to their second-image positions by integrating the velocity field with RK4 over
Synt_Img.n_stepssubsteps. Particles are drawn as Gaussian spots; those leaving the frame re-enter periodically from the opposite side. Triangular-distributed background noise is added and intensities are clipped to [0, 255].- Parameters:
u (2d np.ndarray) – Per-pixel displacement field (pixels between the two exposures).
v (2d np.ndarray) – Per-pixel displacement field (pixels between the two exposures).
xv (2d np.ndarray) – Pixel-coordinate meshgrid matching
u,v.yv (2d np.ndarray) – Pixel-coordinate meshgrid matching
u,v.trazers_shine (1d np.ndarray) – Per-particle brightness and diameter (from Gen_trazers).
trazers_D (1d np.ndarray) – Per-particle brightness and diameter (from Gen_trazers).
- Returns:
img1, img2 – The synthetic image pair.
- Return type:
2d np.ndarray
- dpivsoft.SyIm.Pix2PIV(Xv, Yv, Uv, Vv, no_boxes_x, no_boxes_y, box_size_1_x, box_size_1_y, box_size_2_x, box_size_2_y)[source]¶
Downsample a per-pixel velocity field onto the coarse PIV grid.
Averages the pixel-level field over each interrogation window, reproducing the window-averaging inherent to classical PIV so a ground-truth field can be compared with a PIV result (or used as the coarse prior in the Stage 2 PIV-conditioned DL model). The grid is laid out with the same margin/spacing as
grid.generate_mesh.- Parameters:
Xv (2d np.ndarray) – Pixel-coordinate meshgrid.
Yv (2d np.ndarray) – Pixel-coordinate meshgrid.
Uv (2d np.ndarray) – Per-pixel velocity components.
Vv (2d np.ndarray) – Per-pixel velocity components.
no_boxes_x (int) – Number of interrogation windows in x and y.
no_boxes_y (int) – Number of interrogation windows in x and y.
box_size_1_x (int) – First- and second-pass window sizes (first pass sets the margin, second pass sets the averaging window).
box_size_1_y (int) – First- and second-pass window sizes (first pass sets the margin, second pass sets the averaging window).
box_size_2_x (int) – First- and second-pass window sizes (first pass sets the margin, second pass sets the averaging window).
box_size_2_y (int) – First- and second-pass window sizes (first pass sets the margin, second pass sets the averaging window).
- Returns:
Xi, Yi (1d np.ndarray) – PIV grid coordinates.
Ui, Vi (2d np.ndarray) – Window-averaged velocity components on the PIV grid.