@@ -635,6 +635,10 @@ def fit_lines(
635
635
f"Total elements: { nrow } Good RMS: { len (ind_goodrms )} "
636
636
f"Refit lines: { np .sum (refit_lines )} "
637
637
)
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
638
642
639
643
# Checking the object model for sinusoidal pattern noise
640
644
if objmodel_check :
@@ -780,7 +784,7 @@ def fit_lines(
780
784
popt = p0
781
785
popt [0 ] = 0
782
786
pcov = np .diag (np .ones (len (popt )))
783
- rms = 0
787
+ infodict , mesg , ier = { "fvec" : 0 }, "Identically Zero" , 0
784
788
else :
785
789
# The optimization method is the "Trust Region Reflective" algorithm
786
790
# The parameters are scaled iteratively from the Jacobian matrix
@@ -794,13 +798,14 @@ def fit_lines(
794
798
method = "trf" ,
795
799
x_scale = "jac" ,
796
800
)
797
- rms = np .sqrt (np .mean (infodict ["fvec" ] ** 2 ))
801
+ rms = np .sqrt (np .mean (infodict ["fvec" ] ** 2 ))
798
802
except RuntimeError :
799
803
# Reached max function evaluations; set popt and pcov
800
804
popt = p0
801
805
popt [0 ] = 0
802
806
pcov = np .diag (np .ones (len (popt )))
803
807
rms = np .inf
808
+ infodict , mesg , ier = {"fvec" : 0 }, "Runtime Error" , 0
804
809
805
810
# Diagnositc Plot showing particular rows ==========>
806
811
if show_diagnostic and img_row in [76 , 193 , 285 , 412 ]:
0 commit comments