Skip to content

Example using IDL bits

Ken Kehoe edited this page Jan 4, 2017 · 3 revisions

To use the tests first decide which tests are relevant to the analysis and are to be used for masking data. 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.

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

tests = [1, 2, 3, 5] 

Create a single mask value combining all the tests from the 'tests' array.

mask = TOTAL(ISHFT(1L,tests-1), /PRESERVE_TYPE) ;

Show the flags set in the mask:

print, mask, FORMAT='(b)'

10111

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
Clone this wiki locally