Re: [Matplotlib-users] open ascii grid data and plot

2012-03-25 Thread questions anon
excellent, thanks, that worked and was able to plot using matplotlib
without ending up with the logical_or error.
thanks everyone

On Thu, Mar 22, 2012 at 3:59 AM, Goyo  wrote:

> El día 21 de marzo de 2012 01:03, questions anon
>
> > f=np.genfromtxt(inputfile, skip_header=6, dtype=None, names=True)
>
> I don't think you should be using dtype=None if you wand a 2D array.
> Also the names=True thing makes no sense to me since there isn't a row
> with field names. Try just this and I guess you'll get a 2D array:
>
> f=np.genfromtxt(inputfile, skip_header=6)
>
> Goyo
>
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-21 Thread Goyo
El día 21 de marzo de 2012 01:03, questions anon

> f=np.genfromtxt(inputfile, skip_header=6, dtype=None, names=True)

I don't think you should be using dtype=None if you wand a 2D array.
Also the names=True thing makes no sense to me since there isn't a row
with field names. Try just this and I guess you'll get a 2D array:

f=np.genfromtxt(inputfile, skip_header=6)

Goyo

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-20 Thread questions anon
thanks for all of your responses. I agree with Benjamin that I have two
issues, and firstly I need to figure out importing the text to a 2d array
before plotting.
I can take this question elsewhere but will run it by you first:
My problem seems to be that when I use np.genfromtxt it imports my 2d array
as a 1d array. I have tried using np.reshape

import numpy as np

inputfile=r"d:/BoMdata/r19000117.txt"
outputfolder=r"d:/BoMdata/outputfolder"
f=np.genfromtxt(inputfile, skip_header=6, dtype=None, names=True)


print "f is: ", f[1:2]
print "f shape: ", f.shape
print "f dtype: ", f.dtype
print "f size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 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 9.49085e-05, 0.00056383, 0.00132367, 0.00417144, 0.00618987,
0.00776004, 0.0094961, 0.011557, 0.0139465, 0.0166607, 0.019674, 0.0229193,
0.0262693, 0.0295119, 0.0323237, 0.0342322, 0.0341227, 0.0288054,
0.0163089, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.00245558, 0.0309294, 0.0521848, 0.0663444, 0.0706948,
0.0681689, 0.0633213, 0.0575578, 0.0514137, 0.0452683, 0.0393741,
0.0338871, 0.0288934, 0.0244262, 0.0204939, 0.0170896, 0.014127, 0.0115916,
0.00944895, 0.00765294, 0.00615862, 0.00486124, 0.00325027, 0.000950427,
9.23129e-05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0

Re: [Matplotlib-users] open ascii grid data and plot

2012-03-20 Thread Benjamin Root
On Mon, Mar 19, 2012 at 5:28 PM, questions anon wrote:

> So when I add "np.logical_or" to the beginning of the script it makes no
> difference to the error message that I receive.
>
> I have tried reshaping the array but I receive an error message of:
> Traceback (most recent call last):
>   File "", line 1, in 
> f.reshape(691,886)
> ValueError: total size of new array must be unchanged
>
> Is there a way to use np.genfromtxt and define the rows and columns on
> import?
>
> Thanks
>
>
I think you have two completely separate problems.  They are completely
unrelated to each other.  The np.logical_or() issue happens within Basemap
while your np.genfromtext() happens in your module.  For the
np.logical_or() issue, I suspect that there is something wrong with your
installation (maybe EPD is conflicting with a pre-existing python
install?).  As for np.genfromtext(), I would put the code back to the way
it was before (the original call looked right to me).

Ben Root
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-19 Thread questions anon
So when I add "np.logical_or" to the beginning of the script it makes no
difference to the error message that I receive.

I have tried reshaping the array but I receive an error message of:
Traceback (most recent call last):
  File "", line 1, in 
f.reshape(691,886)
ValueError: total size of new array must be unchanged

Is there a way to use np.genfromtxt and define the rows and columns on
import?

Thanks

On Fri, Mar 16, 2012 at 7:10 AM, Goyo  wrote:

