Skip to content

Commit

Permalink
copying arrays to avoid side effects on gaussian fitting
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmejia committed Nov 12, 2024
1 parent 073bbe2 commit 18f625d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions python/lvmdrp/core/spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3350,10 +3350,16 @@ def fitSepGauss(
fit_bg=True,
warning=False,
):
error = self._error if self._error is not None else numpy.ones(self._dim, dtype=numpy.float32)
mask = self._mask if self._mask is not None else numpy.zeros(self._dim, dtype=bool)
error[mask] = numpy.inf
# copy main arrays to avoid side effects
data = self._data.copy()
error = self._error.copy() if self._error is not None else numpy.ones(self._dim, dtype=numpy.float32)
mask = self._mask.copy() if self._mask is not None else numpy.zeros(self._dim, dtype=bool)

# update mask to account for unmasked invalid pixels
# mask |= (~numpy.isfinite(data) | ~numpy.isfinite(error))

# reset bad pixels in data and error
error[mask] = numpy.inf
data[mask] = 0.0

flux = numpy.ones(len(cent_guess)) * numpy.nan
Expand Down

0 comments on commit 18f625d

Please sign in to comment.