-
Notifications
You must be signed in to change notification settings - Fork 167
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
JP-3364 allow wcs shifts for IFU individual exposures in cube_build #8720
JP-3364 allow wcs shifts for IFU individual exposures in cube_build #8720
Conversation
Example of how to make an offset file: offsets['filename'] = [] af = asdf.AsdfFile({'offsets':offsets}) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8720 +/- ##
==========================================
+ Coverage 61.78% 61.81% +0.02%
==========================================
Files 377 377
Lines 38836 38915 +79
==========================================
+ Hits 23996 24056 +60
- Misses 14840 14859 +19 ☔ View full report in Codecov by Sentry. |
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 code looks good to me.
I did notice there was no update to the docs. This is important as the format of the file and the units of the offsets are needed info for users. These were questions I had that I found by reviewing the code changes. Updating the docs with this new option should be done.
@karllark I will definitely update the docs. I just want to make sure the approach I have made is what is expected. I need to include docs on how to make the asdf offset file. |
@tapastro I have included in a comment the code I used to create the asdf offset file. Does look about right ? |
Great. Yes, the approach makes sense to me. |
There was a comment about how you made the asdf file? I think I'm making mine incorrectly, as I'm getting errors using it. |
@drlaw1558 offsets['filename'] = [] af = asdf.AsdfFile({'offsets':offsets}) |
One thing I noticed- the code matches on local filenames, while associations can sometimes be full-path filenames. That's probably ok, but worth noting in the documentation that the ASDF file should contain only the filenames and not the full paths otherwise it won't match them properly. We'll also definitely need to give the above code to create input files explicitly in the documentation as ASDF files are very non-intuitive for most folks. Another thought: we probably want the offsets to be used in actual arcseconds rather than difference in sky coordinates. I.e., in the test case I'm using (PID 1523) I'm specifying an offset of 1.0 in both RA and in DEC, but the source is barely moving in the RA direction because of the cos(dec) term (this case is at 70 degrees South). We could choose either convention, but I think having offsets be consistent units of arcsec regardless of where we are on the sky makes most sense, and handle the cos(dec) translation to sky coordinates under the hood. |
@drlaw1558 I was wondering about the cos(dec) term. Since the user is creating the offset file I was not sure what made the most sense in how to specific what the ra offset should be. I used IFU cubes created from a single file and then centroided on the source to figure out a set of ra and dec offsets than I then feed back to cube build. I assume the cos(dec) term we need to apply is the dec of CRVAL2. Is this too circular ? Should we provide one work flow on how to do this. 1. Build a cube at a given crval1 and crval2 determine the ra and dec offset. This offset file is then provided to a new run of cube_build with the same crval1, crval2. Or am I thinking about this too narrowly |
@jemorrison These cubes are so small that the dec we use should be irrelevant; CRVAL2 should be fine, it doesn't matter if the new cubes use slightly different CRVAL1/CRVAL2 before/after the pointing tweak. Given that offsets are generally sub-arcsecond, I'd expect that any inconsistencies in which dec we use for the cos(dec) term should only matter at the few nano-arcsec level. We could also use the nanmedian of the input declinations, or the header keyword pointing information, whichever is simplest. |
6941f8c
to
cf90db7
Compare
I don't think I have the cos(dec) term correct. I am dividing by it - thinking when you are at large dec you want the offset to larger in ra . But the more I think about this I think I should just have this reviewed and someone can point out my mistakes cause that does not feel right to me. I might need a clearer description in the docs on that ra and dec offset - how they are determined - absolute not relative. |
4226727
to
1c5a745
Compare
I can not get the readthedocs built. Locally I get failures I have not idea how to fix: In the past I have used the cl results to look for doc error but I am not finding what is in the 'Details' at all helpful |
I tested your branch locally in my environment, and was able to build them (with some warnings), so it's probably an issue with your setup/local repo rather than the changes to the docs. Are you running |
Also, searching for 'warn' in the details from the docs build on CI, I think this is the relevant problem:
|
And one more comment, about getting the cosine term right -- it might be better to use an astropy SkyCoord or similar to do the offset math for you. |
@melanieclarke what version of sphinx should I have. I have Sphinx v7.4.7 |
The Sphinx version shouldn't be terribly important, as long as it's <8. Upgrading mine to 7.4.7 I am still able to build the docs on your branch. From the error message, it sounds like it's looking for a jwst import it can't find. If you're able to run the pipeline okay from the environment you're making the docs in, then it may be an issue with some old documentation artifacts or something like that - you could try doing a Otherwise, I'd recommend rebuilding your python environment and see if a fresh start sorts you out. |
Looks correct to me; inputs are assumed to be offsets in units of arcsec. Conversion to actual change in values of the RA coordinate divides this by cos(dec), which will result in making the value difference larger near the poles. Empirically, the shift that I see in data cubes processed with the code now look as expected too- specifying an offset of (1,1) moved the source the same number of spaxels N and E in the data cube. |
@drlaw1558 @nden Is this the right approach ? |
9fd6f69
to
dfa83a7
Compare
One last regtest run to make sure there are no interactions with other merged PRs: |
No relevant regtest failures. Merging now! |
Resolves JP-3364
Closes #7876
This PR addresses allows the user to provide a list of ra and decs for each input file. The shifts are provided in arc seconds
prior to the projections into the xi/eta space (tangent plane). This allows for a cube-space fix to the known WCS issue based on user-defined inputs. For each input file in the association cube_build creates the cubes there must be a ra and dec shift provided in an OFFSET file.
An ifuoffset.schema.yaml file was added to the cube_build step (instead of stdatamodels). This schema file defines the format of the offset file.
The offsets are defined by a filename, raoffset, and decoffset list. The units of the offset are required to be arcsec and are required to be in the offset file. This offset file must be an asdf file.
An example of how to make the offset files is provided in the documentation.
Checklist for PR authors (skip items if you don't have permissions or they are not applicable)
CHANGES.rst
within the relevant release sectionHow to run regression tests on a PR
https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1723/