Skip to content

Commit

Permalink
minor cleanup to skip needless array copy in continuum objective
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Buhler committed Sep 2, 2024
1 parent 7f36418 commit 7ced18f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions py/fastspecfit/continuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,6 @@ def _stellar_objective(self, params, templateflux,
vdisp = None
templatecoeff = params[1:]

# FIXME: write results directly into resid array instead of
# allocating new
fullmodel = self.build_stellar_continuum(
templateflux, templatecoeff,
ebv=ebv, vdisp=vdisp, conv_pre=conv_pre,
Expand All @@ -857,17 +855,15 @@ def _stellar_objective(self, params, templateflux,
if synthspec:
modelflux = self.continuum_to_spectroscopy(fullmodel)
spec_resid = resid[:resid_split]
spec_resid[:] = specflux
spec_resid -= modelflux
spec_resid *= specistd

np.subtract(modelflux, specflux, spec_resid)
spec_resid *= specistd

if synthphot:
modelflam = self.continuum_to_photometry(fullmodel)
phot_resid = resid[resid_split:]
phot_resid[:] = objflam
phot_resid -= modelflam
phot_resid *= objflamistd

np.subtract(modelflam, objflam, phot_resid)
phot_resid *= objflamistd

return resid


Expand Down

0 comments on commit 7ced18f

Please sign in to comment.