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

Correct filling of photo_electron_image container in SimtelEventSource #943

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ctapipe/io/simteleventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def __generator(self):
telescope_events = array_event['telescope_events']
tracking_positions = array_event['tracking_positions']
for tel_id, telescope_event in telescope_events.items():
tel_index = self.file_.header['tel_id'].tolist().index(tel_id)
telescope_description = self.file_.telescope_descriptions[tel_id]

data.mc.tel[tel_id].dc_to_pe = array_event['laser_calibrations'][tel_id]['calib']
Expand All @@ -205,12 +206,11 @@ def __generator(self):
data.mc.tel[tel_id].time_slice = float(pixel_settings['time_slice'])

n_pixel = data.r0.tel[tel_id].waveform.shape[-2]

data.mc.tel[tel_id].photo_electron_image = array_event.get(
'photoelectrons', {}
).get(tel_id)
if data.mc.tel[tel_id].photo_electron_image is None:
data.mc.tel[tel_id].photo_electron_image = np.zeros((n_pixel, ), dtype='i2')
data.mc.tel[tel_id].photo_electron_image = (
array_event.get('photoelectrons', {})
.get(tel_index, {})
.get('photoelectrons', np.zeros(n_pixel, dtype='float32'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is np.zeros correct here? or should it be np.nans since we have no idea what the values are ... instead of being sure they were zeros.

Copy link
Member

@dneise dneise Jan 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it was also np.zeros before this PR .. so this PR is in principle not responsible for adressing this .. but still.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np.zeros was what was returned in the case of HESSIOEventSource, but I don't have a strong opinion about what to return...

For normal simtel files (prod3+), the np.zeros will never be returned anyway. Only in the case of the prod2 test files

)

tracking_position = tracking_positions[tel_id]
data.mc.tel[tel_id].azimuth_raw = tracking_position['azimuth_raw']
Expand Down