Пример #1
0
def rotate_region_from_roe_corner(
    region: Union[Tuple, reg.Region2D],
    shape_native: Tuple[int, int],
    roe_corner: Tuple[int, int],
) -> reg.Region2D:
    """
    Rotates a (y0, y1, x0, x1) region such that its read-out electronics corner (``roe_corner``) are positioned at
    the 'bottom-left' (e.g. [1,0]).

    Parameters
    ----------
    region
        The coordinates on the image of the (y0, y1, x0, y1) ``Region2D`` that are rotated.
    shape_native
        The 2D shape of the `Array2D` the regions are located on, required to determine the rotated `region`.
    roe_corner
        The corner of the ``Array2D``at which the read-out electronics are located (e.g. (1, 1) is the bottom-right corner).
        The rotation is based on this such that the the read-out electronics are in the bottom-left (e.g. (1, 0)).

    Returns
    -------
    aa.Region2D
        The rotated (y0, y1, x0, x1) ``Region2D`` where the read out electronics are at the bottom left corner, (1, 0).
    """
    if region is None:
        return None

    if roe_corner == (1, 0):
        return reg.Region2D(region=region)
    elif roe_corner == (0, 0):
        return reg.Region2D(region=(
            shape_native[0] - region[1],
            shape_native[0] - region[0],
            region[2],
            region[3],
        ))
    elif roe_corner == (1, 1):
        return reg.Region2D(region=(
            region[0],
            region[1],
            shape_native[1] - region[3],
            shape_native[1] - region[2],
        ))
    elif roe_corner == (0, 1):
        return reg.Region2D(region=(
            shape_native[0] - region[1],
            shape_native[0] - region[0],
            shape_native[1] - region[3],
            shape_native[1] - region[2],
        ))
Пример #2
0
    def bottom_left(
        cls,
        parallel_size=2086,
        serial_size=2128,
        serial_prescan_size=51,
        serial_overscan_size=29,
        parallel_overscan_size=20,
    ):

        if parallel_overscan_size > 0:

            parallel_overscan = reg.Region2D((
                parallel_size - parallel_overscan_size,
                parallel_size,
                serial_prescan_size,
                serial_size - serial_overscan_size,
            ))

        else:

            parallel_overscan = None

        serial_prescan = reg.Region2D(
            (0, parallel_size, 0, serial_prescan_size))
        serial_overscan = reg.Region2D((
            0,
            parallel_size - parallel_overscan_size,
            serial_size - serial_overscan_size,
            serial_size,
        ))

        layout_2d = Layout2DEuclid(
            shape_2d=(parallel_size, serial_size),
            original_roe_corner=(1, 0),
            parallel_overscan=parallel_overscan,
            serial_prescan=serial_prescan,
            serial_overscan=serial_overscan,
        )

        return layout_2d.new_rotated_from_roe_corner(roe_corner=(1, 0))
Пример #3
0
    def from_sizes(cls,
                   roe_corner,
                   serial_prescan_size=24,
                   parallel_overscan_size=20):
        """
        Use an input array of the left quadrant in electrons and perform the rotations required to give correct
        arctic clocking.

        See the docstring of the `FrameACS` class for a complete description of the Euclid FPA, quadrants and
        rotations.
        """

        parallel_overscan = reg.Region2D(
            (2068 - parallel_overscan_size, 2068, serial_prescan_size, 2072))

        serial_prescan = reg.Region2D((0, 2068, 0, serial_prescan_size))

        return lo.Layout2D.rotated_from_roe_corner(
            roe_corner=roe_corner,
            shape_native=(2068, 2072),
            parallel_overscan=parallel_overscan,
            serial_prescan=serial_prescan,
        )
Пример #4
0
    def __init__(
        self,
        shape_2d,
        original_roe_corner=(1, 0),
        parallel_overscan=None,
        serial_prescan=None,
        serial_overscan=None,
    ):
        """
        Abstract base class for a charge injection pattern_ci, which defines the regions charge injections appears \
         on a charge-injection frame_ci, the input normalization and other properties.

        Parameters
        -----------
        normalization : float
            The normalization of the charge injection lines.
        regions: [(int,)]
            A list of the integer coordinates specifying the corners of each charge injection region \
            (top-row, bottom-row, left-column, right-column).
        """

        self.shape_2d = shape_2d
        self.original_roe_corner = original_roe_corner

        if isinstance(parallel_overscan, tuple):
            parallel_overscan = reg.Region2D(region=parallel_overscan)

        if isinstance(serial_prescan, tuple):
            serial_prescan = reg.Region2D(region=serial_prescan)

        if isinstance(serial_overscan, tuple):
            serial_overscan = reg.Region2D(region=serial_overscan)

        self.parallel_overscan = parallel_overscan
        self.serial_prescan = serial_prescan
        self.serial_overscan = serial_overscan
Пример #5
0
def region_after_extraction(
        original_region: reg.Region2D,
        extraction_region: reg.Region2D) -> reg.Region2D or None:

    if original_region is None:
        return None

    y0, y1 = x0x1_after_extraction(
        x0o=original_region[0],
        x1o=original_region[1],
        x0e=extraction_region[0],
        x1e=extraction_region[1],
    )
    x0, x1 = x0x1_after_extraction(
        x0o=original_region[2],
        x1o=original_region[3],
        x0e=extraction_region[2],
        x1e=extraction_region[3],
    )

    if None in [y0, y1, x0, x1]:
        return None
    else:
        return reg.Region2D((y0, y1, x0, x1))