Skip to content

Deformable Mirror

queue_listerner instance-attribute

queue_listerner = setup_logging()

logger instance-attribute

logger = getLogger()

external_logger_flag instance-attribute

external_logger_flag = False

tag instance-attribute

tag = 'deformableMirror'

floating_precision instance-attribute

floating_precision = floating_precision

flip_ instance-attribute

flip_ = flip

flip_lr instance-attribute

flip_lr = flip_lr

sign instance-attribute

sign = sign

altitude instance-attribute

altitude = altitude

nActs instance-attribute

nActs = nActs

mechCoupling instance-attribute

mechCoupling = mechCoupling

dm_layer instance-attribute

dm_layer = buildLayer(telescope, altitude)

pitch instance-attribute

pitch = D_fov / (nActs - 1)

misReg instance-attribute

misReg = MisRegistration(
    0, 0, 0, 1, telescope=telescope, logger=logger
)

valid_act_thresh_outer instance-attribute

valid_act_thresh_outer = valid_act_thresh_outer

validActThreshpercentage instance-attribute

validActThreshpercentage = get(
    "validActThreshpercentage", 0.0
)

maxStrokePtV instance-attribute

maxStrokePtV = get('maxStrokePtV', 0.0001)

dynamic_model_path instance-attribute

dynamic_model_path = get('dynamicModel', '')

device instance-attribute

device = device('cuda' if is_available() else 'cpu')

typeDM instance-attribute

typeDM = 'cartesian'

epsilon instance-attribute

epsilon = sqrt(-1 * log(mechCoupling)) / pitch

high_res_coords instance-attribute

high_res_coords = T

dyn_A instance-attribute

dyn_A = None

dyn_B instance-attribute

dyn_B = None

dyn_C instance-attribute

dyn_C = None

dyn_D instance-attribute

dyn_D = None

__init__

__init__(
    telescope,
    nActs: float,
    mechCoupling: float = 0.6,
    coordinates: ndarray = None,
    pitch: float = None,
    modes: ndarray = None,
    misReg=None,
    typeDM: str = "cartesian",
    floating_precision: int = 64,
    altitude: float = None,
    flip=False,
    flip_lr=False,
    sign=1,
    valid_act_thresh_outer=None,
    logger=None,
    **kwargs,
)

Initialize a Deformable Mirror (DM) with zonal or modal influence functions.

Parameters:

Name Type Description Default
telescope Telescope

Telescope associated with this DM.

required
nActs float

Number of actuators in the horizontal axis of the pupil.

required
mechCoupling float

Coupling factor between actuators, by default 0.60.

0.6
coordinates ndarray

Custom actuator coordinates.

None
pitch float

Actuator pitch in meters.

None
modes ndarray

Influence functions or modal basis.

None
misReg MisRegistration

Misregistration object for geometrical offsets.

None
typeDM str

Type of the DM: {cartesian, radial, custom}. By default, custom.

'cartesian'
floating_precision int

Use 32 or 64-bit floats, by default 64.

64
altitude float

Conjugation altitude of the DM in meters.

None
flip bool

Flip the influence functions vertically.

False
flip_lr bool

Flip the influence functions left-right.

False
sign int

Sign of actuation.

1
valid_act_thresh_outer float

Threshold for validating actuators outside pupil.

None
logger Logger

Logger instance.

None
**kwargs dict

Additional keyword arguments.

validActThreshpercentage : float, optional Parameter to select a percentage of the actuator pitch to consider it valid o not. maxStrokePtV : float, optional Maximum mechanical stroke peak-to-valley in [m]. By default 100e-6 [m]. dynamicModel : str, optional Path to the h5 file containing the state-space model of the Deformable Mirror.

{}

generate_cartesian_dm

generate_cartesian_dm(nActs)

Generates a distribution of cartesian points and a logic mask filtering the points that are within the limits of the external pupil diameter.

Parameters:

Name Type Description Default
nActs int

Number of actuators in the square side

