Skip to content

Commit

Permalink
Merge pull request #206 from cta-observatory/remove_average_positions_mc
Browse files Browse the repository at this point in the history
Remove averaging of positions in MCs.
  • Loading branch information
aleberti authored Feb 19, 2024
2 parents 82c573b + 3e46fb4 commit 3cad717
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions magicctapipe/scripts/lst1_magic/lst1_magic_mc_dl0_to_dl1.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import numpy as np
import yaml
from astropy import units as u
from astropy.coordinates import Angle, angular_separation
from ctapipe.calib import CameraCalibrator
from ctapipe.image import (
Expand All @@ -38,7 +37,7 @@
number_of_islands,
timing_parameters,
)
from ctapipe.instrument import FocalLengthKind, SubarrayDescription
from ctapipe.instrument import FocalLengthKind
from ctapipe.io import EventSource, HDF5TableWriter
from traitlets.config import Config

Expand Down Expand Up @@ -392,28 +391,8 @@ def mc_dl0_to_dl1(input_file, output_dir, config, focal_length):
n_events_processed = event.count + 1
logger.info(f"\nIn total {n_events_processed} events are processed.")

# Convert the telescope coordinate to the one relative to the center
# of the LST and MAGIC positions, and reset the telescope IDs
position_mean = u.Quantity(list(tel_positions.values())).mean(axis=0)

tel_positions_lst_magic = {}
tel_descriptions_lst_magic = {}
IDs_in_use = np.asarray(list(assigned_tel_ids.values()))
IDs_in_use = IDs_in_use[IDs_in_use > 0]
for k in IDs_in_use:
tel_positions_lst_magic[k] = tel_positions[k] - position_mean
tel_descriptions_lst_magic[k] = tel_descriptions[k]

subarray_lst_magic = SubarrayDescription(
"LST-MAGIC-Array", tel_positions_lst_magic, tel_descriptions_lst_magic
)
tel_positions = subarray_lst_magic.positions

logger.info("\nTelescope positions:")
logger.info(format_object(tel_positions))

# Save the subarray description
subarray_lst_magic.to_hdf(output_file)
subarray.to_hdf(output_file)

# Save the simulation configuration
with HDF5TableWriter(output_file, group_name="simulation", mode="a") as writer:
Expand Down

0 comments on commit 3cad717

Please sign in to comment.