예제 #1
0
def build_camera_geometry(cam_settings, telescope):
    pixel_shape = cam_settings['pixel_shape'][0]
    try:
        pix_type, pix_rotation = CameraGeometry.simtel_shape_to_type(pixel_shape)
    except ValueError:
        warnings.warn(
            f'Unkown pixel_shape {pixel_shape} for camera_type {telescope.camera_name}',
            UnknownPixelShapeWarning,
        )
        pix_type = 'hexagon'
        pix_rotation = '0d'

    camera = CameraGeometry(
        telescope.camera_name,
        pix_id=np.arange(cam_settings['n_pixels']),
        pix_x=u.Quantity(cam_settings['pixel_x'], u.m),
        pix_y=u.Quantity(cam_settings['pixel_y'], u.m),
        pix_area=u.Quantity(cam_settings['pixel_area'], u.m**2),
        pix_type=pix_type,
        pix_rotation=pix_rotation,
        cam_rotation=-Angle(cam_settings['cam_rot'], u.rad),
        apply_derotation=True,

    )

    return camera
예제 #2
0
def build_camera_geometry(cam_settings, telescope):
    pixel_shape = cam_settings['pixel_shape'][0]
    try:
        pix_type, pix_rotation = CameraGeometry.simtel_shape_to_type(
            pixel_shape)
    except ValueError:
        warnings.warn(
            f'Unkown pixel_shape {pixel_shape} for camera_type {telescope.camera_name}',
            UnknownPixelShapeWarning,
        )
        pix_type = 'hexagon'
        pix_rotation = '0d'

    camera = CameraGeometry(
        telescope.camera_name,
        pix_id=np.arange(cam_settings['n_pixels']),
        pix_x=u.Quantity(cam_settings['pixel_x'], u.m),
        pix_y=u.Quantity(cam_settings['pixel_y'], u.m),
        pix_area=u.Quantity(cam_settings['pixel_area'], u.m**2),
        pix_type=pix_type,
        pix_rotation=pix_rotation,
        cam_rotation=-Angle(cam_settings['cam_rot'], u.rad),
        apply_derotation=True,
    )

    return camera
예제 #3
0
    def _build_telescope_description(self, file, tel_id):
        pix_x, pix_y = u.Quantity(file.get_pixel_position(tel_id), u.m)
        focal_length = u.Quantity(file.get_optical_foclen(tel_id), u.m)
        n_pixels = len(pix_x)

        try:
            telescope = guess_telescope(n_pixels, focal_length)
        except ValueError:
            telescope = UNKNOWN_TELESCOPE

        pixel_shape = file.get_pixel_shape(tel_id)[0]
        try:
            pix_type, pix_rot = CameraGeometry.simtel_shape_to_type(
                pixel_shape)
        except ValueError:
            warnings.warn(
                f'Unkown pixel_shape {pixel_shape} for tel_id {tel_id}',
                UnknownPixelShapeWarning,
            )
            pix_type = 'hexagon'
            pix_rot = '0d'

        pix_area = u.Quantity(file.get_pixel_area(tel_id), u.m**2)

        mirror_area = u.Quantity(file.get_mirror_area(tel_id), u.m**2)
        num_tiles = file.get_mirror_number(tel_id)
        cam_rot = file.get_camera_rotation_angle(tel_id)
        num_mirrors = file.get_mirror_number(tel_id)

        camera = CameraGeometry(
            telescope.camera_name,
            pix_id=np.arange(n_pixels),
            pix_x=pix_x,
            pix_y=pix_y,
            pix_area=pix_area,
            pix_type=pix_type,
            pix_rotation=pix_rot,
            cam_rotation=-Angle(cam_rot, u.rad),
            apply_derotation=True,
        )

        optics = OpticsDescription(
            name=telescope.name,
            num_mirrors=num_mirrors,
            equivalent_focal_length=focal_length,
            mirror_area=mirror_area,
            num_mirror_tiles=num_tiles,
        )

        return TelescopeDescription(
            name=telescope.name,
            type=telescope.type,
            camera=camera,
            optics=optics,
        )
