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 <module>
    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  -9999
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 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
<questions.a...@gmail.com>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 <pgmdevl...@gmail.com> 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" <questions.a...@gmail.com>
>> 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 <ben.r...@ou.edu> 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 <module>
>>>>>>
>>>>>>     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
>>>
>>>
>
------------------------------------------------------------------------------
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

Reply via email to