Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73453

Re: Problem with numpy 2D Histogram

Newsgroups comp.lang.python
Date 2014-06-20 04:58 -0700
References <f6254d0b-4803-47c8-8b58-aadc9d762610@googlegroups.com> <mailman.11162.1403256365.18130.python-list@python.org> <ba14b490-1f5e-4079-9acb-b15f7b72afc9@googlegroups.com> <mailman.11163.1403262032.18130.python-list@python.org>
Message-ID <aedf37ab-7787-4f63-9437-faa1da980bdf@googlegroups.com> (permalink)
Subject Re: Problem with numpy 2D Histogram
From Jamie Mitchell <jamiemitchell1604@gmail.com>

Show all headers | View raw


On Friday, June 20, 2014 12:00:15 PM UTC+1, Peter Otten wrote:
> Jamie Mitchell wrote:
> 
> 
> 
> > I have changed my x and y data to float64 types but I am still getting the
> 
> > same error message?
> 
> 
> 
> Please double-check by adding
> 
> 
> 
> assert x.dtype == np.float64
> 
> assert y.dtype == np.float64
> 
> 
> 
> If none of these assertions fail try to make a minimal script including some 
> 
> data that provokes the TypeError and post it here.

OK this is my code:

swh_Q0_con_sw=netCDF4.Dataset('/data/cr1/jmitchel/Q0/swh/controlperiod/south_west/swhcontrol_swest_annavg.nc','r')
hs_Q0_con_sw=swh_Q0_con_sw.variables['hs'][:]
x=hs_Q0_con_sw.astype(float64)
# When I print the dtype of x here it says 'float64'
mwp_Q0_con_sw=netCDF4.Dataset('/data/cr1/jmitchel/Q0/mean_wave_period/south_west/controlperiod/mwpcontrol_swest_annavg1D.nc','r')
te_Q0_con_sw=mwp_Q0_con_sw.variables['te'][:]
y=te_Q0_con_sw.astype(float64)
If I try assert x.dtype == np.float64 I get:
AssertionError

hist,xedges,yedges=np.histogram2d(x,y,bins=10)
TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe' 

Thanks,

Jamie

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 01:46 -0700
  Re: Problem with numpy 2D Histogram Peter Otten <__peter__@web.de> - 2014-06-20 11:25 +0200
    Re: Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 02:57 -0700
      Re: Problem with numpy 2D Histogram Peter Otten <__peter__@web.de> - 2014-06-20 13:00 +0200
        Re: Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 04:58 -0700
          Re: Problem with numpy 2D Histogram Peter Otten <__peter__@web.de> - 2014-06-20 14:30 +0200
  Re: Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 06:54 -0700

csiph-web