To use the tests decide which tests are relevant to the analysis, and are to be used for masking data from the analysis. For this example, 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.
First, lets assume the data and companion QC fields are ten element arrays and equal to the values
Next, create an array of tests to use in the mask to exclude values
tests = [1, 2, 3, 5]
Create a single integer mask summarizing all the tests of interest from the 'tests' array.
mask = 0for test in tests: mask = mask + (1 << test-1) # mask is equal to 23 for tests 1,2,3,5print bin(mask) # print the binary representation of mask 0b10111
Search the companion QC field for at least one of the tests to be tripped. 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.
for ii in range(0,len(qc_direct_normal_broadband)): if qc_direct_normal_broadband[ii] & mask != 0: direct_normal_broadband[ii] = float('nan')print direct_normal_broadband [nan, nan, nan, nan, 11, 20, 50, 110, nan, 134]
If a different set of tests were desired the only part that needs to change is 'tests', the rest of the code is independent of datastream or analysis.