> El día 15 de marzo de 2012 05:14, questions anon
>  escribió:
> > I think my error is from the np.genfromtxt because I just checked the
> size
> > of my data and it appears in 1D rather than 2D.
>
> This is unsurprising since your file has just one row of data. I
> overlooked that because the weird error message drove all my attention
> to it. You can reshape the resulting array to (691, 886). Still that
> error message should not be there in any case.
>
> >> I don't really understand what np.logical_or is or how to use it?
> >> I have tried just calling it at the beginning of the script
>
> np.logical_or computes the logical out of two boolean arrays. It's
> called internally by countourf and that's triggering the exception:
>
> AttributeError: logical_or
>
> Which makes no sense at all because:
> 1. np is expected to be an alias for numpy and numpy *does* have an
> attribute called logical_or.
> 2. In case np didn't have an attribute called logical_or (for whatever
> reason) it would cause an exception but the error message should be
> something like "AttributeError: 'module' object has no attribute
> 'logical_or'".
>
> You where asked to call np.logical_or at the beginning of the script
> in order to know if it triggers the exception in that context.
>
> >> [...] but I still end up with the same error.
>
> So the call at the beginning didn't trigger the error?
>
> Regards
>
> Goyo
>
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-15 Thread Goyo
El día 15 de marzo de 2012 05:14, questions anon
 escribió:
> I think my error is from the np.genfromtxt because I just checked the size
> of my data and it appears in 1D rather than 2D.

This is unsurprising since your file has just one row of data. I
overlooked that because the weird error message drove all my attention
to it. You can reshape the resulting array to (691, 886). Still that
error message should not be there in any case.

>> I don't really understand what np.logical_or is or how to use it?
>> I have tried just calling it at the beginning of the script

np.logical_or computes the logical out of two boolean arrays. It's
called internally by countourf and that's triggering the exception:

AttributeError: logical_or

Which makes no sense at all because:
1. np is expected to be an alias for numpy and numpy *does* have an
attribute called logical_or.
2. In case np didn't have an attribute called logical_or (for whatever
reason) it would cause an exception but the error message should be
something like "AttributeError: 'module' object has no attribute
'logical_or'".

You where asked to call np.logical_or at the beginning of the script
in order to know if it triggers the exception in that context.

>> [...] but I still end up with the same error.

So the call at the beginning didn't trigger the error?

Regards

Goyo

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-14 Thread questions anon
I think my error is from the np.genfromtxt because I just checked the size
of my data and it appears in 1D rather than 2D.
if I try taking out 'skip_header' I end up with this error:

Traceback (most recent call last):
  File "d:\BoMdata\plotrainfall.py", line 63, in 
f=np.genfromtxt(inputfile, dtype=None, names=True)
  File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 1560, in
genfromtxt
raise ValueError(errmsg)
ValueError: Some errors were detected !
Line #7 (got 886 columns instead of 2)
Line #8 (got 886 columns instead of 2)
Line #9 (got 886 columns instead of 2)
Line #10 (got 886 columns instead of 2)
Line #11 (got 886 columns instead of 2)
Line #12 (got 886 columns instead of 2)
Line #13 (got 886 columns instead of 2)

my data as opened in notepad looks like:

ncols 886
nrows 691
xllcorner 111.975
yllcorner -44.525
cellsize  0.05
NODATA_value  -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

how do I skip those first few rows but still end up with a 2D array?


On Thu, Mar 15, 2012 at 12:16 PM, questions anon
wrote:

> I don't really understand what np.logical_or is or how to use it?
> I have tried just calling it at the beginning of the script but I still
> end up with the same error.
>
>
> On Thu, Mar 15, 2012 at 10:59 AM, Pierre GM  wrote:
>
>> That's your whole log? You're sure you're not redefining np in the
>> background, via a variable or another module?
>> Have you tried to call np.logical_or at the very beginning of your
>> script, or in a brand new environment (after importing numpy as np)?
>> It's definitely not a matplotlib pb, but where is it coming on your side,
>> that's the question...
>> On Mar 14, 2012 11:35 PM, "questions anon" 
>> wrote:
>>
>>> Thanks for responding. It is 'sort of' good to know that it can't be
>>> explained as I just thought it was my incompetency!
>>> I tried the np rather than N but that made no differences.
>>> thanks again
>>>
>>>
>>> On Thu, Mar 15, 2012 at 7:48 AM, Benjamin Root  wrote:
>>>


 On Tue, Mar 13, 2012 at 4:23 PM, questions anon <
 questions.a...@gmail.com> wrote:

