[Numpy-discussion] Question about numpy.ma masking

Gökhan Sever gokhansever at gmail.com
Tue May 4 21:38:04 EDT 2010


Hello,

I have the following arrays read as masked array.

I[10]: basic.data['Air_Temp'].mask
O[10]: array([ True, False, False, ..., False, False, False], dtype=bool)

[12]: basic.data['Press_Alt'].mask
O[12]: False

I[13]: len basic.data['Air_Temp']
-----> len(basic.data['Air_Temp'])
O[13]: 1758


The first item data['Air_Temp'] has only the first element masked and this
result with mask attribute being created an equal data length bool array. On
the other hand data['Press_Alt'] has no elements to mask yielding a 'False'
scalar. Is this a documented behavior or intentionally designed this way?
This is the only case out of 20 that breaks my code as following: :)

IndexError                                Traceback (most recent call last)

    130 for k in range(len(shorter)):
    131     if (serialh.data['dccnTempSF'][k] != 0) \
--> 132        and (basic.data['Air_Temp'].mask[k+diff] == False):
    133         dccnConAmb[k] = serialc.data['dccnConc'][k] * \
    134                         physical.data['STATIC_PR'][k+diff] * \

IndexError: invalid index to scalar variable.

since mask is a scalar in this case, nothing to loop terminating with an
IndexError.

-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100504/83eee040/attachment.html>


More information about the NumPy-Discussion mailing list