Skip to content

Commit

Permalink
improved continuum fit
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Jun 2, 2021
1 parent fe2204c commit f284e15
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pysme/continuum_and_radial_velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,11 @@ def cont_fit(sme, segment, x_syn, y_syn, rvel=0, only_mask=False):

deg = sme.cscale_degree
p0 = sme.cscale[segment]
func = lambda x, *p: yp * np.polyval(p, x)
func = lambda x, *p: (yp * np.polyval(p, xs) - y) / u
try:
popt, pcov = curve_fit(
func, xs, y, sigma=u, p0=p0, loss="soft_l1", method="trf", xtol=None
)
except RuntimeError:
res = least_squares(func, x0=p0, loss="soft_l1", method="trf", xtol=None)
popt = res.x
except RuntimeError as ex:
logger.warning("Could not determine the continuum")
popt = p0
# popt = res.x
Expand Down

0 comments on commit f284e15

Please sign in to comment.