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

cache

A collection of all calculated quantities.

Type

dict

decorrelated_scan_2(f1, f2)
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_scan_3(f1, f2, f3)
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

tuple of numpy.ndarray

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
  • sample_points (int) – the length of the obtained ACF

  • t0 (int) – the start time point of the average window

  • t1 (int) – the end time point of the average window

Returns

all the valid velocities

from the valid and trimmed trajectories

Return type

list of numpy.ndarray

save_cache(filename='')
Retrieve all the quantities from self.time and self.cache,

and also dump them to a csv file.

Parameters

filename (str) – if it is not empty, the quantities will be dumped

Returns

{name : values_in_average_blocks}

Return type

dict

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
Returns

the effective attraction in different average windows

Return type

numpy.ndarray

scan_biased_attraction_err(bins, space_bin_number, repeat, **kwargs)

Using the bootstrap method to

Parameters
Returns

the strandard error of the effective attraction

in different average windows

Return type

numpy.ndarray

scan_biased_gr(bins, space_bin_number=50, **kwargs)
Parameters
Returns

The radial distribution function assuming

biased density distribution

Return type

numpy.ndarray

scan_gr(tank, bins, number)
Parameters
Returns

The radial distribution function

Return type

numpy.ndarray

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 if len(velocity) > min_number in this frame

Returns

The moving-average of the Vicsek order parameter

Return type

numpy.ndarray

scan_vicsek_order_std(min_number=0)
Parameters

min_number (int) – only take frame into consideration if len(velocity) > min_number in this frame

Returns

The moving-average of the Vicsek order parameter

Return type

numpy.ndarray

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 or SimMovie

trajs

a list of trajectories

Type

list of fish_track.linking.Trajectory

is_simulation

set the True if the movie is SimMovie

Type

bool

is_pbc

set the True if the particles are in a periodic boundary

Type

bool

Abbrs:
  1. flctn_not: non-translational fluctuation

    (the collective translation is removed)

  2. flctn_noi: non-isometric fluctuation

    (the collective translation & rotaton is removed)

  3. 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 or numpy.ndarray) – the number of bins or the bin edges

  • start (int) – the start frame for the analysis

  • stop (int or None) – the end frame for the analysis, if being None the end frame is the last frame

  • transform (str) –

    here are possible options

    1. T - corr of non-translational fluctuations

    2. I - corr of non-isometric fluctuations

    3. S - corr of non-similar fluctuations

    4. N - corr of vanilla fluctuations

  • get_raw_data (bool) – if True, return the raw data for scipy.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 and frame + 1

Parameters
  • frame (int) – the frame number

  • want_flctn (bool) – if false, the velocities will be returned, instead of their fluctuations

Returns

r0 (shape (n, dim)) , r1 (shape (n, dim))

Return type

tuple ( numpy.ndarray, numpy.ndarray )

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

(numpy.ndarray)

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

(numpy.ndarray)

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

(numpy.ndarray)

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

numpy.ndarray

get_projection(points)
Parameters

points (numpy.ndarray) – positions, shape (n, 3)

Returns

projected positions, shape (3, n)

Return type

numpy.ndarray

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 angle D - 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 or numpy.ndarray) –

Returns

\(z = f(r)\)

Return type

float or numpy.ndarray

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 boundary

  • n_radical (int) – number of bins radically

  • n_angular (int) – number of bins for the angles

Returns

The average and standard deviation of numbers in different boxes

Return type

tuple

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 frame

  • no_vertices (bool) – if being True, ignore the vertices of the convex hull generated by positoins

Returns

nn_locations, nn_distances

Return type

tuple

fish_corr.static.get_nn_iter(frames, no_vertices=True)

Get an iteractive objectable that yields nn distances in different frames

Parameters

frames (list of numpy.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 or tuple) – the legnth of the cubic simulation box, or the size along each dimensions (lx, ly, lz, …)

Returns

nn_locations and nn_distances

Return type

tuple

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 frame

  • velocities (numpy.ndarray) – velocities of all particles in 1 frame

  • no_vertices (bool) – if being True, ignore the vertices

Returns

nn_locations and nn_distances

Return type

tuple

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

tuple

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 or tuple) – the legnth of the cubic simulation box, or the size along each dimensions (lx, ly, lz, …)

Returns

nn_locations and nn_distances

Return type

tuple

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

numpy.ndarray

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

numpy.ndarray

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

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 of Trajectory

movie

hold the positions of particle in different frames

Type

dict of np.ndarray

__labels

hold the ID of particle in different frames label i corresponds to trajs[i]

Type

dict of np.ndarray

__indice_pairs

the paired indices of frame i and frame i+1

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
Parameters
  • t0 (int) – the start frame index.

  • t1 (int) – the end frame index.

Returns

the trimmed trajectories between t0 and t1.

Return type

list

indice_pair(frame)

Return two set of indices, idx_0 & idx_1 Movie[frame][idx_0] corresponds to Movie[frame + 1][idx_1]

Parameters

frame (int) – the frame number

Returns

the indices in frame and frame + 1

Return type

tuple of np.ndarray

label(frame)
load(filename: str)

Load a saved file in the hard drive

make()

Go through all frames, making code faster with the object

save(filename: str)

Save all data using picle

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.

Parameters
  • filename (str) – the name of the xyz file.

  • tank (Tank) – the Tank object.

Returns

None

update_trajs(blur=0, interpolate=False)

Reconstruct self.trajs, typically used if Trajectory 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

list

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

float

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

float

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) – every step points in time were chosen as t0 in the calculation

Returns

The auto-correlation function of the variable

Return type

numpy.ndarray

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

tuple

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
Returns

the best rotation matrix R, r1 @ R = r2

Return type

numpy.ndarray

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 histogram

  • random_gas (numpy.ndarray) – positions of uncorrelated ideal gas, shape (N, 3)

Returns

get the rdf values inside each bin

Return type

numpy.ndarray

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_number

  • frame_number (int) – the total frame number

Returns

the average speed in many frames

Return type

int

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_number

  • frame_number (int) – the total frame number

Returns

the average speed in many frames

Return type

int

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 instance

  • bins (numpy.ndarray) – the bins for the distance histogram

  • random_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

numpy.ndarray

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

Module contents