Skip to content

alignment

Main driver script for running the alignment. You typically want to use the lat_alignment entrypoint rather than calling this directly.

adjust_panel(panel, mnum, fit, cfg)

Helper function to get the adjustments for a single panel.

Parameters:

Name Type Description Default
panel Panel

The mirror panel to adjust.

required
mnum int

The mirror number. 1 for the primary and 2 for the secondary.

required
fit bool

If True fit for the adjustments by modeling them as rotations of the panel. If False just use the raw residuals.

required
cfg dict

The configuration dictionairy.

required

Returns:

Name Type Description
adjustments NDArray[float32]

The adjustments to make for the panel. This is a 17 element array with the following structure: [mnum, panel_row, panel_col, dx, dy, d_adj1, ..., d_adj5, dx_err, dy_err, d_adj1_err, ..., d_adj5_err].

Source code in lat_alignment/alignment.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
def adjust_panel(
    panel: mir.Panel, mnum: int, fit: bool, cfg: dict
) -> NDArray[np.float32]:
    """
    Helper function to get the adjustments for a single panel.

    Parameters
    ----------
    panel : mir.Panel
        The mirror panel to adjust.
    mnum : int
        The mirror number.
        1 for the primary and 2 for the secondary.
    fit: bool
        If True fit for the adjustments by modeling them as rotations of the panel.
        If False just use the raw residuals.
    cfg : dict
        The configuration dictionairy.

    Returns
    -------
    adjustments : NDArray[np.float32]
        The adjustments to make for the panel.
        This is a 17 element array with the following structure:
        `[mnum, panel_row, panel_col, dx, dy, d_adj1, ..., d_adj5, dx_err, dy_err, d_adj1_err, ..., d_adj5_err]`.
    """
    adjustments = np.zeros(17, np.float32)
    adjustments[0] = mnum
    adjustments[1] = panel.row
    adjustments[2] = panel.col
    if fit:
        meas_adj = panel.meas_adj.copy()
        meas_adj[:, 2] -= panel.meas_adj_resid
        meas_surface = panel.meas_surface.copy()
        meas_surface[:, 2] -= panel.meas_adj_resid
        dx, dy, d_adj, dx_err, dy_err, d_adj_err = adj.calc_adjustments(
            panel.can_surface, meas_surface, meas_adj, **cfg.get("adjust", {})
        )
    else:
        dx = 0
        dx_err = 0
        dy = 0
        dy_err = 0
        d_adj = -1 * panel.adj_resid
        d_adj_err = np.zeros_like(d_adj)
    # The primary has x and z opposite to what is intuitive
    if mnum == 1:
        dx *= -1
        d_adj *= -1
    adjustments[3:] = np.array(
        [dx, dy] + list(d_adj) + [dx_err, dy_err] + list(d_adj_err)
    )

    return adjustments