Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coma aberration #72

Merged
merged 11 commits into from
Jun 20, 2022
13 changes: 11 additions & 2 deletions magicctapipe/scripts/lst1_magic/lst1_magic_event_coincidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from astropy.time import Time
from ctapipe.containers import EventType
from ctapipe.instrument import SubarrayDescription
from ctapipe.coordinates import CameraFrame
from lstchain.reco.utils import add_delta_t_key
from magicctapipe.utils import (
check_tel_combination,
Expand All @@ -57,6 +58,9 @@

accuracy_time = 1e-7 # final digit of a timestamp, unit: [sec]

nominal_foclen_lst = 28 # unit: [m]
effective_foclen_lst = 29.30565 # unit: [m]

tel_names = {
1: 'LST-1',
2: 'MAGIC-I',
Expand Down Expand Up @@ -98,10 +102,10 @@ def load_lst_data_file(input_file):

try:
# Try to load DL2 data at first:
event_data = pd.read_hdf(input_file, key=f'dl2/event/telescope/parameters/LST_LSTCam')
event_data = pd.read_hdf(input_file, key='dl2/event/telescope/parameters/LST_LSTCam')
except:
# Load DL1 data:
event_data = pd.read_hdf(input_file, key=f'dl1/event/telescope/parameters/LST_LSTCam')
event_data = pd.read_hdf(input_file, key='dl1/event/telescope/parameters/LST_LSTCam')

event_data.set_index(['obs_id', 'event_id', 'tel_id'], inplace=True)
event_data.sort_index(inplace=True)
Expand Down Expand Up @@ -156,6 +160,11 @@ def load_lst_data_file(input_file):
# Read the subarray description:
subarray = SubarrayDescription.from_hdf(input_file)

if focal_length == nominal_foclen_lst:
# Set the effective focal length to the subarray:
subarray.tel[1].optics.equivalent_focal_length = u.Quantity(effective_foclen_lst, u.m)
subarray.tel[1].camera.geometry.frame = CameraFrame(focal_length=u.Quantity(effective_foclen_lst, u.m))

return event_data, subarray


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def mc_dl0_to_dl1(input_file, output_dir, config, muons_analysis):
logger.info('\nLoading the input file:')
logger.info(input_file)

event_source = EventSource(input_file)
event_source = EventSource(input_file, focal_length_choice='effective')

obs_id = event_source.obs_ids[0]
subarray = event_source.subarray
Expand Down