|
|
To use the tests, decide which are relevant to the analysis, and are to be used for masking data. [For this example](direct-normal-broadband), all tests with an assessment of "Bad" are chosen, except for test 4 which is not in use. The bits to be set in a mask are [1, 2, 3, 5]. Bit 6 is described as "Indeterminate" and will not be part of the mask applied to the data.
|
|
|
|
|
|
For example, assume the data and companion QC fields are ten element arrays and equal to the values
|
|
|
|
|
|
@direct_normal_broadband = (10, 9, -1, -0.1, 11, 20, 50, 110, 12200, 134);
|
|
|
@qc_direct_normal_broadband = (16, 16, 3, 1, 0, 0, 0, 0, 4, 32);
|
|
|
|
|
|
To create and apply a mask for tests 1, 2, 3 and 5
|
|
|
|
|
|
# Create a mask to check for tests 1,2,3 and 5.
|
|
|
@tests = (1,2,3,5);
|
|
|
$mask = 0;
|
|
|
foreach $test (@tests){$mask = $mask + (1 << $test-1)}
|
|
|
|
|
|
# Or create a mask directly in binary to check for tests 1,2,3 and 5 (tests are packed right to left).
|
|
|
$mask = 0b10111
|
|
|
|
|
|
# Apply the mask to the QC field to see if any tests we are interested in have been tripped.
|
|
|
# At the same time, replace direct normal broadband data values with NaN when tests have failed.
|
|
|
for ($ii=0; $ii<=$#direct_normal_broadband; $ii++){
|
|
|
$direct_normal_broadband[$ii] = "NaN"+1. if (($qc_direct_normal_broadband[$ii] & $mask) != 0);
|
|
|
}
|
|
|
|
|
|
Finally, print the data array, to see how the mask was applied:
|
|
|
|
|
|
print "@direct_normal_broadband\n";
|
|
|
nan nan nan nan 11 20 50 110 nan 134 |
|
|
\ No newline at end of file |