High-quality scientific graphics with MathGL: An interview with Alexey Balakin

This week we have for you an interview with Alexey Balakin the lead developer of MathGL a library to render high-quality scientific graphics and manage big data arrays. Do not miss the video!

F4S: Hello Alexey. Please, give us an introduction about yourself.

Alexey: I’m Alexey Balakin, 35 years old, Russian (live in Nizhny Novgorod), married, have newborn son.

I work in the Institute of Applied Physics Russian Academy of Sciences (IAP RAS) as senior researcher. I defended Ph.D. in plasma physics at 2001, and recently (31th October) defended a secondary degree (i.e. Russian doctor of science degree). My area of interest includes electron-ion collisions in strong electromagnetic fields, nonlinear optics (including Raman compression in plasma and self-action/self-compression of few-cycle pulses), quasioptics (first of all for EC heating of magnetized plasma). The theory of collisions in strong fields was awarded by Russian state prize for young scientist in the area of science and technology in 2004.

F4S: What is MathGL?

Alexey: MathGL is …

* a library for making high-quality scientific graphics under Linux and Windows;
* a library for the fast data plotting and data processing of large data arrays;
* a library for working in window and console modes and for easy embedding into other programs;
* a library with large and growing set of graphics.

In fact, MathGL now (v.1.*) is just a core for data plotting. But for next release (v.2.0) it will contain also a set of programs for WYSIWYG data plotting (based on UDAV another of my programs, http://udav.sourceforge.net/). (F4S note: check this fun use for UDAV)


F4S: Why and when did MathGL come to be?

Alexey: I think that I should start from “when”. It was at 2004 during my stay in Princeton (USA). I was involved into studying laser pulse compression in plasma by Raman backscattering. One of the goals of this study was determining the optimal conditions for the experiment, which required a lot of heavy numerical simulations. They were performed on a computer cluster and I experienced some difficulties downloading to local PC, processing and plotting these huge 2D and/or 3D data arrays.

Moreover, the data sizes were so big that usual tools (like, Matlab) couldn’t plot them correctly (and/or quickly). This triggered the initial impulse for creating my own tool for plotting in the cluster, i.e. exactly at the place where the data was produced.

This gives an answer for question “why”: I needed a tool for making plots of large (or huge) data arrays. Moreover, I needed a tool which can be used via SSH session (i.e. in console, without any GUI) or as a part of another program (i.e. to be library). My project, which satisfied these requirements, became MathGL. At the same time, a GUI is very useful for fine tunning of the plot. As a result, I wrote UDAV, which use its own simple (I hope) script language for plotting. In parallel, I got many suggestions for making special kinds of plot (like, flows, ternary, belts, different diagrams, boxplot, candle plot and so on). It made MathGL one of the tools with the most wide set of plot kinds.

So, MathGL was and is a tool which I use in my scientific work constantly.

F4S: In which language(s) and platform(s) is the project developed?

Alexey: Most of the code is written in C++. It allows me to deeply optimize the plotting routines. Also it gives me ability to easily write interfaces to other languages: C, Forth and Fortran. The first one can be used directly or via SWIG interface in a lot of languages. Right now two of them (Python and Octave) are included by default.

There is a difference in v.2.0 — the structure became more complicated:

1. low-level (in development) is written in C++;
2. mid-level has pure-C functions for all MathGL features;
3. high-level has C++ classes which contain only inline functions calling C-functions;
4. swig-level uses high-level classes for providing interfaces.

Such structure allows one:

* to use the same binary for any C++ compiler (without recompilation);
* to extend (derive own classes) standard classes by its own plotting or data processing functions.

Project was intentionally cross-platform — when I started it I used Linux (on server/cluster) and Windows (on laptop; now I prefer Linux too). Many people have reported that MathGL can be compiled in MacOS too.
Surface plot

Surface plot

F4S: Does MathGL have sponsors? How are the sponsors supporting the project?

Alexey: Hmm, yes. I’d received once some funds for extending MathGL to some specific functions. The prize of Troophes du Libre was very helpful too — MathGL won 1st prize in category “Science” on Troophes du Libre competition at 2009. Also I received some money from Adsense, but it is really small and I’m thinking about removing it.

F4S: How many users do you estimate MathGL have?

Alexey: This is difficult question. There are more than 3000 downloads for v.1.11.2 and about 1300 downloads for UDAV (latest version only). These numbers don’t include downloads from other sites, from Linux repositories and so on. Also I know a number of users who use latest SVN version only.

F4S: Do you know where is MathGL used?

Alexey: Hmm, I never try to collect such kind of statistics. I know about several Russian institution … no idea.

F4S: How many team members does the project have?

Alexey: There are 3 members. I’m responsible for most of thecode. Dmitry Kulagin is responsible for configure/make/install procedures. And Michail Vidiassov is responsible for IDTF/U3D export, MacOS support and partially for font rendering.

F4S: In what areas of MathGL development do you currently need help?

Alexey: I can denote 4 areas:

1. Testing and possible writing interfaces for different
languages. As I said before, MathGL has SWIG interface, which can
support about 20 languages (including Java, D, C#, R, Ruby and so on).
But only two of them (Python and Octave) are actually supported now –
the languages which I more or less know.

2. Writing widgets for different toolkits. Again, right now I use Qt
and FLTK toolkits, and MathGL has widgets for these toolkits only. I
more or less know wxWidgets and plan to write a widget for WX too. But
right now I have no idea about GTK and other ones.

3. Writing functions for import data from more or less exotic formats
(like DICOM). And more generally — writing or suggesting data
processing or data plotting functions.

4. And of course, improving documentation, adding translations (now
only English and Russian ones are written), writing HOWTOs or guides.

F4S: How can people get involved with the project?

Alexey: See question above. Also, they can send me suggestions for new plots, new features and so on. And recommend this software. And use this software 🙂

F4S: What features are in the roadmap?

Alexey: There are a lot of features, which are already done in SVN version — I planned to make release at October, but was too busy with thesis defense and business trip to France … so, I hope it will be finished by winter.

These features include new method for primitive drawing (should be faster), new separation of C/C++ interface (see question #4), export to a set of new formats (LaTeX, 3D formats, bitmap formats and so on), new kinds of plot, quaternary coordinates and automatic projections, axis labeling and so on.

Also there are several features which should be done before release:

1. Parallelization — it is mostly done, but needs minor improvements.
2. Import data from animated GIF and DICOM files — I’m not sure that will be in v.2.0.
3. Export graphics to 3D formats (X3D or VRML, JavaScript+WebGL)
4. Adding GTK and WX widgets — again not for v.2.0.
5. Adding new plot kinds (mostly some exotic ones)
6. Adding automatic plot projections — it will become a bit closer to CAD.
7. Strongly improve UDAV and include it in MathGL. Here I plan to write something like click-and-plot interface (as addition to current script-oriented interface). Exactly this point is the major delay for release of v.2.0.

And finally, I have to describe new features in MathGL documentation, (re-)write examples and hints.

F4S: Which projects, blogs or sites related to open source software for science can you recommend?

Alexey: For scientific applications: TeX, Maxima and its front-end wxMaxima, Qt, GSL, FFTW3, SWIG, FLTK — very fast and simple but have limited Unicode support (it seems that it was improved in latest version)

In fact, there are a lot of good projects, starting from Gnome and KDE, including kdevelop, firefox, thunderbird, gimp, inkscape, libre-office, and games (kdegames, wesnoth, …) and many other. Generally the idea of open source with repositories of thousands useful programs and libraries which can cover most of areas looks very attractive.

F4S: Why do you consider free/libre open source software important for the advancement of your field?

Alexey: Because, as I said before, open source contain tools for most of my (scientific and home usage) interests. It is much stabler and much better integrated as similar tools under MS Windows. And it looks much more functional in my opinion. The only lack (for me) was the absence of good plotting tool, but now that gap is closed by MathGL.

Yes, there are areas where there are no good enough tools (for example, CAD). But open source looks well suitable for office, for programming, for science, for home, and possible for design and photography.

F4S: Is there any other topic you would like our readers to know about?

Alexey: Most of my projects are more or less specific — for calculation of some scientific tasks. There is a project (named PocketMK) of general interest — it is a simulator of a famous soviet programmable calculator MK-61. Unfortunately, it was written many years ago, and was written for devices with Windows Mobile. I plan to rewrite PocketMK for Android but right now I have no time for it.

Interview: MathGL Alexey Balakin Trophées du Logiciel Libre Free Software Awards

F4S: Where people can contact you and learn more about MathGL?

Alexey: The web-site is http://mathgl.sourceforge.net/ . The most appropriate way to contact me is google group http://groups.google.com/group/mathgl , another way is via e-mail or in forum (http://sourceforge.net/projects/mathgl/forums — but I do not look on it so often).

F4S: Thank you for sharing with us more about you and MathGL.

Alexey: It was a pleasure for me.

About admin_rsquareedge