pept.processing.VectorField2D#
- class pept.processing.VectorField2D(diameter, columns=['vx', 'vy'], dimensions='xy', resolution=(50, 50), xlim=None, ylim=None, max_workers=None, verbose=True)[source]#
Bases:
Reducer
Compute a 2D vector field - effectively two 2D grids computed from two columns, for example X and Y velocities.
Reducer signature:
PointData -> VectorField2D.fit -> VectorGrid2D list[PointData] -> VectorField2D.fit -> VectorGrid2D numpy.ndarray -> VectorField2D.fit -> VectorGrid2D
Examples
Compute a velocity vector field in the Y and Z dimensions (velocities were first calculated using
pept.tracking.Velocity
):>>> from pept.processing import * >>> trajectories = pept.PointData(...) >>> field = VectorField2D(0.6, ["vy", "vz"], "yz").fit(trajectories) >>> field VectorGrid2D(xpixels, ypixels)
Create a quiver plot using Plotly (may be a bit slow):
>>> scaling = 16 >>> fig = field.quiver(scaling) >>> fig.show()
Create a 2D vector field (needs PyVista):
>>> scaling = 16 >>> fig = field.vectors(scaling) >>> fig.plot(cmap = "magma")
- __init__(diameter, columns=['vx', 'vy'], dimensions='xy', resolution=(50, 50), xlim=None, ylim=None, max_workers=None, verbose=True)[source]#
Methods
__init__
(diameter[, columns, dimensions, ...])copy
([deep])Create a deep copy of an instance of this class, including all inner attributes.
fit
(samples)load
(filepath)Load a saved / pickled PEPTObject object from filepath.
save
(filepath)Save a PEPTObject instance as a binary pickle object.
- copy(deep=True)#
Create a deep copy of an instance of this class, including all inner attributes.
- static load(filepath)#
Load a saved / pickled PEPTObject object from filepath.
Most often the full object state was saved using the .save method.
- Parameters
- filepath
filename
orfile
handle
If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
- Returns
pept.PEPTObject
subclass
instance
The loaded object.
Examples
Save a LineData instance, then load it back:
>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]]) >>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")
- save(filepath)#
Save a PEPTObject instance as a binary pickle object.
Saves the full object state, including inner attributes, in a portable binary format. Load back the object using the load method.
- Parameters
- filepath
filename
orfile
handle
If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
Examples
Save a LineData instance, then load it back:
>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]]) >>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")