qse  0.5.4
Public Member Functions | Private Attributes | Friends | List of all members
QseScanAverager Class Reference

#include <qsescanaverager.h>

Inheritance diagram for QseScanAverager:
Inheritance graph

Public Member Functions

 QseScanAverager (QseDataSet *inData, QseDataSet *outData, const QString &name, QObject *parent=0)
 
void exec ()
 
void startAveraging ()
 
void addScanToAverage (int i)
 
void finishAveraging ()
 
- Public Member Functions inherited from QseEXAFSOperator
 QseEXAFSOperator (QseDataSet *inData, QseDataSet *outData, const QString &name, QObject *parent=0)
 
QseDataSetinputData ()
 
QseDataSetoutputData ()
 
bool matchesEnergyPattern (const QseColumn *col, int colnum)
 
bool matchesEnergyColumn (const QseColumn *col, int colnum)
 
bool matchesDetectorPattern (const QseColumn *col, int colnum)
 
bool matchesDetectorColumn (const QseColumn *col, int colnum)
 
bool matchesNormalizationPattern (const QseColumn *col, int colnum)
 
bool matchesNormalizationColumn (const QseColumn *col, int colnum)
 
bool matchesSecondsPattern (const QseColumn *col, int colnum)
 
bool matchesSecondsColumn (const QseColumn *col, int colnum)
 
bool matchesCopyPattern (const QseColumn *col, int colnum)
 
bool matchesCopyColumn (const QseColumn *col, int colnum)
 
bool matchesCopyNormalizedPattern (const QseColumn *col, int colnum)
 
bool matchesCopyNormalizedColumn (const QseColumn *col, int colnum)
 
bool matchesCopyRatePattern (const QseColumn *col, int colnum)
 
bool matchesCopyRateColumn (const QseColumn *col, int colnum)
 
bool matchesCopyTotalCountsPattern (const QseColumn *col, int colnum)
 
bool matchesCopyTotalCountsColumn (const QseColumn *col, int colnum)
 
- Public Member Functions inherited from QseOperator
 QseOperator (const QString &name, QObject *parent=0)
 
QString name () const
 
void setName (const QString &name)
 
void addParameter (QseParameter *parameter)
 

Private Attributes

QseScanm_Result
 
QseScanm_Totals
 
int m_NScans
 
int m_LookupIndex
 

Friends

class QseScanAveragerUI
 

Additional Inherited Members

- Public Types inherited from QseEXAFSOperator
enum  QseScanRole { UnspecifiedScanRole = -1, ScanNotUsedRole, ScanUsedRole }
 
enum  QseColumnRole {
  UnspecifiedRole = -1, NotUsedRole, DetectorRole, NormalizationRole,
  EnergyRole, SecondsRole, CopyRole, CopyNormalizedRole,
  CopyRateRole, CopyTotalCountsRole
}
 
- Signals inherited from QseOperator
void message (const QString &msg)
 
- Static Public Member Functions inherited from QseEXAFSOperator
static QColor colorForRole (QseColumnRole r)
 
static QColor backgroundColorForRole (QseColumnRole r)
 
- Protected Attributes inherited from QseEXAFSOperator
QseDataSetm_InputData
 
QseDataSetm_OutputData
 
QseRegExpParameter m_EnergyPattern
 
QseRegExpParameter m_DetectorPattern
 
QseRegExpParameter m_NormalizationPattern
 
QseRegExpParameter m_SecondsPattern
 
QseRegExpParameter m_CopyPattern
 
QseRegExpParameter m_CopyNormalizedPattern
 
QseRegExpParameter m_CopyRatePattern
 
QseRegExpParameter m_CopyTotalCountsPattern
 
QHash< const QseScan
*, QseScanRole
m_ScanExceptions
 
QHash< const QseColumn
*, QseColumnRole
m_Exceptions
 

Detailed Description

Definition at line 10 of file qsescanaverager.h.

Constructor & Destructor Documentation

QseScanAverager::QseScanAverager ( QseDataSet inData,
QseDataSet outData,
const QString &  name,
QObject *  parent = 0 
)

Definition at line 8 of file qsescanaverager.cpp.

9  : QseEXAFSOperator(inData, outData, name, parent),
10  m_Result(NULL),
11  m_Totals(NULL),
12  m_NScans(0),
13  m_LookupIndex(0)
14 {
15 }
QseScan * m_Result
QseEXAFSOperator(QseDataSet *inData, QseDataSet *outData, const QString &name, QObject *parent=0)
QString name() const
Definition: qseoperator.cpp:11
QseScan * m_Totals

Member Function Documentation

void QseScanAverager::addScanToAverage ( int  i)

Definition at line 32 of file qsescanaverager.cpp.

References QseColumn::data(), QseScan::header(), QseEXAFSOperator::m_InputData, m_LookupIndex, m_NScans, m_Result, m_Totals, QseColumn::name(), QseScan::name(), QseScan::scanCommand(), QseColumn::setData(), and QseOperator::setName().

