|
46 | 46 | List,
|
47 | 47 | CaselessStrEnum,
|
48 | 48 | Unicode,
|
| 49 | + UseEnum, |
49 | 50 | TelescopeParameter,
|
50 | 51 | )
|
51 | 52 | from ctapipe.instrument import SubarrayDescription
|
| 53 | +from ctapipe.instrument.optics import FocalLengthKind |
52 | 54 | from ctapipe.io import read_table
|
53 | 55 | from dl1_data_handler.image_mapper import ImageMapper
|
54 | 56 |
|
@@ -192,6 +194,21 @@ class DLDataReader(Component):
|
192 | 194 | ),
|
193 | 195 | ).tag(config=True)
|
194 | 196 |
|
| 197 | + focal_length_choice = UseEnum( |
| 198 | + FocalLengthKind, |
| 199 | + default_value=FocalLengthKind.EFFECTIVE, |
| 200 | + help=( |
| 201 | + "If both nominal and effective focal lengths are available in the" |
| 202 | + " SimTelArray file, which one to use for the `~ctapipe.coordinates.CameraFrame`" |
| 203 | + " attached to the `~ctapipe.instrument.CameraGeometry` instances in" |
| 204 | + " the `~ctapipe.instrument.SubarrayDescription`, which will be used in" |
| 205 | + " CameraFrame to TelescopeFrame coordinate transforms. " |
| 206 | + " The 'nominal' focal length is the one used during " |
| 207 | + " the simulation, the 'effective' focal length is computed using specialized " |
| 208 | + " ray-tracing from a point light source" |
| 209 | + ), |
| 210 | + ).tag(config=True) |
| 211 | + |
195 | 212 | min_telescopes = Int(
|
196 | 213 | default_value=1,
|
197 | 214 | help=(
|
@@ -270,7 +287,7 @@ def __init__(
|
270 | 287 | )
|
271 | 288 |
|
272 | 289 | # Set up the subarray
|
273 |
| - self.subarray = SubarrayDescription.from_hdf(self.first_file) |
| 290 | + self.subarray = SubarrayDescription.from_hdf(self.first_file, focal_length_choice=self.focal_length_choice) |
274 | 291 | selected_tel_ids = None
|
275 | 292 | if self.allowed_tels is not None:
|
276 | 293 | selected_tel_ids = np.array(list(self.allowed_tels), dtype=np.int16)
|
@@ -318,7 +335,7 @@ def __init__(
|
318 | 335 | # Check that all files have the same SubarrayDescription
|
319 | 336 | for filename in self.files:
|
320 | 337 | # Read SubarrayDescription from the new file
|
321 |
| - subarray = SubarrayDescription.from_hdf(filename) |
| 338 | + subarray = SubarrayDescription.from_hdf(filename, focal_length_choice=self.focal_length_choice) |
322 | 339 |
|
323 | 340 | # Filter subarray by selected telescopes
|
324 | 341 | if selected_tel_ids is not None:
|
@@ -817,9 +834,9 @@ def _transform_to_cam_coord_offsets(self, table) -> Table:
|
817 | 834 | table["telescope_pointing_altitude"],
|
818 | 835 | frame=altaz,
|
819 | 836 | )
|
820 |
| - # Set the camera frame with the focal length and rotation of the camera |
| 837 | + # Set a new camera frame with the pixel rotation of the camera |
821 | 838 | camera_frame = CameraFrame(
|
822 |
| - focal_length=self.subarray.tel[tel_id].optics.equivalent_focal_length, |
| 839 | + focal_length=self.subarray.tel[tel_id].camera.geometry.frame.focal_length, |
823 | 840 | rotation=self.pix_rotation[tel_id],
|
824 | 841 | telescope_pointing=fix_tel_pointing,
|
825 | 842 | )
|
|
0 commit comments