open ascii grid data and plot

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 -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.anon@…287…> 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 <pgmdevlist@…287…> 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.anon@…287…> 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.root@…1304…> wrote:

On Tue, Mar 13, 2012 at 4:23 PM, questions anon <questions.anon@…287…> 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.anon@…287…> 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

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

···

El día 15 de marzo de 2012 05:14, questions anon <questions.anon@...287...> escribió:

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 “<pyshell#0>”, 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 <goyodiaz@…287…> wrote:

El día 15 de marzo de 2012 05:14, questions anon > > <questions.anon@…287…> 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.

  1. 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

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

···

On Mon, Mar 19, 2012 at 5:28 PM, questions anon <questions.anon@…287…> 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 “<pyshell#0>”, 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

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: ",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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, 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, 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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)]
f shape: (690,)
f dtype: [(‘0’, ‘<i4’), (‘0_1’, ‘<i4’), (‘0_2’, ‘<i4’), (‘0_3’, ‘<i4’), (‘0_4’, ‘<i4’), (‘0_5’, ‘<i4’), (‘0_6’, ‘<i4’), (‘0_7’, ‘<i4’), (‘0_8’, ‘<f8’), (‘0_9’, ‘<f8’), (‘0_10’, ‘<f8’), (‘0_11’, ‘<f8’), (‘0_12’, ‘<f8’), (‘0_13’, ‘<f8’), (‘0_14’, ‘<f8’), (‘0_15’, ‘<f8’), (‘0_16’, ‘<f8’), (‘0_17’, ‘<f8’), (‘0_18’, ‘<f8’), (‘0_19’, ‘<f8’), (‘0_20’, ‘<f8’), (‘0_21’, ‘<f8’), (‘0_22’, ‘<f8’), (‘0_23’, ‘<f8’), (‘0_24’, ‘<f8’), (‘0_25’, ‘<f8’), (‘0_26’, ‘<f8’), (‘0_27’, ‘<f8’), (‘0_28’, ‘<f8’), (‘0_29’, ‘<f8’), (‘0_30’, ‘<f8’), (‘0_31’, ‘<f8’), (‘0_32’, ‘<f8’), (‘0_33’, ‘<f8’), (‘0_34’, ‘<f8’), (‘0_35’, ‘<f8’), (‘0_36’, ‘<f8’), (‘0_37’, ‘<f8’), (‘0_38’, ‘<f8’), (‘0_39’, ‘<f8’), (‘0_40’, ‘<f8’), (‘0_41’, ‘<f8’), (‘0_42’, ‘<f8’), (‘0_43’, ‘<f8’), (‘0_44’, ‘<f8’), (‘0_45’, ‘<f8’), (‘0_46’, ‘<f8’), (‘0_47’, ‘<f8’), (‘0_48’, ‘<f8’), (‘0_49’, ‘<f8’), (‘0_50’, ‘<f8’), (‘0_51’, ‘<f8’), (‘0_52’, ‘<f8’), (‘0_53’, ‘<f8’), (‘0_54’, ‘<f8’), (‘0_55’, ‘<f8’), (‘0_56’, ‘<f8’), (‘0_57’, ‘<f8’), (‘0_58’, ‘<f8’), (‘0_59’, ‘<f8’), (‘0_60’, ‘<f8’), (‘0_61’, ‘<f8’), (‘0_62’, ‘<f8’), (‘0_63’, ‘<f8’), (‘0_64’, ‘<f8’), (‘0_65’, ‘<f8’), (‘0_66’, ‘<f8’), (‘0_67’, ‘<f8’), (‘0_68’, ‘<f8’), (‘0_69’, ‘<f8’), (‘0_70’, ‘<f8’), (‘0_71’, ‘<f8’), (‘0_72’, ‘<f8’), (‘0_73’, ‘<f8’), (‘0_74’, ‘<f8’), (‘0_75’, ‘<f8’), (‘0_76’, ‘<f8’), (‘0_77’, ‘<f8’), (‘0_78’, ‘<f8’), (‘0_79’, ‘<f8’), (‘0_80’, ‘<f8’), (‘0_81’, ‘<f8’), (‘0_82’, ‘<f8’), (‘0_83’, ‘<f8’), (‘0_84’, ‘<f8’), (‘0_85’, ‘<f8’), (‘0_86’, ‘<f8’), (‘0_87’, ‘<f8’), (‘0_88’, ‘<f8’), (‘0_89’, ‘<f8’), (‘0_90’, ‘<f8’), (‘0_91’, ‘<f8’), (‘0_92’, ‘<f8’), (‘0_93’, ‘<f8’), (‘0_94’, ‘<f8’), (‘0_95’, ‘<f8’), (‘0_96’, ‘<f8’), (‘0_97’, ‘<f8’), (‘0_98’, ‘<f8’), (‘0_99’, ‘<f8’), (‘0_100’, ‘<f8’), (‘0_101’, ‘<f8’), (‘0_102’, ‘<f8’), (‘0_103’, ‘<f8’), (‘0_104’, ‘<f8’), (‘0_105’, ‘<f8’), (‘0_106’, ‘<f8’), (‘0_107’, ‘<f8’), (‘0_108’, ‘<f8’), (‘0_109’, ‘<f8’), (‘0_110’, ‘<f8’), (‘0_111’, ‘<f8’), (‘0_112’, ‘<f8’), (‘0_113’, ‘<f8’), (‘0_114’, ‘<f8’), (‘0_115’, ‘<f8’), (‘0_116’, ‘<f8’), (‘0_117’, ‘<f8’), (‘0_118’, ‘<f8’), (‘0_119’, ‘<f8’), (‘0_120’, ‘<f8’), (‘0_121’, ‘<f8’), (‘0_122’, ‘<f8’), (‘0_123’, ‘<f8’), (‘0_124’, ‘<f8’), (‘0_125’, ‘<f8’), (‘0_126’, ‘<f8’), (‘0_127’, ‘<f8’), (‘0_128’, ‘<f8’), (‘0_129’, ‘<f8’), (‘0_130’, ‘<f8’), (‘0_131’, ‘<f8’), (‘0_132’, ‘<f8’), (‘0_133’, ‘<f8’), (‘0_134’, ‘<f8’), (‘0_135’, ‘<f8’), (‘0_136’, ‘<f8’), (‘0_137’, ‘<f8’), (‘0_138’, ‘<f8’), (‘0_139’, ‘<f8’), (‘0_140’, ‘<f8’), (‘0_141’, ‘<f8’), (‘0_142’, ‘<f8’), (‘0_143’, ‘<f8’), (‘0_144’, ‘<f8’), (‘0_145’, ‘<f8’), (‘0_146’, ‘<f8’), (‘0_147’, ‘<f8’), (‘0_148’, ‘<f8’), (‘0_149’, ‘<f8’), (‘0_150’, ‘<f8’), (‘0_151’, ‘<f8’), (‘0_152’, ‘<f8’), (‘0_153’, ‘<f8’), (‘0_154’, ‘<f8’), (‘0_155’, ‘<f8’), (‘0_156’, ‘<f8’), (‘0_157’, ‘<f8’), (‘0_158’, ‘<f8’), (‘0_159’, ‘<f8’), (‘0_160’, ‘<f8’), (‘0_161’, ‘<f8’), (‘0_162’, ‘<f8’), (‘0_163’, ‘<f8’), (‘0_164’, ‘<f8’), (‘0_165’, ‘<f8’), (‘0_166’, ‘<f8’), (‘0_167’, ‘<f8’), (‘0_168’, ‘<f8’), (‘0_169’, ‘<f8’), (‘0_170’, ‘<f8’), (‘0_171’, ‘<f8’), (‘0_172’, ‘<f8’), (‘0_173’, ‘<f8’), (‘0_174’, ‘<f8’), (‘0_175’, ‘<f8’), (‘0_176’, ‘<f8’), (‘0_177’, ‘<f8’), (‘0_178’, ‘<f8’), (‘0_179’, ‘<f8’), (‘0_180’, ‘<f8’), (‘0_181’, ‘<f8’), (‘0_182’, ‘<f8’), (‘0_183’, ‘<f8’), (‘0_184’, ‘<i4’), (‘0_185’, ‘<i4’), (‘0_186’, ‘<i4’), (‘0_187’, ‘<i4’), (‘0_188’, ‘<i4’), (‘0_189’, ‘<i4’), (‘0_190’, ‘<i4’), (‘0_191’, ‘<i4’), (‘0_192’, ‘<i4’), (‘0_193’, ‘<i4’), (‘0_194’, ‘<i4’), (‘0_195’, ‘<i4’), (‘0_196’, ‘<i4’), (‘0_197’, ‘<i4’), (‘0_198’, ‘<i4’), (‘0_199’, ‘<i4’), (‘0_200’, ‘<i4’)]

Traceback (most recent call last):
File “d:/BoMdata/plotrainfall_v3.py”, line 10, in
print "f dtype: ", f.dtype[1:2]
ValueError: Field key must be an integer, string, or unicode.

···

On Wed, Mar 21, 2012 at 1:47 AM, Benjamin Root <ben.root@…1304…> wrote:

On Mon, Mar 19, 2012 at 5:28 PM, questions anon <questions.anon@…287…> 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 “<pyshell#0>”, 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

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

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 <goyodiaz@…287…> 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