OttoStruve / muler

A Python package for working with pipeline-produced spectra from IGRINS, HPF, and Keck NIRSPEC
https://muler.readthedocs.io
MIT License
15 stars 9 forks source link

trim_edges not working for IGRINS example data #73

Closed gmace closed 2 years ago

gmace commented 2 years ago
Screen Shot 2021-12-03 at 12 39 56 PM
gully commented 2 years ago

:pray: Thank you Greg for filing this Issue! I am see the problem! It occurs here:

https://github.com/OttoStruve/muler/blob/ed7d092fbfaf87b22c622cd7264859fb1219ac4a/src/muler/echelle.py#L542-L546

The x_values are the native IGRINS pixels, and muler aspires to maintain this ancillary pixel label through all operations. Somehow that aspiration has fallen short here, which has caused a bug. The offending spectrum is the final order, number 27. If you isolate that spectrum: spec = spec_list[27], you can see that the pixels are not getting properly accounted for in the masking process:

Screenshot from 2021-12-03 17-03-04

I will take a look at why the masking is not correctly applied to the x_values.

An alternative solution is that specutils should keep track of the pixel labels. They might have a mechanism for doing that, and if they do I'd prefer to use their method over ours!

Thanks again for raising the issue! :)

gully commented 2 years ago

Hi @gmace I found the problem, it was due to line 542 above--- a dictionary key is not considered an attribute, so the conditional on line 542 was never met. This bug appeared in two places, so I have fixed both locations. You can now conduct trim_edges and remove_nans in any order. :pray: Thank you again for filing the Issue, which brought the problem to our attention.

Moving forward we have also added this scenario as a test case so that everytime the code changes, we will make sure routine operations like these successfully commute.

Please update your muler installation with git pull origin main, restart your Jupyter notebook, and verify that the solution resolved your Issue. Thanks again!