Skip to content

Commit 3da5898

Browse files
authored
Merge pull request #155 from cta-observatory/choice_focal_length
Add choice of focal length
2 parents 84aa0b9 + 88f31dc commit 3da5898

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

dl1_data_handler/reader.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
List,
4747
CaselessStrEnum,
4848
Unicode,
49+
UseEnum,
4950
TelescopeParameter,
5051
)
5152
from ctapipe.instrument import SubarrayDescription
53+
from ctapipe.instrument.optics import FocalLengthKind
5254
from ctapipe.io import read_table
5355
from dl1_data_handler.image_mapper import ImageMapper
5456

@@ -192,6 +194,21 @@ class DLDataReader(Component):
192194
),
193195
).tag(config=True)
194196

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+
195212
min_telescopes = Int(
196213
default_value=1,
197214
help=(
@@ -270,7 +287,7 @@ def __init__(
270287
)
271288

272289
# 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)
274291
selected_tel_ids = None
275292
if self.allowed_tels is not None:
276293
selected_tel_ids = np.array(list(self.allowed_tels), dtype=np.int16)
@@ -318,7 +335,7 @@ def __init__(
318335
# Check that all files have the same SubarrayDescription
319336
for filename in self.files:
320337
# 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)
322339

323340
# Filter subarray by selected telescopes
324341
if selected_tel_ids is not None:
@@ -817,9 +834,9 @@ def _transform_to_cam_coord_offsets(self, table) -> Table:
817834
table["telescope_pointing_altitude"],
818835
frame=altaz,
819836
)
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
821838
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,
823840
rotation=self.pix_rotation[tel_id],
824841
telescope_pointing=fix_tel_pointing,
825842
)

0 commit comments

Comments
 (0)