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

JP-2922: Use new source_id syntax for level-3 products #8442

Merged
merged 21 commits into from
May 31, 2024

Conversation

hbushouse
Copy link
Collaborator

@hbushouse hbushouse commented Apr 26, 2024

Resolves JP-2922

Closes #7287

This PR updates all the source_id handling machinery within associations, calwebb_spec2 steps, and the calwebb_spec3 pipeline to handle the new source_id syntax for level-3 source-based products, which includes an increase in the number of source_id digits from 5 to 9, and implements the use of "b" and "v" source prefixes for NIRSpec MOS data extracted from background and virtual slits, respectively.

Note that the exp_to_source routine has been updated to use "source_name" as the key for sorting MOS datamodels, because it's the only piece of meta data available that properly distinguishes between "source", "background", and "virutal" slits. source_id values can overlap with one another for MOS now (e.g. a "real" source slit can have the same source_id value as a background slit). Other multi-slit modes (NIRSpec FS and NIRCam/NIRISS WFSS) still use source_id for sorting in exp_to_source, because they don't have source_name populated (names are unknown).

Checklist for maintainers

  • added entry in CHANGES.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant milestone
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR
  • Make sure the JIRA ticket is resolved properly

Copy link

codecov bot commented May 9, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 23 lines in your changes missing coverage. Please review.

Project coverage is 57.89%. Comparing base (4179c09) to head (60ada9b).
Report is 321 commits behind head on master.

Files with missing lines Patch % Lines
jwst/pipeline/calwebb_spec3.py 5.00% 19 Missing ⚠️
jwst/assign_wcs/nirspec.py 85.71% 3 Missing ⚠️
jwst/exp_to_source/exp_to_source.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8442      +/-   ##
==========================================
- Coverage   57.97%   57.89%   -0.09%     
==========================================
  Files         387      387              
  Lines       38830    38849      +19     
==========================================
- Hits        22513    22491      -22     
- Misses      16317    16358      +41     

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

@hbushouse
Copy link
Collaborator Author

Latest regression test run is here: https://plwishmaster.stsci.edu:8081/job/RT/job/JWST-Developers-Pull-Requests/1453/

Unfortunately it includes a large number of unrelated failures, due to an update to a NIRCam photom ref file earlier today. Remaining related failures are due to expected differences in file names and source_id values in multislit files. Will make another run once the truth files have been updated for the NIRCam photom change, just to make it simpler to sort out.

@hbushouse hbushouse marked this pull request as ready for review May 17, 2024 19:46
@hbushouse hbushouse requested review from nden and melanieclarke May 17, 2024 19:47
Copy link
Collaborator

@melanieclarke melanieclarke left a comment

Choose a reason for hiding this comment

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

This all looks good to me. I spot checked some MOS data with virtual and background slits, and found header values as described for SRCNAME, SOURCEID, and SRCALIAS. Filenames from spec3 also looked right.

Copy link
Collaborator

@nden nden left a comment

Choose a reason for hiding this comment

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

The new source names for virtual and background slits do not contain the program number any more. Is this on purpose? Is it what users would expect?

source_alias = "vrt_{}".format(abs(source_id))
stellarity = 0.0
source_ra = 0.0
source_dec = 0.0
Copy link
Collaborator

@nden nden May 23, 2024

Choose a reason for hiding this comment

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

This is a change in behavior. Previously source_x/ypos and source_ra/dec for virtual slits came from the msa file. I think it makes sense to get them from the msa file because the assumption is there are sources in those slits. For a program I checked those are set in the msa file and this code resets them to 0 which we probably don't want to do.
In terms of setting these attributes should virtual slits be treated like source slits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wow, you're right! I was (blindly) assuming that slits with a virtual source, identified by their negative source_id value in the MSA shutter table, would not have any corresponding info in the MSA source table, and hence was not even bothering to load it. But they do have entries in the source table. For example, here are the shutter table rows for virtual slit 87, which has source_id=-70. And there is a corresponding row in the source table for source_id=-70:

FITS_rec([(87, 88, 4, 345, 1, -70, 'N', 'OPEN', 0.5, 0.5, 1, 'Y'),
          (87, 88, 4, 345, 1,   0, 'Y', 'OPEN', nan, nan, 2, 'N'),
          (87, 88, 4, 345, 1,   0, 'Y', 'OPEN', nan, nan, 3, 'N')],

(1345, -70, '1345_-70', '-09:-039:0.0000 +53:00:57.29', 215.1912160802715, 53.01591471620116, 'None', 0.0)

The x/ypos values are set to 0.5 in the shutter table, so that won't have any change relative to the defaults I had been assigning, but it would result in real values for all the other items, like source_name (1345_-70), alias, ra, dec, and stellarity.

Good catch!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Latest commits have updated this function to get source info from the MSA source table for both "real" (source_id > 0) and virtual (source_id < 0) sources. No more zeroing out source-related info for slits with virtual sources.

@hbushouse
Copy link
Collaborator Author

@hbushouse
Copy link
Collaborator Author

Latest regtest run results show only expected differences in source-related keyword values for virtual slits, as well as slight differences in the PATHLOSS_PS array values for virtual slits, because they now have source position info. Also just a few unrelated differences due to other recent PR merges. So the whole run looks good.

Ready for a final review.

@hbushouse hbushouse requested review from nden and melanieclarke May 29, 2024 14:24
Copy link
Collaborator

@melanieclarke melanieclarke left a comment

Choose a reason for hiding this comment

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

LGTM!

@hbushouse
Copy link
Collaborator Author

@nden Do you want to have another look at this yet?

@nden
Copy link
Collaborator

nden commented May 30, 2024

I'll review today

@nden
Copy link
Collaborator

nden commented May 31, 2024

Something in the code was reverted and now the names of the virtual slits are the same as on master. On the positive side I see source_ra/dec for the virtual slits populated with the data from the msa file.

@hbushouse
Copy link
Collaborator Author

Something in the code was reverted and now the names of the virtual slits are the same as on master. On the positive side I see source_ra/dec for the virtual slits populated with the data from the msa file.

Something in the code was reverted and now the names of the virtual slits are the same as on master. On the positive side I see source_ra/dec for the virtual slits populated with the data from the msa file.

Yes, that's expected. The latest version of the code no longer does any "tweaking" of the source info for virtual slits, but instead just uses all the entries from the source table in the MSA file, so in essence they're treated exactly the same as regular source slits, hence we would not expect any difference in things like source name, alias, etc. compared to the existing code on master. The only special handling that virtual slits get now is to remove the negative sign from the source_id value when the source_id gets used to create the level-3 file names. Everything else, including their negative source_id's, funky source names and aliases, etc. are passed along unchanged from what's in the MSA file.

Copy link
Collaborator

@nden nden left a comment

Choose a reason for hiding this comment

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

Looks good

@nden nden merged commit 1a62240 into spacetelescope:master May 31, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment