Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Climatology Missing Values Test: Use masked array data and mask to create z_idx #108

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading