[Numpy-discussion] Questions about masked arrays

Gökhan Sever gokhansever@gmail....
Tue Oct 6 22:47:11 CDT 2009


On Tue, Oct 6, 2009 at 10:15 PM, Pierre GM <pgmdevlist@gmail.com> wrote:

>
> On Oct 6, 2009, at 10:58 PM, Gökhan Sever wrote:
> >
> > I see your points. I don't want to give you extra work, don't
> > worry :) It just seem a bit bizarre:
> >
> > I[27]: c.data['Air_Temp'].fill_value
> > O[27]: 999999.99990000005
> >
> > I[28]: c.data['Air_Temp'][4].fill_value
> > O[28]: 1e+20
> >
> > As you see, it just returns two different fill_values.
>
> I know, but I hope you see the difference : in the first line, you
> access the `fill_value` of the array. In the second, you access the
> `fill_value` of the `masked` constant. Each time you access a masked
> element of an array with __getitem__, you get the masked constant. We
> could force the constant to inherit the fill_value of the array that
> calls __getitem__, but it'd be propagated.
>
>
Got these points. Thanks

It took a while I had to re-built matplotlib to use ipython -pylab :)

I built the numpy again source from the trunk and arccos (as well as other
arc functions) problem has disappeared. It all started with trying to
calculate great circle navigation equations using masked arrays, and seeing
this range_calc function returning some weird results where it was not
supposed to do. Further tracing down the error to arccos.

def range_calc(lat_r, lat_t, long_r, long_t):
    range = degrees(arccos(sin(radians(lat_r)) * sin(radians(lat_t)) +
cos(radians(lat_r)) * cos(radians(lat_t)) * cos(radians(long_t - long_r))))
* F
    azimuth = degrees(arccos((sin(radians(lat_t)) - cos(radians(range / F))
* sin(radians(lat_r))) / (sin(radians(range / F)) * cos(radians(lat_r)))))

    if long_t - long_r < 0:
        azimuth = 360 - azimuth

    return range, azimuth

Happy now ;)




> > I know eventually you will be the one handling this :) it might be
> > good to add this issue to the tracker.
>
> Go for it, but don't expect anything before the release of 1.4.0 (in
> the next few months)
>
>
I will do this shortly.



> >
> > > 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 ?
> >
> > OK, I use meld to diff my copy of ma/core.py with the latest trunk
> > version. There are lots of differences :) So there is a possibility
> > that I might have built my local numpy before 09/08. I should renew
> > my copy. Do you know the link of svn browser for the numpy? I don't
> > know how you are making separate installations without overriding
> > other package? I either use Sage (if I have extra time) or SPD. They
> > are both shipped with numpy 1.3.0.
>
> Make yourself a favor and install virtualenv and virtualenvwrapper.
> That way, several versions of the same package can coexist without
> interference. Oh, and install pip till you're at it:
>
> http://pypi.python.org/pypi/virtualenv
> http://www.doughellmann.com/projects/virtualenvwrapper/
> http://pypi.python.org/pypi/pip
>
>
>
"pip" this is the first time I am hearing. Will give these tools a try
probably this weekend.

Thanks again for your clarifications.

Now, I have to update my advisor's numpy to make his code running correctly.
In the first place his code was running properly by using manually created
masks for numpy arrays. Using the masked arrays we broke it. Now we know
what causing the error. It feels good :)


>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091006/d90749aa/attachment.html 


More information about the NumPy-Discussion mailing list