Skip to content

Commit

Permalink
Merge pull request #233 from morcuended/fix_pointing
Browse files Browse the repository at this point in the history
Optimize pointing scripts
  • Loading branch information
rlopezcoto committed Nov 26, 2019
2 parents 6412af1 + 8f611b8 commit b3ca986
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions lstchain/pointing/pointings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _read_drive_report(self):
else:
raise Exception("No drive report file found")

def cal_pointingposition(self, ev_time):
def cal_pointingposition(self, ev_time, drive_data):
"""
Calculating pointing positions by interpolation
Expand All @@ -65,10 +65,9 @@ def cal_pointingposition(self, ev_time):
a container filled with drive information
"""
drive_container = LSTDriveContainer()
data = self._read_drive_report()
drive_container.time = data['time'].data
drive_container.azimuth_avg = data['azimuth_avg'].data
drive_container.altitude_avg = data['altitude_avg'].data
drive_container.time = drive_data['time'].data
drive_container.azimuth_avg = drive_data['azimuth_avg'].data
drive_container.altitude_avg = drive_data['altitude_avg'].data

xp = drive_container.time
lower_drive_time = xp[xp < ev_time].max()
Expand Down
10 changes: 7 additions & 3 deletions lstchain/reco/dl0_to_dl1.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ def r0_to_dl1(input_filename=get_dataset_path('gamma_test_large.simtel.gz'),

dl1_container = DL1ParametersContainer()

if pointing_file_path:
# Open drive report
pointings = PointingPosition()
pointings.drive_path = pointing_file_path
drive_data = pointings._read_drive_report()

extra_im = ExtraImageInfo()
extra_im.prefix = '' # get rid of the prefix

Expand Down Expand Up @@ -311,9 +317,7 @@ def r0_to_dl1(input_filename=get_dataset_path('gamma_test_large.simtel.gz'),
dl1_container.gps_time = gps_time

if pointing_file_path:
pointings = PointingPosition()
pointings.drive_path = pointing_file_path
azimuth, altitude = pointings.cal_pointingposition(utc_time.unix)
azimuth, altitude = pointings.cal_pointingposition(utc_time.unix, drive_data)
event.pointing[telescope_id].azimuth = azimuth
event.pointing[telescope_id].altitude = altitude
dl1_container.az_tel = azimuth
Expand Down

0 comments on commit b3ca986

Please sign in to comment.