> also I have tried running it on a different computer and the same
> error occurred
>
>
> On Wed, Mar 14, 2012 at 8:22 AM, questions anon <
> questions.a...@gmail.com> wrote:
>
>> thanks for looking into this Goyo.
>> The complete code:
>>
>>
>> import numpy as N
>> import matplotlib.pyplot as plt
>> from numpy import ma as MA
>> from mpl_toolkits.basemap import Basemap
>> import os
>>
>> shapefile="E:/GIS_layers/DSE_REGIONS"
>> inputfile=r"d:/BoMdata/r19000117.txt"
>> outputfolder=r"d:/BoMdata/outputfolder"
>>
>> f=N.genfromtxt(inputfile, skip_header=6,  dtype=float, names=True)
>> print f[0:5]
>>
>>
>> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>>
>> llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
>> map.drawcoastlines()
>> map.drawstates()
>> map.readshapefile(shapefile, 'DSE_REGIONS')
>>
>> xi=N.linspace(111.975, 156.275, 886)
>> yi=N.linspace(-44.525, -9.975, 691)
>> x,y=map(*N.meshgrid(xi,yi))
>> plt.title('rainfall')
>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>> l,b,w,h =0.1,0.1,0.8,0.8
>> cax = plt.axes([l+w+0.025, b, 0.025, h])
>> plt.colorbar(CS,cax=cax, drawedges=True)
>> plt.savefig((os.path.join(outputfolder, 'rainfall.png')))
>> plt.show()
>> plt.close()
>>
>>
>> and the complete error:
>>
>>
>> Traceback (most recent call last):
>>   File "d:/BoMdata/plotrainfall_v2.py", line 23, in 
>>
>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>   File
>> "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py", line
>> 3072, in contourf
>>
>> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
>> AttributeError: logical_or
>>
>> Any feedback/ideas will be greatly appreciated.
>>
>>
>>
 Your error is very strange and it just simply should not be happening.
 On a completely wild guess, could you try replacing "import numpy as N"
 with "import numpy as np" and replace all instances of "N" with "np"?

 Ben Root


>>>
>>>
>>> --
>>> Virtualization & Cloud Management Using Capacity Planning
>>> Cloud comput

Re: [Matplotlib-users] open ascii grid data and plot

2012-03-14 Thread questions anon
Thanks for responding. It is 'sort of' good to know that it can't be
explained as I just thought it was my incompetency!
I tried the np rather than N but that made no differences.
thanks again


On Thu, Mar 15, 2012 at 7:48 AM, Benjamin Root  wrote:

>
>
> On Tue, Mar 13, 2012 at 4:23 PM, questions anon 
> wrote:
>
>> also I have tried running it on a different computer and the same error
>> occurred
>>
>>
>> On Wed, Mar 14, 2012 at 8:22 AM, questions anon > > wrote:
>>
>>> thanks for looking into this Goyo.
>>> The complete code:
>>>
>>>
>>> import numpy as N
>>> import matplotlib.pyplot as plt
>>> from numpy import ma as MA
>>> from mpl_toolkits.basemap import Basemap
>>> import os
>>>
>>> shapefile="E:/GIS_layers/DSE_REGIONS"
>>> inputfile=r"d:/BoMdata/r19000117.txt"
>>> outputfolder=r"d:/BoMdata/outputfolder"
>>>
>>> f=N.genfromtxt(inputfile, skip_header=6,  dtype=float, names=True)
>>> print f[0:5]
>>>
>>>
>>> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>>>
>>> llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
>>> map.drawcoastlines()
>>> map.drawstates()
>>> map.readshapefile(shapefile, 'DSE_REGIONS')
>>>
>>> xi=N.linspace(111.975, 156.275, 886)
>>> yi=N.linspace(-44.525, -9.975, 691)
>>> x,y=map(*N.meshgrid(xi,yi))
>>> plt.title('rainfall')
>>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>> l,b,w,h =0.1,0.1,0.8,0.8
>>> cax = plt.axes([l+w+0.025, b, 0.025, h])
>>> plt.colorbar(CS,cax=cax, drawedges=True)
>>> plt.savefig((os.path.join(outputfolder, 'rainfall.png')))
>>> plt.show()
>>> plt.close()
>>>
>>>
>>> and the complete error:
>>>
>>>
>>> Traceback (most recent call last):
>>>   File "d:/BoMdata/plotrainfall_v2.py", line 23, in 
>>>
>>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>>   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
>>> line 3072, in contourf
>>>
>>> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
>>> AttributeError: logical_or
>>>
>>> Any feedback/ideas will be greatly appreciated.
>>>
>>>
>>>
> Your error is very strange and it just simply should not be happening.  On
> a completely wild guess, could you try replacing "import numpy as N" with
> "import numpy as np" and replace all instances of "N" with "np"?
>
> Ben Root
>
>
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-14 Thread Benjamin Root
On Tue, Mar 13, 2012 at 4:23 PM, questions anon wrote:

> also I have tried running it on a different computer and the same error
> occurred
>
>
> On Wed, Mar 14, 2012 at 8:22 AM, questions anon 
> wrote:
>
>> thanks for looking into this Goyo.
>> The complete code:
>>
>>
>> import numpy as N
>> import matplotlib.pyplot as plt
>> from numpy import ma as MA
>> from mpl_toolkits.basemap import Basemap
>> import os
>>
>> shapefile="E:/GIS_layers/DSE_REGIONS"
>> inputfile=r"d:/BoMdata/r19000117.txt"
>> outputfolder=r"d:/BoMdata/outputfolder"
>>
>> f=N.genfromtxt(inputfile, skip_header=6,  dtype=float, names=True)
>> print f[0:5]
>>
>>
>> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>>   llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
>> map.drawcoastlines()
>> map.drawstates()
>> map.readshapefile(shapefile, 'DSE_REGIONS')
>>
>> xi=N.linspace(111.975, 156.275, 886)
>> yi=N.linspace(-44.525, -9.975, 691)
>> x,y=map(*N.meshgrid(xi,yi))
>> plt.title('rainfall')
>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>> l,b,w,h =0.1,0.1,0.8,0.8
>> cax = plt.axes([l+w+0.025, b, 0.025, h])
>> plt.colorbar(CS,cax=cax, drawedges=True)
>> plt.savefig((os.path.join(outputfolder, 'rainfall.png')))
>> plt.show()
>> plt.close()
>>
>>
>> and the complete error:
>>
>>
>> Traceback (most recent call last):
>>   File "d:/BoMdata/plotrainfall_v2.py", line 23, in 
>>
>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
>> line 3072, in contourf
>> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
>> AttributeError: logical_or
>>
>> Any feedback/ideas will be greatly appreciated.
>>
>>
>>
Your error is very strange and it just simply should not be happening.  On
a completely wild guess, could you try replacing "import numpy as N" with
"import numpy as np" and replace all instances of "N" with "np"?

Ben Root
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-13 Thread questions anon
also I have tried running it on a different computer and the same error
occurred

On Wed, Mar 14, 2012 at 8:22 AM, questions anon wrote:

> thanks for looking into this Goyo.
> The complete code:
>
>
> import numpy as N
> import matplotlib.pyplot as plt
> from numpy import ma as MA
> from mpl_toolkits.basemap import Basemap
> import os
>
> shapefile="E:/GIS_layers/DSE_REGIONS"
> inputfile=r"d:/BoMdata/r19000117.txt"
> outputfolder=r"d:/BoMdata/outputfolder"
>
> f=N.genfromtxt(inputfile, skip_header=6,  dtype=float, names=True)
> print f[0:5]
>
>
> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>   llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
> map.drawcoastlines()
> map.drawstates()
> map.readshapefile(shapefile, 'DSE_REGIONS')
>
> xi=N.linspace(111.975, 156.275, 886)
> yi=N.linspace(-44.525, -9.975, 691)
> x,y=map(*N.meshgrid(xi,yi))
> plt.title('rainfall')
> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
> l,b,w,h =0.1,0.1,0.8,0.8
> cax = plt.axes([l+w+0.025, b, 0.025, h])
> plt.colorbar(CS,cax=cax, drawedges=True)
> plt.savefig((os.path.join(outputfolder, 'rainfall.png')))
> plt.show()
> plt.close()
>
>
> and the complete error:
>
>
> Traceback (most recent call last):
>   File "d:/BoMdata/plotrainfall_v2.py", line 23, in 
>
> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
> line 3072, in contourf
> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
> AttributeError: logical_or
>
> Any feedback/ideas will be greatly appreciated.
>
>
>
>
> On Wed, Mar 14, 2012 at 4:59 AM, Goyo  wrote:
>
>> El día 12 de marzo de 2012 23:25, questions anon
>>  escribió:
>> [...]
>> >
>> > Is this how the data should look when it has been imported from an
>> ascii to
>> > a numpy array?
>>
>> I can't see anything obiously wrong in your code or your data --I did
>> not dive too deep into it though. What is weird is the traceback:
>>
>> Traceback (most recent call last):
>>  File "d:\plotrainfall.py", line 40, in 
>>CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
>> line 3072, in contourf
>>np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
>> AttributeError: logical_or
>>
>> Is that the complete traceback?
>>
>> Goyo
>>
>
>
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-13 Thread questions anon
thanks for looking into this Goyo.
The complete code:

import numpy as N
import matplotlib.pyplot as plt
from numpy import ma as MA
from mpl_toolkits.basemap import Basemap
import os

shapefile="E:/GIS_layers/DSE_REGIONS"
inputfile=r"d:/BoMdata/r19000117.txt"
outputfolder=r"d:/BoMdata/outputfolder"

f=N.genfromtxt(inputfile, skip_header=6,  dtype=float, names=True)
print f[0:5]

map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
  llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
map.drawcoastlines()
map.drawstates()
map.readshapefile(shapefile, 'DSE_REGIONS')
xi=N.linspace(111.975, 156.275, 886)
yi=N.linspace(-44.525, -9.975, 691)
x,y=map(*N.meshgrid(xi,yi))
plt.title('rainfall')
CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
l,b,w,h =0.1,0.1,0.8,0.8
cax = plt.axes([l+w+0.025, b, 0.025, h])
plt.colorbar(CS,cax=cax, drawedges=True)
plt.savefig((os.path.join(outputfolder, 'rainfall.png')))
plt.show()
plt.close()


and the complete error:

Traceback (most recent call last):
  File "d:/BoMdata/plotrainfall_v2.py", line 23, in 
CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
line 3072, in contourf
np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
AttributeError: logical_or

Any feedback/ideas will be greatly appreciated.



On Wed, Mar 14, 2012 at 4:59 AM, Goyo  wrote:

> El día 12 de marzo de 2012 23:25, questions anon
>  escribió:
> [...]
> >
> > Is this how the data should look when it has been imported from an ascii
> to
> > a numpy array?
>
> I can't see anything obiously wrong in your code or your data --I did
> not dive too deep into it though. What is weird is the traceback:
>
> Traceback (most recent call last):
>  File "d:\plotrainfall.py", line 40, in 
>CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
> line 3072, in contourf
>np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
> AttributeError: logical_or
>
> Is that the complete traceback?
>
> Goyo
>
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-13 Thread Goyo
El día 12 de marzo de 2012 23:25, questions anon
 escribió:
[...]
>
> Is this how the data should look when it has been imported from an ascii to
> a numpy array?

I can't see anything obiously wrong in your code or your data --I did
not dive too deep into it though. What is weird is the traceback:

Traceback (most recent call last):
  File "d:\plotrainfall.py", line 40, in 
CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
line 3072, in contourf
np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
AttributeError: logical_or

Is that the complete traceback?

Goyo

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-12 Thread questions anon
Thanks for responding. I do think the error is with how I prepare the data
(importing as a numpy array) because I have used matplotlib a million time
with no problems.
Maybe I should be taking this question elsewhere about importing the data
but thought I would add some more info.
The data in the txt file looks like this when I open it in notepad:
ncols 886
nrows 691
xllcorner 111.975
yllcorner -44.525
cellsize  0.05
NODATA_value  -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0

and some of the info I received with it:
General Category:Gridded daily data
Geographic Bounding Box
See Below
North Bounding Latitude
-9.975
South Bounding Latitude
-44.525
East Bounding Longitude
156.275
West Bounding Longitude
111.975
Stored Data Format
Arc/Info grids–all Australia
Available Format Type
ASCII row major

I am currently using:
f=N.genfromtxt(inputfile, skip_header=6,  dtype=float, names=True)
with the output looking like:

