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

Cannot Normalize IGRINSSpectrum Object #69

Closed ericasaw closed 3 years ago

ericasaw commented 3 years ago

I've been trying to read in a few A0 normalized spectrum, but each I try to normalize the spectrum (just using spec.normalize()) I get the following error:

UnitTypeError: SpectralCoord instances require units equivalent to '(Unit("Hz"), Unit("m"), Unit("J"), Unit("1 / m"), Unit("km / s"))', so cannot set it to ''.

Can provide example data fits if needed, haven't been able to get normalize to work on any of them yet.

ericasaw commented 3 years ago

Temporary work around, can just plot (spec.flux / np.nanmedian(spec.flux)) for the flux values ie:

plt.figure(figsize = (10,5)) ax = plt.subplot(111) ax.plot(spec.wavelength, (spec.flux / np.nanmedian(spec.flux))) ax.set_ylim(0.6, 1.2)

gully commented 3 years ago

Hey, thanks for raising the issue! Do you have the up-to-date GitHub version? Did you install the developer version or pip version?

There was an astropy units issue that we resolved recently, which seems related.

gully commented 3 years ago

Hi @ericasaw, we figured it out! See https://github.com/OttoStruve/muler/issues/70 and links therein for the detective work.

In short, an upstream dependency changed, it was not the fault of muler (or really anyone for that matter), and we are happy that our automated tests and version control helped us arrive at the answer and workarounds.

I know as a user these bugs can feel frustrating--- thank you for your providing the workaround, having patience, and continuing to help grow the framework. To update to the new version you should re-run the developer instructions:

cd muler # make sure you are in the top-level directory of the muler code
git pull origin main  # pull the most recent changes
python setup.py develop

You can optionally run the unit tests to see if all the tests pass:

py.test -vs

The unit tests are expecting the muler_example_data to be within the tests/data/ directory, but you can put any reduced IGRINS data in that directory to test it out (needs both spec_a0v.fits files and sn.fits files to work).

I hope that helps, let me know if any problems persist for you and thanks again for filing your issue!