On Fri, May 7, 2010 at 3:28 PM, Pierre GM <[email protected]> wrote:
> On May 4, 2010, at 8:38 PM, Gökhan Sever wrote: > > 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. > > > Gokhan, > Sorry for not getting back sooner, web connectivity was limited on my side. > I must admit I can't really see what you're tring to do here, but I'll > throw some random comments: > * If you're using structured MaskedArrays, it's a really bad idea to call > one of the fields "data", as it may interact in a non-obvious way with the > actual "data" property (the one that outputs a view of the array as a pure > ndarray). > Hello Pierre, basic.data is a dictionary containing all masked array items. When I read the original data into scripts, my main constructor-reader class automatically converts data to masked arrays. basic.data['Air_Temp'] is a masked array itself, little confusing for sure it also has 'data' attribute. In the above example I check one condition looping in mask value. When mask attribute isn't an bool-array (when there is no missing value in data) the condition fails asserting an IndexError. I was wondering why it doesn't yield a bool-array instead of giving me a scalar False. -- Gökhan
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
