9 const QList< int >& Includes,
12 const QString& dataType,
16 data( raw ), includes( Includes ), range_left( left ),
17 range_right( right ), order( initial_order ), residuals( r )
19 setWindowTitle( tr(
"Determine Radial Invariant Noise" ) );
22 QHBoxLayout*
main =
new QHBoxLayout(
this );
23 main->setSpacing ( 2 );
24 main->setContentsMargins( 2, 2, 2, 2 );
28 QVBoxLayout* info =
new QVBoxLayout();
34 QHBoxLayout* spin =
new QHBoxLayout;
36 QLabel* lb_spin =
us_label( tr(
"Fit Order:" ) );
37 spin->addWidget( lb_spin );
41 connect(
ct_order, SIGNAL( valueChanged (
double ) ),
44 info->addLayout( spin );
47 QHBoxLayout* buttons =
new QHBoxLayout;
50 connect( pb_cancel, SIGNAL( clicked() ), SLOT( reject() ) );
51 buttons->addWidget( pb_cancel );
54 connect( pb_accept, SIGNAL( clicked() ), SLOT( accept() ) );
55 buttons->addWidget( pb_accept );
57 info->addLayout( buttons );
59 main->addLayout( info );
61 QString y_axis = tr(
"Absorbance" );
62 if ( dataType ==
"IP" ) y_axis = tr(
"Fringes" );
66 tr(
"Scan Time (seconds)" ), y_axis );
71 main->addLayout( plot );
78 order = (int)new_order;
82 double* coeffs =
new double[
order ];
83 double* absorbance_integral =
new double[ scan_count ];
84 double* fit =
new double[ scan_count ];
85 double* scan_time =
new double[ scan_count ];;
93 for (
int i = 0; i < scan_count; i++ )
95 if ( !
includes.contains( i ) )
continue;
103 ( indexRight - indexLeft );
105 absorbance_integral[ scan ] = 0.0;
108 for (
int j = indexLeft + 1; j <= indexRight; j++ )
112 absorbance_integral[ scan ] += avg * delta_r;
120 for (
int i = 0; i < scan_count; i++ )
122 if ( !
includes.contains( i ) )
continue;
131 for (
int i = 0; i < scan_count; i++ )
137 for (
int j = 0; j <
order; j++ )
138 fit[ scan ] += coeffs[ j ] * pow(
data.
scanData[ i ].seconds, j );
140 residuals << absorbance_integral[ scan ] - fit[ scan ];
149 QString s = tr(
"Coefficients for %1th order polynomial fit\n" ).arg(
order );
152 for (
int i = 0; i <
order; i++ )
154 QString coef = QString::number( coeffs[ i ],
'e', 6 );
155 if ( coef.at( 0 ) !=
'-' ) coef.prepend(
" " );
156 s = tr(
"Coefficient %1: " ).arg( i + 1 ) + coef;
160 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
165 for (
int i = 0; i < scan_count; i++ )
167 if ( !
includes.contains( i ) )
continue;
173 integrals->setData( scan_time, absorbance_integral, scan );
174 integrals->setPen( QPen( Qt::yellow ) );
177 polyfit->setData( scan_time, fit, scan );
178 integrals->setPen( QPen( Qt::magenta ) );
183 delete [] absorbance_integral;
191 const QList< int >& includes,
195 QList< double >& residuals )
197 int scan_count = data.
scanData.size();
199 double* coeffs =
new double[
order ];
200 double* absorbance_integral =
new double[ scan_count ];
201 double* fit =
new double[ scan_count ];
202 double* scan_time =
new double[ scan_count ];;
210 for (
int i = 0; i < scan_count; i++ )
212 if ( ! includes.contains( i ) )
continue;
219 double delta_r = ( range_right -
range_left ) /
220 ( indexRight - indexLeft );
222 absorbance_integral[ scan ] = 0.0;
225 for (
int j = indexLeft + 1; j <= indexRight; j++ )
229 absorbance_integral[ scan ] += avg * delta_r;
237 for (
int i = 0; i < scan_count; i++ )
239 if ( ! includes.contains( i ) )
continue;
240 scan_time[ scan++ ] = data.
scanData[ i ].seconds;
248 for (
int i = 0; i < scan_count; i++ )
250 if ( includes.contains( i ) )
254 for (
int j = 0; j <
order; j++ )
255 fit[ scan ] += coeffs[ j ] * pow( data.
scanData[ i ].seconds, j );
257 residuals << absorbance_integral[ scan ] - fit[ scan ];
266 delete [] absorbance_integral;