[ (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.

Is this how the data should look when it has been imported from an ascii to
a numpy array?

thanks


On Fri, Mar 9, 2012 at 5:27 PM, Benjamin Root  wrote:

>
>
> On Wednesday, March 7, 2012, questions anon 
> wrote:
> > Hi all,
> > I am still having a problem with the same code. I am not sure if maybe
> the problem is how I read the data in as numpy.genfromtxt
> > Is there a step I need to take to convert the data to numpy array to
> then read into matplotlib?
>
> Sorry for the delay.
>
> As far as I can tell, you are doing everything correctly.  The error you
> are getting would seem to indicate something wrong with your EPD install,
> or perhaps a conflict with another install on numpy or mpl.
>
> I would suggest completely clearing out your python and EPD install and
> reinstalling it fresh.
>
> Ben Root
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-08 Thread Benjamin Root
On Wednesday, March 7, 2012, questions anon 
wrote:
> Hi all,
> I am still having a problem with the same code. I am not sure if maybe
the problem is how I read the data in as numpy.genfromtxt
> Is there a step I need to take to convert the data to numpy array to then
read into matplotlib?

Sorry for the delay.

As far as I can tell, you are doing everything correctly.  The error you
are getting would seem to indicate something wrong with your EPD install,
or perhaps a conflict with another install on numpy or mpl.

I would suggest completely clearing out your python and EPD install and
reinstalling it fresh.

Ben Root
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-08 Thread Paul Hobson
In my GIS experience, rasters don't have prj files. That's something
that seems to be pretty specific to ESRI shapefiles. Point is, I don't
think that's going to help you.

All of the basemap examples use netcdf files. I think your path of
least resistance right now is to figure out how to convert your text
file to a numpy array (check?), and then that array to a netcdf that
is structured such that you can follow the basemap examples:
http://matplotlib.github.com/basemap/users/examples.html

Hope that helps,
-paul

On Wed, Mar 7, 2012 at 8:21 PM, questions anon  wrote:
> Hi all,
> I am still having a problem with the same code. I am not sure if maybe the
> problem is how I read the data in as numpy.genfromtxt
> Is there a step I need to take to convert the data to numpy array to then
> read into matplotlib?
> Thanks
>
>
> On Fri, Mar 2, 2012 at 11:49 AM, questions anon 
> wrote:
>>
>> python, numpy through enthought -
>> Python 2.7.2 |EPD 7.1-1 (32-bit)| (default, Jul  3 2011, 15:13:59) [MSC
>> v.1500 32 bit (Intel)] on win32
>> imports at the top of the script:
>>
>> import numpy as N
>> import matplotlib.pyplot as plt
>> from numpy import ma as MA
>> from mpl_toolkits.basemap import Basemap
>> import os
>>
>>
>>
>> On Thu, Mar 1, 2012 at 4:42 PM, Benjamin Root  wrote:
>>>
>>>
>>>
>>> On Wednesday, February 29, 2012, questions anon wrote:

 I have had some progress reading in the data but am unsure how to create
 lats and lons from the info I have (see above).
 the error I am receiving is:

 Traceback (most recent call last):
   File "d:\plotrainfall.py", line 40, in 
     CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
 line 3072, in contourf

 np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
 AttributeError: logical_or


 from the below code:


 onefile=r"E:/test_in/r19000117.txt"

 f=N.genfromtxt(onefile, skip_header=6,  dtype=float, names=True)
 print f


 map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,

 llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
 map.drawcoastlines()
 map.drawstates()
 xi=N.linspace(111.975, 156.275, 886)
 yi=N.linspace(-44.525, -9.975, 691)
 x,y=map(*N.meshgrid(xi,yi))
 plt.title('rainfall')
 CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
 l,b,w,h =0.1,0.1,0.8,0.8
 cax = plt.axes([l+w+0.025, b, 0.025, h])
 plt.colorbar(CS,cax=cax, drawedges=True)
 plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
 plt.show()
 plt.close()


>>>
>>> How did you install numpy?  Which version are you using?  What are your
>>> imports at the top of this script?
>>>
>>> Ben Root
>>
>>
>
>
> --
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-07 Thread questions anon
Hi all,
I am still having a problem with the same code. I am not sure if maybe the
problem is how I read the data in as numpy.genfromtxt
Is there a step I need to take to convert the data to numpy array to then
read into matplotlib?
Thanks


On Fri, Mar 2, 2012 at 11:49 AM, questions anon wrote:

> python, numpy through enthought -
> Python 2.7.2 |EPD 7.1-1 (32-bit)| (default, Jul  3 2011, 15:13:59) [MSC
> v.1500 32 bit (Intel)] on win32
> imports at the top of the script:
>
> import numpy as N
> import matplotlib.pyplot as plt
> from numpy import ma as MA
> from mpl_toolkits.basemap import Basemap
> import os
>
>
>
> On Thu, Mar 1, 2012 at 4:42 PM, Benjamin Root  wrote:
>
>>
>>
>> On Wednesday, February 29, 2012, questions anon wrote:
>>
>>> I have had some progress reading in the data but am unsure how to create
>>> lats and lons from the info I have (see above).
>>> the error I am receiving is:
>>>
>>> Traceback (most recent call last):
>>>   File "d:\plotrainfall.py", line 40, in 
>>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>>   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
>>> line 3072, in contourf
>>>
>>> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
>>> AttributeError: logical_or
>>>
>>>
>>> from the below code:
>>>
>>>
>>> onefile=r"E:/test_in/r19000117.txt"
>>>
>>> f=N.genfromtxt(onefile, skip_header=6,  dtype=float, names=True)
>>> print f
>>>
>>>
>>> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>>>
>>> llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
>>> map.drawcoastlines()
>>> map.drawstates()
>>> xi=N.linspace(111.975, 156.275, 886)
>>> yi=N.linspace(-44.525, -9.975, 691)
>>> x,y=map(*N.meshgrid(xi,yi))
>>> plt.title('rainfall')
>>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>> l,b,w,h =0.1,0.1,0.8,0.8
>>> cax = plt.axes([l+w+0.025, b, 0.025, h])
>>> plt.colorbar(CS,cax=cax, drawedges=True)
>>> plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
>>> plt.show()
>>> plt.close()
>>>
>>>
>>>
>> How did you install numpy?  Which version are you using?  What are your
>> imports at the top of this script?
>>
>> Ben Root
>>
>
>
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-01 Thread questions anon
python, numpy through enthought -
Python 2.7.2 |EPD 7.1-1 (32-bit)| (default, Jul  3 2011, 15:13:59) [MSC
v.1500 32 bit (Intel)] on win32
imports at the top of the script:

import numpy as N
import matplotlib.pyplot as plt
from numpy import ma as MA
from mpl_toolkits.basemap import Basemap
import os


On Thu, Mar 1, 2012 at 4:42 PM, Benjamin Root  wrote:

>
>
> On Wednesday, February 29, 2012, questions anon wrote:
>
>> I have had some progress reading in the data but am unsure how to create
>> lats and lons from the info I have (see above).
>> the error I am receiving is:
>>
>> Traceback (most recent call last):
>>   File "d:\plotrainfall.py", line 40, in 
>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>>   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
>> line 3072, in contourf
>> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
>> AttributeError: logical_or
>>
>>
>> from the below code:
>>
>>
>> onefile=r"E:/test_in/r19000117.txt"
>>
>> f=N.genfromtxt(onefile, skip_header=6,  dtype=float, names=True)
>> print f
>>
>>
>> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>>   llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
>> map.drawcoastlines()
>> map.drawstates()
>> xi=N.linspace(111.975, 156.275, 886)
>> yi=N.linspace(-44.525, -9.975, 691)
>> x,y=map(*N.meshgrid(xi,yi))
>> plt.title('rainfall')
>> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>> l,b,w,h =0.1,0.1,0.8,0.8
>> cax = plt.axes([l+w+0.025, b, 0.025, h])
>> plt.colorbar(CS,cax=cax, drawedges=True)
>> plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
>> plt.show()
>> plt.close()
>>
>>
>>
> How did you install numpy?  Which version are you using?  What are your
> imports at the top of this script?
>
> Ben Root
>
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-03-01 Thread Jean-Baptiste Marquette

Le 29 févr. 2012 à 23:29, questions anon a écrit :

> I have a txt file (with an associated prj file) containing gridded weather 
> data.
> Firstly how can I open this file and convert it to a numpy array?

You should have a look on ATpy package : http://atpy.github.com/

Cheers
JB--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-02-29 Thread Benjamin Root
On Wednesday, February 29, 2012, questions anon wrote:

> I have had some progress reading in the data but am unsure how to create
> lats and lons from the info I have (see above).
> the error I am receiving is:
>
> Traceback (most recent call last):
>   File "d:\plotrainfall.py", line 40, in 
> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
>   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
> line 3072, in contourf
> np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
> AttributeError: logical_or
>
>
> from the below code:
>
>
> onefile=r"E:/test_in/r19000117.txt"
>
> f=N.genfromtxt(onefile, skip_header=6,  dtype=float, names=True)
> print f
>
>
> map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
>   llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
> map.drawcoastlines()
> map.drawstates()
> xi=N.linspace(111.975, 156.275, 886)
> yi=N.linspace(-44.525, -9.975, 691)
> x,y=map(*N.meshgrid(xi,yi))
> plt.title('rainfall')
> CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
> l,b,w,h =0.1,0.1,0.8,0.8
> cax = plt.axes([l+w+0.025, b, 0.025, h])
> plt.colorbar(CS,cax=cax, drawedges=True)
> plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
> plt.show()
> plt.close()
>
>
>
How did you install numpy?  Which version are you using?  What are your
imports at the top of this script?

Ben Root
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] open ascii grid data and plot

2012-02-29 Thread questions anon
I have had some progress reading in the data but am unsure how to create
lats and lons from the info I have (see above).
the error I am receiving is:

Traceback (most recent call last):
  File "d:\plotrainfall.py", line 40, in 
CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py",
line 3072, in contourf
np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask))
AttributeError: logical_or


