Skip to content

Commit

Permalink
Merge pull request #69 from JamisonTalley/update_check_convergence
Browse files Browse the repository at this point in the history
Add a return value to the check_convergence method
  • Loading branch information
JPGlaser authored Nov 1, 2024
2 parents f1541e1 + a9b4597 commit 2092cd5
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/pint_pal/lite_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,20 +1484,38 @@ def check_convergence(fitter):
Parameters
==========
fitter: `pint.fitter` object
Returns
=======
output_val: string object that corresponds to the printed outputs of the checker
"""
chi2_decrease = fitter.resids_init.chi2-fitter.resids.chi2
print(f"chi-squared decreased during fit by {chi2_decrease}")
message = str(f"chi-squared decreased during fit by {chi2_decrease}")
print(message)
output_val = []
output_val.append(message)
if hasattr(fitter, "converged") and fitter.converged:
print("Fitter has converged")
message = "Fitter has converged"
print(message)
output_val.append(message)
else:
if abs(chi2_decrease)<0.01:
print("Fitter has probably converged")
message = "Fitter has probably converged"
print(message)
output_val.append(message)
elif chi2_decrease<0:
log.warning("Fitter has increased chi2!")
message = "Fitter has increased chi2!"
log.warning(message)
output_val.append(message)
else:
log.warning("Fitter may not have converged")
message = "Fitter may not have converged"
log.warning(message)
output_val.append(message)
if chi2_decrease > 0.01:
log.warning("Input par file is not fully fitted")
message = "Input par file is not fully fitted"
log.warning(message)
output_val.append(message)
return output_val

def file_look(filenm, plot_type = 'profile'):
""" Plots profile, GTpd, or YFp for a single file
Expand Down

0 comments on commit 2092cd5

Please sign in to comment.