prysm.segmented#

Tools for working with segmented systems.

class prysm.segmented.Hex(q, r, s)#

Bases: tuple

Create new instance of Hex(q, r, s)

count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

q#

Alias for field number 0

r#

Alias for field number 1

s#

Alias for field number 2

prysm.segmented.add_hex(h1, h2)#

Add two hex coordinates together.

prysm.segmented.sub_hex(h1, h2)#

Subtract two hex coordinates.

prysm.segmented.mul_hex(h1, h2)#

Multiply two hex coordinates.

prysm.segmented.hex_dir(i)#

Hex direction associated with a given integer, wrapped at 6.

prysm.segmented.hex_neighbor(h, direction)#

Neighboring hex in a given direction.

prysm.segmented.hex_to_xy(h, radius, rot=90)#

Convert hexagon coordinate to (x,y), if all hexagons have a given radius and rotation.

prysm.segmented.scale_hex(h, k)#

Scale a hex coordinate by some constant factor.

prysm.segmented.hex_ring(radius)#

Compute all hex coordinates in a given ring.

class prysm.segmented.CompositeHexagonalAperture(x, y, rings, segment_diameter, segment_separation, segment_angle=90, exclude=())#

Bases: object

An aperture composed of several hexagonal segments.

Create a new CompositeHexagonalAperture.

Note that __init__ is relatively computationally expensive and hides a lot of work.

Parameters:
  • x (numpy.ndarray) – array of x sample positions, of shape (m, n)

  • y (numpy.ndarray) – array of y sample positions, of shape (m, n)

  • rings (int) – number of rings in the structure

  • segment_diameter (float) – flat-to-flat diameter of each segment, same units as x

  • segment_separation (float) – edge-to-nearest-edge distance between segments, same units as x

  • segment_angle (float, optional, {0, 90}) – rotation angle of each segment

  • exclude (sequence of int) – which segment numbers to exclude. defaults to all segments included. The 0th segment is the center of the array. Other segments begin from the “up” orientation and count clockwise.

prepare_opd_bases(basis_func, orders, basis_func_kwargs=None, normalization_radius=None)#

Prepare the polynomial bases for per-segment phase errors.

Parameters:
  • basis_func (callable) – a function with signature basis_func(orders, [x, y or r, t], **kwargs) for example, zernike_nm_sequence from prysm.polyomials fits the bill

  • orders (iterable) – sequence of polynomial orders or indices. for example, zernike_nm_sequence may be combined with a monoindexing function as e.g. orders=[noll_to_nm(j) for j in range(3,12)]

  • basis_func_kwargs (dict) – any keyword arguments to pass to basis_func. The spatial coordinates will already be passed based on inspection of the function signature and should not be attempted to be included here

  • normalization_radius (float) – the normaliation radius to use to convert local surface coordinates to normalized coordinates for an orthogonal polynomial. if None, defaults to the half segment vertex to vertex distance, v to v is 2/sqrt(3) times the segment diameter given in the constructor if basis_func does not take arguments (r, t), the radius is assumed to be equal in X and Y

compose_opd(coefs, out=None)#

Compose per-segment optical path errors using the basis from prepare_opd_bases.

Parameters:
  • coefs (iterable) – an iterable of coefficients for each segment present, i.e. excluding those in the exclude list from the constructor if an array, must be of shape (len(self.segment_ids), len(orders)) where orders comes from the proceeding call to prepare_opd_bases

  • out (numpy.ndarray) – array to insert OPD into, allocated if None

Returns:

OPD map of real datatype

Return type:

numpy.ndarray

class prysm.segmented.CompositeKeystoneAperture(x, y, center_circle_diameter, rings, ring_radius, segments_per_ring, segment_gap, rotation_per_ring=None)#

Bases: object

Composite apertures with keystone shaped segments.

Create a new CompositeKeystoneAperture.

Parameters:
  • x (numpy.ndarray) – array of x sample positions, of shape (m, n)

  • y (numpy.ndarray) – array of y sample positions, of shape (m, n)

  • center_circle_diameter (float) – diameter of the circular supersegment at the center of the aperture

  • segment_gap (float) – segment gap, same units as x and y; has the sense of the full gap, not the radius of the gap

  • rings (int) – number of rings in the aperture

  • ring_radius (float or Iterable) – the radius of each ring, i.e. (OD-ID). Can be an iterable for variable radius of each ring

  • segments_per_ring (int or Iterable) – number of segments in a given ring. Can be an iterable for variable segment count in each ring

  • rotation_per_ring (float or Iterable, optional) –

    the rotation of each ring. Rotation is used to avoid alignment of segment gaps into radial lines, when fractal segment divisions are used.

    For example, two rings with [8, 16] segments per ring will produce a gap in the second ring aligned to the gap in the previous ring.

    None for this argument will shift/rotate/phase the second ring by (360/16)=22.5 degrees so that the gaps do not align

compose_opd(center_coefs, segment_coefs, out=None)#

Compose per-segment optical path errors using the basis from prepare_opd_bases.

Parameters:
  • coefs (iterable) – an iterable of coefficients for each segment present, i.e. excluding those in the exclude list from the constructor if an array, must be of shape (len(self.segment_ids), len(orders)) where orders comes from the proceeding call to prepare_opd_bases

  • out (numpy.ndarray) – array to insert OPD into, allocated if None

Returns:

OPD map of real datatype

Return type:

numpy.ndarray