Skip to content

Commit

Permalink
Fix # values affected text to account for NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
dnowacki-usgs committed Jun 5, 2024
1 parent 1fc0229 commit 302e9c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions stglib/core/qaqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def trim_min(ds, var):
if var + "_min" in ds.attrs:
cond = ds[var] >= ds.attrs[var + "_min"]
affected = cond.size - cond.sum()
affected = cond.size - cond.sum() - ds[var].isnull().sum()
ds[var] = ds[var].where(cond)

notetxt = f"Values filled where less than {ds.attrs[var + '_min']} units; {affected.values} values affected. "
Expand All @@ -23,7 +23,7 @@ def trim_min(ds, var):
def trim_max(ds, var):
if var + "_max" in ds.attrs:
cond = ds[var] <= ds.attrs[var + "_max"]
affected = cond.size - cond.sum()
affected = cond.size - cond.sum() - ds[var].isnull().sum()
ds[var] = ds[var].where(cond)

notetxt = f"Values filled where greater than {ds.attrs[var + '_max']} units; {affected.values} values affected. "
Expand Down Expand Up @@ -280,10 +280,10 @@ def trim_fliers(ds, var):
a = a.filled()

cond = np.isfinite(a)
affected = cond.size - cond.sum()
affected = cond.size - cond.sum() - ds[var].isnull().sum()
ds[var] = ds[var].where(cond)

notetxt = f"Fliers of {ds.attrs[var + '_fliers']} or fewer points removed; {affected} values affected. "
notetxt = f"Fliers of {ds.attrs[var + '_fliers']} or fewer points removed; {affected.values} values affected. "

ds = utils.insert_note(ds, var, notetxt)

Expand Down Expand Up @@ -339,7 +339,7 @@ def trim_mask(ds, var):
cond = ~ds[trimvar].isnull()
ds[var] = ds[var].where(cond)

affected = cond.size - cond.sum()
affected = cond.size - cond.sum() - ds[var].isnull().sum()

notetxt = f"Values filled using {trimvar} mask; {affected.values} values affected. "
ds = utils.insert_note(ds, var, notetxt)
Expand Down

0 comments on commit 302e9c0

Please sign in to comment.