[Numpy-discussion] Extract groups of/individual bit values from UInt16 array [SEC=UNCLASSIFIED]

Pinner, Luke Luke.Pinner at environment.gov.au
Wed Oct 13 00:14:28 EDT 2010


I'm working with some MODIS satellite imagery. MODIS data includes a
quality flag mask. For the particular dataset I'm working with, this is
a two dimensional unsigned 16 bit integer array. The quality flags are
stored as one or more bits in each integer value:

Bits are numbered from 0 (least significant bit)
	Bit	Long name	Key
	0-1	MODLAND_QA
				00=VI produced, good quality
				01=VI produced, but check other QA
				10=Pixel produced, but most probably
cloudy
				11=Pixel not produced due to other
reasons
				   than clouds
	2-5	VI usefulness
				0000=Highest quality
				0001=Lower quality
				0010=Decreasing quality
				0100=Decreasing quality
				1000=Decreasing quality
				1001=Decreasing quality
				1010=Decreasing quality
				1100=Lowest quality
				1101=Quality so low that it is not
useful
				1110=L1B data faulty
				1111=Not useful for any other reason/not
				     processed
	...<SNIP>...
	15	Possible shadow
				0=No
				1=Yes


Some typical values are:
arr=numpy.array([51199,37013,36885,36889,34841,2062,34837,2061,35033,349
61,2185,37013,36885,2185,4109,4233], dtype=numpy.uint16)

How would I extract groups of/individual bit values from such an array?

Regards
Luke Pinner


------
If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments. 



Please consider the environment before printing this email.

------




More information about the NumPy-Discussion mailing list