fish_corr package¶
Submodules¶
fish_corr.dynamic module¶
- class fish_corr.dynamic.AverageAnalyser(movie, win_size: int, step_size: int, start=0, end=0)¶
Bases:
object
Calculate the averaged properties from a movie
- movie¶
Movie or SimMovie instance
- Type
fish_track.linking.Movie
- Decorrelated version of
scan_array()
the time averaged signals were averaged by randomly selected data points to reduce possible error-induced correlation
- Parameters
f1 (
function
) – the function to generate signal,f1(self) -> signal_1
f2 (
function
) – the function to generate signal,f2(self) -> signal_2
- Returns
the time averaged signals
- Return type
tuple
(numpy.ndarray
,numpy.ndarray
)
- Decorrelated version of
- Decorrelated version of
scan_array()
the time averaged signals were averaged by randomly selected data points to reduce possible error-induced correlation
- Parameters
f1 (
function
) – the function to generate signal,f1(self) -> signal_1
f2 (
function
) – the function to generate signal,f2(self) -> signal_2
f3 (
function
) – the function to generate signal,f3(self) -> signal_3
- Returns
the time averaged signals
- Return type
- Decorrelated version of
- get_trimmed_velocities(sample_points, t0, t1)¶
- Find & Trim trajectories that fits in time range between t0 to t1
then obtain its velocities
t0 t1 │ sample_points │ │ ...... │ 1. Valid traj, the size between t0 and │ ─────────▶ │ t1 is larger than sample_points │ │ │ ...... │ 2. Invalid traj, being too short │ ───▶ │ │ │ ..╬... │ 3. Invalid traj, the size between t0 ─────┼───▶ │ and t1 is too short, "too_early" │ │ │ ...╬.. 4. Invalid traj, "too_late" │ ───┼───▶ │ │ │ ...... │ ─────┼──────────────────────┼───▶ 5. Valid traj, but will be trimmed │ │ ──────┴──────────────────────┴──────▶ Time
- Parameters
- Returns
- all the valid velocities
from the valid and trimmed trajectories
- Return type
- save_cache(filename='')¶
- Retrieve all the quantities from self.time and self.cache,
and also dump them to a csv file.
- scan_array(array)¶
Get the average value of an array in all the average windows
- Parameters
array (
numpy.ndarray
) – number of a 1D array, being a feature in each frame. The array is assumed to start at frame self.start
- scan_array_std(array: numpy.ndarray)¶
the array is assumed to start at frame self.start
- scan_biased_attraction(bins, space_bin_number, **kwargs)¶
- Parameters
bins (
numpy.ndarray
) – the bins fornumpy.histogram()
space_bin_number (
int
) – number of bins to devide space to generated biased random gas
- Returns
the effective attraction in different average windows
- Return type
- scan_biased_attraction_err(bins, space_bin_number, repeat, **kwargs)¶
Using the bootstrap method to
- Parameters
bins (
numpy.ndarray
) – the bins fornumpy.histogram()
space_bin_number (
int
) – number of bins to devide space to generated biased random gas
- Returns
- the strandard error of the effective attraction
in different average windows
- Return type
- scan_biased_gr(bins, space_bin_number=50, **kwargs)¶
- Parameters
bins (
numpy.ndarray
) – the bins fornumpy.histogram()
space_bin_number (
int
) – number of bins to devide space to generated biased random gas
- Returns
- The radial distribution function assuming
biased density distribution
- Return type
- scan_gr(tank, bins, number)¶
- Parameters
tank (
fish_corr.static.Tank
) – a instance ofTank
to perform random samplingbins (
numpy.ndarray
) – the bins fornumpy.histogram()
number (
int
) – number of (posiible) particles per frame
- Returns
The radial distribution function
- Return type
- scan_nn(no_vertices=True)¶
- scan_nn_pbc(box)¶
- scan_nn_pbc_std(box)¶
- scan_nn_std(no_vertices=True)¶
- scan_number()¶
- scan_orientation_acf(sample_points: int)¶
Calculate the averaged rotational relaxation time for the movie
- Parameters
sample_points (
int
) – the maximum lag time (\(\tau\)) in the ACF calculation (get_acf()
)- Returns
the acf functions in different time windows
- scan_rotation(sample_points)¶
Scan the average relaxation time of the orientation
- scan_rotation_err(sample_points, repeat=10)¶
- Get the standard error of the rotational relaxation time (tau) using
bootstrap method
- scan_speed(min_number=0)¶
- Parameters
min_number (
int
) – only take frame into consideration if len(velocity) > min_number in this frame
- scan_speed_std(min_number=0)¶
- Parameters
min_number (
int
) – only take frame into consideration if len(velocity) > min_number in this frame
- scan_vicsek_order(min_number=0)¶
- Parameters
min_number (
int
) – only take frame into consideration iflen(velocity) > min_number
in this frame- Returns
The moving-average of the Vicsek order parameter
- Return type
- class fish_corr.dynamic.Critic(movie, is_simulation=False, pbc=0)¶
Bases:
object
Calculate the dynamical order & correlations from a fish movie
- movie¶
a Movie instance where positiosn and velocities can be retrieved
- Type
Movie
orSimMovie
- trajs¶
a list of trajectories
- Type
- Abbrs:
- flctn_not: non-translational fluctuation
(the collective translation is removed)
- flctn_noi: non-isometric fluctuation
(the collective translation & rotaton is removed)
- flctn_nos: non-similar fluctuation
(the collective translation & rotation & isotropic scaling is removed)
- get_corr_flctn(bins, start, stop=None, transform='N', get_raw_data=False)¶
Get the time-average connected correlation function of the fluctuation
- Parameters
bins (
int
ornumpy.ndarray
) – the number of bins or the bin edgesstart (
int
) – the start frame for the analysisstop (
int
or None) – the end frame for the analysis, if being None the end frame is the last frametransform (
str
) –here are possible options
T
- corr of non-translational fluctuationsI
- corr of non-isometric fluctuationsS
- corr of non-similar fluctuationsN
- corr of vanilla fluctuations
get_raw_data (
bool
) – if True, return the raw data forscipy.stats.binned_statistic
otherwise return the mean value of velocity correlation
- get_isometry(frame)¶
return the best isometric transformation (rotation) to transform points in _frame_ to _frame+1_
- get_orders(start=0, stop=None, size_threshold=5, report=False)¶
- Return nan for one frame if the matched pair in that frame is smaller
than size_threshold
- get_position_pair(frame, want_flctn=True)¶
Retrieve the fluctuation of velocities in
frame
andframe + 1
- Parameters
- Returns
r0 (shape (n, dim)) , r1 (shape (n, dim))
- Return type
- get_similarity(frame)¶
return the best similar transformation (rotation + dilation) to transform points in _frame_ to _frame+1_
- fish_corr.dynamic.get_nn_movie(analyser)¶
get the average nearest neighbour distance of all frames from a analyser this is intended to be used for AverageAnalyser.decorrelated_scan_3() or AverageAnalyser.decorrelated_scan_3()
- Parameters
analyser (AverageAnalyser) – instance of the AverageAnalyser
- Returns
the average nn-distance in all frames
- Return type
- fish_corr.dynamic.get_order_movie(analyser)¶
get the dynamical order of all frames from a analyser this is intended to be used for AverageAnalyser.decorrelated_scan_3() or AverageAnalyser.decorrelated_scan_3()
- Parameters
analyser (AverageAnalyser) – instance of the AverageAnalyser
- Returns
the dynamical order (polarisation) in all frames
- Return type
- fish_corr.dynamic.get_spd_movie(analyser)¶
- get the average speed of all frames from a analyser
this is intended to be used for AverageAnalyser.decorrelated_scan_3() or AverageAnalyser.decorrelated_scan_3()
- Parameters
analyser (AverageAnalyser) – instance of the AverageAnalyser
- Returns
the average speed in all frames
- Return type
fish_corr.static module¶
- class fish_corr.static.Tank(base, surface=None)¶
Bases:
object
A fish tank in 3D, whose surface can be described by
\[z = c \cdot r ^ 2\]where \(c = 0.7340428\), and the length unit for the equation is m [meter]
- curvilinear_2_cylindar(L, D)¶
- get_curvilinear(points)¶
- get_cylinder(points)¶
- Parameters
points (
numpy.ndarray
) – positions, shape (n, 3)- Returns
positions in cylinder coordinate system, shape (3, n)
- Return type
- get_projection(points)¶
- Parameters
points (
numpy.ndarray
) – positions, shape (n, 3)- Returns
projected positions, shape (3, n)
- Return type
- get_xyz(points)¶
return shape: (3, n)
- random(number)¶
Random points inside tank use rejection method to generate random points inside the tank
- random_curvilinear(points)¶
Generate random points in a box in the curvilinear coordinate
(L, θ, D)
L
- curvilinear lengthθ
- azimuth angleD
- cloest distance from fish to tank
- z(r)¶
calculate the z coordinate on the hyprobolic function
\[z = \textsf{self.c} * r^2\]the input/output unit is mm
- Parameters
r (
float
ornumpy.ndarray
) –- Returns
\(z = f(r)\)
- Return type
- fish_corr.static.a2r_cost(x, c, y)¶
- fish_corr.static.box_density_polar(positions, centre, radius, n_radical, n_angular)¶
Generate mesh in a polar coordinate, each box has the same area Calculate the mean & std of number points in each bin
- Parameters
positions (
numpy.ndarray
) – particle positions (n, 2)centre (
numpy.ndarray
) – boundary centre, shape (2, )radius (
numpy.ndarray
) – the radius of the boundaryn_radical (
int
) – number of bins radicallyn_angular (
int
) – number of bins for the angles
- Returns
The average and standard deviation of numbers in different boxes
- Return type
- fish_corr.static.get_nn(positions, no_vertices=True)¶
Calculate the NN distances and relative locations of NNs
- Parameters
positions (
numpy.ndarray
) – positions of all particles in one frameno_vertices (
bool
) – if being True, ignore the vertices of the convex hull generated by positoins
- Returns
nn_locations, nn_distances
- Return type
- fish_corr.static.get_nn_iter(frames, no_vertices=True)¶
Get an iteractive objectable that yields nn distances in different frames
- Parameters
frames (
list
ofnumpy.ndarray
) – the positions of particles in many frames
- fish_corr.static.get_nn_iter_pbc(frames, box)¶
Get an iteractive objectable that yields nn distances in different frames
- fish_corr.static.get_nn_pbc(positions, box)¶
- Calculate the NN distances and relative locations of NNs in a
periodic box
- Parameters
positions (
numpy.ndarray
) – positions in one frame, shape (n, dim)velocities (
numpy.ndarray
) – velocities in one frame, shape (n, dim)box (
float
ortuple
) – the legnth of the cubic simulation box, or the size along each dimensions (lx, ly, lz, …)
- Returns
nn_locations and nn_distances
- Return type
- fish_corr.static.get_nn_with_velocity(positions, velocities, no_vertices=True)¶
Calculate the NN distances and relative locations of NNs.
- The distances were rotated so that the x-axis is aligned
with the velocity of different particles
- Parameters
positions (
numpy.ndarray
) – positions of all particles in 1 framevelocities (
numpy.ndarray
) – velocities of all particles in 1 frameno_vertices (
bool
) – if being True, ignore the vertices
- Returns
nn_locations and nn_distances
- Return type
- fish_corr.static.get_nn_with_velocity_2d(positions, velocities, no_vertices=True)¶
Calculate the NN distances and relative locations of NNs
- The distances were rotated so that the x-axis is aligned with
the velocity of different particles
- Parameters
positions (
numpy.ndarray
) – positions of all particles in one frame, shape (N, 2)velocities (
numpy.ndarray
) – velocities of all particles in one frame, shape (N, 2)no_vertices (
bool
) – if being True, ignore the vertices
- Returns
nn_locations and nn_distances
- Return type
- fish_corr.static.get_nn_with_velocity_pbc(positions, velocities, box)¶
Calculate the NN distances and relative locations of NNs The distances were rotated so that the x-axis is aligned with the velocity of different particles
- Parameters
positions (
numpy.ndarray
) – positions in one frame, shape (n, dim)velocities (
numpy.ndarray
) – velocities in one frame, shape (n, dim)box (
float
ortuple
) – the legnth of the cubic simulation box, or the size along each dimensions (lx, ly, lz, …)
- Returns
nn_locations and nn_distances
- Return type
- fish_corr.static.get_poda(positions, velocities)¶
- Calculate the [p]airwise [o]rientational [d]eviation [a]ngles
inside a cubic box with periodic boundary condition see the graphical illustration for the meaning of poda
(the idea is from Hartmut Löwen)
◥ orientation i ╱ ╱ ╱ ╮ poda ● ─────────▶ ● i j
- Parameters
positions (
numpy.ndarray
) – the positions of all the particles, shape (n, dim)velocities (
numpy.ndarray
) – the velocities of all the particles, shape (n, dim)
- Returns
the pairwise poda values, shape (n * (n - 1), )
- Return type
- fish_corr.static.get_poda_pbc(positions, velocities, box)¶
- Calculate the [p]airwise [o]rientational [d]eviation [a]ngles
see the graphical illustration for the meaning of poda
(the idea is from Hartmut Löwen)
◥ orientation i ╱ ╱ ╱ ╮ poda ● ─────────▶ ● i j
- Parameters
positions (
numpy.ndarray
) – the positions of all the particles, shape (n, dim)velocities (
numpy.ndarray
) – the velocities of all the particles, shape (n, dim)
- Returns
the pairwise poda values, shape (n * (n - 1), )
- Return type
- fish_corr.static.get_rot_mat(r_from, r_to)¶
Get a rotation matrix R that rotate one vector to another
R @ r_from = r_to
- Parameters
r_from (np.array) – the vector to be rotated, shape (n, 3)
r_to (np.array) – the vector after the rotation, shape (3,)
- Returns
the rotation matrix, shape (n, 3, 3)
- Return type
np.array
- fish_corr.static.get_rot_mat_2d(r_from, r_to)¶
Get a rotation matrix R that rotate one vector to another
R @ r_from = r_to
- Parameters
r_from (np.array) – the vector to be rotated, shape (n, 2)
r_to (np.array) – the vector after the rotation, shape (2,)
- Returns
the rotation matrix, shape (n, 2, 2)
- Return type
np.array
- fish_corr.static.reduce_angle_gap(angles)¶
Angles should be in between 0 to 2pi
fish_corr.tower_sample module¶
use tower sampling to generate random numbers
- fish_corr.tower_sample.bisection_search(arg0: float, arg1: numpy.ndarray[int64]) int ¶
bisection search
- fish_corr.tower_sample.build_tower(arg0: numpy.ndarray[int64]) numpy.ndarray[int64] ¶
generate discrete CDF
- fish_corr.tower_sample.tower_sampling(arg0: int, arg1: numpy.ndarray[int64]) numpy.ndarray[int64] ¶
using tower sampling
fish_corr.utility module¶
- class fish_corr.utility.GCE(trajs, good_frames=None)¶
Bases:
object
Estimating the Group Centre, trying to use knowledge of good frames to reduce the error
- class fish_corr.utility.Movie(trajs, blur=None, interpolate=False)¶
Bases:
object
Store both the trajectories and positions of experimental data
Movie[f] - the positions of all particles in frame f Movie.velocity(f) - the velocities of all particles in frame f p0, p1 = Movie.indice_pair(f) Movie[f][p0] & Movie[f+1][p1] correspond to the same particles
- trajs¶
- Type
list
ofTrajectory
- __labels¶
hold the ID of particle in different frames label
i
corresponds totrajs[i]
- Type
dict
of np.ndarray
Example
>>> def rand_traj(): return (np.arange(100), np.random.random((100, 3))) # 3D, 100 frames >>> trajs = [rand_traj() for _ in range(5)] # 5 random trajectories >>> movie = Movie(trajs) >>> movie[0].shape # movie[f] = positions of frame f (5, 3) >>> movie.velocity(0).shape # movie.velocity(f) = velocities of frame f (5, 3) >>> pairs = movie.indice_pair(0) # movie.indice_pairs(f) = (labels in frame f, labels in frame f+1) >>> np.allclose(pairs[0], np.arange(5)) True >>> np.allclose(pairs[1], np.arange(5)) True >>> movie[0][pairs[0]].shape # movie[f][pairs[0]] corresponds to movie[f+1][pairs[1]] (5, 3)
- add(m2)¶
Attach another movie to the end of current movie.
- This function should be used in the case where a large
recording is splited into different movie files.
- Parameters
m2 (Movie) – another Movie instance to be attached to the end of current movie.
- Returns
None
- get_trimmed_trajs(t0, t1)¶
Get all trajectories that is between frame t0 and t1
t0 t1 │ │ 1. Fully accepted │ =========▶ │ ................................................... │ │ 2. Trimmed │ │ │ ====┼──▶ ─────┼===▶ │ │ │ ─────┼======================┼───▶ ................................................... │ │ 3. Ignored │ │ ──────▶ │ │ ──────▶ too_eraly │ │ too late │ │ ──────┴──────────────────────┴──────▶ Time
- indice_pair(frame)¶
Return two set of indices, idx_0 & idx_1
Movie[frame][idx_0]
corresponds toMovie[frame + 1][idx_1]
- label(frame)¶
- make()¶
Go through all frames, making code faster with the object
- save_xyz(filename)¶
Dump the movie as xyz files. Particle labels indicate the IDs.
- Parameters
filename (str) – the name of the xyz file
- save_xyz_with_tank(filename, tank)¶
Dump the movie as xyz files. Particle labels indicate the IDs.
- update_trajs(blur=0, interpolate=False)¶
Reconstruct
self.trajs
, typically used ifTrajectory
is modified
- velocity(frame)¶
Retireve velocity at given frame
- Parameters
frame (int / tuple) – specifying a frame number or a range of frames
- Returns
- velocities of all particle in one frame or many frames,
the “shape” is (frame_num, particle_num, dimension) it is not a numpy array because particle_num in each frame is different
- Return type
- class fish_corr.utility.SimMovie(positions, velocities)¶
Bases:
object
- export_xyz(filename, comment='none')¶
- indice_pair(frame)¶
- label(frame)¶
- load(filename)¶
- make()¶
- save(filename)¶
- velocity(frame)¶
- class fish_corr.utility.Trajectory(time, positions, blur=None, velocities=None, blur_velocity=None)¶
Bases:
object
- interpolate()¶
- offset(shift)¶
offset all time points by an amount of shift
- predict(t)¶
predict the position of the particle at time t
- fish_corr.utility.biased_discrete_nd(variables, bins, size=1)¶
Generate random numbers that have the joint distribution of many variables Using tower sampling
- Parameters
variabels (
numpy.ndarray
) – a iterable of random variables, each variable is a numpy array shape: (Number, Dimension)bins (
numpy.ndarray
) – the bin for generating the discrete distribution, it can be either shape: (Dimension, bin_number)size (
int
) – the number of generated random numbers
- fish_corr.utility.fit_acf_exp(data, method='exp', want_par=False)¶
Use function \(y = exp(-x / a) \cdot b\) to fit the acf data The fitting result a is a proxy to relaxation time
- Parameters
data (
numpy.ndarray
) – the data to be fit, it can be either (tau, acf) or just acf, with the shape of (2, n) or (n,)method (str) – different methods to extract a relaxation time. - exp: expoential decay; - se: stretched exponential; - le: linear fit of the log data; - none: take the x value when y approaches 1/e;
want_par (bool) – if true, extra fitting parameter will be returned to construct the fitting function
- Returns
fitting parameter a, relaxation time
- Return type
Example
>>> tau = np.arange(100) >>> acf = np.exp(-tau / 10) >>> data = np.array((tau, acf)) >>> np.isclose(fit_acf_exp(acf), 10) True >>> np.isclose(fit_acf_exp(data), 10) True
- fish_corr.utility.fit_maxwell_boltzmann(speed, bins)¶
fit the speed distribution with maxwell boltzmann distribution the average of the energy (< speed ** 2> is fixed) return: the dimension & fitting function
- fish_corr.utility.fit_rot_acf(acf, delta)¶
Using linear fit to get the intersection of the acf function and x-axis
- Parameters
acf (
numpy.ndarray
) – the acf function, shape (2, n) or (n, )delta (
float
) – the range above/below 0, which will be fitted linearly
- Returns
the relaxation time
- Return type
Example
>>> tau = np.arange(101) >>> acf = 1 - np.linspace(0, 2, 101) >>> data = np.array((tau, acf)) >>> np.isclose(fit_rot_acf(acf, 0.1), 50) True >>> np.isclose(fit_rot_acf(data, 0.1), 50) True
- fish_corr.utility.get_acf(var, size=0, step=1)¶
Calculate the auto-correlation function for a n-dimensional variable
\[Y[\tau] = \left\langle \sum_i^\text{ndim}{X\left[t, i\right] \cdot X\left[t+\tau, i\right]} \right\rangle\]- Parameters
var (
numpy.ndarray
) – a continual nD variable. the shape is (number, dimension)size (
int
) – the maximum size of \(\tau\), by default \(\tau\) == len(var)step (
int
) – everystep
points in time were chosen as t0 in the calculation
- Returns
The auto-correlation function of the variable
- Return type
- fish_corr.utility.get_acf_fft(var, size, nstep, nt)¶
not finished
- fish_corr.utility.get_best_dilatation_rotation(r1, r2, init_guess=None)¶
Calculate the best dilation & rotation matrices between two sets of points
(r1 @ Lambda) @ Rotation = r2
- Parameters
r1 (
numpy.ndarray
) – a collection of 3D positions, shape (N, 3)r2 (
numpy.ndarray
) – a collection of 3D positions, shape (N, 3)init_guess (
bool
) – the initial guess for numerical optimisation
- Returns
(dilation matrix Lambda, rotation matrix Rotation)
- Return type
- fish_corr.utility.get_best_rotation(r1, r2)¶
Calculate the best rotation to relate two sets of vectors
See the paper [A solution for the best rotation to relate two sets of vectors] for detail
all the points were treated equally, which means w_n = 0 (in the paper)
- Parameters
r1 (
numpy.ndarray
) – a collection of 3D points, shape (n, 3)r2 (
numpy.ndarray
) – a collection of 3D points, shape (n, 3)
- Returns
the best rotation matrix R,
r1 @ R = r2
- Return type
- fish_corr.utility.get_biased_gr(frames, positions, bins, space_bin_number, **kwargs)¶
- Parameters
frames (
numpy.ndarray
) – positions of all particles in different frames, shape (frame, n, dim)positions (
numpy.ndarray
) – all positions in the entire movie, shape (N, 3)bins (
numpy.ndarray
or int) – the bins for the distance histogram or the bin number
- fish_corr.utility.get_biased_gr_randomly(frames, positions, bins, space_bin_number, **kwargs)¶
- Parameters
frames (
numpy.ndarray
) – positions of all particles in different frames, shape (frame, n, dim)positions (
numpy.ndarray
) – all positions in the entire movie, shape (N, 3)bins (
numpy.ndarray
or int) – the bins for the distance histogram or the bin number
- fish_corr.utility.get_centre(trajectories, frame)¶
- fish_corr.utility.get_centre_move(trajectories, frame)¶
calculate the movement of the centre from
[frame]
to[frame + 1]
only the trajectories who has foodsteps in both frames were used
- fish_corr.utility.get_centres(trajectories, frames)¶
- fish_corr.utility.get_convex_hull_from_trajs(trajectories, target_num=0)¶
- fish_corr.utility.get_gr(frames, bins, random_gas)¶
- Compare the radial distribution function from a collection of coordinates
by comparing the distance distribution of particles in different frames with the random gas
- The density of the system and the random gas is chosen to be the same for each frame
which reduced the effect of the possible tracking error
Sample the random gas in clever ways to consider different boundaries
- Parameters
frames (
numpy.ndarray
) – positions of particles in different frames, shape (frame, n, dim)bins (
numpy.ndarray
or int) – the bins for the distance histogramrandom_gas (
numpy.ndarray
) – positions of uncorrelated ideal gas, shape (N, 3)
- Returns
get the rdf values inside each bin
- Return type
- fish_corr.utility.get_gr_pbc(frames, bins, random_gas, box)¶
- fish_corr.utility.get_mean_spd(velocity_frames, frame_number, min_number)¶
Calculate the average speed in many frames, given the velocities
- Parameters
velocity_frames (
numpy.ndarray
) – velocity in different frames, shape (frame, n, dim)min_number (
numpy.ndarray
) – only include frames if its particle number> min_numberframe_number (
int
) – the total frame number
- Returns
the average speed in many frames
- Return type
- fish_corr.utility.get_msd(trajectories, size, step=1)¶
- fish_corr.utility.get_rg_tensor(trajectories, target_num=0)¶
- fish_corr.utility.get_std_spd(velocity_frames, frame_number, min_number)¶
Calculate the standard deviation of speed in many frames, given the velocities
- Parameters
velocity_frames (
numpy.ndarray
) – velocity in different frames, shape (frame, n, dim)min_number (
numpy.ndarray
) – only include frames if its particle number> min_numberframe_number (
int
) – the total frame number
- Returns
the average speed in many frames
- Return type
- fish_corr.utility.get_vanilla_gr(frames, tank, bins, random_size)¶
- Parameters
frames (
numpy.ndarray
) – positions of all particles in different frames, shape (frame, n, dim)tank (
Tank
) – a static.Tank instancebins (
numpy.ndarray
) – the bins for the distance histogramrandom_size (
int
) – the number of random gas particles, its should be: len(frames) * particle_number_per_frame
- fish_corr.utility.get_vicsek_order(velocity_frames, min_number)¶
Calculate the average Vicsek order parameters across different frames
- Parameters
velocity_frames (
list
) – the velocity of particles at different frames “shape” (frame_num, particle_num, dimension) it is not a numpy array because particle_num in each frame is different
- fish_corr.utility.maxwell_boltzmann_nd(v, theta, v_sq_mean)¶
- fish_corr.utility.pdist_pbc(positions, box)¶
Get the pair-wise distances of particles in a priodic boundary box
- Parameters
positiosn (
numpy.ndarray
) – coordinate of particles, shape (N, dim)box (
float
) – the length of the priodic bondary. The box should be cubic
- Returns
- the pairwise distance, shape ( (N * N - N) / 2, ),
use
scipy.spatial.distance.squareform
to recover the matrix form.
- Return type
- fish_corr.utility.plot_spatial_3d(positions, r, bin_num, title='', figsize=(6, 3), axes=[], unit='mm', show=True, savename='')¶
Generate orthogonal slices of a 3D spatial distribution of many points in 3D
- Parameters
positions (np.ndarray) – coordinates measured in 3D space, shape (n, dim)
r (float) – the distribution is measured in the range of (-r, r)
bin_num (int) – the number of bins
title (str) – the titile of the plot
figsize (tuple) – the (length, width) of the figure in inches
axes (list) – [optional]
unit (str) – the unit of the coordinates
show (bool) – if true, the distribution will be plotted
savename (str) – if not blank, the plot would be saved to the harddrive
- Returns
None
fish_corr.voro module¶
Voronoi analysis using voro++ in 3D
- fish_corr.voro.get_indices_with_voro_volumes_select(arg0: numpy.ndarray[float64], arg1: numpy.ndarray[int32], arg2: float, arg3: float) numpy.ndarray[int32] ¶
getting the indices with voronoi cells volumes in a confined parbobla gemetry, given indices of points inside the convex hull
- fish_corr.voro.get_voro_volumes(arg0: numpy.ndarray[float64], arg1: float, arg2: float) numpy.ndarray[float64] ¶
getting the voronoi cells volumes in a confined parbobla gemetry
- fish_corr.voro.get_voro_volumes_select(arg0: numpy.ndarray[float64], arg1: numpy.ndarray[int32], arg2: float, arg3: float) numpy.ndarray[float64] ¶
getting the voronoi cells volumes in a confined parbobla gemetry, given indices of points inside the convex hull