-
Notifications
You must be signed in to change notification settings - Fork 77
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
Component class for adding pointing position using Drive Reports. #159
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.
Hi
I don't really get the approach now...
If there is already a LSTDriveContainer
that you are using, what is the need for another one here to contain (apparently?) the same info?
I thought the approach was globally:
- read raw data with
ctapipe_io_lst
--> fillLSTDriveContainer
- compute pointing position from the raw data --> update
event.pointing
Let me know what I got wrong here.
Hi Thomas @vuillaut Thanks for your comments
Perhaps, I didn't get your point. We wanted to have
I thought this is the way we wanted finally to proceed following our previous discussion in #153 |
Right, my bad, I read the code too quickly and though it was a |
c17ed19
to
420d58f
Compare
Looks good to me but if @FrancaCassol could have a quick look that'd be perfect. |
@FrancaCassol Can you have a look into this issue? |
Yes, sorry I will do it soon |
Hi @labsaha,
|
Hi @FrancaCassol,
ev_time is the arrival time for each of the event in the data file. I assume that the event container will have information filled with timing for each of the event. Once we have that information that will be passed to this class to do the interpolation
It will be simply like this
I don't know how you are handling timing information. If you have some code which is dealing with timing information for each of the events, please let me know. Then I can make a proper example file following this.
We may not need a separate directory. But to make it clear that this directory is for code dealing with pointing information, I created it. I think there is no harm in having a directory like this at this stage. Then it will be easy for developers to find out the scripts associated with different separate purposes. I think I have created this component class following your suggestions. I am not sure if I understood you correctly then.
Yes, I can do this once the previous issues you mentioned are solved. |
Hi @labsaha, I am afraid your approach is not really ctapipe compliant.
In ctapipe data are treated event wise, so you will not handle the time of several events at the time. Also, luckily you don't need it. Given that the driver position rate (0.5 Hz) is much slower than the event rate, for each event we need simply to find the time interval where the event occurred between two driver positions. From these two points we can simply linearly calculate the driver position at the event time (assuming the driver velocity is constant, but I think this is a reasonable assumption in a 2 second time interval during the data taking, what do you think @moralejo?). All this can be very easily done at the reader level as said several times.
ctapipe works event-wise, you find the timing information in the event containers (R0, R1, DL0). I strongly suggest you to have a deeper look at the structure of ctapipe and try the examples so to get accustomed to the capipe approach
Actually, I suggested to create a Component only if it does something more than the linear interpolation between two points, otherwise it seems to me a bit overdone. Could you please verify with the driver people if there are corrections that must be applied on the values that they give to us or some post treatments to be eventually included in lstchain? |
Perhaps the example I have given considering a time array is not suitable one. But one can just use event-wise like
Could you please specifically tell me which variable contains event-time in MC DL0 which is similar to what we will have as event time in the data file?
This is not just doing interpolation which is quick and easy but finding the time interval which is a bit expensive computationally and required to be done several times. |
After modifying the code on this PR a bit Daniel @morcuended has included the pointing positions on DL1 file of real data. He also included |
Here is an example of an altitude-vs-gps_time plot for the run 1491 (32 subruns) that lasts around 100 minutes: The altitude was calculated event-wise taking into account the gps_time values based on the NTP time stamps: |
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 @labsaha I think it is easier if you make the changes in this PR
lstchain/pointing/pointings.py
Outdated
|
||
""" | ||
timeL = ev_time[0] | ||
timeH = ev_time[-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.
Since ev_time
will be just a single value, I suggest deleting these two lines:
timeL = ev_time[0]
timeH = ev_time[-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.
Sure. We don't need it anymore
lstchain/pointing/pointings.py
Outdated
drive_container.El_avg = data['El_avg'].data | ||
xp = drive_container.time | ||
|
||
ind = np.where((xp >= timeL) & (xp <= timeH)) |
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.
In addition, the way to calculate the lower and upper elements of the drive time and their indices should be done like by adding these two lines:
lower_element = xp[xp < ev_time].max()
upper_element = xp[xp > ev_time].min()
and replacing ind = np.where((xp >= timeL) & (xp <= timeH))
by:
ind = np.hstack(
np.argwhere((xp >= lower_element) & (xp <= upper_element))
)
The rest keeps the same
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.
Do you really need the indexes?
A mask will be faster
time_in_window = (xp >= timeL) & (xp <= timeH)
run_times = xp[time_in_window]
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.
Ok. We can modify accordingly.
lstchain/pointing/pointings.py
Outdated
drive_container.El_avg = data['El_avg'].data | ||
xp = drive_container.time | ||
|
||
ind = np.where((xp >= timeL) & (xp <= timeH)) |
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.
Do you really need the indexes?
A mask will be faster
time_in_window = (xp >= timeL) & (xp <= timeH)
run_times = xp[time_in_window]
lstchain/pointing/pointings.py
Outdated
A table of drive reports | ||
|
||
""" | ||
from astropy.io import ascii |
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.
pep8 recommends making all imports at the beginning of the file
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.
Ok. We'll put it at the beginning
lstchain/pointing/pointings.py
Outdated
run_Az = drive_container.Az_avg[ind] | ||
run_El = drive_container.El_avg[ind] |
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.
pep8: no capital letter for variables
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.
Ok. Thanks
Do you want to update |
I think we will do it in this PR |
We will be needing this PR to be merged soon, @labsaha could you make the last changes to add the interpolated values so we can go ahead and merge? Thanks |
@rlopezcoto I got busy with some other things. I'll add the last changes today. |
).tag(config=True) | ||
|
||
tel_id = Int( | ||
0, |
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 tel_id be 1 instead of 0 here?
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 did it following the same piece of code defined in the component class of ctapipe
@morcuended will make a new PR to show how this can be used to get the |
Since some changes are suggested by @vuillaut following the PR at Related to failed checks: We don't understand why it failed. It doesn't seem that the script is related to the failed checks. |
I restarted the build and it worked. Since the ctapipe_io_lst PR was merged, is everybody is happy with the changes? |
@rlopezcoto Yes, @morcuended will make a separate PR for the interpolated values. |
was it though? 😅 |
Grrrrr |
PR we were waiting for was already merge. So this PR should be ready to merge as well. |
This is the new PR following our previous discussion at #153. @FrancaCassol @vuillaut Please have a look. This is following the Component class as designed in ctapipe.