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: ", f.size

print f.reshape(691, 886)

f is:  [ (0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 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.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, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 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 <module>
    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.r...@ou.edu> wrote:

>
>
> On Mon, Mar 19, 2012 at 5:28 PM, questions anon 
> <questions.a...@gmail.com>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 <module>
>>     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

Reply via email to