Conventions¶
Here, we will outline some of the conventions used by prysm. These will be useful to understand if extending the library, or performing custom analysis.
prysm uses a large number of classes which carry data and metadata about the signals with their namesakes. They can be divided loosely into two caregories,
phases
images
Both have common properties of x
and y
, which are one dimensional arrays giving the gridded coordinates in x and y.
[1]:
# an example of a phasetype object and an imagetype object
from prysm import Pupil, Slit
pu = Pupil()
sl = Slit(1, sample_spacing=0.075, samples=64)
pu.x[:3], sl.y[:3] # only first three elements for brevity
[1]:
(array([0.5 , 0.49212598, 0.48425197]),
array([2.4 , 2.325, 2.25 ]))
Each has an array that holds the numerical representation of the signal itself, for phaestype objects this is phase
and for imagetype objects this is data
. The convention is y,x
indices, consistent with numpy. This is the opposite convention used by matlab.
[2]:
pu.phase[:3,:3], sl.data[:3,:3]
[2]:
(array([[nan, nan, nan],
[nan, nan, nan],
[nan, nan, nan]]), array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]]))
both inherit from BasicData (in fact, just about every class in prysm does) which imbues them with a brevy of properties:
[3]:
from prysm._basicdata import BasicData
help(BasicData)
Help on class BasicData in module prysm._basicdata:
class BasicData(builtins.object)
 BasicData(x, y, data)

 Abstract base class holding some data properties.

 Methods defined here:

 __init__(self, x, y, data)
 Initialize a new BasicData instance.

 Parameters
 
 x : `numpy.ndarray`
 x unit axis
 y : `numpy.ndarray`
 y unit axis
 data : `numpy.ndarray`
 data

 Returns
 
 BasicData
 the BasicData instance

 copy(self)
 Return a (deep) copy of this instance.

 
 Data descriptors defined here:

 __dict__
 dictionary for instance variables (if defined)

 __weakref__
 list of weak references to the object (if defined)

 center_x
 Center "pixel" in x.

 center_y
 Center "pixel" in y.

 sample_spacing
 centertocenter sample spacing.

 samples_x
 Number of samples in the x dimension.

 samples_y
 Number of samples in the y dimension.

 shape
 Proxy to phase or data shape.

 size
 Proxy to phase or data size.

 slice_x
 Retrieve a slice through the X axis of the phase.

 Returns
 
 self.unit : `numpy.ndarray`
 ordinate axis
 slice of self.phase or self.data : `numpy.ndarray`

 slice_y
 Retrieve a slice through the Y axis of the phase.

 Returns
 
 self.unit : `numpy.ndarray`
 ordinate axis
 slice of self.phase or self.data : `numpy.ndarray`

 unit_x

 unit_y
prysm is a metadataheavy library, with many functions and procedures taking a several arguments, most of which populated with sane default values. A number of these defaults can be controlled through prysm’s config object,
[4]:
from prysm import config
[5]:
controlled_properties = [i for i in dir(config) if not i.startswith('_') and not i == 'initialized']
print(controlled_properties)
['Q', 'backend', 'chbackend_observers', 'image_colormap', 'lw', 'phase_colormap', 'precision', 'precision_complex', 'zernike_base', 'zorder']
To change the value used by prysm, simply assign to the property,
[6]:
# use 32bit floats instead of 64bit, ~50% speedup to all operations in exchange for accuracy
config.precision = 32