Skip to content

trajectory

Script for analyzing trajectory of a point on optical elements.

correct_rot(src, angle, cent, off=0)

Remove the rotation of an element from a point. For example undo corotation from a point on the LATR.

Parameters:

Name Type Description Default
src NDArray[float64]

The data to rotate. Should be (npoint, ndim).

required
angle NDArray[float64]

The angle in degrees of the element at each data point. Should by (npoint,).

required
cent NDArray[float64]

The center of rotation of the point. Should be (ndim,).

required

Returns:

Name Type Description
src NDArray[float64]

The data with the rotation removed. The input is also modified in place.

Source code in lat_alignment/trajectory.py
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
def correct_rot(
    src: NDArray[np.float64],
    angle: NDArray[np.float64],
    cent: NDArray[np.float64],
    off: float = 0,
) -> NDArray[np.float64]:
    """
    Remove the rotation of an element from a point.
    For example undo corotation from a point on the LATR.

    Parameters
    ----------
    src : NDArray[np.float64]
        The data to rotate.
        Should be `(npoint, ndim)`.
    angle : NDArray[np.float64]
        The angle in degrees of the element at each data point.
        Should by `(npoint,)`.
    cent : NDArray[np.float64]
        The center of rotation of the point.
        Should be `(ndim,)`.

    Returns
    -------
    src : NDArray[np.float64]
        The data with the rotation removed.
        The input is also modified in place.
    """
    for i, (pt, ang) in enumerate(zip(src, angle)):
        rot = Rotation.from_euler("Y", -1 * (ang - off), degrees=True)
        src[i] = rot.apply(pt - cent) + rot.apply(cent)
    return src

get_angle(data, mode, start, sep, logger)

Reconstruct the angle of an opitcal element from data of a point.

Parameters:

Name Type Description Default
data NDArray[float64]

A (npoint, ndim) array describing the motion of a point.

required
mode str

The mode this data was taken in. Should be continious or step.

required
start float

The angle of the element at the first data point. Should be in degrees.

required
sep float

The seperation between measurements. If we are in continious mode this should be in mm. If we are in step mode this should be in deg.

required
logger Logger

The logger object to use.

required

Returns:

Name Type Description
angle NDArray[float64]

The reconstructed angle in degrees. Will be a (npoint,) array.

center NDArray[float64]

The center of rotation.

Source code in lat_alignment/trajectory.py
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
def get_angle(
    data: NDArray[np.float64],
    mode: str,
    start: float,
    sep: float,
    logger: logging.Logger,
) -> tuple[NDArray[np.float64], NDArray[np.float64]]:
    """
    Reconstruct the angle of an opitcal element from data of a point.

    Parameters
    ----------
    data : NDArray[np.float64]
        A `(npoint, ndim)` array describing the motion of a point.
    mode : str
        The mode this data was taken in.
        Should be `continious` or `step`.
    start : float
        The angle of the element at the first data point.
        Should be in degrees.
    sep : float
        The seperation between measurements.
        If we are in `continious` mode this should be in mm.
        If we are in `step` mode this should be in deg.
    logger : logging.Logger
        The logger object to use.

    Returns
    -------
    angle : NDArray[np.float64]
        The reconstructed angle in degrees.
        Will be a `(npoint,)` array.
    center : NDArray[np.float64]
        The center of rotation.
    """
    logger.info(
        "\tReconstructing angle in %s mode using a start of %f deg and a seperation of %f",
        mode,
        start,
        sep,
    )
    # Recover the angle
    theta, sphere = _get_sphere_and_angle(data, start, logger)

    # Convert delta to an angle delta
    if mode == "continious":
        logger.warning(
            "\t\tReconstructing angle from continious data, this is approximate and should not be used for pointing corrections! Trajectory Errors will also only be approximate!"
        )
        dtheta = np.rad2deg(sep / sphere.radius) / 32.0
    elif mode == "step":
        dtheta = sep
    else:
        raise ValueError(f"Invalid mode: {mode}")

    # Quantize
    theta_corr = _quantize_angle(theta, dtheta, start)

    return theta_corr, np.array(sphere.point, np.float64)