Skip to content

Commit

Permalink
Merge pull request #108 from iwensu0313/masked_data
Browse files Browse the repository at this point in the history
Climatology Missing Values Test: Use masked array data and mask to create z_idx
  • Loading branch information
ocefpaf authored Apr 5, 2024
2 parents da1d6dd + 738e8a4 commit 4f1bee8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ioos_qc/qartod.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def check(self, tinp, inp, zinp):
flag_arr = np.ma.empty(inp.size, dtype='uint8')
flag_arr.fill(QartodFlags.UNKNOWN)

# If the value is masked set the flag to MISSING
flag_arr[inp.mask] = QartodFlags.MISSING

# Iterate over each member and apply its spans on the input data.
# Member spans are applied in order and any data points that fall into
# more than one member are flagged by each one.
Expand Down Expand Up @@ -376,7 +379,8 @@ def check(self, tinp, inp, zinp):
else:
# If there is no z data in the config, don't try to filter by depth!
# Set z_idx to all True to prevent filtering
z_idx = np.ones(inp.size, dtype=bool)
# Must use inp.data to create masked array so that the masked value is ignored when we assign the FAIL, SUSPECT, and GOOD flags
z_idx = np.ma.array(data=~np.isnan(inp.data), mask=inp.mask, fill_value=999999)

# Combine the T and Z indexes
values_idx = (t_idx & z_idx)
Expand All @@ -396,9 +400,6 @@ def check(self, tinp, inp, zinp):
flag_arr[(values_idx & ~fail_idx & suspect_idx)] = QartodFlags.SUSPECT
flag_arr[(values_idx & ~fail_idx & ~suspect_idx)] = QartodFlags.GOOD

# If the value is masked set the flag to MISSING
flag_arr[inp.mask] = QartodFlags.MISSING

return flag_arr

@staticmethod
Expand Down

0 comments on commit 4f1bee8

Please sign in to comment.