-
Notifications
You must be signed in to change notification settings - Fork 78
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
Time lapse corr spike b #167
Time lapse corr spike b #167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add some comments on the code about the nature of the spikes and why they need to be interpolated
It would also be great to have some pep8-ing of the code (spaces between operator...) to improve the readability.
lstchain/calib/camera/r0.py
Outdated
@@ -341,15 +340,18 @@ def do_time_lapse_corr(waveform, expected_pixel_id, local_clock_list, fc, last_t | |||
val = waveform[gain, pixel, k] - ped_time(time_diff_ms) | |||
waveform[gain, pixel, k] = val | |||
|
|||
# updating times from slices -1 to 38 remove spike b (small jump of signal) | |||
# without interpolation (Seiya Nozaki idea) | |||
posads0 = int((0 + fc[nr_module, gain, pix]) % size4drs) | |||
if posads0+40 < 4096: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of 4096, I would use some variable name, like len_drs4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lstchain/calib/camera/r0.py
Outdated
interpolate_spike_B(waveform, gain, spike_b_position, pixel) | ||
# The correction is only needed for even last capacitor (lc) in the | ||
# first half of the DRS4 ring | ||
if (fc_old[nr_module, gain, pix] + 39) % 2 == 0 and (fc_old[nr_module, gain, pix] + 39) % 1024 <= 510: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numbers like 38, 39 could be len_drs4_window
(or something like that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
else: | ||
for k in prange(0, 39): | ||
for k in prange(-1, 39): | ||
posads = int((k + fc[nr_module, gain, pix]) % size4drs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this run to 38?
@rlopezcoto Thanks for comments. |
Hi @pawel21, |
Hi @FrancaCassol But the dt correction function and spike interpolation are messy, because multiple conditions change, and also things can be optimized differently (e.g. the old correction required updating times from one capacitor before the actual readout to 38th capacitor including, and the code was optimized to avoid too many loops. Now the special cases when you cross the ring look different. |
Hi @rlopezcoto , @FrancaCassol , @SeiyaNozaki I made some clean-up. Please look at my new codes and get this into the lstchain master as soon as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pawel21, this looks very good, I'd recommend it to be merged as soon as you have performed the small corrections I suggested
lstchain/calib/camera/r0.py
Outdated
@@ -252,24 +315,80 @@ def interpolate_pseudo_pulses(waveform, expected_pixel_id, fc, fc_old, n_modules | |||
for pix in prange(0, n_pix): | |||
for k in prange(0, 4): | |||
# looking for spike A first case | |||
abspos = int(1024 - roisize - 2 - fc_old[nr_module, gain, pix] + k * 1024 + size4drs) | |||
abspos = int(1025 - roi_size - 2 - fc_old[nr_module, gain, pix] + k * 1024 + size4drs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define 1025 as size1drs
+ 1, with size1drs
= 1024 or something like that?
Could you please also add a small explanation about this change as a comment? we had some e-mail interchange that may be lost for the future...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
# last capacitor (lc) in the first half of the | ||
# DRS4 ring | ||
if ((fc_old[nr_module, gain, pix] + (roi_size-1)) % 2 == 0 and (fc_old[nr_module, gain, pix] + (roi_size-1)) % 1024 <= 511): | ||
pixel = expected_pixel_id[nr_module * 7 + pix] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, 511 can be size1drs
/2 - 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lstchain/calib/camera/r0.py
Outdated
for pix in prange(0, n_pix): | ||
for k in prange(0, 4): | ||
# looking for spike A first case | ||
abspos = int(1024 - roi_size - 2 -fc_old[nr_module, gain, pix]+ k * 1024 + size4drs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comments as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lstchain/calib/camera/r0.py
Outdated
roi_size = 40 | ||
for nr_module in prange(0, number_of_modules): | ||
time_now = local_clock_list[nr_module] | ||
for gain in prange(0, 2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(0, n_gain)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lstchain/calib/camera/r0.py
Outdated
for nr_module in prange(0, number_of_modules): | ||
time_now = local_clock_list[nr_module] | ||
for gain in prange(0, 2): | ||
for pix in prange(0, 7): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(0, n_pix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lstchain/calib/camera/r0.py
Outdated
@@ -170,25 +191,57 @@ def time_lapse_corr(self, event, tel_id): | |||
event : `ctapipe` event-container | |||
tel_id : id of the telescope | |||
""" | |||
|
|||
run_id = event.lst.tel[1].svc.configuration_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pawel21,
please, change tel[1] with tel[tel_id]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hi @rlopezcoto , for me this code is good for merging |
I have modified code according Seiya's Nozaki idea:
Updating times from slices -1 to 38 remove spike b (small jump of signal) without interpolation (Seiya Nozaki idea).
Interpolation spike A is only needed for even last capacitor (lc) in the first half of the DRS4 ring.