from the below code:


onefile=r"E:/test_in/r19000117.txt"

f=N.genfromtxt(onefile, skip_header=6,  dtype=float, names=True)
print f


map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9,
  llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i')
map.drawcoastlines()
map.drawstates()
xi=N.linspace(111.975, 156.275, 886)
yi=N.linspace(-44.525, -9.975, 691)
x,y=map(*N.meshgrid(xi,yi))
plt.title('rainfall')
CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet)
l,b,w,h =0.1,0.1,0.8,0.8
cax = plt.axes([l+w+0.025, b, 0.025, h])
plt.colorbar(CS,cax=cax, drawedges=True)
plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
plt.show()
plt.close()




On Thu, Mar 1, 2012 at 9:29 AM, questions anon wrote:

> I have a txt file (with an associated prj file) containing gridded weather
> data.
> Firstly how can I open this file and convert it to a numpy array?
> and then how to plot in matplotlib, paticularly how to use the lat, lon
> and nrows,ncols.
> ncols=886
> nrows=691
> longitude west=111.975, east=156.275
> latitude north=-9.975, south=-44.525
> cell size=0.05
>
> My attempt below:
> --
>
> onefile=open("E:/test_in/r19000117.txt", 'r')
>
> map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
>   llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
> map.drawcoastlines()
> map.drawstates()
> xi=N.linspace(111.975, 156.275, 886)
> yi=N.linspace(-44.525, -9.975, 691)
> x,y=map(*N.meshgrid(xi,yi))
> plt.title('rainfall')
> CS = map.contourf(x,y, onefile, cmap=plt.cm.jet)
> l,b,w,h =0.1,0.1,0.8,0.8
> cax = plt.axes([l+w+0.025, b, 0.025, h])
> plt.colorbar(CS,cax=cax, drawedges=True)
> plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
> plt.show()
> plt.close()
>
>
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] open ascii grid data and plot

2012-02-29 Thread questions anon
I have a txt file (with an associated prj file) containing gridded weather
data.
Firstly how can I open this file and convert it to a numpy array?
and then how to plot in matplotlib, paticularly how to use the lat, lon and
nrows,ncols.
ncols=886
nrows=691
longitude west=111.975, east=156.275
latitude north=-9.975, south=-44.525
cell size=0.05

My attempt below:
--

onefile=open("E:/test_in/r19000117.txt", 'r')

map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,
  llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')
map.drawcoastlines()
map.drawstates()
xi=N.linspace(111.975, 156.275, 886)
yi=N.linspace(-44.525, -9.975, 691)
x,y=map(*N.meshgrid(xi,yi))
plt.title('rainfall')
CS = map.contourf(x,y, onefile, cmap=plt.cm.jet)
l,b,w,h =0.1,0.1,0.8,0.8
cax = plt.axes([l+w+0.025, b, 0.025, h])
plt.colorbar(CS,cax=cax, drawedges=True)
plt.savefig((os.path.join(OutputFolder, 'rainfall.png')))
plt.show()
plt.close()
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users