epix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ePiX-devel] Proposed ata pruning function


From: Marcus D. Hanwell
Subject: [ePiX-devel] Proposed ata pruning function
Date: Fri, 6 Apr 2007 23:46:44 +0100
User-agent: KMail/1.9.6

Hi,

I have been working on a data pruning function today and have come up with a 
prototype. Not sure if it is still a little sloppy or if anyone else had any 
ideas on what they would like from it. For me it goes along with my improved 
data_file read function - read in my data files and select the part of the 
graph we are interested in.

This is great for highlighting particular sections in a different colour (plot 
a pruned section in red for example) or deleting the background noise points 
in some graphs. I am sure there are lots more uses too. You can ofcourse use 
the write function to output them to a file and analyse further.

I have already been using it in my own analysis and it does what I am looking 
for. Typically you would use it by issuing,

data_file data("my_data.dat");
data.prune(2.0, 20.0, 1);
data.plot(PATH);

It defaults to pruning on column 1 and would delete all points outside the 
range 2.0 < x < 20.0 in this particular case. Below is my proposed code for 
the function.

Thanks,

Marcus

  void prune(double min, double max, unsigned int col = 1);

  void data_file::prune(double min, double max, unsigned int col)
  {
    // Erase rows where the data is outside of the specified range
    std::vector<std::vector<double>::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)++;
      }
    }
  }

Attachment: pgpEQ5aS1BMv2.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]