View spectral info in 2D images - #1134
Conversation
ejeschke
left a comment
There was a problem hiding this comment.
Hi @debora-pe , thanks for this PR! I have small request to make the extraction of the wavelength more efficient by caching the wavelength array after you build it. Could you try my suggestion in the review?
In the future we might be able to improve it further by building the wavelength array when the image is loaded if we detect the correct FITS headers.
| waveimg = np.tile(wave_array[:, np.newaxis], _wd) | ||
| else: | ||
| raise ValueError(f"Unsupported spectral axis: {spec_axis}") | ||
|
|
There was a problem hiding this comment.
@debora-pe , thanks for this very useful PR!
We should look at either A) building the wavelength array when the AstroImage is loaded or a WCS is set, or B) building and caching it in the AstroImage in this function. Otherwise it is constantly being built and rebuilt as the user sweeps the cursor across the image. The former would be cleaner, but the latter is not too bad. There is a metadata dictionary in every AstroImage which would be the logical place to store this.
Example here, just after you have created the wavelength array:
self.set(wavelen_array=waveimg)Then, see the check above, to avoid having to rebuild the array. Let me know if you think this would work ok (maybe give it a try and update this PR)?
| return self.wcs.radectopix(ra_deg, dec_deg, coords=coords, | ||
| naxispath=self.revnaxis) | ||
|
|
||
| def pixtospec(self, x, y): |
There was a problem hiding this comment.
(See comment below)
# check for cached wavelength array
waveimg = self.get('wavelen_array', None)
if waveimg is None:
# build wavelength array
Thanks @ejeschke for your comments. I follow your suggestion and it seems working well. Thanks! |
|
@debora-pe, I had to make a white space correction to get it to pass |
|
@ejeschke for future reference, unless the PR author specifically uncheck a box, you could have pushed your change straight to this PR branch instead of making a new PR off this branch. FYI. |
I tried, but it wouldn't let me. I think the owner of the repo needs to allow that. |
|
It's possible I didn't try the right method. There was also something about being able to fix small typos and so forth directly in the PR by clicking the Edit option on the file being showed in the "Files Changed", but that was greyed out for me. |
|
Hmm. Well, too late for this PR now, but if it comes up again, I'll be happy to help debug. Thanks! |
|
Credit was properly given, and @debora-pe is now a contributor |
|
It wasn't meant as accusation or anything. Sorry if I came across otherwise. Thanks, all! |
Not at all, no worries! |
Description
This pull request is to add the possibility to view rectified 2D spectral images that have wavelength information recorded in the header. With this, the wavelength value in each pixels is displayed.