

Why astronomers (and other scientists) should program in Python - gammarator
http://bellm.org/blog/2011/05/27/why-astronomers-should-program-in-python/

======
juiceandjuice
Actually most astronomers and physicists I know are already moving toward
Python.

Coming from a mixed particle physics and astronomy experiment, almost all our
tools are written in Python for researchers, but usually with ROOT (C++,
<http://root.cern.ch/> ) underneath. ROOT is python friendly.

SciPy/NumPy, PyROOT, PyFITS are all unbeatable tools for anything in Physics
or Astronomy as far as I'm concerned. Throw some knowledge of C in with that,
and you can scale anything up to supercomputing clusters or back down to your
laptop, and that's a very important, powerful thing for a scientist.

------
foob
In high energy physics we've recently completed a big transition from
FORTRAN77 to C++. PAW and CERNLIB were standard in the 90's but now most major
experiments use ROOT. You can use ROOT with Python but most people don't
bother. Programming comes pretty naturally to most physicists and learning the
details of the ROOT libraries and experiment specific libraries takes much
more time than picking up C++. I've seen most grad students get comfortable
with the basics of C++ in a couple of days while they typically struggle with
the usage of the libraries for a number of months. The documentation is
autogenerated from the code so in many cases you need to read through the
library code to figure out how things work. In these situations it's very
helpful to be as comfortable as possible in C++. The benefit of using Python
instead of C++ would be fairly minimal in my opinion because so much of
analysis work depends on understanding these libraries that are written in a
lower level language out of necessity.

What occurred to me while reading this article though is that we should
perhaps be using Python for our scripting needs. We have a number of scripts
that we use regularly for querying databases and submitting jobs and most of
them are written in Perl. I think that Python would be much easier to read and
hack; especially because most of the physicists don't know Perl.

------
masterzora
Background: I've done a touch of IDL astronomy programming with Marc Buie. I
haven't touched IDL or astronomy for about a year, though I am still in
contact with a couple astronomers.

In my (anecdotal) experience, it seems that a number of astronomers would
actually love to move to Python but I've only seen one actually make an effort
to make the move. The primary reason cited has been that some particular
library modules they use haven't been ported yet. Glancing around the links
from the article, it definitely seems that the porting has come a long way,
but that's not the same thing as completeness.

Now, obviously the best solution would be if these astronomers each took it
upon themselves to translate their own necessary tools and contribute back to
the Python community, but that's pretty unrealistic, I think. I write Python
for at least a good 8-10 hours/day and my IDL was clean, tight, and well-
documented and I'm still terrified of the thought of translating my project.

Of course, the other question I have (and would _love_ an answer to) is how
well Python holds up performance-wise to well-crafted IDL astronomy code. We
were working with a data set large enough that, even on a cluster, each step
of the process took between several days and a couple weeks. If Python could
improve that, it would have been amazing, but if it would only hurt then
Python would basically be useless for that project.

------
cop359
You know what's even easier to learn and more beginner friendly, has great
debugging tools and is very powerful? MATLAB.

And most engineers/scientists use it. If you know MATLAB, I don't see why you
would even bother going to figure out the dozens of Python libraries
available.

~~~
thesnark
MATLAB is a bad choice for science. It is proprietary, making it difficult to
share work among people who do not own a license, therefore making it more
difficult to reproduce results.

Not to mention the fact that the MATLAB language is extremely awkward anytime
you want to work with something that isn't a matrix.

~~~
dexen
GNU Octave [0] is mostly compatible with MATLAB. GPLed and implemented in
Fortran and C++, it's pretty much hack-able to your needs.

 _> MATLAB language is extremely awkward anytime you want to work with
something that isn't a matrix._

From my limited experience, that's true but rarely of relevance. You can, and
want to, use matrix operations all the way. Less bugs (simplier code), faster
execution.

[0] <http://www.gnu.org/software/octave/>

~~~
thesnark
In my experience 90% of scientific data analysis work is: getting the data,
cleaning it and transforming it into a form suitable for analysis. MATLAB
fails miserably at these tasks.

~~~
dexen
_> 90% of scientific data analysis work is: (...) and transforming it into a
form suitable for analysis._

Is that infinite recursion or endless loop? Or is there an end to it, caused
by quantum nature of work -- at some point the 90% becomes an undivisible
unit? ;-)

((terribly sorry, couldn't help it))

At any rate, that sounds like you want to feed the input through a pipe of
simple, programmable textual filters -- cue sed, awk etc. And then pipe into
standard input of something -- I know Octave has standard input, MATLAB I
wouldn't be so sure.

------
zwieback
I imagine any kind of number crunching would be done in a different language
or use optimized libraries. I wonder how many numerical apps are moving from
Fortran to modern C++, e.g. using templates for optimized number crunching.

~~~
tmarthal
I think that a lot of 'number crunching' scientific programs that evolved in
the 1990's were written in Matlab. Most of them in the 1980's and earlier
where in FORTRAN77. Where the comparison to python really gets interesting is
the addition of the REPL, the (now mature) NumPy/SciPy libraries, tkinter
(python Tk libraries), and a bunch of other common things that are causing
many established scientists and engineers to ditch their Matlab licenses and
move towards python.

This is more geared at the analyst level, which you could compare astronomers
to, rather than the scientific programmer level (who have been writing C or
C++ in the 1990s/2000s instead of Matlab). Python makes things neat because
the same libraries (mentioned in the article) that the scientific programmers
are using can now be used directly by the analysts/astronomers.

------
TheSOB88
Maybe finding those people and engaging them on a personal level would help
more than submitting to HN.

