QXRD
0.11.16
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
qxrd
source
qxrdpolarintensityfitter.cpp
Go to the documentation of this file.
1
#include "
qxrdpolarintensityfitter.h
"
2
#include "
qcepimagedata.h
"
3
#include <qmath.h>
4
#include <qmatrix4x4.h>
5
6
QxrdPolarIntensityFitter::QxrdPolarIntensityFitter
(
QcepDoubleImageDataPtr
data,
int
colNum) :
7
m_Data(data),
8
m_ColNum(colNum),
9
m_FittedAverage(0.0),
10
m_FittedAmplitude(0.0)
11
{
12
}
13
14
QxrdPolarIntensityFitter::~QxrdPolarIntensityFitter
()
15
{
16
}
17
18
double
QxrdPolarIntensityFitter::fittedAverage
()
19
{
20
return
m_FittedAverage
;
21
}
22
23
double
QxrdPolarIntensityFitter::fittedAmplitude
()
24
{
25
return
m_FittedAmplitude
;
26
}
27
28
int
QxrdPolarIntensityFitter::fit
()
29
{
30
if
(
m_Data
) {
31
int
nRows =
m_Data
->get_Height();
32
33
double
vStart =
m_Data
->get_VStart();
34
double
vStep =
m_Data
->get_VStep();
35
36
double
sumn = 0, sumaa = 0, sumab = 0, sumbb = 0, sumva = 0, sumvb = 0;
37
38
for
(
int
i=0; i<nRows; i++) {
39
double
x = vStart + i*vStep;
40
double
a = 1;
41
double
b = cos(2.0*x*M_PI/180.0);
42
double
v =
m_Data
->value(
m_ColNum
, i);
43
44
if
(v == v) {
45
sumn += 1;
46
sumaa += a*a;
47
sumab += a*b;
48
sumbb += b*b;
49
50
sumva += v*a;
51
sumvb += v*b;
52
}
53
}
54
55
if
(sumn > 5) {
56
QMatrix4x4 m;
// Initialized as unit matrix
57
58
m(0,0) = sumaa;
59
m(1,0) = sumab;
60
m(0,1) = sumab;
61
m(1,1) = sumbb;
62
63
bool
invertible;
64
65
QMatrix4x4 inv = m.inverted(&invertible);
66
67
if
(invertible) {
68
m_FittedAverage
= inv(0,0)*sumva + inv(0,1)*sumvb;
69
m_FittedAmplitude
= inv(1,0)*sumva + inv(1,1)*sumvb;
70
}
else
{
71
m_FittedAverage
= sumva/sumaa;
72
m_FittedAmplitude
= 0;
73
}
74
}
75
}
76
77
return
true
;
78
}
79
QxrdPolarIntensityFitter::fit
int fit()
Definition:
qxrdpolarintensityfitter.cpp:28
QxrdPolarIntensityFitter::~QxrdPolarIntensityFitter
~QxrdPolarIntensityFitter()
Definition:
qxrdpolarintensityfitter.cpp:14
QxrdPolarIntensityFitter::m_Data
QcepDoubleImageDataPtr m_Data
Definition:
qxrdpolarintensityfitter.h:19
qxrdpolarintensityfitter.h
QxrdPolarIntensityFitter::m_FittedAverage
double m_FittedAverage
Definition:
qxrdpolarintensityfitter.h:21
qcepimagedata.h
QxrdPolarIntensityFitter::m_FittedAmplitude
double m_FittedAmplitude
Definition:
qxrdpolarintensityfitter.h:22
QxrdPolarIntensityFitter::fittedAmplitude
double fittedAmplitude()
Definition:
qxrdpolarintensityfitter.cpp:23
QxrdPolarIntensityFitter::fittedAverage
double fittedAverage()
Definition:
qxrdpolarintensityfitter.cpp:18
QxrdPolarIntensityFitter::m_ColNum
int m_ColNum
Definition:
qxrdpolarintensityfitter.h:20
QxrdPolarIntensityFitter::QxrdPolarIntensityFitter
QxrdPolarIntensityFitter(QcepDoubleImageDataPtr data, int colNum)
Definition:
qxrdpolarintensityfitter.cpp:6
QcepDoubleImageDataPtr
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr
Definition:
qcepimagedata-ptr.h:16
Generated by
1.8.10