def prepare_subarray_info(self, 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 camera = self._camera_cache.get(telescope.camera_name) if camera is None: camera = build_camera_geometry(cam_settings, telescope) self._camera_cache[telescope.camera_name] = camera optics = OpticsDescription( name=telescope.name, num_mirrors=telescope.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, )
def prepare_subarray_info(self, 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 camera = self._camera_cache.get(telescope.camera_name) if camera is None: camera = build_camera_geometry(cam_settings, telescope) self._camera_cache[telescope.camera_name] = camera optics = OpticsDescription( name=telescope.name, num_mirrors=telescope.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, )
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, )
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, )
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, )
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, )
def prepare_subarray_info(self, 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"] pixel_settings = telescope_description["pixel_settings"] n_pixels = cam_settings["n_pixels"] focal_length = u.Quantity(cam_settings["focal_length"], u.m) if self.focal_length_choice == "effective": try: focal_length = u.Quantity( cam_settings["effective_focal_length"], u.m) except KeyError as err: raise RuntimeError( f"the SimTelEventSource option 'focal_length_choice' was set to " f"{self.focal_length_choice}, but the effective focal length " f"was not present in the file. ({err})") try: telescope = guess_telescope(n_pixels, focal_length) except ValueError: telescope = UNKNOWN_TELESCOPE camera = self._camera_cache.get(telescope.camera_name) if camera is None: camera = build_camera(cam_settings, pixel_settings, telescope) self._camera_cache[telescope.camera_name] = camera optics = OpticsDescription( name=telescope.name, num_mirrors=telescope.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, tel_type=telescope.type, optics=optics, camera=camera, ) 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, )