nematicfield¶
OrientationField utility functions for computation of the nematic field.
- orientationfield.nematicfield.draw_nematic_field(nem_field, box_size, **kwargs)¶
Draw nematic field using nematic_field function.
- Return type:
ndarray- Parameters:
nem_field (np.ndarray) – nematic field array obtained from nematic_field.
box_size (int) – size of boxes
- Kwargs:
uniform_bg (bool): Whether to hide squares and instead opt to colour the lines themselves. Defaults to True. lengths (bool): Whether to toggle lengths view instead of colourmap. Defaults to False.
- Returns:
Image of nematic field according to given parameters.
- Return type:
ndarray
- orientationfield.nematicfield.extract(Q)¶
Get norm and angle from a (2,2)-array nematic.
- Parameters:
Q (np.ndarray) – (2,2)-array representing the nematic
- Returns:
(norm, angle) where the angle is in [0,pi)
- Return type:
tuple
- orientationfield.nematicfield.extract_points(nem_field, mask, box_size, params, invert_mask)¶
Generate point data for storing positions and information of boxes.
- Return type:
tuple[list,dict]- Parameters:
nem_field (np.ndarray) – Nematic field array of shape (h,w,2,2), or (t,h,w,2,2).
mask (np.ndarray) – Mask array of shape (h,w).
box_size (int) – Size of boxes.
params (list) – List of (str) parameter names. Must be a subset of [‘Qxx’, ‘Qxy’, ‘norm’, ‘angle’].
invert_mask (bool) – Whether to invert the mask or not. Will change whether mask overlap includes or excludes data.
- Returns:
tuple of list and dict corresponding to points positions and properties respectively.
- Return type:
tuple[list, dict]
- orientationfield.nematicfield.kernel(dr, sigma)¶
Kernel used in integration. Unused.
- Return type:
ndarray- Parameters:
dr (np.ndarray) – Vector along which the kernel is computed.
sigma (float) – bandwidth of the kernel.
- Returns:
(2,2)-array representing the resulting nematic.
- Return type:
ndarray
- orientationfield.nematicfield.kernels(sigma, cutoff_ratio)¶
Returns array representing kernel of nematics over xx and over xy.
- Return type:
tuple[ndarray]- Parameters:
sigma (float) – bandwidth of the kernels
cutoff_ratio (float) – radius/sigma ? might have to confirm with Matthias
- Returns:
tuple of Kxx and Kxy kernels
- Return type:
tuple[np.ndarray]
- orientationfield.nematicfield.loop_over_positions(shape, k=0)¶
Provides list of all positions in an ndarray of given shape.
- Return type:
list[tuple]- Parameters:
shape (tuple) – shape of ndarray
- orientationfield.nematicfield.make_random_line_image(h, w, n)¶
Generate a mask of random lines for testing. Lines are of length somewhere in [0 to h/10] in height and somewhere in [0 to w/10] in width.
- Return type:
ndarray- Parameters:
h (int) – Height of image in px.
w (int) – Width of image in px.
n (int) – Maximum number of lines.
- Returns:
Array with values 0 and 1 representing mask of image.
- Return type:
ndarray
- orientationfield.nematicfield.nematic_field(a, sigma, cutoff_ratio)¶
Run integration over a given area image array a. Each element in the array will be summed over and an “average nematic” will be computed by integrating over a circle around it, of a radius defined by kernel bandwidth and cutoff ratio.
- Return type:
ndarray- Parameters:
a (np.ndarray) – area over which integral is calculated
sigma (float) – bandwidth of the kernel
cutoff_ratio (float) – radius/sigma ? might have to confirm with Matthias
- Returns:
(h,w,2,2)-array representing per-pixel nematics of the whole image.
- Return type:
ndarray
- orientationfield.nematicfield.tesselate(img, x, y)¶
Make list of rectangle subdivisions of an array, such that every element in original in array appears in one single subdivision.
- Return type:
list[ndarray]- Parameters:
img (np.ndarray) – Initial array to subdivide.
x (int) – Width of box.
y (int) – Height of box.
- Raises:
Exception – If provided th and tw aren’t divisors of initial array, it’s impossible to return such a subdivision array.
- Returns:
list of ndarray and tuple representing each subdivision and the coordinates to their corners