Fix bug for nan in rms calculation

pull/56/head
Cees Bassa 2019-11-13 17:37:07 +01:00
parent 55a9ec9bde
commit 6eae028f5c
1 changed files with 9 additions and 0 deletions

View File

@ -151,10 +151,19 @@ def fit_wcs(w, pix_catalog):
dr = np.sqrt(drx*drx+dry*dry)
rms = np.sqrt(np.sum(dr[c]**2)/len(dr[c]))
# Break on nan
if np.isnan(rms):
return w, 0.0, 0.0, 0.0
# Recompute selection
dr[~c] = 1.0
c = (dr < 2.0*rms)
pix_catalog.flag[~c] = 0
# Break if no stars
if np.sum(c) == 0:
return w, 0.0, 0.0, 0.0
# Break if converged
if np.sum(c) == nstars:
break