ePiX Updates - Easier File Reading

In the past few weeks I have been doing lots of data analysis and graph plotting. I use some graphical tools such as Grace, Veusz and QtiPlot but when doing lots of plots for a big document I wanted something a little more scriptable.

ePiX seemed to fit this bill and when I contacted the author about a few problems I had getting it to work he was very responsive. He is a mathematician whereas I am a physicist and have to handle lots of data in general. So I found the data file reading quite fragile. It does however have some great advantages such as being able to write LaTeX equations right into the graphs and figures.

Absorption profile plotted by ePiX

The image shown above shows a plot of the absorption profile of a gold nanoparticle suspension. In the recent ePiX 1.0.24 release I added a tokeniser to the file reading functions of the data_file class in order to make data file reading more robust and I was able to read all my data files in using a simple loop and plot them as shown.

I have also just finished a data pruning function for the same class, but I am not sure if there is a better way to implement it. It uses brute force right now to iterate through the data and erase unwanted points. It does work well but I am not sure if there is a better way to accomplish its goal using some of the STL algorithms. It does need to delete the whole row though.

  void data_file::prune(double min, double max, unsigned int col)
  {
    // Erase rows where the data is outside of the specified range
    std::vector::iterator> iter(m_data.size());
    for (unsigned int i = 0; i < m_data.size(); i++)
      iter.at(i) = m_data.at(i).begin();

    while (iter.at(0) != m_data.at(0).end())
    {
      if ( *iter.at(col-1) < min || *iter.at(col-1) > max )
      {
        for (unsigned int j = 0; j < m_data.size(); j++)
          m_data.at(j).erase(iter.at(j));
      }
      else
      {
        for (unsigned int j = 0; j < m_data.size(); j++)
          iter.at(j)++;
      }
    }
  }

This pretty much covers the extra bits I needed for data analysis. A nice legend function would be good as drawing legends isn't as automated as I might like. I would welcome any feedback on the prune function as I think this would make a good addition to ePiX.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Marcus D. Hanwell on :

Marcus D. HanwellI hadn't come across PyXPlot before. I did spot asymptote which seems to be very similar. I think one of the clinchers for me was ePiX being C++ and so I didn't have to learn that much and I can leverage my knowledge of C++ to perform analysis and scripting of my graphs.

I have to admit it has been tough finding the perfect visualisation environment for me. There is a lot of choice out there but nothing quite ticks all the boxes for me. Extending ePiX to tick the bigger boxes seemed reasonable. Choice is certainly good but there is only so long one wants to spend getting to grips with a new data plotting tool...

drear on :

drearLooks nice indeed.

Yet, as an applied statistician, mostly, the The R Project for Statistical Computing has been superior environment for almost every single problem I have encountered in my recent work (a slight exaggeration, but still...) . And no other program provides such plotting facilities.

Although, like ePiX, presumably, it has always had problems with huge data sets even in high-quality cluster environments. Nevertheless, I recommend to get acquainted with it if you are not yet familiar with it.

Marcus D. Hanwell on :

Marcus D. HanwellI am familiar with R, you will even find me in the ChangeLog for the Gentoo package. I could never get it to produce graphs I was happy with from a visual standpoint and right now (as I am writing up my thesis) presentation is the most important thing to me.

ePiX also allows me to leverage my C++ knowledge and use the many libraries available for C++. It is more LaTeX like too which is a plus for me as I use Kile may be 70% of the time right now. For producing figures in papers ePiX would also seem like a great choice to me but I would certainly use other tools for analysis.

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.