Re: Python arrays and sting formatting options



On 2008-09-30, Peter Pearson <ppearson@xxxxxxxxxxxxxxx> wrote:
On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Rebori wrote:

1. Multi dimensional arrays - how do you load them in python
For example, if I had:
-------
1 2 3
4 5 6
7 8 9

10 11 12
13 14 15
16 17 18
-------
with "i" being the row number, "j" the column number, and "k" the ..
uhmm, well, the "group" number, how would you load this ?

If fortran90 you would just do:

do 10 k=1,2
do 20 i=1,3

read(*,*)(a(i,j,k),j=1,3)

20 continue
10 continue

How would the python equivalent go ?

You would drag yourself out of the 1960s, install numpy, and
then do something like this:

a = read_array(open("filename.dat","r"))

Since you're coming from the FORTRAN world (thank you for that
stroll down Memory Lane), you might be doing scientific
computations, and so might be interested in the SciPy package
(Google scipy), which gives you arrays and matrices. Don't
expect to be able to use it without learning some Python,
though.

If not full-up scipy (which provides all sorts of scientific
and numerical-analysis stuff), then at least numpy (which
provides the basic array/matrix operations:

http://numpy.scipy.org/

Though the software is free, the documentation isn't. You've
got to buy the book if you want something to read. IMO, it's
definitely worth it, and a good way to support the project even
if you don't really need something to keep your bookends apart.

Scientific Python is something else the OP might be interested
in. Yes, Scientific Python is different than SciPy:

http://dirac.cnrs-orleans.fr/plone/software/scientificpython/overview/

If you're a Windows user, I can recommend the Enthough Python
distribution. It has all sorts of numerical and scientific
"batteries included".

http://www.enthought.com/products/epd.php

It includes both scipy and scientific python as well as several
options for data visualization (e.g. matplotlib, VTK).

There's also an Enthought Python distro for Linux, but I've
never tried it. I run Gentoo Linux, and there are standard
ebuilds for pretty much all of the stuff in EPD.

--
Grant Edwards grante Yow! I've read SEVEN
at MILLION books!!
visi.com
.



Relevant Pages

  • Re: [ANN] Python(x,y) 2.6.3.0 released
    ... It is the first release based on Python 2.6 -- note that Pythonversion number will now follow the included Python version vX.Y.Z.N will be based on Python vX.Y.Z). ... Pythonis a free Python distribution providing a ready-to-use scientific development software for numerical computations, data analysis and data visualization based on Python programming language, Qt graphical user interfaces, Eclipse integrated development environment and Spyder interactive development environment. ... Spyder 1.0.0 -- the Scientific PYthon Development EnviRonment, a powerful MATLAB-like development environment introducing exclusive features in the scientific Python community ... Pydev 1.5.0 -- now including the powerful code analysis features of Pydev Extensions ...
    (comp.lang.python)
  • [ANN] Python(x,y) 2.6.3.0 released
    ... It is the first release based on Python 2.6 -- note that Pythonversion number will now follow the included Python version vX.Y.Z.N will be based on Python vX.Y.Z). ... Pythonis a free Python distribution providing a ready-to-use scientific development software for numerical computations, data analysis and data visualization based on Python programming language, Qt graphical user interfaces, Eclipse integrated development environment and Spyder interactive development environment. ... Spyder 1.0.0 -- the Scientific PYthon Development EnviRonment, a powerful MATLAB-like development environment introducing exclusive features in the scientific Python community ... Pydev 1.5.0 -- now including the powerful code analysis features of Pydev Extensions ...
    (comp.lang.python)
  • Re: Possible Ruby-centric NASA SBIR area
    ... How much effort do you already have invested in Ruby? ... been working hard on scientific python for 10 years (scipy, numpy, ... vtk python interfaces, weave, f2py). ...
    (comp.lang.ruby)
  • Re: nonlinear least square
    ... > I know that there are such a modules in Scientific Python and SciPy ... important to you -- I doubt you'll find a better pure Python ...
    (comp.lang.python)
  • Re: nonlinear least square
    ... >fit from within Python. ... >I know that there are such a modules in Scientific Python and SciPy has ...
    (comp.lang.python)