-
Notifications
You must be signed in to change notification settings - Fork 269
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
Chunk interpolation to select calibration data #2634
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
Analysis Details1 IssueCoverage and DuplicationsProject ID: cta-observatory_ctapipe_AY52EYhuvuGcMFidNyUs |
|
||
return np.nan | ||
|
||
self._interpolators[tel_id][column] = interpolate_chunk |
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 think it's a bit weird here to store closures in a dict instead of just calling a method with tel_id
and column
that then checks if the necessary table exists.
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, i'll change it to a method
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.
The current implementation follows the PointingInterpolator approach, but of course can be changed.
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.
so, _check_interpolators
in the parent class assumes the current implementation. If i change it to what you describe i will need to make changes to the parent class or forgo this check for the ChunkInterpolator
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.
Maybe keeping it like this is better.
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.
👍 Looks good, the __call__
method is missing on the interface though
I am not sure if putting the private methods you listed here to the base class will work out in the end, but you'll see how much code can be shared between the chunk interpolator and the linear interpolator.
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, i'll work on the implementation now.
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.
Shall we take an opportunity and stop using interp1d
? It is legacy, andscipy
suggests this: https://docs.scipy.org/doc/scipy/tutorial/interpolate/1D.html#tutorial-interpolate-1dsection
Also, if we call a base class LinearInterpolator, I guess we should enforce linearity (in the example above, e.g. cubic spline can be applied)
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.
There is no replacement for linear 1d interpolation for interp1d. It is legacy, but not deprecated.
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 also got tricked by "may be removed in the future"
I am a bit stuck here with one of the tests. test_hdf5 is failing in pytest begause the data from the file is not loaded correctly. When i look in the test what x and y values the interpolators have i get some wrong values. However if i try to do the same outside of pytest it works. I used this code to test by myself:
Has anyone an idea what is wrong here? |
@@ -57,7 +173,7 @@ def test_invalid_input(): | |||
wrong_unit = Table( | |||
{ | |||
"time": Time(1.7e9 + np.arange(3), format="unix"), | |||
"azimuth": [1, 2, 3] * u.deg, | |||
"azimuth": np.radians([1, 2, 3]) * u.rad, |
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.
Why did you change these tests 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.
The test is explicitly to test the unit conversion, so please don't change to rad
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.
The PointingInterpolator
is supposed to use radians for input:
157 expected_units = {"azimuth": u.rad, "altitude": u.rad}
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.
right, and this test checks that correct exception is raised in case the units are not matching. Please revert back
@@ -72,8 +188,8 @@ def test_hdf5(tmp_path): | |||
table = Table( | |||
{ | |||
"time": t0 + np.arange(0.0, 10.1, 2.0) * u.s, | |||
"azimuth": np.linspace(0.0, 10.0, 6) * u.deg, |
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
@@ -82,8 +198,8 @@ def test_hdf5(tmp_path): | |||
with tables.open_file(path) as h5file: | |||
interpolator = PointingInterpolator(h5file) | |||
alt, az = interpolator(tel_id=1, time=t0 + 1 * u.s) | |||
assert u.isclose(alt, 69 * u.deg) | |||
assert u.isclose(az, 1 * u.deg) | |||
assert u.isclose(alt, np.radians(69) * u.rad) |
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
@ctoennis the problem you're experiencing with the test is because you have class attributes in the base class that are shared between the class instances, including the |
@mexanick Thanks, i got the issue fixed. |
I will need a method to select calibration data for the strar tracker. I made some slides to decribe how it is supposed to work:
https://docs.google.com/presentation/d/1oxIcYSQvGnU7IQYy3fGdcv0qXiLpvaXR9YtmnDesj4Y/edit?usp=sharing