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

Add Keck aperture #155

Merged
merged 38 commits into from
Mar 28, 2023
Merged

Add Keck aperture #155

merged 38 commits into from
Mar 28, 2023

Conversation

vkooten
Copy link
Collaborator

@vkooten vkooten commented Aug 30, 2022

This adds Keck aperture and lyot stop for Keck 2. It solves part of #134 and #153

Picture of aperture:
keck

@vkooten vkooten requested a review from ehpor August 30, 2022 18:09
@codecov
Copy link

codecov bot commented Aug 30, 2022

Codecov Report

Merging #155 (303b20b) into master (8a84f3e) will decrease coverage by 0.07%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #155      +/-   ##
==========================================
- Coverage   80.93%   80.86%   -0.07%     
==========================================
  Files          95       95              
  Lines        6923     7103     +180     
==========================================
+ Hits         5603     5744     +141     
- Misses       1320     1359      +39     
Impacted Files Coverage Δ
hcipy/aperture/__init__.py 100.00% <ø> (ø)
hcipy/aperture/realistic.py 91.84% <ø> (-4.73%) ⬇️

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Owner

@ehpor ehpor left a comment

Choose a reason for hiding this comment

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

  • There are lots of flake8 errors. You can look at Azure for a full list of them since the annotations only show the first twenty). Or you can run flake8 yourself locally.
  • Lots of whitespace issues. Hcipy uses tabs for indentation (I know... smh; I've been looking for a way to change this without clobbering the whole git history).
  • Add a pytest for the Keck aperture, making sure to check normalization and segmentation.
  • Put a PNG of the baseline aperture (as checked by the Pytest for an easy check for us and documentation).
  • You can also add the Keck aperture (not Lyot stop) to the telescope pupils tutorial. Or I can do that in a separate PR afterwards. Let me know which option you want.

Added by Iva on 23 Feb 2023:

  • make sure return_segments parameter works as it should, in aperture function
  • same for normalized, in aperture function
  • I don't see a central obscuration popping up, gotta fix that; in aperture function

hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
hcipy/aperture/realistic.py Outdated Show resolved Hide resolved
@ehpor ehpor added the enhancement New feature or request label Aug 30, 2022
@ehpor ehpor added this to the v0.6.0 release milestone Aug 30, 2022
@ehpor ehpor linked an issue Aug 30, 2022 that may be closed by this pull request
@ivalaginja
Copy link
Collaborator

ivalaginja commented Feb 25, 2023

  • Put a PNG of the baseline aperture (as checked by the Pytest for an easy check for us and documentation).

@ehpor do you really mean a PNG with this or the fits.gz files in the baseline folder of the tests? I wasn't able to find other PNG references.

Sorry for the billion commits and tests, I am flying a little blind since this branch is on a fork (that's not mine) and I didn't want to install the fork in dev mode, in a new env and so on.

I should be almost done with things, the tests pass when I copy-paste and run them locally. As for the tutorial notebook, I added what I think needs to be there but because of not importing the forked package I wasn't able to run it.

Happy to fix things if there is still something open or something went wrong.

@ivalaginja
Copy link
Collaborator

ivalaginja commented Feb 25, 2023

Two of the new tests are still failing, let me look into it...

@ivalaginja
Copy link
Collaborator

ivalaginja commented Feb 25, 2023

@ehpor please advise: the two tests that are failing do so because the reconstruction of the aperture from the segments does not have the central obscuration, while the original aperture does when with_spiders is True. This seems to be because Keck, as opposed to LUVOIR A, TMT and ELT does not generate the central obscuration by getting rid of a subset of segments in the center, instead it just uses a circular aperture.

This also made me notice how the Keck aperture uses the with_spiders keyword to control the presence of the spiders and central obscuration at the same time, which is not what the other telescopes do. There, the central obscuration is always there. Even when I change this so that the central obscuration is not tethered to that boolean and the obscuration is always there, the tests fail (now four of them instead of only two) because the from-segment reconstruction is not adding the central obscuration.

The simplest solution I see is to (a) always include the central obscuration in Keck, independent of with_spiders and (b) add the central obscuration to the reconstruction from segments in the test.

Thoughts?

Edit:
I just realized the solution I suggested above is not really possible because it would require the function check_aperture() to be able to identify the case in which it's testing case, and we'd need to put the diameter of the central obscuration in there. I'll stand by until I hear from you Emiel.

ivalaginja added a commit that referenced this pull request Mar 1, 2023
@ivalaginja ivalaginja requested a review from ehpor March 15, 2023 14:24
@ehpor
Copy link
Owner

ehpor commented Mar 15, 2023

@ivalaginja With the PNG, I literally mean a screenshot of DS9 of the fits file that serves as the baseline. In the past, even a glance at that file showed that the aperture was completely wrong. And people just let the code generate an aperture and assume that because the test passes, that they've implemented the Keck or VLT aperture correctly.

@ivalaginja
Copy link
Collaborator

@ivalaginja With the PNG, I literally mean a screenshot of DS9 of the fits file that serves as the baseline. In the past, even a glance at that file showed that the aperture was completely wrong. And people just let the code generate an aperture and assume that because the test passes, that they've implemented the Keck or VLT aperture correctly.

Where are those though? I wasn't able to locate them on the repo.

@ehpor
Copy link
Owner

ehpor commented Mar 15, 2023

In tests/baseline_for_apertures/keck/*. They're added by this PR.

@ehpor
Copy link
Owner

ehpor commented Mar 15, 2023

@ehpor please advise: the two tests that are failing do so because the reconstruction of the aperture from the segments does not have the central obscuration, while the original aperture does when with_spiders is True. This seems to be because Keck, as opposed to LUVOIR A, TMT and ELT does not generate the central obscuration by getting rid of a subset of segments in the center, instead it just uses a circular aperture.

This also made me notice how the Keck aperture uses the with_spiders keyword to control the presence of the spiders and central obscuration at the same time, which is not what the other telescopes do. There, the central obscuration is always there. Even when I change this so that the central obscuration is not tethered to that boolean and the obscuration is always there, the tests fail (now four of them instead of only two) because the from-segment reconstruction is not adding the central obscuration.

The simplest solution I see is to (a) always include the central obscuration in Keck, independent of with_spiders and (b) add the central obscuration to the reconstruction from segments in the test.

Thoughts?

Edit: I just realized the solution I suggested above is not really possible because it would require the function check_aperture() to be able to identify the case in which it's testing case, and we'd need to put the diameter of the central obscuration in there. I'll stand by until I hear from you Emiel.

The segments that are returned should be the illuminated part of the segment, not the full segment itself. Therefore, the segments in the first ring of Keck should contain the central obscuration. In principle, the sum of all the segments should be equal to the returned segments. This is what the test is checking for. This would be a few extra lines at the end of the function:

if return_segments:
    def segment_with_central_obscuration(segment):
        return lambda grid: segment(grid) * (1 - make_circular_aperture(central_obscuration_diameter)(grid))
    segments = [segment_with_central_obscuration(segment) for segment in segments]

or something like this without typos.

@ivalaginja ivalaginja self-assigned this Mar 20, 2023
@ivalaginja
Copy link
Collaborator

In tests/baseline_for_apertures/keck/*. They're added by this PR.

@ehpor just to clarify: this is supposed to be a plain png file, uncompressed? Any preferences on the file name? pupil.png, keck.png, keck_pupil.png? Am I seeing right that none of the other folders in baseline_for_apertures contains such a png file yet?

@ivalaginja
Copy link
Collaborator

I don't understand. Everything passes locally and I have no uncommitted changes except for the png file and the .DS_Store files, which is completely irrelevant.

@ivalaginja
Copy link
Collaborator

Ah. The old reference files do not have the central obscuration in some cases, while what I compare to locally does.

@ivalaginja
Copy link
Collaborator

There we go.

@ivalaginja ivalaginja requested review from ehpor and removed request for ehpor March 24, 2023 13:29
@ivalaginja
Copy link
Collaborator

Ready for review @ehpor

Copy link
Owner

@ehpor ehpor left a comment

Choose a reason for hiding this comment

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

LGTM.

@ehpor
Copy link
Owner

ehpor commented Mar 28, 2023

Flake8 doesn't report that it finished. This has to do with reviewdog, I think, see #174. I manually checked flake8 and it seems fine. Also, flake8 itself finished successfully on CI. I'm forcing a merge as admin.

@ehpor ehpor merged commit b646ebf into ehpor:master Mar 28, 2023
@ehpor
Copy link
Owner

ehpor commented Mar 28, 2023

Thanks for the contribution @vkooten! 🎉

@ivalaginja ivalaginja deleted the add_keck_aperture branch March 28, 2023 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Keck aperture
3 participants