stcorp / harp

Data harmonization toolset for scientific earth observation data
http://stcorp.github.io/harp/doc/html/index.html
BSD 3-Clause "New" or "Revised" License
55 stars 18 forks source link

Apply bitfield operator to validity of TROPOMI product #278

Closed zxdawn closed 1 year ago

zxdawn commented 1 year ago

Usually, I check specific errors of processing quality flag by:

pqf_mask = 0b1111111
pqf = ds['processing_quality_flags'].to_masked_array().astype('uint32') & pqf_mask

However, the processing_quality_flags named validity has been converted from uint32 to int32 by harp automatically. Is it possible to convert it back to uint32 in operation and filter it by bitfield operator =&? Or any other easier ways?

zxdawn commented 1 year ago

Well, find out. I can store the result into a new variable named pqf and use that to filter data.

pqf = product.validity.data.astype('uint32') & 0b1111111
product.pqf = harp.Variable(pqf, ["time",])
product_pqf = harp.execute_operations(product, operations='pqf==0')