Closed stscijgbot-jp closed 2 months ago
Comment by Howard Bushouse on JIRA:
Tyler Pauly I'm downloading the data for this right now from MAST and will put in ██████████████████████████████████████████ when I've got them. Given that the level 2 and 3 products in MAST right now are from 1.8.2 processing, I'm retrieving the uncal files, so that we can reprocess with 1.9.6 all the way from the start, just in case anything else upstream leads to changes that would not make this a fair test.
Comment by Howard Bushouse on JIRA:
Hien Tran Looking more carefully at the log above, I'm confused. First I see "jw02783002001_03103_00001-seg001_mirimage_calints.fits" being processed successfully through the extract_1d and white_light steps, but then it fails when processing "jw02783_001001_4103_00001-seg002_mirimage_calints.fits". Those two datasets are from different observations (obs-002 and obs-001) and also have different activity id's. On the surface it seems to me like those don't belong together in the same level 3 association. So maybe that's the problem (in the generation of the tso3 ASN?). We'll check.
Comment by Tyler Pauly on JIRA:
The crash is a result of code added for JP-2677, which made an assumption that all science models in the input association are segments corresponding to one int_times
table. The input c1000_tso3 association here has all segments from obs 001 but also a segment from o002. The pool states that both observations are science, and also pairs them in a group association candidate (c1000), while APT shows obs 002 is listed as a background observation. I would suggest that we ask APT/MIRI team/program PI if obs002 should be labelled as a background observation, such that its spectra are not included in the final output x1dints file.
It's not clear if tso3 is working improperly - is it expected that we'll have group-level association candidates where we are merging observations with separate int_times
tables into a final product with entries from both/multiple int_times
? This may be the question for MIRI team/CalWG.
Comment by Sarah Kendrew on JIRA:
Observation 2 is a dedicated background, which we are now recommending that people take with LRS slitless observations. The pipeline shouldn't try to subtract this from the science data though, and it should not be folded into the science data product (not sure if I'm interpreting Tyler Pauly 's comment above correctly). Apologies, we should have checked with the pipeline whether this would cause issues.
Comment by Tyler Pauly on JIRA:
Hi Sarah Kendrew , my understanding of the remaining issue (which may be limited) is that observation 2, labeled "background observation" in APT, is not pointing to a target that is defined as a background. Because the target is not defined as a BKGDTARG, no background labels will be applied to exposures in associations for processing. The pool file will not show any observations as backgrounds, because the label field of the observation in APT is not carried forward.
The pipeline issue will likely continue unless a second target is defined which is labeled as a background target in the program. I think further questions should maybe be directed towards APT, as the pipeline problem is really a downstream effect of the APT program settings.
Comment by Sarah Kendrew on JIRA:
OK thanks Tyler Pauly . How big of an issue is it if we do nothing? I think it's fine for these observations to not go through level 3 processing, but if every time the error arises it creates pesky work for someone, then we can obv find a workaround.
looks like we have another case of this issue with new data jw02965-c1000_20230709t121734_tso3_00001, a MIR_LRS-SLITLESS tso3 asn consisting of obs 1 (target) & 2 (bkgrn), with 2 defined as a GROUP association candidate, not BACKGROUND.
Comment by Howard Bushouse on JIRA:
Tyler Pauly do you have a copy of the pool file for this program? If so, could you put it in █████████████████████████████████████████ along with the other data files for this?
Comment by Howard Bushouse on JIRA:
The only obvious difference in meta data between the obs-1 and obs-2 data are the XOFFSET/YOFFSET values, due to the use of the special requirement in obs-2 to move the target out of the aperture. Unfortunately those particular values are not included in the pool files and hence it may not be possible to use them (at least not easily) in updated ASN rules to exclude the obs-2 background exposure(s) from the level-3 ASN. Similarly, it would also not be easy to have APT exclude them from the c1000 candidate ID, because it too has no obvious indicators to suggest anything unusual about obs-2 (other than the SR with the offset).
Comment by John Scott on JIRA:
We have another case, jw03548-c1000_20230724t111939_tso3_00001, which is a new observation processed with build 9.2.2
2023-07-24 14:33:52,497 - stpipe.Tso3Pipeline.extract_1d - INFO - Step extract_1d done
Traceback (most recent call last):
File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.10.1.20230413-py3.9/bin/strun", line 28, in <module>
step = Step.from_cmdline(sys.argv[1:])
File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.10.1.20230413-py3.9/lib/python3.9/site-packages/stpipe/step.py", line 179, in from_cmdline
return cmdline.step_from_cmdline(args)
File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.10.1.20230413-py3.9/lib/python3.9/site-packages/stpipe/cmdline.py", line 343, in step_from_cmdline
step.run(*positional)
File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.10.1.20230413-py3.9/lib/python3.9/site-packages/stpipe/step.py", line 454, in run
step_result = self.process(*args)
File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.10.1.20230413-py3.9/lib/python3.9/site-packages/jwst/pipeline/calwebb_tso3.py", line 173, in process
x1d_result.int_times[row[0] - 1] = row
File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.10.1.20230413-py3.9/lib/python3.9/site-packages/astropy/io/fits/fitsrec.py", line 574, in __setitem__
self.field(self.names[idx])[key] = value.field(self.names[idx])
IndexError: index 165 is out of bounds for axis 0 with size 10 ```
Comment by John Scott on JIRA:
Also jw01274-c1000_20231114t122509_tso3_00001
Traceback (most recent call last):File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.11.4.20230814-py3.9/bin/strun", line 26, in <module>step = Step.from_cmdline(sys.argv[1:])File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.11.4.20230814-py3.9/lib/python3.9/site-packages/stpipe/step.py", line 186, in from_cmdlinereturn cmdline.step_from_cmdline(args)File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.11.4.20230814-py3.9/lib/python3.9/site-packages/stpipe/cmdline.py", line 386, in step_from_cmdlinestep.run(*positional)File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.11.4.20230814-py3.9/lib/python3.9/site-packages/stpipe/step.py", line 478, in runstep_result = self.process(*args)File "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.11.4.20230814-py3.9/lib/python3.9/site-packages/jwst/pipeline/calwebb_tso3.py", line 173, in processx1d_result.int_times[row[0] - 1] = rowFile "/dms/local/jwst/pipeline/pkgs/miniconda3/envs/jwstdp-1.11.4.20230814-py3.9/lib/python3.9/site-packages/astropy/io/fits/fitsrec.py", line 567, in __setitem__self.field(self.names[idx])[key] = value.field(self.names[idx]) ```
I don't see a clear deficiency in the JDox documentation of how APT programs should be designed, but nonetheless these seem to have slipped through with APT incorrectly configured. It's clear from a visual analysis of the APT program what the users intended, but it's not obvious that there's any metadata that could unambiguously communicate that.
Howard Bushouse Tyler Pauly Is there any way to 'hack' the metadata of a program after the fact to fix errors such as these? I'm thinking of the SDSS solution to occasionally-corrupted header info, which was to maintain a list of exposures that had to be header-fixed prior to processing. We could then hand-fix cases such as these when they come up by forcing (say) PID 1274 Obs 5 to be the background for Obs 4.
Thoughts?
Comment by Tyler Pauly on JIRA:
For an observation to be the background, it needs to have the correct association candidate and it needs to have the BKGDTARG flag turned to True. For the candidate, I think that's probably in the APT/PPS realm. The same is true of BKGDTARG, but that part seems more 'hackable'.
If users want background observations, a target needs to be labeled as a background, i.e. BKGDTARG=True. If APT needs separate targets for this, i.e. the same target can't be considered science in one observation and a background in another, perhaps this is a feature request for APT?
PIDs 1274, 3548, 2783, and 2965 above all look like user error. There's an easy way of doing what they wanted in APT, but they didn't follow guidelines in setting up the program and program technical review missed the error.
So, to what extent do we save users from their own mistakes? Scientifically, I'd say it would be better if we hack BKGDTARG=True when we see this crash (after pinging the relevant instrument team to confirm whether that's a reasonable assumption for each new case). Effort-wise, which is worse for DMS to deal with, having PIDs around that will fail out of the pipeline as above, or having to hack the BKGDTARG flags?
Comment by Howard Bushouse on JIRA:
David Law We'd have to check with SDP/DMS folks to find out if there's a way to permanently "hack" metadata values for a dataset, e.g. to change the setting of BKGDTARG. I think there's the possibility of the use of some kind of "override" files that get invoked whenever a given dataset is reprocessed, the contents of which tell it what changes to make to metadata. But yeah, how much effort is worth it to save users from themselves.
Comment by Tyler Pauly on JIRA:
Hi Hien Tran and/or Jesse Doggett, do you have any thoughts or suggestions on the comments by Howard and David? Effectively, some programs will cause errors for operations/repro unless they are either excluded or "hacked" to have background flags corrected for some observations. Is there a preference on either option, or option 3: let the errors continue? Any suggestions on other options not yet voiced would also be welcome.
Comment by Jesse Doggett on JIRA:
If I understand correctly, hacking the BKGDTARG flags means modifying the PPS database. Essentially, I think, that is correcting the APT data in the PPS database.
Comment by Sarah Kendrew on JIRA:
Just to add that we are gradually updating all TSO programs to add the background target appropriately, so this won't happen. Making TA for slitless LRS has also simplified the implementation in APT, which will help. But I've had at least one that we missed due to already being set to flight-ready - sorry about that. This can also be resolved by fleshing out the background subtraction step in the pipeline for slitless LRS, which I believe is on team LRS' to do list.
Comment by Sarah Kendrew on JIRA:
I'm really sorry, we have another observation coming up that will have this problem - PID 3557 Obs 9 + 16 (16 is the background). I asked the PI to implement the background differently, with a dedicated background target, but unfortunately as the target has been observed by a previous observation in the same program, it is now locked in APT.
the test to hack the bkgdtarg keyword on the dms side (DMSOPS-1211) seems to work ok. i can go ahead and apply the hack to the rest of the affected visits, however, thanks to JP-3308, we will never see this issue anymore. i don't know if anything else can be done on this ticket, so i think it can probably be closed.
Issue JP-3146 was created on JIRA by Hien Tran:
repro of program 2783 from l1a with b9.1.2 is giving the following tso3 error when processing a MIR_LRS-SLITLESS dataset jw02783-c1000_20230320t092349_tso3_00001