Skip to content

Commit

Permalink
manually calculate the residuals and chisq for the fitresults
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Apr 6, 2022
1 parent e78c32e commit db6d338
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pysme/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def get_bounds(self, sme):
else:
result[i] = [-10, 11]
elif name[:8].lower() == "linelist":
pass
result[i] = [-np.inf, np.inf]
else:
result[i] = bounds[name]

Expand Down Expand Up @@ -601,8 +601,10 @@ def update_fitresults(self, sme, result, segments):
sme.fitresults.covariance = covar
sme.fitresults.gradient = result.grad
sme.fitresults.derivative = result.jac
sme.fitresults.residuals = result.fun
sme.fitresults.chisq = np.sum(result.fun ** 2) / (
sme.fitresults.residuals = (
(sme.spec[segments] - sme.synth[segments]) / sme.uncs[segments]
)[sme.mask_line[segments]]
sme.fitresults.chisq = np.sum(sme.fitresults.residuals ** 2) / (
result.fun.size - len(self.parameter_names)
)
sme.fitresults.iterations = self.iteration
Expand Down

0 comments on commit db6d338

Please sign in to comment.