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

`EchelleSpectrumList.remove_nans()` applies masking in-place, rather than on a copy #86

Closed gully closed 2 years ago

gully commented 2 years ago

EchelleSpectrumList.remove_nans() applies masking in-place, rather than on a copy. The EchelleSpectrum.remove_nans() correctly applies masking on a copy. We need to correct the list-like operations.

Minimal working example:

fn = 'SDCH_20201202_0059.spec_a0v.fits'
spec_list = IGRINSSpectrumList.read(fn).normalize()

spec_list[0].meta['x_values']
 > array([   0,    1,    2, ..., 2045, 2046, 2047])

spec_list.remove_nans().plot() # no assignment to anywhere!

spec_list[0].meta['x_values']
 > array([ 451,  452,  453, ..., 1681, 1682, 1683]) # an inplace operation has occurred!  Undesired behavior!
kfkaplan commented 2 years ago

I fixed the methods to act on a copy of self instead. See the pull request https://github.com/OttoStruve/muler/pull/87