Closed stscieisenhamer closed 4 years ago
@philhodge There is now another sub-directory called spec2_partials
with the assign_wcs and photom files saved.
The input to the extract_1d
step contained two "slits," one with shape (107, 0) and the other with shape (5, 14). extract_1d
skipped the first one because it was empty, and then the step tried to process the second one. The function find_dispaxis
determines the dispersion direction by comparing the wavelengths at three pixels, one near the middle of the image (see below for clarification), the next pixel to the right, and the next pixel up. If the wavelength changes more rapidly in one axis than the other, that axis is assumed to be the dispersion direction. If there is a wavelength
attribute, the wavelengths are taken from that array. If not, the wavelengths are computed by using the WCS function.
The pixel "near the middle of the image" is taken to be the middle of wcs.bounding_box
if that is not None. For this file, the bounding box was None, so the middle of the 2-D cutout was used as the starting pixel. Because the shape was (5, 14), that pixel was x = 7, y = 2 (zero indexed). The wavelengths computed by the WCS function only changed within the range x = 2 to 6, however; for x = 7 to 13 the values were all equal to 2.3.
s1 = model.slits[1]
wcs1 = s1.meta.wcs
wl = np.zeros((5, 14), dtype=np.float64)
for j in range(5):
for i in range(14):
_, _, wavelength, _ = wcs1(i, j, 2)
wl[j, i] = wavelength
print(wl[:, 0:2])
[[ 0.75 0.75]
[ 0.75 0.75]
[ 0.75 0.75]
[ 0.75 0.75]
[ 0.75 0.75]]
print(wl[:, 2:7])
[[ 0.81711023 1.15033439 1.48355855 1.81678271 2.15000687]
[ 0.81711023 1.15033439 1.48355855 1.81678271 2.15000687]
[ 0.81711023 1.15033439 1.48355855 1.81678271 2.15000687]
[ 0.81711023 1.15033439 1.48355855 1.81678271 2.15000687]
[ 0.81711023 1.15033439 1.48355855 1.81678271 2.15000687]]
print(wl[:, 7:])
[[ 2.3 2.3 2.3 2.3 2.3 2.3 2.3]
[ 2.3 2.3 2.3 2.3 2.3 2.3 2.3]
[ 2.3 2.3 2.3 2.3 2.3 2.3 2.3]
[ 2.3 2.3 2.3 2.3 2.3 2.3 2.3]
[ 2.3 2.3 2.3 2.3 2.3 2.3 2.3]]
If pixels outside the range x = 2 to 6 were regarded as invalid and had been flagged as such by having wavelengths set to NaN, the find_dispaxis
function would have evaluated wavelengths over the entire cutout region, and np.nanmean would have been used to determine which axis had the larger change in (non-NaN) wavelength:
dwlx = wl[:, 1:-1] - wl[:, 0:-2]
dwly = wl[1:-1, :] - wl[0:-2, :]
dwlx = np.nanmean(dwlx)
dwly = np.nanmean(dwly)
dwlx
0.12916666666666665
dwly
0.0
Does the second (non-empty) slit in this case correspond to the 0th-order and hence that might explain why there's no change in wavelength values?
Once #1801 gets merged, which will restrict 'extract_2d' to only extracting orders +1 and +2, this will result in no workable slits at all, because those two fall off the detector. I suspect that the direct image data in this test case, from which the source catalog is derived, may be garbage and hence we don't happen to get any useful sources/slits defined for extraction.
That's true, the second slit does have 'SPORDER = 0'. I hadn't noticed that before. However, the wavelengths computed by the wcs function are the same, regardless of what spectral order is specified (it's the third argument) when wcs is called.
The find_dispaxis
function in extract_1d
probably needs to check the DQ extension, in addition to filtering out NaNs in the wavelengths. In this case, however, DQ was 2 for almost half of the array, the "good" half, and the data sure don't look saturated to me.
FYI: Looking at the i2d image, there is no real signal there that I can see, so no surprise that the catalog is odd.
Can we create a catalog to put sources in specific places, just to ensure that everything else works? I know there is a regression test, but can this be done for this dataset?
Sure, just edit the source catalog file.
Yes, editing the source catalog will do it. All that probably needs to happen is to just change the location (in either RA/Dec or pixel space) of the source(s) that are defined in it. The tricky bit is figuring out what new values to use to make it fall within the proper location of the grism image, but that can be done through a little trial and error (been there, done that).
well, going with the center, both in pixel and sky, the same error occurs.
Issue
When running
calwebb_spec2
on NIS WFSS spectra, theextract_1d
step has issues findingdispaxis
. Example:Resources
An example dataset can be found in
where the above example command can be run in.