Skip to content

Commit

Permalink
Merge pull request #147 from NOC-MSM/127_interpolation_error_in_TandS
Browse files Browse the repository at this point in the history
issue 127, a fix for the temp and salinity interpolation issues.

I want this in to simplify my AMM7v4.0.4 documentation that is in progress
  • Loading branch information
jpolton authored Aug 20, 2024
2 parents 1465a3f + 1b54bb4 commit ab4b741
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/pybdy/nemo_bdy_extr_tm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,19 @@ def extract_month(self, year, month):
else:
id_121 = self.id_121_3d
tmp_filt = self.tmp_filt_3d

tmp_valid = np.invert(np.isnan(dst_bdy.flatten("F")[id_121]))


#tmp_valid = np.invert(np.isnan(dst_bdy.flatten("F")[id_121]))
# interpolation points that are not wet (=0) need to be reflected
# in the denominator
tmp_valid = np.invert(dst_bdy.flatten('F')[id_121] == 0 )
# raises invalid divide error when all points are dry,
# this is ok because the numerator=0 as well so it will
# set to NaN which is set to zero later in code
np.seterr(invalid='ignore')
dst_bdy = np.nansum(
dst_bdy.flatten("F")[id_121] * tmp_filt, 2
) / np.sum(tmp_filt * tmp_valid, 2)

np.seterr(invalid='warn')
# Finished first run operations
# self.first = False

Expand All @@ -890,6 +896,7 @@ def extract_month(self, year, month):
np.nanmax(dst_bdy),
)
dst_bdy[nan_ind] = 0

self.logger.info(
" post dst_bdy %s %s", np.nanmin(dst_bdy), np.nanmax(dst_bdy)
)
Expand Down

0 comments on commit ab4b741

Please sign in to comment.