-
Notifications
You must be signed in to change notification settings - Fork 10
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
rectification of spectral traces #227
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev_master #227 +/- ##
==============================================
- Coverage 75.41% 74.93% -0.48%
==============================================
Files 149 149
Lines 15283 15406 +123
==============================================
+ Hits 11525 11544 +19
- Misses 3758 3862 +104
☔ View full report in Codecov by Sentry. |
Here's a notebook (hidden in a zip so that github accepts it) that demonstrates the rectification for METIS (simulating MICADO is a bit too heavy for a notebook). |
rect_spec = np.zeros_like(Xarr, dtype=np.float32) | ||
|
||
ihdu = 0 | ||
for hdu in hdulist: |
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.
for hdu in hdulist: | |
for ihdu, hdu in enumerate(hdulist): |
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.
That suggestion does not work like this - the reason is that ihdu
is used to index the interps
list, which is not exactly parallel to hdulist
(the primary du of hdulist
is jumped over). enumerate(hdulist[1:])
should work for all existing cases, but I wouldn't want to rely on that.
I had to rerun the notebook to realise this, which is good justification for including it in automatic testing.
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.
for hdu in hdulist: | |
imghdulist = [hdu for hdu in hdulist if isinstance(hdu, fits.ImageHDU)] | |
assert len(imhdulist) == len(interps) | |
# from Python 3.10 on, the above assert statement could be replaced by passing | |
# strict=True to the zip below | |
for hdu, interp in zip(imghdulist, interps): |
As far as I can tell, the individual hdus are not modified in this loop, only accessed. Only drawback I could think of is memory consumption, because we essentially create a copy of hdulist
. Either way, I don't want to overcomplicate things, and the original implementation is probably just fine.
Summary of our (@oczoske, @hugobuddel, @teutoburg) in-person discussion earlier today:
We can merge this as far as I'm concerned, but not sure whether @oczoske still wants to add some things, so I'll just approve. |
I'll merge this, because the corresponding PR in the IRDB has been merged, and now the CI there is failing. |
Convenience method to produce rectified 2D spectra (wavelength, position along slit) from a detector readout.
SpectralTrace.rectify(hdulist, ...)
SpectralTraceList.rectify_traces(hdulist)
The main input is
hdulist
, the product ofOpticalTrain.readout()
. The output is aHDUList
where each extension correspond to the rectified spectrum from one trace in the trace list (only traces within the wavelength range of the filter are considered).For now, it is mandatory to provide the slit length by the keywords
xi_min
andxi_max
(e.g. -4, 4 for METIS LSS, -1.5, 1.5 for the MICADO short slit) explicitely on the command line. Alternatively, these values can be added manually to the header ofhdulist[0]
as keywordsHIERARCH INS SLIT XIMIN
and... XIMAX
. This is stupid but I could not find a way to get these values automatically...