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

Support reading sim_telarray DST0 files #1777

Open
ParsonsRD opened this issue Aug 24, 2021 · 3 comments
Open

Support reading sim_telarray DST0 files #1777

ParsonsRD opened this issue Aug 24, 2021 · 3 comments

Comments

@ParsonsRD
Copy link
Member

Hi all,
The reading of the DST0 files (essentially dl1 data level) produced by Konrad's sim_telarray is currently broken. When reading these files the pedestal subtraction is currently not performed correctly. This seems to be due to the following code in simteleventsource.py:

pedestal = cam_mon["pedestal"] / cam_mon["n_ped_slices"]
In this case cam_mon["n_ped_slices"] will have a value of whatever the number of slices was in the original simulation (typically something large like 40), but in the DST0 the pedestal stored is that of the integrated signal, i.e. a number of slices = 1. So will result in a subtraction of a far too low value. As far as I know there is no flag in the data to confirm that you are reading a DST0 file so a fix is not obvious. One option could be to use the n_samples length of the waveform from

n_gains, n_pixels, n_samples = adc_samples.shape

As this should always be the same as the pedestal samples for a sim_telarray output file, but one for a DST0 file. But there may be safer alternatives out there.

@ParsonsRD ParsonsRD changed the title Pedestal subration broken for sim_telarray DST0 files Pedestal subtraction broken for sim_telarray DST0 files Aug 24, 2021
@kosack
Copy link
Contributor

kosack commented Aug 24, 2021

Do you have an example DST0 file (ideally small) we could add to the test suite?

Right now SimTelEventSource only supports raw simtel files, but it should be easy to implement handling the DST format ones, either in SimTelEventSource itself, or a derived version. At the very least it should fail with an error if a DST0 file is used, so our current is_compatible() function is not sufficient.

I guess DST0 files just have the traces already integrated? Or are there other differences?

@ParsonsRD
Copy link
Member Author

Sure attached is my 10 event example file that I use for the template generation test functions. I found this issue when updating the template generation to v0.11.0.

gamma_HESS_example.simhess.gz

@kosack kosack added the bug label Aug 24, 2021
@kosack kosack added this to the v0.12.0 milestone Sep 15, 2021
@maxnoe maxnoe modified the milestones: v0.12.0, v0.12.1 Dec 6, 2021
@maxnoe maxnoe modified the milestones: v0.15.1, v0.16.0 Jun 2, 2022
@kosack kosack modified the milestones: v0.16.0, v0.17.0 Aug 26, 2022
@kosack kosack changed the title Pedestal subtraction broken for sim_telarray DST0 files Support reading sim_telarray DST0 files Aug 26, 2022
@maxnoe maxnoe modified the milestones: v0.17.0, v0.18.0 Sep 21, 2022
@maxnoe
Copy link
Member

maxnoe commented Jan 12, 2023

Sorry for only coming back to this now. The file you provided only contains ADCSums, not ADCSamples:

In the case where no adc samples are found in the SimTelEventSource, adc_samples is filled from adc_sums, upshaed to a 3d array.

From todays point of view, this is certainly wrong and should not be done, instead we should directly fill the DL1 images using the ADCSums, right?

for tel_id, telescope_event in telescope_events.items():
adc_samples = telescope_event.get("adc_samples")
if adc_samples is None:
adc_samples = telescope_event["adc_sums"][:, :, np.newaxis]

@maxnoe maxnoe linked a pull request Jan 19, 2023 that will close this issue
@maxnoe maxnoe modified the milestones: v0.18.0, v0.19.0 Jan 20, 2023
@kosack kosack modified the milestones: v0.20.0, v0.21.0 Sep 8, 2023
@maxnoe maxnoe modified the milestones: v0.21.0, 0.22.0 Mar 22, 2024
@maxnoe maxnoe modified the milestones: 0.22.0, 0.23.0 Sep 10, 2024
@maxnoe maxnoe removed this from the 0.23.0 milestone Nov 12, 2024
@maxnoe maxnoe added this to the 0.24.0 milestone Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants