Re: [Numpy-discussion] Arrays as nested dtype
On Fri, Apr 8, 2011 at 9:23 PM, Robert Love wrote: > > Using np.loadtxt I can easily read my file that has columns of time, mode, > 3 float64 for position and 3 for velocity like this. > > dt = dtype([('time', '|S12'), > ('mode','|S3'),('rx','f8'),('ry','f8'),('rz','f8'),('vx','f8'),('vy','f8'),('vz','f8')]) > > data = np.loadtxt('file', dtype=dt) > > > I can then put the two pairs of 3 components into np.arrays and start > performing the vector operations I need. > > How can I read them directly into np.arrays? > > > dt = dtype([('time', '|S12'), ('mode','|S3'),np.array('r'), np.array('v')]) > > I've seen examples for nested data that create a tuple but not an array. > Any tips appreciated. > If you do this: >>> dt = dtype([('time', '|S12'), ('mode','|S3'), ('r','f8', 3), ('v','f8',3)]) >>> data = np.loadtxt('file', dtype=dt) then data['r'] and data['v'] are the arrays of positions and velocities. You can then give them more convenient names: >>> r = data['r'] >>> v = data['v'] Warren > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Arrays as nested dtype
Using np.loadtxt I can easily read my file that has columns of time, mode, 3 float64 for position and 3 for velocity like this. dt = dtype([('time', '|S12'), ('mode','|S3'),('rx','f8'),('ry','f8'),('rz','f8'),('vx','f8'),('vy','f8'),('vz','f8')]) data = np.loadtxt('file', dtype=dt) I can then put the two pairs of 3 components into np.arrays and start performing the vector operations I need. How can I read them directly into np.arrays? dt = dtype([('time', '|S12'), ('mode','|S3'),np.array('r'), np.array('v')]) I've seen examples for nested data that create a tuple but not an array. Any tips appreciated. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] netcdf to grib format
No sir . I got another method for converting this,,, we can use CDO(climate data operators) this tool is help ful On Fri, Apr 8, 2011 at 10:04 PM, David Brown wrote: > Hi Nadav, > > I'm sorry to disappoint you but PyNIO has read-only support for GRIB. It > can be used to convert GRIB to NetCDF but not the other way around. > -Dave Brown > PyNIO developer > > On Apr 8, 2011, at 10:31 AM, dileep kunjaai wrote: > > Thank you sir ,thank uuuvery much.. > > On Fri, Apr 8, 2011 at 9:03 PM, Nadav Horesh wrote: > >> Wikipedia has this link >> >> http://www.pyngl.ucar.edu/Nio.shtml >> >> Does it do the job? >> >> Nadav >> >> -- >> *From:* numpy-discussion-boun...@scipy.org [ >> numpy-discussion-boun...@scipy.org] On Behalf Of dileep kunjaai [ >> dileepkunj...@gmail.com] >> *Sent:* 08 April 2011 15:21 >> *To:* Discussion of Numerical Python >> *Subject:* [Numpy-discussion] netcdf to grib format >> >> Dear sir, >> Is there any tool for changing the 'netcdf' file format to 'grib' format >> in python or cdat >> >> -- >> DILEEPKUMAR. R >> J R F, IIT DELHI >> >> >> ___ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion >> >> > > > -- > DILEEPKUMAR. R > J R F, IIT DELHI > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > -- DILEEPKUMAR. R J R F, IIT DELHI ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] netcdf to grib format
Hi Nadav, I'm sorry to disappoint you but PyNIO has read-only support for GRIB. It can be used to convert GRIB to NetCDF but not the other way around. -Dave Brown PyNIO developer On Apr 8, 2011, at 10:31 AM, dileep kunjaai wrote: > Thank you sir ,thank uuuvery much.. > > On Fri, Apr 8, 2011 at 9:03 PM, Nadav Horesh wrote: > Wikipedia has this link > > http://www.pyngl.ucar.edu/Nio.shtml > > Does it do the job? > > Nadav > > From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] > On Behalf Of dileep kunjaai [dileepkunj...@gmail.com] > Sent: 08 April 2011 15:21 > To: Discussion of Numerical Python > Subject: [Numpy-discussion] netcdf to grib format > > Dear sir, > Is there any tool for changing the 'netcdf' file format to 'grib' format in > python or cdat > > -- > DILEEPKUMAR. R > J R F, IIT DELHI > > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > > > > -- > DILEEPKUMAR. R > J R F, IIT DELHI > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] netcdf to grib format
Thank you sir ,thank uuuvery much.. On Fri, Apr 8, 2011 at 9:03 PM, Nadav Horesh wrote: > Wikipedia has this link > > http://www.pyngl.ucar.edu/Nio.shtml > > Does it do the job? > > Nadav > > -- > *From:* numpy-discussion-boun...@scipy.org [ > numpy-discussion-boun...@scipy.org] On Behalf Of dileep kunjaai [ > dileepkunj...@gmail.com] > *Sent:* 08 April 2011 15:21 > *To:* Discussion of Numerical Python > *Subject:* [Numpy-discussion] netcdf to grib format > > Dear sir, > Is there any tool for changing the 'netcdf' file format to 'grib' format > in python or cdat > > -- > DILEEPKUMAR. R > J R F, IIT DELHI > > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > -- DILEEPKUMAR. R J R F, IIT DELHI ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] netcdf to grib format
Wikipedia has this link http://www.pyngl.ucar.edu/Nio.shtml Does it do the job? Nadav From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] On Behalf Of dileep kunjaai [dileepkunj...@gmail.com] Sent: 08 April 2011 15:21 To: Discussion of Numerical Python Subject: [Numpy-discussion] netcdf to grib format Dear sir, Is there any tool for changing the 'netcdf' file format to 'grib' format in python or cdat -- DILEEPKUMAR. R J R F, IIT DELHI ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] How to use a function into "import function" in python
Thank you sir thank you for your quick and correct answer On Fri, Apr 8, 2011 at 5:52 PM, Alan G Isaac wrote: > On 4/8/2011 6:54 AM, dileep kunjaai wrote: > > I defined a function " hit_rate( )" i want to use this into "import > function(name of function)". > > http://docs.python.org/tutorial/modules.html > > Alan Isaac > > ___ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > -- DILEEPKUMAR. R J R F, IIT DELHI ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Unable to clone git repository
Disclaimer: I'm on windows (Win7 x64) Following the instructions at: http://docs.scipy.org/doc/numpy/dev/gitwash/following_latest.html I got the following (rather unhelpful) error message: C:\dev\src>git clone git://github.com/numpy/numpy.git Cloning into numpy... github.com[0: 207.97.227.239]: errno=No error fatal: unable to connect a socket (No error) After a bit of googling I got the vague impression that this may possibly be to do with work blocking access? Fortunately I was able clone the read only https url - https://github.com/numpy/numpy C:\dev\src>git clone https://github.com/numpy/numpy.git Cloning into numpy... remote: Counting objects: 60461, done. remote: Compressing objects: 100% (13476/13476), done. remote: Total 60461 (delta 47928), reused 58235 (delta 46157) Receiving objects: 100% (60461/60461), 19.41 MiB | 2.66 MiB/s, done. Resolving deltas: 100% (47928/47928), done. I would suggest that since they are "the instructions if you just want to follow the latest NumPy source, but you don’t need to do any development" that providing the https url as an alternative would be helpful. Perhaps something like: From the command line: git clone git://github.com/numpy/numpy.git You should now have a copy of the code tree in the new `numpy` directory. If this doesn't work you can try the alternative read-only url: git clone https://github.com/numpy/numpy.git ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] How to use a function into "import function" in python
On 4/8/2011 6:54 AM, dileep kunjaai wrote: > I defined a function " hit_rate( )" i want to use this into "import > function(name of function)". http://docs.python.org/tutorial/modules.html Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] netcdf to grib format
Dear sir, Is there any tool for changing the 'netcdf' file format to 'grib' format in python or cdat -- DILEEPKUMAR. R J R F, IIT DELHI ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] How to use a function into "import function" in python
Fri, 08 Apr 2011 16:24:58 +0530, dileep kunjaai wrote: > I defined a function " hit_rate( )" i want to use this into "import > function(name of function)". Please read the Python tutorial first: http://docs.python.org/tutorial/ http://docs.python.org/tutorial/modules.html ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] How to use a function into "import function" in python
Dear sir, I defined a function " hit_rate( )" i want to use this into "import function(name of function)". For example: I defined a function as * def* hit_function(a,b,c): . ,... * return* value Now I want to use this in another function as * def *test_hr( ): import hit_function(a, b, c) ... ,, , *return* value1 Please help me to solve this problem. thanking you -- DILEEPKUMAR. R J R F, IIT DELHI ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion