Skip to content

Commit

Permalink
found bug with lon_ix in WOA interpolation
Browse files Browse the repository at this point in the history
was causing incorrect weights (-ve, > 1)
  • Loading branch information
Gordon authored and Gordon committed Jul 24, 2020
1 parent 56521c2 commit 1a8d01c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bgcArgo/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,26 @@ def interp_woa_data(track, woa_track, data, verbose=False):
xwt[1].append(lat_wt)

lon_ix1 = np.where(lon < track[i,2])[0]
print(lon[lon_ix1])
if lon_ix1.shape[0] == 0:
lon_ix1 = 0
else:
lon_ix1 = lon_ix1[0]
lon_ix1 = lon_ix1[-1]
lon_ix2 = lon_ix1 + 1

if lon_ix2 == lon.shape[0]:
print('NOTE: longitude is unbounded, giving all averaging weight to nearest observation')
lon_ix1 = lon_ix1 - 1
lon_ix2 = lon_ix2 - 1
if verbose:
sys.stdout.write('NOTE: longitude is unbounded, giving all averaging weight to nearest observation\n')
lon_ix1 -= 1
lon_ix2 -= 1
lon_wt = 0
else:
dx1 = lon[lon_ix2] - lon[lon_ix1]
dx2 = track[i,2] - lon[lon_ix1]
lon_wt = (dx1 - dx2) / dx1

print([lon_wt, dx1, dx2, lon[lon_ix1], lon[lon_ix2], track[i,2]])

xwt[2].append(lon_wt)

# ---------------------------------------------------------------------
Expand Down

0 comments on commit 1a8d01c

Please sign in to comment.