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

Store both equivalent and effective focal length in OpticsDescription, add __slots__ #1923

Merged
merged 7 commits into from
Jul 11, 2022

Conversation

maxnoe
Copy link
Member

@maxnoe maxnoe commented Jun 2, 2022

This is adding a new field effective_focal_length to the optics description, so we don't need to choose there but when we actually do the transforms.

Like this, it's clear inside ctapipe what focal length is used when and it doesn't depend on options what is inside the OpticsDescription.

The choice options now say which of the focal lengths is attached to the CameraGeometry.frame attribute when creating the subarray, so all things loading a subarray (SimTelEventSource, HDF5EventSource, Subarray.from_hdf, TableLoader) now gain this option.

@maxnoe maxnoe force-pushed the optics_effective_focal_length branch 3 times, most recently from 0739a81 to b31fdec Compare June 2, 2022 14:40
@codecov
Copy link

codecov bot commented Jun 2, 2022

Codecov Report

Merging #1923 (6186848) into master (2b08140) will decrease coverage by 0.00%.
The diff coverage is 96.87%.

@@            Coverage Diff             @@
##           master    #1923      +/-   ##
==========================================
- Coverage   92.35%   92.34%   -0.01%     
==========================================
  Files         193      193              
  Lines       15585    15621      +36     
==========================================
+ Hits        14393    14425      +32     
- Misses       1192     1196       +4     
Impacted Files Coverage Δ
ctapipe/io/datawriter.py 90.09% <ø> (ø)
ctapipe/io/eventseeker.py 78.94% <ø> (ø)
ctapipe/io/tests/test_prod2.py 100.00% <ø> (ø)
ctapipe/tools/tests/test_process.py 95.58% <ø> (ø)
ctapipe/instrument/subarray.py 91.18% <88.88%> (-0.48%) ⬇️
ctapipe/io/simteleventsource.py 95.08% <88.88%> (-0.38%) ⬇️
ctapipe/instrument/optics.py 90.47% <93.75%> (-0.09%) ⬇️
ctapipe/conftest.py 94.25% <100.00%> (ø)
ctapipe/core/traits.py 95.16% <100.00%> (+0.01%) ⬆️
ctapipe/instrument/__init__.py 100.00% <100.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b08140...6186848. Read the comment docs.

nbiederbeck
nbiederbeck previously approved these changes Jun 28, 2022
@maxnoe maxnoe marked this pull request as ready for review June 28, 2022 15:48
@maxnoe maxnoe requested a review from nbiederbeck June 28, 2022 15:48
nbiederbeck
nbiederbeck previously approved these changes Jun 29, 2022
@maxnoe
Copy link
Member Author

maxnoe commented Jun 30, 2022

Let's merge this PR and the other one affecting the data model: #1949 and then I can recreate the higher level test data files with the new data model for the machine learning module.

@maxnoe maxnoe force-pushed the optics_effective_focal_length branch from f31afde to 91f9510 Compare July 4, 2022 15:27
@maxnoe maxnoe added this to the v0.16.0 milestone Jul 4, 2022
@maxnoe maxnoe requested review from kosack and nbiederbeck July 4, 2022 16:42
nbiederbeck
nbiederbeck previously approved these changes Jul 5, 2022
@maxnoe maxnoe force-pushed the optics_effective_focal_length branch from 91f9510 to 19bdf73 Compare July 5, 2022 11:54
@maxnoe maxnoe requested a review from nbiederbeck July 6, 2022 15:32
ctapipe/instrument/optics.py Show resolved Hide resolved
ctapipe/io/simteleventsource.py Show resolved Hide resolved
@maxnoe maxnoe force-pushed the optics_effective_focal_length branch 2 times, most recently from b92929b to 41abc58 Compare July 7, 2022 14:01
@maxnoe maxnoe requested a review from kosack July 7, 2022 14:04
@maxnoe maxnoe force-pushed the optics_effective_focal_length branch from 41abc58 to 687f38c Compare July 7, 2022 14:22
kosack
kosack previously approved these changes Jul 7, 2022
Copy link
Member

@vuillaut vuillaut left a comment

Choose a reason for hiding this comment

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

nominal and equivalent are the same thing right?
Maybe use a single consistent naming everywhere?

ctapipe/instrument/optics.py Outdated Show resolved Hide resolved
ctapipe/instrument/optics.py Outdated Show resolved Hide resolved
@@ -538,7 +547,7 @@ def to_hdf(self, h5file, overwrite=False, mode="a"):
meta["reference_itrs_z"] = itrs.z.to_value(u.m)

@classmethod
def from_hdf(cls, path):
def from_hdf(cls, path, focal_length_choice="effective"):
Copy link
Member

Choose a reason for hiding this comment

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

do we expect other possibilities than equivalent and effective in the future?
If not, a boolean effective=True might be less error prone than typing a string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I will use an enum instead

Copy link
Contributor

Choose a reason for hiding this comment

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

it's possible that in the future this is a calibration parameter that is measured in-situ as well. I know in HESS, for example, we store both the nominal and measured and have to correct for the difference, and for the HESS CT5 telescope, there is even an autofocus system that can dynamically change the focal length. So I agree that an ENUM is best here, in case we add other ways to obtain this information.

@maxnoe
Copy link
Member Author

maxnoe commented Jul 8, 2022

nominal and equivalent are the same thing right?

Only for single mirror telescopes, this is why the docstring says: "This is the nominal focal length for single mirror telescopes and the equivalent focal length for dual mirror telescopes". For dual mirror telescopes, there are two nominal focal lengths and the equivalent focal length is the thin lens focal length that would give the same image.

@vuillaut
Copy link
Member

vuillaut commented Jul 8, 2022

nominal and equivalent are the same thing right?

Only for single mirror telescopes, this is why the docstring says: "This is the nominal focal length for single mirror telescopes and the equivalent focal length for dual mirror telescopes". For dual mirror telescopes, there are two nominal focal lengths and the equivalent focal length is the thin lens focal length that would give the same image.

Sorry I read too quickly. Thank you for the explanation.

@maxnoe
Copy link
Member Author

maxnoe commented Jul 8, 2022

@vuillaut @kosack please review again, the num is now implemented.

@maxnoe
Copy link
Member Author

maxnoe commented Jul 8, 2022

Sorry @kosack, had to fix the docs build

@kosack kosack merged commit f6319f9 into master Jul 11, 2022
@kosack kosack deleted the optics_effective_focal_length branch July 11, 2022 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants