On Sat, May 8, 2010 at 7:52 PM, Gökhan Sever <[email protected]> wrote:
> Hello,
>
> Consider my masked arrays:
>
> I[28]: type basic.data['Air_Temp']
> -----> type(basic.data['Air_Temp'])
> O[28]: numpy.ma.core.MaskedArray
>
> I[29]: basic.data['Air_Temp']
> O[29]:
> masked_array(data = [-- -- -- ..., -- -- --],
>              mask = [ True  True  True ...,  True  True  True],
>        fill_value = 999999.9999)
>
>
> I[17]: basic.data['Air_Temp'].data = np.ones(len(basic.data['Air_Temp']))*30
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
>
> ----> 1
>       2
>       3
>       4
>       5
>
> AttributeError: can't set attribute
>
> Why this assignment fails? I want to set each element in the original
> basic.data['Air_Temp'].data to another value. (Because the main instrument
> was forgotten to turn on for that day, and I am using a secondary
> measurement data for Air Temperature for my another calculation. However it
> fails. Although single assignment works:
>
> I[13]: basic.data['Air_Temp'].data[0] = 30
>
> Shouldn't this be working like the regular NumPy arrays do?

Based on the traceback, I'd say it's because you're trying to replace
the object pointed to by the .data attribute. Instead, try to just
change the bits contained in .data:

basic.data['Air_Temp'].data[:] = np.ones(len(basic.data['Air_Temp']))*30

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to