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

Weird Plotting Glitch #132

Open ericasaw opened 1 year ago

ericasaw commented 1 year ago

Was working on plotting some IGRINS spectra order by order this morning and I found this weird glitch. When you execute a line like specs[0][order].normalize().plot() (where specs is a list of IGRINSSpectrumLists) the plotted spectrum for a particular order is nicely normalized, but if you initialize a matplotlib figure and subplot and instead execute specs[0][order].normalize().plot(ax = ax) the plotted order is not normalized. If instead you set your new axis equal to the plot for the normalized order (ax = specs[0][order].normalize().plot()) the order is normalized and you can change things about the plot like the title, range, etc. Thought it was kind of weird, is anyone else running into this?

gully commented 1 year ago

My guess is this is a copy issue--- whether the .plot operates on a copy or a view of the original. As a workaround, I recommend making an intermediate spectrum:

temp_spec = specs[0][order].normalize()
temp_spec.plot(ax = ax)

or maybe even:

temp_spec = specs[0][order]
temp_spec = temp_spec.normalize()
temp_spec.plot(ax = ax)

Merely a workaround until a scrupulous look at how/whether intermediate copies are made. The copying behavior is a legacy of how specutils stores SpectrumCollections. Someday I'd like to get a specutils contributor to give a critical look at muler-- they'd probably have some good guidance.

gully commented 1 year ago

Hi @ericasaw is this plotting glitch still an issue? If so, can you provide a minimal reproducible example, and which version of muler you are using?