required

Returns:

Name Type Description
coordinates ndarray

X and Y coordinates aranged as [nActs**2,2]

validAct ndarray

Logic mask of valid actuators

nValidAct int

Number of valid actuators

generate_radial_dm

generate_radial_dm()

Generate a distribution of radial actuator points approximated by a hexagonal grid, with a logic mask filtering the points within the external pupil diameter.

Returns:

Name Type Description
coordinates ndarray

X and Y coordinates arranged as [nActs, 2].

validAct ndarray

Boolean mask of valid actuators.

nValidAct int

Number of valid actuators.

precomputeGaussianRBFInterpolant

precomputeGaussianRBFInterpolant(
    input_points, output_points, epsilon
)

Generates a distribution of radial points approximated by hexagons, and a logic mask filtering the points that are within the limits of the external pupil diameter.

Parameters:

Name Type Description Default
input_points ndarray

Coordinates of the mirror actuators

required
output_points ndarray

Coordinates of the high resolution output grid

required
epsilon float

Radial scaling factor for the Gaussian fitting

required

Returns:

Name Type Description
L Tensor

Triangular Cholesky descomposition matrix

phi_eval Tensor

Inteprolator based on output - input Euclidean distance

buildLayer

buildLayer(telescope, altitude)

Construct and configure the DM layer at a given conjugation altitude.

Parameters:

Name Type Description Default
telescope Telescope

Telescope providing aperture and resolution information.

required
altitude float

Altitude in meters to conjugate the DM layer.

required

Returns:

Type Description
dmLayerClass

Configured DM layer with geometric and aperture metadata.

get_dm_pupil

get_dm_pupil(src)

Compute pupil mask seen by a source at the DM altitude.

Parameters:

Name Type Description Default
src Source

Source object with angular position.

required

Returns:

Type Description
ndarray

Binary square mask (1s where the source is affected).

get_dm_opd

get_dm_opd(source)

Compute the Optical Path Difference (OPD) and phase from the DM for a given source.

Parameters:

Name Type Description Default
source Source

Source object defining wavelength and position.

required

Returns:

Type Description
tuple of np.ndarray

OPD in meters and phase in radians.

saturateShape

saturateShape(cmd)

Saturate the command of the mirror.

Parameters:

Name Type Description Default
cmd ndarray

Command required from the mirror.

required

Returns:

Type Description
cmd_saturated

Command executed by the mirror.

load_dynamic_model

load_dynamic_model(filename, samplingTime)

Load the state-space model of the deformable mirror from an HDF5 file.

Parameters:

Name Type Description Default
filename str

Path to the H5 file containing the discrete state-space matrices.

required
samplingTime float

Sampling time used to discretize the model [s].

required

Returns:

Name Type Description
A Tensor

Discrete state-transition matrix.

B Tensor

Discrete input-state matrix.

C Tensor

Discrete state-output matrix.

D Tensor

Discrete feedthrough matrix.

applyDynamics

applyDynamics(cmd)

Apply a state-space to the command of the mirror to obtain the temporal response of the mirror

Parameters:

Name Type Description Default
cmd Tensor

Command required from the mirror.

required

Returns:

Name Type Description
dyn_cmd Tensor

Temporal command executed by the mirror.

updateDMShape

updateDMShape(val, dynamicResponse=True)

Update the OPD map from the current coefficients or 2D grid.

Parameters:

Name Type Description Default
val ndarray

Either a coefficient vector or a 2D shape map.

required

Returns:

Type Description
bool

True if update was successful.

updateMisreg

updateMisreg(elapsedTime)

Update the mis-registration params by the temporal factor.

Parameters:

Name Type Description Default
elapsedTime float

Time elapsed in seconds.

required

Returns:

Type Description
bool

True if updated successfully.

print_properties

print_properties()

Print a summary of the DM configuration.

Returns:

Type Description
None

setup_logging

setup_logging(logging_level=logging.WARNING)

__del__

__del__()