open_viewmin.nematic.jones#

Jones matrix calculations for transmission of polarized light through the nematic liquid crystal.

Adapted from code originally written by Sophie Ettinger and adapted for open-Qmin data by Yvonne Zagzag.

Module Contents#

Functions#

_add_jones_arrows(plotter, coord_index, center, actor_name)

_add_jones_lambda_arrow(plotter, p_dir, a_dir, ...)

_double_headed_arrow(center, direction, **kwargs)

add_jones_to_plotter(plotter[, n, site_types])

Add planes to back of box, colored by RGB Jones matrix transmission

add_jones_toolbar_to_plotter(plotter[, n, site_types])

Add planes to back of box, colored by RGB Jones matrix transmission

get_director_data_from_plotter(plotter, n, site_types)

Use plotter's existing nematic director data for Jones matrix

get_quarter_wave_plate_jones(angle)

jones_light_propagation_through_sample(director, ...)

Calculate Jones matrix product for light propagation through nematic

jones_matrices_multiple_wavelengths(n, site_types[, ...])

Calculate list of Jones matrices for a sequence of wavelengths.

jones_matrix(n_phi, phi_ext, phi_ord)

Calculate Jones matrix array for one slice at constant z.

list_to_xyz_mat(data, dims)

Convert a flattened data array to shape (Lx, Ly, Lz, ...).

n_and_site_types_from_open_qmin(filename)

Import Q-tensor data in the open-Qmin data_format

permute_axes(arr, axis_name)

Permute coordinate axes so that the optical axis corresponds to

polarizer_matrix_from_angle(angle)

Calculate projection matrix along a polarizer's direction in the xy

pom_animation_rotate_polarizers(plotter[, n, ...])

Create video of simulated polarized optical microscopy images

pom_image_color(jones_mats[, polarizer_angle, ...])

Given Jones matrices for red, green, and blue light propagation,

pom_image_one_wavelength(jones_mat_product, p_angle, ...)

Simulated polarized optical microscopy image using a single wavelength

pom_image_sequence_rotate_polarizers(ax, n, site_types)

Create image sequence of simulated polarized optical microscopy images

rgb_to_texture(rgb_data[, sigma])

Transform 2D NumPy float rgb array to PyVista texture

rotation_matrix_2d(angle)

Calculate 2x2 rotation matrix

rotation_transform(mat, rot_mat)

Calculate M' = R M R^T for given matrix M and rotation matrix R.

save_jones_data(plotter, filename)

save_jones_data_GUI(plotter[, filename])

save_jones_images(plotter, filename)

save_jones_images_GUI(plotter[, filename])

open_viewmin.nematic.jones._add_jones_arrows(plotter, coord_index, center, actor_name)#
open_viewmin.nematic.jones._add_jones_lambda_arrow(plotter, p_dir, a_dir, jones_arrows_scale, arrows_center, lambda_arrow_actor_name)#
open_viewmin.nematic.jones._double_headed_arrow(center, direction, **kwargs)#
open_viewmin.nematic.jones.add_jones_to_plotter(plotter, n=None, site_types=None)#

Add planes to back of box, colored by RGB Jones matrix transmission and normal to x, y, z.

Parameters:
  • plotter (open_viewmin.NematicPlot or open_viewmin.NematicPlotNoQt) –

  • n (numpy.ndarray or None, optional) – director data; if None, director will be taken from plotter

  • site_types (numpy.ndarray, “off”, or None) – site types data; if “off”, all sites are taken to be bulk; if None, site types data will be taken from plotter

open_viewmin.nematic.jones.add_jones_toolbar_to_plotter(plotter, n=None, site_types=None)#

Add planes to back of box, colored by RGB Jones matrix transmission and normal to x, y, z, with polarizer/analyzer angles and brightness controlled by sliders.

Parameters:
  • plotter (open_viewmin.NematicPlot) –

  • n (numpy.ndarray or None, optional) – director data; if None, director will be taken from plotter

  • site_types (numpy.ndarray, “off”, or None) – site types data; if “off”, all sites are taken to be bulk; if None, site types data will be taken from plotter

Returns:

callback that refreshes Jones planes by re-applying the control slider widgets

Return type:

callable()

open_viewmin.nematic.jones.get_director_data_from_plotter(plotter, n, site_types)#

Use plotter’s existing nematic director data for Jones matrix calculations