예제 #4
0
    def _build_telescope_description(self, file, tel_id):
        pix_x, pix_y = u.Quantity(file.get_pixel_position(tel_id), u.m)
        focal_length = u.Quantity(file.get_optical_foclen(tel_id), u.m)
        n_pixels = len(pix_x)

        try:
            telescope = guess_telescope(n_pixels, focal_length)
        except ValueError:
            telescope = UNKNOWN_TELESCOPE

        pixel_shape = file.get_pixel_shape(tel_id)[0]
        try:
            pix_type, pix_rot = CameraGeometry.simtel_shape_to_type(pixel_shape)
        except ValueError:
            warnings.warn(
                f'Unkown pixel_shape {pixel_shape} for tel_id {tel_id}',
                UnknownPixelShapeWarning,
            )
            pix_type = 'hexagon'
            pix_rot = '0d'

        pix_area = u.Quantity(file.get_pixel_area(tel_id), u.m**2)

        mirror_area = u.Quantity(file.get_mirror_area(tel_id), u.m**2)
        num_tiles = file.get_mirror_number(tel_id)
        cam_rot = file.get_camera_rotation_angle(tel_id)
        num_mirrors = file.get_mirror_number(tel_id)

        camera = CameraGeometry(
            telescope.camera_name,
            pix_id=np.arange(n_pixels),
            pix_x=pix_x,
            pix_y=pix_y,
            pix_area=pix_area,
            pix_type=pix_type,
            pix_rotation=pix_rot,
            cam_rotation=-Angle(cam_rot, u.rad),
            apply_derotation=True,
        )

        optics = OpticsDescription(
            name=telescope.name,
            num_mirrors=num_mirrors,
            equivalent_focal_length=focal_length,
            mirror_area=mirror_area,
            num_mirror_tiles=num_tiles,
        )

        return TelescopeDescription(
            name=telescope.name, type=telescope.type,
            camera=camera, optics=optics,
        )
예제 #5
0
def build_camera(cam_settings, pixel_settings, telescope):
    pixel_shape = cam_settings['pixel_shape'][0]
    try:
        pix_type, pix_rotation = CameraGeometry.simtel_shape_to_type(
            pixel_shape)
    except ValueError:
        warnings.warn(
            f'Unkown pixel_shape {pixel_shape} for camera_type {telescope.camera_name}',
            UnknownPixelShapeWarning,
        )
        pix_type = 'hexagon'
        pix_rotation = '0d'

    geometry = CameraGeometry(
        telescope.camera_name,
        pix_id=np.arange(cam_settings['n_pixels']),
        pix_x=u.Quantity(cam_settings['pixel_x'], u.m),
        pix_y=u.Quantity(cam_settings['pixel_y'], u.m),
        pix_area=u.Quantity(cam_settings['pixel_area'], u.m**2),
        pix_type=pix_type,
        pix_rotation=pix_rotation,
        cam_rotation=-Angle(cam_settings['cam_rot'], u.rad),
        apply_derotation=True,
    )
    readout = CameraReadout(
        telescope.camera_name,
        sampling_rate=u.Quantity(1 / pixel_settings['time_slice'], u.GHz),
        reference_pulse_shape=pixel_settings['ref_shape'].astype('float64',
                                                                 copy=False),
        reference_pulse_sample_width=u.Quantity(pixel_settings['ref_step'],
                                                u.ns),
    )

    return CameraDescription(camera_name=telescope.camera_name,
                             geometry=geometry,
                             readout=readout)
예제 #6
0
def build_camera(cam_settings, pixel_settings, telescope):
    pixel_shape = cam_settings["pixel_shape"][0]
    try:
        pix_type, pix_rotation = CameraGeometry.simtel_shape_to_type(
            pixel_shape)
    except ValueError:
        warnings.warn(
            f"Unkown pixel_shape {pixel_shape} for camera_type {telescope.camera_name}",
            UnknownPixelShapeWarning,
        )
        pix_type = "hexagon"
        pix_rotation = "0d"

    geometry = CameraGeometry(
        telescope.camera_name,
        pix_id=np.arange(cam_settings["n_pixels"]),
        pix_x=u.Quantity(cam_settings["pixel_x"], u.m),
        pix_y=u.Quantity(cam_settings["pixel_y"], u.m),
        pix_area=u.Quantity(cam_settings["pixel_area"], u.m**2),
        pix_type=pix_type,
        pix_rotation=pix_rotation,
        cam_rotation=-Angle(cam_settings["cam_rot"], u.rad),
        apply_derotation=True,
    )
    readout = CameraReadout(
        telescope.camera_name,
        sampling_rate=u.Quantity(1 / pixel_settings["time_slice"], u.GHz),
        reference_pulse_shape=pixel_settings["ref_shape"].astype("float64",
                                                                 copy=False),
        reference_pulse_sample_width=u.Quantity(pixel_settings["ref_step"],
                                                u.ns),
    )

    return CameraDescription(camera_name=telescope.camera_name,
                             geometry=geometry,
                             readout=readout)
