Skip to content

Commit 9b831e0

Browse files
authored
Merge pull request #10 from LowellObservatory/issue_9_fix
Fix Issue #9
2 parents 25bb4ab + a44b530 commit 9b831e0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

obstools/scrub_deveny_pickup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,10 @@ def fit_lines(
635635
f"Total elements: {nrow} Good RMS: {len(ind_goodrms)} "
636636
f"Refit lines: {np.sum(refit_lines)}"
637637
)
638+
# If there are no "good" RMS values, cannot refit. Return
639+
if len(ind_goodrms) == 0:
640+
print("No good fit values to use for start of refitting. Skip.")
641+
return orig_fitc
638642

639643
# Checking the object model for sinusoidal pattern noise
640644
if objmodel_check:
@@ -780,7 +784,7 @@ def fit_lines(
780784
popt = p0
781785
popt[0] = 0
782786
pcov = np.diag(np.ones(len(popt)))
783-
rms = 0
787+
infodict, mesg, ier = {"fvec": 0}, "Identically Zero", 0
784788
else:
785789
# The optimization method is the "Trust Region Reflective" algorithm
786790
# The parameters are scaled iteratively from the Jacobian matrix
@@ -794,13 +798,14 @@ def fit_lines(
794798
method="trf",
795799
x_scale="jac",
796800
)
797-
rms = np.sqrt(np.mean(infodict["fvec"] ** 2))
801+
rms = np.sqrt(np.mean(infodict["fvec"] ** 2))
798802
except RuntimeError:
799803
# Reached max function evaluations; set popt and pcov
800804
popt = p0
801805
popt[0] = 0
802806
pcov = np.diag(np.ones(len(popt)))
803807
rms = np.inf
808+
infodict, mesg, ier = {"fvec": 0}, "Runtime Error", 0
804809

805810
# Diagnositc Plot showing particular rows ==========>
806811
if show_diagnostic and img_row in [76, 193, 285, 412]:

0 commit comments

Comments
 (0)