I have a memmap for reading binary data (> 1000 files of >> 1000 records each)
f = np.memmap('data.dat', dtype= myFormat, mode= 'r')
and know how to count records satisfying a condition depending on a single field (named 'Status' in myFormat):
eval = f['Status'] & 0x20 == 0x20
nNotEval = np.count_nonzero(eval == False)
Another field is used conditionally on eval:
v = calibration * f['V'][eval]
Now, how to combine two conditions element-wise? The following failes:
unexpected = (f['Status'] & 0x02 == 0) and (v > 15.)
Python protests "The truth value of an array with more than one element is ambiguous" and suggests "Use a.any() or a.all()", but that is not what I need for
nUnexpected = np.count_nonzero(unexpected)
Do I have to iterate? If so, how is the syntax? Something like for (a,b) in ...
?