API reference#
pyorc’s API consists of several subclasses of the xarray.Dataset
and xarray.DataArray
data models.
In a nutshell, xarray’s data models are meant to store and analyze scientific datasets with multiple
dimensions. A xarray.DataArray
contains one variable with possibly several dimensions and coordinates
within those dimensions. A xarray.Dataset
may contain multiple xarray.DataArray
objects, with shared
coordinates. In pyorc typically the coordinates are time
for time epochs measured in seconds since
the beginning of a video, x
for horizontal grid spacing (in meters), y
for vertical grid spacing
(in meters). Operations you can apply on both data models are very comparable with operations you may
already use in pandas, such as resampling, reindexing, aggregations, and so on.
Note
We highly recommend to use the excellent xarray manual side-by-side with pyorc
to understand
how to effectively work with the xarray ecosystem.
In the remaining sections, we describe the API classes, and the functions they are based on.
CameraConfig class#
Class and properties#
|
Camera configuration containing information about the perspective of the camera with respect to real world coordinates |
Returns geographical bbox fitting around corners points of area of interest in camera perspective |
|
Returns rows and columns in projected frames from |
|
Returns Affine transform of projected frames from |
Setting of properties and attributes#
|
Establish bbox based on a set of camera perspective corner points Assign corner coordinates to camera configuration |
|
Set ground control points for the given CameraConfig |
|
Set the lens parameters of the given CameraConfig |
|
Calibrates and sets the properties |
|
Set the geographical position of the lens of current CameraConfig. |
Exporting#
Return the CameraConfig object as dictionary |
|
Write the CameraConfig object to json structure |
|
Convert CameraConfig object to string |
Retrieve geometrical information#
|
Establish a transformation matrix for a certain actual water level h_a. |
|
Retrieve depth for measured bathymetry points using the camera configuration and an actual water level, measured in local reference (e.g. |
Convert z coordinates of bathymetry to height coordinates in local reference (e.g. |
Plotting methods#
|
Plot the geographical situation of the CameraConfig. |
|
Plot bounding box for orthorectification in a geographical projection ( |
Video class#
Class and properties#
|
Video class, inheriting parts from cv2.VideoCapture. |
CameraConfig object |
|
float, frames per second |
|
int, last frame considered in analysis |
|
int, first frame considered in analysis |
|
list of 4 lists (int) with [column, row] locations of area of interest in video objective |
Getting frames from video objects#
|
Retrieve one frame. |
|
Get a xr.DataArray, containing a dask array of frames, from start_frame until end_frame, expected to be read lazily. |
Frames subclass#
These methods can be called from an xarray.DataArray
that is generated using pyorc.Video.get_frames
.
Class and properties#
|
Frames functionalities that can be applied on xr.DataArray |
Camera configuration belonging to the processed video |
|
Shape of the original camera objective of the processed video (e.g. |
|
Actual water level belonging to the processed video |
Enhancing frames#
|
Convert frames in edges, using a band convolution filter. |
|
Remove the mean of sampled frames. |
|
Apply a difference over time (i.e. |
|
Smooth each frame with a Gaussian kernel. |
Projecting frames to planar views#
|
Project frames into a projected frames object, with information from the camera_config attr. |
Retrieving surface velocities from frames#
|
Perform PIV computation on projected frames. |
Visualizing frames#
|
Creates QuadMesh plot from a RGB or grayscale frame on a new or existing (if ax is not None) axes |
|
Store an animation of the frames in the object |
|
Write frames to a video file without any layout |
Velocimetry subclass#
These methods can be called from an xarray.Dataset
that is generated using pyorc.Frames.get_piv
.
Class and properties#
|
Velocimetry functionalities that can be applied on |
Camera configuration belonging to the processed video |
|
Shape of the original camera objective of the processed video (e.g. |
|
Actual water level belonging to the processed video |
Temporal masking methods#
The mask methods below either require or may have a dimension time
in the data. Therefore they are most logically
applied before doing any reducing over time.
|
Masks values if the velocity scalar lies outside a user-defined valid range. |
|
Masks values with too low correlation |
|
filters on the expected angle. |
|
Masks values if neighbours over a certain rolling length before and after, have a significantly higher velocity than value under consideration, measured by tolerance. |
|
Mask outliers measured by amount of standard deviations from the mean. |
|
Masks locations if their variance (std/mean in time) is above a tolerance level for either or both x and y direction. |
|
Masks locations with a too low amount of valid velocities in time, measured by fraction with |
Spatial masking methods#
The spatial masking methods look at a time reduced representation of the grid results. The resulting mask can be applied on a full time series and will then mask out grid cells over its full time span if these do not pass the mask.
|
Masks values when their value deviates more than tolerance (measured as relative fraction) from the mean of its neighbours (inc. |
|
Masks values if their surrounding neighbours (inc. |
Data infilling#
|
Replaces values in a certain window size with mean of their neighbours. |
Getting data over transects#
|
Interpolate all variables to supplied x and y coordinates of a cross section. |
|
Set encoding parameters for all typical variables in a velocimetry dataset. |
Plotting methods#
alias of |
|
|
Creates pcolormesh plot from velocimetry results on new or existing axes |
|
Creates scatter plot of velocimetry or transect results on new or existing axes |
|
Creates streamplot of velocimetry results on new or existing axes |
|
Creates quiver plot from velocimetry results on new or existing axes |
Transect subclass#
These methods can be called from an xarray.Dataset
that is generated using pyorc.Velocimetry.get_transect
.
Class and properties#
|
Transect functionalities that can be applied on |
Camera configuration belonging to the processed video |
|
Shape of the original camera objective of the processed video (e.g. |
|
Actual water level belonging to the processed video |
Derivatives#
|
Set "v_eff" and "v_dir" variables as effective velocities over cross-section, and its angle |
|
Get camera-perspective column, row coordinates from cross-section locations. |
River flow methods#
|
Integrate time series of depth averaged velocities [m2 s-1] into cross-section integrated flow [m3 s-1] estimating one or several quantiles over the time dimension. |
|
Depth integrated velocity for quantiles of time series using a correction v_corr between surface velocity and depth-average velocity. |
Plotting methods#
alias of |
|
|
Creates quiver plot from velocimetry results on new or existing axes |
|
Creates scatter plot of velocimetry or transect results on new or existing axes |