예제 #7
0
    def prepare_subarray_info(telescope_descriptions, header):
        """
        Constructs a SubarrayDescription object from the
        ``telescope_descriptions`` given by ``SimTelFile``

        Parameters
        ----------
        telescope_descriptions: dict
            telescope descriptions as given by ``SimTelFile.telescope_descriptions``
        header: dict
            header as returned by ``SimTelFile.header``

        Returns
        -------
        SubarrayDescription :
            instrumental information
        """

        tel_descriptions = {}  # tel_id : TelescopeDescription
        tel_positions = {}  # tel_id : TelescopeDescription

        for tel_id, telescope_description in telescope_descriptions.items():
            cam_settings = telescope_description['camera_settings']

            n_pixels = cam_settings['n_pixels']
            focal_length = u.Quantity(cam_settings['focal_length'], u.m)

            try:
                telescope = guess_telescope(n_pixels, focal_length)
            except ValueError:
                telescope = UNKNOWN_TELESCOPE

            pixel_shape = cam_settings['pixel_shape'][0]
            try:
                pix_type, pix_rotation = CameraGeometry.simtel_shape_to_type(pixel_shape)
            except ValueError:
                warnings.warn(
                    f'Unkown pixel_shape {pixel_shape} for tel_id {tel_id}',
                    UnknownPixelShapeWarning,
                )
                pix_type = 'hexagon'
                pix_rotation = '0d'

            camera = CameraGeometry(
                telescope.camera_name,
                pix_id=np.arange(n_pixels),
                pix_x=u.Quantity(cam_settings['pixel_x'], u.m),
                pix_y=u.Quantity(cam_settings['pixel_y'], u.m),
                pix_area=u.Quantity(cam_settings['pixel_area'], u.m**2),
                pix_type=pix_type,
                pix_rotation=pix_rotation,
                cam_rotation=-Angle(cam_settings['cam_rot'], u.rad),
                apply_derotation=True,

            )

            optics = OpticsDescription(
                name=telescope.name,
                num_mirrors=cam_settings['n_mirrors'],
                equivalent_focal_length=focal_length,
                mirror_area=u.Quantity(cam_settings['mirror_area'], u.m**2),
                num_mirror_tiles=cam_settings['n_mirrors'],
            )

            tel_descriptions[tel_id] = TelescopeDescription(
                name=telescope.name,
                type=telescope.type,
                camera=camera,
                optics=optics,
            )

            tel_idx = np.where(header['tel_id'] == tel_id)[0][0]
            tel_positions[tel_id] = header['tel_pos'][tel_idx] * u.m

        return SubarrayDescription(
            "MonteCarloArray",
            tel_positions=tel_positions,
            tel_descriptions=tel_descriptions,
        )
예제 #8
0
    def prepare_subarray_info(telescope_descriptions, header):
        """
        Constructs a SubarrayDescription object from the
        ``telescope_descriptions`` given by ``SimTelFile``

        Parameters
        ----------
        telescope_descriptions: dict
            telescope descriptions as given by ``SimTelFile.telescope_descriptions``
        header: dict
            header as returned by ``SimTelFile.header``

        Returns
        -------
        SubarrayDescription :
            instrumental information
        """

        tel_descriptions = {}  # tel_id : TelescopeDescription
        tel_positions = {}  # tel_id : TelescopeDescription

        for tel_id, telescope_description in telescope_descriptions.items():
            cam_settings = telescope_description['camera_settings']

            n_pixels = cam_settings['n_pixels']
            focal_length = u.Quantity(cam_settings['focal_length'], u.m)

            try:
                telescope = guess_telescope(n_pixels, focal_length)
            except ValueError:
                telescope = UNKNOWN_TELESCOPE

            pixel_shape = cam_settings['pixel_shape'][0]
            try:
                pix_type, pix_rotation = CameraGeometry.simtel_shape_to_type(
                    pixel_shape)
            except ValueError:
                warnings.warn(
                    f'Unkown pixel_shape {pixel_shape} for tel_id {tel_id}',
                    UnknownPixelShapeWarning,
                )
                pix_type = 'hexagon'
                pix_rotation = '0d'

            camera = CameraGeometry(
                telescope.camera_name,
                pix_id=np.arange(n_pixels),
                pix_x=u.Quantity(cam_settings['pixel_x'], u.m),
                pix_y=u.Quantity(cam_settings['pixel_y'], u.m),
                pix_area=u.Quantity(cam_settings['pixel_area'], u.m**2),
                pix_type=pix_type,
                pix_rotation=pix_rotation,
                cam_rotation=-Angle(cam_settings['cam_rot'], u.rad),
                apply_derotation=True,
            )

            optics = OpticsDescription(
                name=telescope.name,
                num_mirrors=cam_settings['n_mirrors'],
                equivalent_focal_length=focal_length,
                mirror_area=u.Quantity(cam_settings['mirror_area'], u.m**2),
                num_mirror_tiles=cam_settings['n_mirrors'],
            )

            tel_descriptions[tel_id] = TelescopeDescription(
                name=telescope.name,
                type=telescope.type,
                camera=camera,
                optics=optics,
            )

            tel_idx = np.where(header['tel_id'] == tel_id)[0][0]
            tel_positions[tel_id] = header['tel_pos'][tel_idx] * u.m

        return SubarrayDescription(
            "MonteCarloArray",
            tel_positions=tel_positions,
            tel_descriptions=tel_descriptions,
        )