Emacs in scientific computing

Part 5 of my series of Scientific Computing underdogs!

GNU emacs is widely know as a powerful text editor for, e.g., programming. Its indentation and syntax highlighting are excellent. However, I realized I have been using it for a while to deal with raw data – in this regard one could call this program an underdog, I guess (or whatever, I just want to keep it with the rest of the SciCompUD series). The feature I use the most is “keyboard macros”, instant macros that are easy to define and use.

Continue reading


Ok, how is awk an underdog in scientific computing. Well, it is very well suited for performing simple tasks on data files.

E.g., you may run

awk ‘{print $1-45,$2/1800*0.82}’ intr.dat

To shift the x value from the first column of the data file, and scale the y value from the second. Or anything one could imagine. The result can be put in another file ( ” … > result.dat “), or piped into another program, e.g. xmgrace:

awk ‘{print $1-45,$2/1800*0.82}’ intr.dat > xmgrace -pipe

Script files are also helpful to perform more complex operations on data files, like the following example, that prints just certain lines of a file:


(NR==1) { nn=$1+2 }

{ if ((NR-1)%nn==0) { print $1 }
else if ((NR-1)%nn!=nn-1) {
print $1, 1*$4

print nn


awk + gnuplot together!!!

Look at this beautiful command that plots a data file, plus the data in line 2:

plot ‘data.dat’ w l, “< awk ‘(NR==2) {print $0}’ data.dat “

The command must be executed from gnuplot. It works by “piping” the output of the awk command directly into gnuplot.


Part 3 of my series on scientific computing underdogs!!!

capture of gnuplot session

capture of gnuplot session

gnuplot has been around for a long, long time. One of its main features is that it can run as a session, in a terminal. This is helpful when graphics are not available, e.g. in a remote login session. Just type “set terminal dumb” to get a gorgeous, ascii plot of your data. The session uses a language that is also largely common to awk, which is nice. E.g.

plot ‘file.dat’ using ($3*1000):(log($2))

plots log of column 2 of the datafile versus column 3, multiplied by 1000.

Another nice feature is its 3D capabilities, including 2D level maps of 3D functions.


Part 2 of my series of scientific computing underdogs!

xmgrace capture

xmgrace capture

When it comes to plotting and analyzing data, I think a lot of people use (xm)grace, specially those working in linux and other UNIX-like environments. The other main plotting solution is, of course, gnuplot, which is nicely complementary (probably an underdog, too, deserving its own entry).

In Microsoft environments, people tend to use the all-powerful origin, which is rather expensive (I wonder how many actually pay for it in my country, where piracy runs rampant).

Continue reading


Part 1 on my series of scientific software underdogs!

Caption of g3data

Caption of g3data

Thanks to Descartes, most publications show graphs of results, but no data. Of course, the corresponding tables would take lots of paper space. (Lately, many journals offer free additional online repositories for this sort of data, but this good idea seems to be catching on rather slowly.) Anyway, g3data is a simple utility to grab data from graphs.

Usually, you take the graph from a scan or capture it from a pdf file; then, you still need some previous cropping using photo software (e.g. the gimp) — which could also be used to grab the data, by looking at the coordinates and converting. But g3data simplifies this a bit. It also works with skewed graphs (e.g., from manual scans) and logarithmic scales.


A similar solution: getdata graph digitizer