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 basic sky coordinates (WCS) to ScopeSim output #307

Merged
merged 12 commits into from
Dec 13, 2023
Merged

Conversation

teutoburg
Copy link
Contributor

@teutoburg teutoburg commented Dec 11, 2023

  1. Add two functions in optics/image_plane_utils: det_wcs_from_sky_wcs() and sky_wcs_from_det_wcs(), which convert detector (mm) WCS into on-sky (arcsec or deg) WCS and vice versa using the pixel and plate scales. Both in turn use the function create_wcs_from_points(), which has been slightly modified as well. There used to be a bit of a less-than-ideal state because a sky WCS could use either arcsec or deg and ScopeSim is not fully consistent with that, which may lead to bugs if one or the other is incorrectly assumed. All three functions now use astropy units, which is also not ideal for performance, but acceptable for now until we can be certain our units are consistent. If a non-quantity (i.e. float) is passed, a reasonable (documented) unit is assumed. The function header_from_list_of_xy(), which internally also calls create_wcs_from_points(), is unchanged in its parameters and still uses the arcsec flag. This function might be phased out mostly in favor of direct calls to create_wcs_from_points().
  2. Adaptions to these changes in several places, most importantly in FOVManager.generate_fov_list(), which now uses det_wcs_from_sky_wcs(). The code previously there was the main inspiration for the two new functions.
  3. Include the (approximate) on-sky WCS in Detector.hdu, which was the main motivation to do all of this. This will be collected by DetectorArray.readout() and thus also included in the output from OpticalTrain.readout(). In the process, some minor changes to DetectorArray as a whole, mostly documentation, some comments, and everyone's favorite: formatting and linting 🙃
  4. Remove some obsolete lines from OpticalTrain.write_header(), notably the WCS and some input file names, see also Deal with header keywords #305 .
  5. Some minor formatting and cleanup in a few other places.
  6. Add tests for the new WCS functions to ensure a round-trip of sky ➡️ detector ➡️ sky works.

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (262e894) 80.07% compared to head (69fa9a8) 80.28%.

Files Patch % Lines
scopesim/detector/detector_array.py 85.71% 1 Missing ⚠️
scopesim/effects/psf_utils.py 0.00% 1 Missing ⚠️
scopesim/optics/fov.py 90.00% 1 Missing ⚠️
scopesim/optics/image_plane_utils.py 97.91% 1 Missing ⚠️
scopesim/optics/optical_train.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           dev_master     #307      +/-   ##
==============================================
+ Coverage       80.07%   80.28%   +0.20%     
==============================================
  Files             147      147              
  Lines           14819    14844      +25     
==============================================
+ Hits            11866    11917      +51     
+ Misses           2953     2927      -26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: teutoburg <ghost@instruct.at>
@teutoburg teutoburg changed the title Fh/header Add basic sky coordinates (WCS) to ScopeSim output Dec 11, 2023
@teutoburg teutoburg added enhancement New feature or request refactor Implementation improvement tests Related to unit or integration tests labels Dec 11, 2023
This should not happen here at all. Either this is done in apply_to
anyway, or need to do it somewhere else, but not here.
@teutoburg teutoburg marked this pull request as ready for review December 12, 2023 19:53
Copy link
Collaborator

@hugobuddel hugobuddel left a comment

Choose a reason for hiding this comment

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

Great work @teutoburg !

Did you test the IRDB against this branch? I'm a bit worried that this change might break some expectations in the IRDB. But nevertheless I think it is okay to merge this and tackle the problems afterwards. We should be ready for that though.

What still is missing is that the WCS coordinates are not yet added to the headers if any fits header Effects are defined. That is fine for now, as we haven't really defined how to proceed, but all options require this cleanup first and we shouldn't put everything in one PR.

@teutoburg
Copy link
Contributor Author

Did you test the IRDB against this branch? I'm a bit worried that this change might break some expectations in the IRDB. But nevertheless I think it is okay to merge this and tackle the problems afterwards. We should be ready for that though.

Didn't do that yet, but planning to. As you say, should be fine to do it after merging (but before any new release).

What still is missing is that the WCS coordinates are not yet added to the headers if any fits header Effects are defined. That is fine for now, as we haven't really defined how to proceed, but all options require this cleanup first and we shouldn't put everything in one PR.

Yes, that was intentional, to keep things separate that are technically separate. If one or the other ends up breaking something, it'll be easier to deal with it I guess.

@teutoburg teutoburg merged commit 0510a49 into dev_master Dec 13, 2023
22 checks passed
@teutoburg teutoburg deleted the fh/header branch December 13, 2023 13:26
@teutoburg
Copy link
Contributor Author

Yes, that was intentional, to keep things separate that are technically separate. If one or the other ends up breaking something, it'll be easier to deal with it I guess.

Small correction, the WCS should be included anyway, as it's created directly in the Detector. Unless there is some overwriting going on that I'm unaware of...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Implementation improvement tests Related to unit or integration tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants