glue-viz / glue-astronomy

Plugin to add astronomy-specific functionality to glue
https://glue-astronomy.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
11 stars 13 forks source link

allow override of wcs when computing sky region in roi_subset_state_to_region #96

Closed cshanahan1 closed 11 months ago

cshanahan1 commented 12 months ago

In JDaviz (Cubeviz, specifically), sometimes subsets don't contain spatial wcs information in subset.xatt.coords, which is what is used for the pixel-to-sky conversion in roi_subset_state_to_region. To fix this issue, this PR adds the option to provide a different WCS for the conversion, which will override anything in .coords.

(See https://github.com/spacetelescope/jdaviz/pull/2496)

cshanahan1 commented 11 months ago

Looks like I pushed some commits i made before seeing the most recent review comments - I added tests (and moved the old one that tested to_sky) and implemented @pllim of overloading to_sky to allow a new WCS to override anything attached to the subset.

dhomeier commented 11 months ago

Thanks, tests look good! I still would just like to see the exception for an invalid or missing wcs in .coords (the original issue above) tested.

pllim commented 11 months ago

Ideally this should perhaps even use two different WCS to make sure the user-provided is used

Let's not do that. Ideally, subset state should always refer to its parent. But in Cubeviz, we have to hack around the fact that cube ingested into Cubeviz somehow contains .coords without the original spatial WCS info (I cannot find that issue for cross-linking right now). So ideally when this problem is fixed properly, no one will ever have to pass in to_sky as a WCS ever again.

pllim commented 11 months ago

Actually.... I just realized that you do not really need this PR, @cshanahan1 . Since you only use this function to compute pixel region, and then convert to sky region internally in Jdaviz, given that you want to keep both pixel and sky.

😬

dhomeier commented 11 months ago

Let's not do that. Ideally, subset state should always refer to its parent. But in Cubeviz, we have to hack around the fact that cube ingested into Cubeviz somehow contains .coords without the original spatial WCS info

Thanks for the background – that explains why it all appears a bit hackish atm :D! So you think no test for invalid input is needed either?

pllim commented 11 months ago

I actually don't think this PR is needed at all. I am going to revisit https://github.com/spacetelescope/jdaviz/pull/2496 shortly.

dhomeier commented 11 months ago

Thanks; keep me posted! I think we may still want to keep some of the extra test coverage and doc updates.

cshanahan1 commented 11 months ago

I parameterized the tests which is also something we can keep even if we don't move forward with allowing 'to_sky' to be a WCS.

cshanahan1 commented 11 months ago

I'm going to open a PR on a new branch that just has the test + documentation changes we want to keep from this, and close this PR (but keep it separate in case we want to revisit this)

cshanahan1 commented 11 months ago

Closing this for now, doc + test changes we want to keep are in https://github.com/glue-viz/glue-astronomy/pull/97