Parameters:
  • plotter (open_viewmin.NematicPlot or open_viewmin.NematicPlotNoQt) –

  • n (numpy.ndarray or None) – nematic director field in flattened array; if None, data is taken from plotter

  • site_types (numpy.ndarray, “off”, or None) – site types in flattened array; if “off”, all sites are treated as bulk; if None, data is taken from plotter

Returns:

reshaped arrays of nematic director and site types data

Return type:

numpy.ndarray, numpy.ndarray

open_viewmin.nematic.jones.get_quarter_wave_plate_jones(angle)#
open_viewmin.nematic.jones.jones_light_propagation_through_sample(director, site_types, wavelength=6.6e-07, res=4.5e-08, n_ord=1.55, n_ext=1.7, optical_axis='z', n_bdy=1.333)#

Calculate Jones matrix product for light propagation through nematic sample.

Parameters:
  • director (numpy.ndarray) – nematic director field

  • site_types (numpy.ndarray) – array of site types (bulk, boundary, or surface) for the lattice

  • wavelength (float) – wavelength of incident light, in meters

  • res (float) – lattice resolution, in meters

  • n_ord (float) – ordinary index of refraction

  • n_ext (float) – extraordinary index of refraction

  • optical_axis ('x', 'y', or 'z', optional) – light propagation direction

  • n_bdy (float or sequence of floats) – isotropic index of refraction inside boundary

Returns:

Jones matrix for light propagation through the entire simulation box

Return type:

numpy.ndarray

open_viewmin.nematic.jones.jones_matrices_multiple_wavelengths(n, site_types, wavelengths=(6.38e-07, 5.32e-07, 4.65e-07), **kwargs)#

Calculate list of Jones matrices for a sequence of wavelengths.

Parameters:
  • n (numpy.ndarray) – nematic director field

  • site_types (numpy.ndarray) – array of site types (bulk, boundary, surface)

  • wavelengths (sequence of floats) – wavelengths in meters

  • **kwargs – keyword arguments accepted by jones_light_propagation_through_sample

Returns:

list of Jones matrix arrays

Return type:

list(numpy.ndarray)

open_viewmin.nematic.jones.jones_matrix(n_phi, phi_ext, phi_ord)#

Calculate Jones matrix array for one slice at constant z.

Parameters:
  • n_phi (numpy.ndarray) – azimuthal angle of director in plane transverse to light propagation

  • phi_ext (numpy.ndarray) – array of local-frame complex Jones matrices for effective extraordinary index of refraction

  • phi_ord (numpy.ndarray) – local-frame complex Jones matrix for ordinary index of refraction

Returns:

array of lab-frame complex Jones matrices

Return type:

numpy.ndarray

open_viewmin.nematic.jones.list_to_xyz_mat(data, dims)#

Convert a flattened data array to shape (Lx, Ly, Lz, …).

Parameters:
  • data (numpy.ndarray) –

  • dims ((int, int, int)) –

Return type:

numpy.ndarray

open_viewmin.nematic.jones.n_and_site_types_from_open_qmin(filename)#

Import Q-tensor data in the open-Qmin data_format

Parameters:

filename (str) – Filename of open-Qmin-style data.

Returns:

director, site_types arrays

Return type:

numpy.ndarray, numpy.ndarray

open_viewmin.nematic.jones.permute_axes(arr, axis_name)#

Permute coordinate axes so that the optical axis corresponds to axis_name

Parameters:
  • arr (numpy.ndarray) –

  • axis_name ('x', 'y', or 'z') –

Return type:

numpy.ndarray

open_viewmin.nematic.jones.polarizer_matrix_from_angle(angle)#

Calculate projection matrix along a polarizer’s direction in the xy plane.

Parameters:

angle (float) – angle of polarizer with respect to x-axis (after permuting axes so that z is the light propagation direction)

Returns:

polarizer projection matrix

Return type:

numpy.ndarray

open_viewmin.nematic.jones.pom_animation_rotate_polarizers(plotter, n=None, site_types='off', interval=50, filename=None, **kwargs)#

Create video of simulated polarized optical microscopy images with polarizer and analyzer rotating linearly in time through total angle pi/2.

Parameters:
  • plotter (open_viewmin.NematicPlot or open_viewmin.NematicPlotNoQt) –

  • n (numpy.ndarray or None, optional) – nematic director data; if None, this data is taken from the plotter

  • site_types (numpy.ndarray, “off”, or None, optional) – site types data; if “off”, all sites are treated as bulk; if None, data is taken from plotter

  • interval (int, optional) – number of milliseconds between frames of animation

  • filename (str or None, optional) – filename for exported video; if None, no export occurs and the function returns the full HTML string for the video

  • kwargs (dict, optional) – keyword arguments accepted by pom_image_sequence_rotate_polarizers

Returns:

filename of exported video or full HTML string defining the video

Return type:

str

open_viewmin.nematic.jones.pom_image_color(jones_mats, polarizer_angle=0.0, analyzer_angle=None, brightness_factor=1, use_quarter_wave_plate=False)#

Given Jones matrices for red, green, and blue light propagation, generate rgb array (float values in [0, 1]) for a simulated color polarized optical microscopy image.

Parameters:
  • jones_mats ([numpy.ndarray, numpy.ndarray, numpy.ndarray]) – list of three Jones matrix products for propagation of red, green, and blue light (respectively) through the entire sample

  • polarizer_angle (float) – angle of polarizer

  • analyzer_angle (float) – angle of analyzer

  • brightness_factor (float) – multiplier for intensity

  • use_quarter_wave_plate (bool, optional) – whether to insert a quarter wave plate, oriented at a 45-degree counterclockwise rotation from the polarizer, between the polarizer and the sample

Returns:

2D array of rgb values for transmitted light

Return type:

numpy.ndarray

open_viewmin.nematic.jones.pom_image_one_wavelength(jones_mat_product, p_angle, a_angle, use_quarter_wave_plate=False)#

Simulated polarized optical microscopy image using a single wavelength of light.

Parameters:
  • jones_mat_product (numpy.ndarray) – array of Jones matrix products for light propagation through the entire sample

  • p_angle (float) – angle of polarizer with respect to x-axis (after permuting axes so that light propagates along z)

  • a_angle (float) – angle of analyzer with respect to x-axis (after permuting axes so that light propagates along z)

  • use_quarter_wave_plate (bool, optional) – whether to insert a quarter wave plate, oriented at a 45-degree counterclockwise rotation from the polarizer, between the polarizer and the sample

Returns:

2D array of transmitted intensities

Return type:

numpy.ndarray

open_viewmin.nematic.jones.pom_image_sequence_rotate_polarizers(ax, n, site_types, num_frames=10, brightness_factor=1, **kwargs)#

Create image sequence of simulated polarized optical microscopy images with polarizer and analyzer rotating linearly in time through total angle pi/2.

Parameters:
  • ax (matplotlib.axes) – figure axes

  • n (numpy.ndarray or None) – nematic director field in flattened array; if None, data is taken from plotter

  • site_types (numpy.ndarray, “off”, or None) – site types in flattened array; if “off”, all sites are treated as bulk; if None, data is taken from plotter

  • num_frames (int, optional) – number of subdivisions of the [0, pi/2] interval for the polarizer angle, and thus the number of frames in the animation

  • brightness_factor (float, optional) – multiplier for intensity

  • kwargs (dict, optional) – keyword arguments accepted by jones_matrices_multiple_wavelengths

Returns:

list of transmitted intensity images

Return type:

list(matplotlib.axes.Axes.imshow)

open_viewmin.nematic.jones.rgb_to_texture(rgb_data, sigma=1.0)#

Transform 2D NumPy float rgb array to PyVista texture

Parameters:
  • rgb_data (numpy.ndarray) – 2D array of (red, green, blue) intensities, each in the interval [0, 1]

  • sigma (float, optional) – smoothing factor for Gaussian filter; set to 1. for no filter.

Return type:

pyvista.Texture

open_viewmin.nematic.jones.rotation_matrix_2d(angle)#

Calculate 2x2 rotation matrix

Parameters:

angle (float or numpy.ndarray) – rotation angle or array thereof

Returns:

rotation matrix or array thereof

Return type:

numpy.ndarray

open_viewmin.nematic.jones.rotation_transform(mat, rot_mat)#

Calculate M’ = R M R^T for given matrix M and rotation matrix R.

Parameters:
  • mat (numpy.ndarray) – Array of matrices M.

  • rot_mat (numpy.ndarray) – Rotation matrix R.

Returns:

Array of rotated matrices

Return type:

numpy.ndarray

open_viewmin.nematic.jones.save_jones_data(plotter, filename: str)#
open_viewmin.nematic.jones.save_jones_data_GUI(plotter, filename=None)#
open_viewmin.nematic.jones.save_jones_images(plotter, filename: str)#
open_viewmin.nematic.jones.save_jones_images_GUI(plotter, filename=None)#