[Numpy-discussion] Questions about masked arrays

Pierre GM pgmdevlist@gmail....
Tue Oct 6 21:22:26 CDT 2009

On Oct 6, 2009, at 9:54 PM, Gökhan Sever wrote:
> > Also say, if I want to replace that one element back to its original
> > state will it use fill_value as 1e+20 or 999999.9999?
> What do you mean by 'replace back to its original state' ? Using
> `filled`, you mean ?
> Yes, in more properly stated fashion "filled" :)

> I[14]: c.data['Air_Temp'][4]
> O[14]:
> masked_array(data = --,
>              mask = True,
>        fill_value = 1e+20)
> I[15]: c.data['Air_Temp'][4].filled()
> O[15]: array(1e+20)
> Little buggy, isn't it? It properly fill the whole array:
> I[13]: c.data['Air_Temp'].filled()
> O[13]:
> array([  1.31509000e+01,   1.31309000e+01,   1.31278000e+01,
>          1.31542000e+01,   1.00000000e+06,   1.31539000e+01,
>          1.31387000e+01,   1.00000000e+06,   1.00000000e+06,
>          1.00000000e+06,   1.31107000e+01,   1.31351000e+01,
>          1.32073000e+01,   1.32562000e+01,   1.33533000e+01,
>          1.33889000e+01,   1.34067000e+01,   1.32938000e+01,
>          1.31962000e+01,   1.31248000e+01,   1.30411000e+01,
>          1.29534000e+01,   1.28354000e+01,   1.27392000e+01,
>          1.26725000e+01])

Once again, when you access your 5th element, you get the special  
`masked` constant. If you fill this constant, you'll get something  
which is probably not what you want. And I would need a *REALLY*  
compelling reason to change this behavior, as it's gonna break a lot  
of things (the masked constant has been around for a while)

> > > 2-) What is wrong with the arccos calculation? Should not that
> Er, I assume it's np.arccos ?
> Sorry too much time spent in ipython -pylab :)

Well, i use ipython -pylab regularly as well, but still have the  
reflex of using np. ;)

> I[18]: arccos?
> Type:             ufunc
> Base Class:       <type 'numpy.ufunc'>
> String Form:   <ufunc 'arccos'>
> Namespace:        Interactive
> File:             /home/gsever/Desktop/python-repo/numpy/numpy/ 
> __init__.py
> Anyway, I'm puzzled. Works like a charm here (r7438 for numpy.ma).
> Could it be that something went wrng with some ufuncs ?
> This I don't know :(
> I didn't touch
> ma since 09/08 (thanks, svn history), so I don't think it comes from
> here...
> Yes, SVN is a very useful invention indeed.
> I[6]: numpy.__version__
> O[6]: '1.4.0.dev'
> For some reason it doesn't list check-out revision.

I know, and it's bugging me as well. if you have a build directory  
somewhere, check numpy/core/__svn_version__.py

> This is the last resort. I will eventually try this if I don't any  
> other options left.

I gonna have difficulties fixing something that I don't see broken...  
Now, there might be something wrong in my installation. I gonna try to  
install 1.3.0 somwehere. say, what Python are you using ?

More information about the NumPy-Discussion mailing list