ioos / ioos_qc

:ballot_box_with_check: :ocean: IOOS QARTOD and other Quality Control tests implemented in Python
https://ioos.github.io/ioos_qc/
Apache License 2.0
42 stars 27 forks source link

Climatology Test: Handing masked depths without zspan #107

Closed iwensu0313 closed 3 months ago

iwensu0313 commented 3 months ago

Summary

Copied changes from https://github.com/ioos/ioos_qc/pull/104. Added a test to replicate missing values and no zspan set scenario https://github.com/ioos/ioos_qc/issues/65#issuecomment-1033141944. Proposed fix is to set MISSING flag at the end of check() so it doesn't get overridden by the GOOD flag.

Details

At the start of check() we currently set UNKNOWN and MISSING flags

# Start with everything as UNKNOWN (2)
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

However, in this line near the end of the check() function, the slice keeps good data points AND all masked values. And assigns them the QartodFlags.GOOD flag which is a value of 1.

flag_arr[(values_idx & ~fail_idx & ~suspect_idx)] = QartodFlags.GOOD

We do not want MISSING flags (9) to be overridden with a GOOD flag (1), so assigning the MISSING flags at the end can prevent this.

iwensu0313 commented 3 months ago

Tests appear to have all passed, but pre-commit check failing. Need to investigate - converted to draft

ocefpaf commented 3 months ago

Tests appear to have all passed, but pre-commit check failing. Need to investigate - converted to draft

Don't worry too much about pre-commits. Those are only code standards and sometimes we can fix those with:

pre-commit.ci autofix

iwensu0313 commented 3 months ago

Tests appear to have all passed, but pre-commit check failing. Need to investigate - converted to draft

Don't worry too much about pre-commits. Those are only code standards and sometimes we can fix those with:

pre-commit.ci autofix

Sounds good! I figured out how to fix this one. One of the pre-commit checks auto fixed the issue but the other one I had to fix manually in this commit https://github.com/ioos/ioos_qc/pull/107/commits/485d63535eb1f281f4b0473a364dea723c068ab8. I definitely support sticking w/ code standards :)