Skip to content

Commit

Permalink
Use masked array data and mask to create z_idx
Browse files Browse the repository at this point in the history
  • Loading branch information
iwensu0313 committed Apr 2, 2024
1 parent da1d6dd commit 738e8a4
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 738e8a4

Please sign in to comment.