|
|
To use the tests first decide which tests are relevant to the analysis and are to be used for masking data from the analysis. [For this example](https://github.com/ARM-tools/QC-flag-examples/wiki/direct-normal-broadband), all tests with an assessment of "Bad" are chosen, except for test 4 which is not in use. The tests used are [1, 2, 3, 5]. Test 6 is described as "Indeterminate" and will not be part of the mask applied to the data.
|
|
|
|
|
|
For this 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]
|
|
|
|
|
|
Create an array of tests numbers to use in the mask to exclude values
|
|
|
|
|
|
tests = [1, 2, 3, 5]
|
|
|
|
|
|
Create a single mask value summarizing all the tests from the 'tests' array.
|
|
|
|
|
|
mask = TOTAL(ISHFT(1L,tests-1), /PRESERVE_TYPE) ;
|
|
|
|
|
|
Search the companion QC field for at least one of the tests to be tripped. The result of the search is an array of indexes where at leat one of the 'tests' has been set as true. If none of the tests were tripped a single !NULL value is returned.
|
|
|
|
|
|
index = WHERE(qc_direct_normal_broadband AND mask, /NULL)
|
|
|
print, index
|
|
|
0 1 2 3 8
|
|
|
|
|
|
Replace direct normal broadband data values where the companion QC field indicated a test was tripped to the IEEE Not A Number value to exclude from further analysis. If index is equal !NULL the data array is unchanged.
|
|
|
|
|
|
direct_normal_broadband[index] = !Values.F_NAN
|
|
|
print, direct_normal_broadband
|
|
|
NaN NaN NaN NaN 11.0 20.0 50.0 110.0 NaN 134.0
|
|
|
|
|
|
There you go, four lines of code and you're done. If a different set of tests were desired the only part that needs to change is the 'tests' array, the rest of the code is independent of datastream or analysis. This also works with multi-dimensional data variables.
|
|
|
|
|
|
If you're interested in a description using the bits directly you can find a description [here](https://github.com/ARM-tools/QC-flag-examples/wiki/Example-using-IDL-bits) |
|
|
\ No newline at end of file |