Skip to content

Commit e9959cb

Browse files
committed
add overwriting of reference location for the MCs
1 parent 35a358f commit e9959cb

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

dl1_data_handler/reader.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
CInt,
4343
Int,
4444
IntTelescopeParameter,
45+
Float,
4546
Set,
4647
List,
4748
CaselessStrEnum,
@@ -52,6 +53,12 @@
5253
from ctapipe.io import read_table
5354
from dl1_data_handler.image_mapper import ImageMapper
5455

56+
#: Area averaged position of LST-1, MAGIC-1 and MAGIC-2 (using 23**2 and 17**2 m2)
57+
REFERENCE_LOCATION = EarthLocation(
58+
lon=-17.890879 * u.deg,
59+
lat=28.761579 * u.deg,
60+
height=2199 * u.m, # MC obs-level
61+
)
5562
# Reference (dummy) time to insert in the SkyCoord object as the default time
5663
LST_EPOCH = Time("2018-10-01T00:00:00", scale="utc")
5764

@@ -161,6 +168,30 @@ class DLDataReader(Component):
161168
help="Skip files that are not compatible to the reference instead of raising an error",
162169
).tag(config=True)
163170

171+
reference_position_lon = Float(
172+
default_value=REFERENCE_LOCATION.lon.deg,
173+
help=(
174+
"Longitude of the reference location for telescope GroundFrame coordinates."
175+
" Default is the roughly area weighted average of LST-1, MAGIC-1 and MAGIC-2."
176+
)
177+
).tag(config=True)
178+
179+
reference_position_lat = Float(
180+
default_value=REFERENCE_LOCATION.lat.deg,
181+
help=(
182+
"Latitude of the reference location for telescope GroundFrame coordinates."
183+
" Default is the roughly area weighted average of LST-1, MAGIC-1 and MAGIC-2."
184+
)
185+
).tag(config=True)
186+
187+
reference_position_height = Float(
188+
default_value=REFERENCE_LOCATION.height.to_value(u.m),
189+
help=(
190+
"Height of the reference location for telescope GroundFrame coordinates."
191+
" Default is current MC obslevel."
192+
)
193+
).tag(config=True)
194+
164195
allowed_tel_types = List(
165196
default_value=None,
166197
allow_none=True,
@@ -269,8 +300,16 @@ def __init__(
269300
f"When processing real observational data, please provide a single file (currently: '{len(self.files)}')."
270301
)
271302

303+
# Set the reference location from the config
304+
reference_location = EarthLocation(
305+
lon=self.reference_position_lon * u.deg,
306+
lat=self.reference_position_lat * u.deg,
307+
height=self.reference_position_height * u.m,
308+
)
272309
# Set up the subarray
273310
self.subarray = SubarrayDescription.from_hdf(self.first_file)
311+
# Overwrite the reference location of the subarray
312+
self.subarray.reference_location = reference_location
274313
selected_tel_ids = None
275314
if self.allowed_tels is not None:
276315
selected_tel_ids = np.array(list(self.allowed_tels), dtype=np.int16)
@@ -317,7 +356,8 @@ def __init__(
317356
for filename in self.files:
318357
# Read SubarrayDescription from the new file
319358
subarray = SubarrayDescription.from_hdf(filename)
320-
359+
# Overwrite the reference location of the subarray
360+
subarray.reference_location = reference_location
321361
# Filter subarray by selected telescopes
322362
if selected_tel_ids is not None:
323363
subarray = subarray.select_subarray(self.tel_ids)

0 commit comments

Comments
 (0)