33 {
34  QseScan *scan = m_InputData -> scan(i);
35 
36  if (scan) {
37  if (m_NScans == 0) {
38  m_Result -> setName(scan->name()+"_avg");
39  m_Result -> setScanCommand(scan->scanCommand()+"_avg");
40  m_Result -> setScanDateTime(QDateTime::currentDateTime());
41  m_Result -> mergeHeaders(scan->header());
42 
43  m_Totals -> setName(scan->name()+"_totals");
44  m_Totals -> setScanCommand(scan->scanCommand()+"_totals");
45  m_Totals -> setScanDateTime(QDateTime::currentDateTime());
46  m_Totals -> mergeHeaders(scan->header());
47 
48  int ncols = scan -> columnCount();
49 
50  for (int i=0; i<ncols; i++) {
51  QseColumn *col = scan -> column(i);
52  QString nam = col->name();
53 
54  QseColumn *res = m_Result -> appendColumn(nam, col);
55  QseColumn *sum = m_Totals -> appendColumn(nam, col);
56 
57  sum -> assignment(1.0);
58  }
59  } else {
60  m_Result -> appendHeader("#C Averaged : "+scan->scanCommand());
61  m_Result -> mergeHeaders(scan->header());
62 
63  int ncols = scan -> columnCount();
64 
65  for (int i=0; i<ncols; i++) {
66  QseColumn *col = scan -> column(i);
67  QString nam = col->name();
68 
69  QseColumn *res = NULL;
70  QseColumn *sum = NULL;
71 
72  if (m_LookupIndex) {
73  res = m_Result -> column(i);
74  sum = m_Totals -> column(i);
75  } else {
76  res = m_Result -> column(nam);
77  sum = m_Totals -> column(nam);
78  }
79 
80  if (res == NULL) {
81  res = m_Result -> appendColumn(nam, col);
82  if (sum != NULL) {
83  printf("Problem: sum != NULL when res == NULL\n");
84  }
85  sum = m_Totals -> appendColumn(nam, col);
86  sum -> assignment(1.0);
87  } else {
88  if (sum == NULL) {
89  printf("Problem: sum == NULL when res != NULL\n");
90  sum = m_Totals -> appendColumn(nam, col);
91  sum -> assignment(1.0);
92  }
93 
94  int nRowsIn = col -> rowCount();
95  int nRowsOut = res -> rowCount();
96 
97  if (nRowsOut < nRowsIn) {
98  res -> setRowCount(nRowsIn);
99  sum -> setRowCount(nRowsIn);
100  }
101 
102  for (int r=0; r<nRowsIn; r++) {
103  double vres = res->data(r);
104  double vsum = sum->data(r);
105 
106  res->setData(r, vres+col->data(r));
107  sum->setData(r, vsum+1.0);
108  }
109  }
110  }
111  }
112 
113  m_NScans += 1;
114  }
115 }
const double * data() const
Definition: qsecolumn.cpp:62
QStringList header() const
Definition: qsescan.cpp:167
void setData(int n, double v)
Definition: qsecolumn.cpp:79
void setName(const QString &name)
Definition: qseoperator.cpp:16
QString scanCommand() const
Definition: qsescan.cpp:226
QseScan * m_Result
QseDataSet * m_InputData
QString name() const
Definition: qsecolumn.cpp:26
QString name() const
Definition: qsescan.cpp:31
QseScan * m_Totals
void QseScanAverager::exec ( )
virtual

Implements QseOperator.

Definition at line 17 of file qsescanaverager.cpp.

18 {
19 }
void QseScanAverager::finishAveraging ( )

Definition at line 117 of file qsescanaverager.cpp.

References QseScan::column(), QseColumn::division(), QseEXAFSOperator::m_OutputData, m_Result, and m_Totals.

118 {
119  int ncols = m_Result -> columnCount();
120 
121  for (int i = 0; i<ncols; i++) {
122  QseColumn *res = m_Result->column(i);
123  QseColumn *tot = m_Totals->column(i);
124 
125  res->division(tot);
126  }
127 
128  delete m_Totals;
129 
130  m_Result = NULL;
131  m_Totals = NULL;
132 
133  m_OutputData -> emitOperationCompleted();
134 }
void division(const QseColumn *col)
Definition: qsecolumn.cpp:128
QseScan * m_Result
QseColumn * column(int n) const
Definition: qsescan.cpp:104
QseDataSet * m_OutputData
QseScan * m_Totals
void QseScanAverager::startAveraging ( )

Definition at line 21 of file qsescanaverager.cpp.

References QseEXAFSOperator::m_InputData, m_NScans, QseEXAFSOperator::m_OutputData, m_Result, and m_Totals.

22 {
23  m_OutputData -> setHeader(m_InputData -> header());
24  m_OutputData -> setFileName(m_InputData -> fileName()+"_avg");
25 
26  m_Result = m_OutputData -> appendScan();
27  m_Totals = new QseScan("totals");
28 // m_Totals = m_OutputData -> appendScan();
29  m_NScans = 0;
30 }
QseScan * m_Result
QseDataSet * m_InputData
QseDataSet * m_OutputData
QseScan * m_Totals

Friends And Related Function Documentation

friend class QseScanAveragerUI
friend

Definition at line 20 of file qsescanaverager.h.

Member Data Documentation

int QseScanAverager::m_LookupIndex
private

Definition at line 32 of file qsescanaverager.h.

Referenced by addScanToAverage().

int QseScanAverager::m_NScans
private

Definition at line 31 of file qsescanaverager.h.

Referenced by addScanToAverage(), and startAveraging().

QseScan* QseScanAverager::m_Result
private

Definition at line 29 of file qsescanaverager.h.

Referenced by addScanToAverage(), finishAveraging(), and startAveraging().

QseScan* QseScanAverager::m_Totals
private

Definition at line 30 of file qsescanaverager.h.

Referenced by addScanToAverage(), finishAveraging(), and startAveraging().


The documentation for this class was generated from the following files: