1 #include <QDomDocument>
19 return scanData.size();
25 return index( xvalues, xvalue );
31 return xvalues[ radx ];
37 return xvalues[ wavx ];
43 return scanData[ scnx ].rvalues[ radx ];
48 return scanData[ scnx ].rvalues[ radx ];
54 if ( scnx < 0 || scnx >= scanData.size() ||
55 radx < 0 || radx >= scanData[ scnx ].rvalues.size() )
58 scanData[ scnx ].rvalues[ radx ] = value;
67 return ( use_stddev ? scn->
stddevs[ radx ] : 0.0 );
73 int scansize = scanData.size();
76 for (
int ii = 0; ii < scansize; ii++ )
78 sum += scanData[ ii ].temperature;
81 return ( sum / (
double)scansize );
87 int scansize = scanData.size();
91 for (
int ii = 0; ii < scansize; ii++ )
93 double temp = scanData[ ii ].temperature;
94 smin = qMin( smin, temp );
95 smax = qMax( smax, temp );
98 return qAbs( smax - smin );
104 return xvalues.size();
110 return scanData.size();
116 return index( xvalues, xvalue );
122 return xvalues[ radx ];
128 return xvalues[ wavx ];
134 return scanData[ scnx ].rvalues[ radx ];
140 return scanData[ scnx ].rvalues[ radx ];
146 if ( scnx < 0 || scnx >= scanData.size() ||
147 radx < 0 || radx >= scanData[ scnx ].rvalues.size() )
150 scanData[ scnx ].rvalues[ radx ] = value;
159 return ( use_stddev ? scn->
stddevs[ radx ] : 0.0 );
165 int scansize = scanData.size();
168 for (
int ii = 0; ii < scansize; ii++ )
170 sum += scanData[ ii ].temperature;
173 return ( sum / (
double)scansize );
179 int scansize = scanData.size();
183 for (
int ii = 0; ii < scansize; ii++ )
185 double temp = scanData[ ii ].temperature;
186 smin = qMin( smin, temp );
187 smax = qMax( smax, temp );
190 return qAbs( smax - smin );
198 if ( ! ff.open( QIODevice::ReadOnly | QIODevice::Text ) )
return false;
199 QTextStream ts( &ff );
205 QString sc = ts.readLine();
206 QStringList pp = sc.split(
" ", QString::SkipEmptyParts );
208 if ( pp.size() < 8 )
return false;
210 data.
type = pp[ 0 ].toAscii()[ 0 ];
211 data.
cell = pp[ 1 ].toInt();
213 data.
rpm = pp[ 3 ].toDouble();
215 data.
seconds = pp[ 4 ].toDouble();
216 data.
omega2t = pp[ 5 ].toDouble();
217 data.
rpoint = pp[ 6 ].toDouble();
218 data.
count = pp[ 7 ].toInt();
221 data.
rpm = qRound( data.
rpm / 100.0 ) * 100.0;
227 bool interference_data = ( data.
type ==
'P' );
229 while ( ! ts.atEnd() )
233 pp = sc.split(
" ", QString::SkipEmptyParts );
234 if ( pp.size() == 1 )
235 pp = sc.split(
"\t", QString::SkipEmptyParts );
237 double xval = pp[ 0 ].toDouble();
238 double rval = pp[ 1 ].toDouble();
241 if ( ! interference_data && pp.size() > 2 )
243 sval = pp[ 2 ].toDouble();
264 if ( ! ff.open( QIODevice::WriteOnly ) )
return CANTOPEN;
265 QDataStream ds( &ff );
268 quint32 crc = 0xffffffffUL;
271 char magic[ 5 ] =
"UCDA";
272 write( ds, magic, 4, crc );
277 write( ds, fmt, 2, crc );
283 write( ds, (
const char*)&data.
cell, 1, crc );
293 memset( desc,
'\0',
sizeof desc );
296 strncpy( desc, dd.data(),
sizeof desc );
297 write( ds, desc,
sizeof desc, crc );
301 double min_radius = 1.0e99;
302 double max_radius = -1.0e99;
304 for (
int ii = 0; ii < data.
xvalues.size(); ii++ )
306 min_radius = qMin( min_radius, data.
xvalues[ ii ] );
307 max_radius = qMax( max_radius, data.
xvalues[ ii ] );
318 bool allz_stdd =
true;
322 for (
int ii = 0; ii < scCount; ii++ )
327 for (
int jj = 0; jj < ptCount; jj++ )
370 uf.f = (float) min_radius;
371 qToLittleEndian( uf.u, ui.u );
372 write( ds, ui.c, 4, crc );
374 uf.f = (float) max_radius;
375 qToLittleEndian( uf.u, ui.u );
376 write( ds, ui.c, 4, crc );
378 uf.f = (float) ( r2 - r1 );
379 qToLittleEndian( uf.u, ui.u );
380 write( ds, ui.c, 4, crc );
383 qToLittleEndian( uf.u, ui.u );
384 write( ds, ui.c, 4, crc );
387 qToLittleEndian( uf.u, ui.u );
388 write( ds, ui.c, 4, crc );
391 qToLittleEndian( uf.u, ui.u );
392 write( ds, ui.c, 4, crc );
395 qToLittleEndian( uf.u, ui.u );
396 write( ds, ui.c, 4, crc );
399 qToLittleEndian( (quint16)data.
scanData.size(), ui.u );
400 write( ds, ui.c, 2, crc );
403 for (
int ii = 0; ii < data.
scanData.size(); ii++ )
406 qToLittleEndian( crc, ui.u );
407 ds.writeRawData( ui.c, 4 );
431 char d[ 5 ] =
"DATA";
432 write( ds, d, 4, crc );
435 qToLittleEndian( uf.u, ui.u );
436 write( ds, ui.c, 4, crc );
438 uf.f = (float) data.
rpm;
439 qToLittleEndian( uf.u, ui.u );
440 write( ds, ui.c, 4, crc );
442 qToLittleEndian( (quint32)data.
seconds, ui.u );
443 write( ds, ui.c, 4, crc );
446 qToLittleEndian( uf.u, ui.u );
447 write( ds, ui.c, 4, crc );
450 si = (quint16)qRound( data.
wavelength * 10.0 );
451 qToLittleEndian<quint16>( si, ui.u );
454 write( ds, ui.c, 2, crc );
457 qToLittleEndian( uf.u, ui.u );
458 write( ds, ui.c, 4, crc );
460 quint32 valueCount = data.
rvalues.size();
461 qToLittleEndian( valueCount, ui.u );
462 write( ds, ui.c, 4, crc );
471 for (
int ii = 0; ii < data.
rvalues.size(); ii++ )
473 double rval = data.
rvalues[ ii ];
475 si = (quint16) qRound( ( rval - pp.
min_data1 ) / delta );
476 qToLittleEndian( si, ui.u );
477 write( ds, ui.c, 2, crc );
482 double sval = data.
stddevs[ ii ];
483 si = (quint16) qRound( ( sval - pp.
min_data2 ) / delta2 );
484 qToLittleEndian( si, ui.u );
485 write( ds, ui.c, 2, crc );
490 int flagSize = ( valueCount + 7 ) / 8;
496 ds.writeRawData( c, len );
503 if ( ! ff.open( QIODevice::ReadOnly ) )
return CANTOPEN;
504 QDataStream ds( &ff );
507 quint32 crc = 0xffffffffUL;
513 read( ds, magic, 4, crc );
514 if ( strncmp( magic,
"UCDA", 4 ) != 0 )
throw NOT_USDATA;
517 unsigned char ver[ 2 ];
518 read( ds, (
char*) ver, 2, crc );
519 quint32 version = ( ( ver[ 0 ] & 0x0f ) << 8 ) | ( ver[ 1 ] & 0x0f );
523 bool wvlf_new = ( version > (quint32)4 );
527 read( ds, type, 2, crc );
530 QStringList types = QStringList() <<
"RA" <<
"IP" <<
"RI" <<
"FI"
533 if ( ! types.contains( QString( type ) ) )
throw BADTYPE;
534 strncpy( data.
type, type, 2 );
544 read( ds, cell.c, 1, crc );
545 data.
cell = qFromLittleEndian( cell.i );
555 read( ds, desc, 240, crc );
581 read( ds, u1.c, 4, crc );
582 u2.I = qFromLittleEndian( u1.I );
585 read( ds, u1.c, 4, crc );
590 read( ds, u1.c, 4, crc );
591 u2.I = qFromLittleEndian( u1.I );
592 double delta_radius = u2.f;
594 read( ds, u1.c, 4, crc );
595 u2.I = qFromLittleEndian( u1.I );
596 double min_data1 = u2.f;
598 read( ds, u1.c, 4, crc );
599 u2.I = qFromLittleEndian( u1.I );
600 double max_data1 = u2.f;
602 read( ds, u1.c, 4, crc );
603 u2.I = qFromLittleEndian( u1.I );
604 double min_data2 = u2.f;
606 read( ds, u1.c, 4, crc );
607 u2.I = qFromLittleEndian( u1.I );
608 double max_data2 = u2.f;
610 read( ds, si.c, 2, crc );
611 qint16 scan_count = qFromLittleEndian( si.I );
615 for (
int ii = 0 ; ii < scan_count; ii ++ )
617 read( ds, u1.c, 4, crc );
618 if ( strncmp( u1.c,
"DATA", 4 ) != 0 )
throw NOT_USDATA;
623 read( ds, u1.c, 4, crc );
624 u2.I = qFromLittleEndian( u1.I );
628 read( ds, u1.c, 4, crc );
629 u2.I = qFromLittleEndian( u1.I );
633 sc.
rpm = qRound( sc.
rpm / 100.0 ) * 100.0;
636 read( ds, u1.c, 4, crc );
637 sc.
seconds = qFromLittleEndian( u1.I );
640 read( ds, u1.c, 4, crc );
641 u2.I = qFromLittleEndian( u1.I );
645 read( ds, si.c, 2, crc );
647 sc.
wavelength = qFromLittleEndian( si.I ) / 10.0;
649 sc.
wavelength = qFromLittleEndian( si.I ) / 100.0 + 180.0;
652 read( ds, u1.c, 4, crc );
653 u2.I = qFromLittleEndian( u1.I );
657 read( ds, u1.c, 4, crc );
658 valueCount = qFromLittleEndian( u1.I );
661 double factor1 = ( max_data1 - min_data1 ) / 65535.0;
662 double factor2 = ( max_data2 - min_data2 ) / 65535.0;
663 bool stdDev = ( min_data2 != 0.0 || max_data2 != 0.0 );
665 for (
int jj = 0; jj < valueCount; jj++ )
670 read( ds, si.c, 2, crc );
671 rval = qFromLittleEndian( si.I ) * factor1 + min_data1;
675 read( ds, si.c, 2, crc );
676 sval = qFromLittleEndian( si.I ) * factor2 + min_data2;
695 int bytes = ( valueCount + 7 ) / 8;
696 char* interpolated =
new char[ bytes ];
698 read( ds, interpolated, bytes, crc );
702 delete [] interpolated;
710 double radius = min_radius;
712 for (
int jj = 0; jj < valueCount; jj++ )
715 radius += delta_radius;
720 ds.readRawData( (
char*) &read_crc , 4 );
721 if ( crc != qFromLittleEndian( read_crc ) )
throw BADCRC;
734 ds.readRawData( cc, len );
740 QFile ff( filename );
741 if ( ! ff.open( QIODevice::ReadOnly ) )
return CANTOPEN;
743 QXmlStreamReader xml( &ff );
745 while ( ! xml.atEnd() )
749 if ( xml.isStartElement() )
751 if ( xml.name() ==
"identification" )
752 ident ( xml, parameters );
754 else if ( xml.name() ==
"run" )
755 run( xml, parameters );
757 else if ( xml.name() ==
"experiment" )
759 QXmlStreamAttributes a = xml.attributes();
760 parameters.
expType = a.value(
"type" ).toString();
765 bool error = xml.hasError();
768 if ( error )
return BADXML;
775 while ( ! xml.atEnd() )
777 if ( xml.isEndElement() && xml.name() ==
"identification" )
return;
779 if ( xml.isStartElement() && xml.name() ==
"runid" )
781 QXmlStreamAttributes a = xml.attributes();
782 parameters.
runID = a.value(
"value" ).toString();
785 if ( xml.isStartElement() && xml.name() ==
"editGUID" )
787 QXmlStreamAttributes a = xml.attributes();
788 parameters.
editGUID = a.value(
"value" ).toString();
791 if ( xml.isStartElement() && xml.name() ==
"rawDataGUID" )
793 QXmlStreamAttributes a = xml.attributes();
794 parameters.
dataGUID = a.value(
"value" ).toString();
803 QXmlStreamAttributes a = xml.attributes();
804 parameters.
cell = a.value(
"cell" ).toString();
805 parameters.
channel = a.value(
"channel" ).toString();
806 parameters.
wavelength = a.value(
"wavelength" ).toString();
811 while ( ! xml.atEnd() )
813 if ( xml.isEndElement() && xml.name() ==
"run" )
return;
815 if ( xml.isStartElement() && xml.name() ==
"parameters" )
816 params( xml, parameters );
818 if ( xml.isStartElement() && xml.name() ==
"operations" )
821 if ( xml.isStartElement() && xml.name() ==
"edited" )
824 if ( xml.isStartElement() && xml.name() ==
"excludes" )
833 while ( ! xml.atEnd() )
835 if ( xml.isEndElement() && xml.name() ==
"lambdas" )
return;
837 if ( xml.isStartElement() && xml.name() ==
"lambda" )
839 QXmlStreamAttributes a = xml.attributes();
840 parameters.
lambdas << a.value(
"value" ).toString().toInt();
850 bool isEquil = ( parameters.
expType ==
"Equilibrium" );
853 while ( ! xml.atEnd() )
855 if ( xml.isEndElement() && xml.name() ==
"parameters" )
return;
857 else if ( !xml.isStartElement() )
859 if ( xml.isEndElement() && xml.name() ==
"speed" )
866 else if ( xml.name() ==
"speed" )
868 QXmlStreamAttributes a = xml.attributes();
871 = a.value(
"value" ).toString().toDouble();
873 = a.value(
"scanStart" ).toString().toInt();
875 = a.value(
"scanCount" ).toString().toInt();
878 else if ( xml.name() ==
"meniscus" )
880 QXmlStreamAttributes a = xml.attributes();
881 parameters.
meniscus = a.value(
"radius" ).toString().toDouble();
887 else if ( xml.name() ==
"plateau" )
889 QXmlStreamAttributes a = xml.attributes();
890 parameters.
plateau = a.value(
"radius" ).toString().toDouble();
893 else if ( xml.name() ==
"air_gap" )
895 QXmlStreamAttributes a = xml.attributes();
896 parameters.
airGapLeft = a.value(
"left" ).toString().toDouble();
897 parameters.
airGapRight = a.value(
"right" ).toString().toDouble();
898 parameters.
gapTolerance = a.value(
"tolerance" ).toString().toDouble();
901 else if ( xml.name() ==
"baseline" )
903 QXmlStreamAttributes a = xml.attributes();
904 parameters.
baseline = a.value(
"radius" ).toString().toDouble();
907 else if ( xml.name() ==
"data_range" )
909 QXmlStreamAttributes a = xml.attributes();
910 parameters.
rangeLeft = a.value(
"left" ).toString().toDouble();
911 parameters.
rangeRight = a.value(
"right" ).toString().toDouble();
920 else if ( xml.name() ==
"od_limit" )
922 QXmlStreamAttributes a = xml.attributes();
923 parameters.
ODlimit = a.value(
"value" ).toString().toDouble();
932 while ( ! xml.atEnd() )
934 if ( xml.isEndElement() && xml.name() ==
"operations" )
return;
936 if ( xml.isStartElement() && xml.name() ==
"invert" )
939 if ( xml.isStartElement() && xml.name() ==
"remove_spikes" )
942 if ( xml.isStartElement() && xml.name() ==
"floating_data" )
945 if ( xml.isStartElement() && xml.name() ==
"subtract_ri_noise" )
947 QXmlStreamAttributes a = xml.attributes();
948 parameters.
noiseOrder = a.value(
"order" ).toString().toInt();
957 while ( ! xml.atEnd() )
959 if ( xml.isEndElement() && xml.name() ==
"excludes" )
return;
961 if ( xml.isStartElement() && xml.name() ==
"exclude" )
963 QXmlStreamAttributes a = xml.attributes();
964 parameters.
excludes << a.value(
"scan" ).toString().toInt();
973 while ( ! xml.atEnd() )
975 if ( xml.isEndElement() && xml.name() ==
"edited" )
return;
977 if ( xml.isStartElement() && xml.name() ==
"edit" )
980 QXmlStreamAttributes a = xml.attributes();
981 e.
scan = a.value(
"scan" ).toString().toInt();
982 e.
radius = a.value(
"radius" ).toString().toInt();
983 e.
value = a.value(
"value" ).toString().toDouble();
993 const QString& editFilename,
994 QVector< EditedData >& data )
996 QVector< RawData > raw;
998 return loadData( directory, editFilename, data, raw );
1002 const QString& editFilename,
1005 QVector< RawData > raw;
1006 QVector< EditedData > editedData;
1008 int result =
loadData( directory, editFilename, editedData, raw );
1011 data = editedData[ 0 ];
1018 const QString& editFilename,
1019 QVector< EditedData >& data,
1020 QVector< RawData >& raw )
1022 QString ftriple = editFilename.section(
".", -2, -2 );
1024 QString rawDataFile = editFilename;
1025 QString edtFileRead = editFilename;
1026 QString filepart1 = editFilename.section(
".", 0, -7 );
1027 QString filepart2 = editFilename.section(
".", -5, -3 );
1028 rawDataFile = filepart1 +
"." + filepart2 +
".";
1029 QString clambda = ftriple .section(
".", -1, -1 );
1030 bool isMwl = clambda.contains(
"-" );
1034 QString elambda = clambda .section(
"@", -2, -2 );
1035 clambda = clambda .section(
"@", -1, -1 );
1036 edtFileRead = editFilename.section(
".", 0, -3 )
1037 +
"." + elambda +
".xml";
1040 rawDataFile = rawDataFile + clambda +
".auc";
1049 if ( result !=
OK )
throw result;
1051 qApp->processEvents();
1056 if ( result !=
OK )
throw result;
1063 QString clambda = edtFileRead.section(
".", -2, -2 );
1064 if ( clambda.contains(
"-" ) )
1073 QStringList sl = editFilename.split(
"." );
1095 if ( ed.
expType ==
"Equilibrium" )
1101 for (
int ii = 0; ii < dd.scanData.size(); ii++ )
1103 Scan* sc = &dd.scanData[ ii ];
1104 for (
int jj = 0; jj < sc->
rvalues.size(); jj++ )
1112 for (
int ii = 0; ii < ev.
editedPoints.length(); ii++ )
1117 dd.setValue( scnx, radx, value );
1128 for (
int ii = 0; ii < dd.scanData.size(); ii++ )
1130 if ( ev.
excludes.contains( ii ) )
continue;
1143 for (
int ii = 0; ii < ed.
scanData.size(); ii++ )
1151 double smoothed_value;
1154 for (
int ii = 0; ii < ed.
scanData.size(); ii++ )
1158 int end = sc->
rvalues.size() - 1;
1160 for (
int jj = start; jj < end; jj++ )
1165 sc->
rvalues[ jj ] = smoothed_value;
1172 while ( cc & ( 1 << ( 7 - index % 8 ) ) )
1190 for (
int ii = 0; ii < ed.
scanData.size(); ii++ )
1192 for (
int jj = 0; jj < ed.
scanData[ ii ].rvalues.size(); jj++ )
1193 ed.
scanData[ ii ].rvalues[ jj ] -= residuals[ ii ];
1205 for (
int ii = 0; ii < data.
scanData.size(); ii++ )
1207 if ( ev.
excludes.contains( ii ) )
continue;
1215 for (
int kk = r_left; kk <= r_right; kk++ )
1216 sum += data.
reading( ii, kk );
1218 double average = sum / ( r_right - r_left + 1 );
1220 for (
int jj = ii + 1; jj < data.
scanData.size(); jj++ )
1228 for (
int kk = r_left; kk <= r_right; kk++ )
1231 double delta = sum / ( r_right - r_left + 1 );
1234 for (
int kk = 0; kk < sc->
rvalues.size(); kk++ )
1238 for (
int jj = ii; jj < data.
scanData.size(); jj++ )
1242 for (
int kk = 0; kk < sc->
rvalues.size(); kk++ )
1258 QVector< int > included;
1259 QVector< double > integral;
1260 double val_min = 1.e+99;
1262 for (
int scx = 0; scx < data.
scanData.size(); scx++ )
1264 if ( ee.
excludes.contains( scx ) )
continue;
1279 for (
int rr = r_left; rr <= r_right; rr++ )
1280 integral[ kk ] += data.
reading( scx, rr ) + 1000.0;
1286 for (
int rr = r_left; rr <= r_right; rr++ )
1287 val_min = qMin( val_min, sc->
rvalues[ rr ] );
1294 for (
int scx = 1; scx < included.size(); scx++ )
1301 int previous = scx - 1;
1303 double points = (double) ( r_right - r_left + 1 );
1305 while ( integral[ current ] <= integral[ previous ] )
1307 integral[ current ] += points;
1311 while ( integral[ current ] > integral[ previous ] )
1313 integral[ current ] -= points;
1318 for (
int rr = r_left; rr <= r_right; rr++ )
1319 sc->
rvalues[ rr ] += (
double) position;
1321 double diff1 = integral[ previous ] - integral[ current ];
1323 double diff2 = integral[ previous ] - ( integral[ current ] + points );
1329 for (
int rr = r_left; rr <= r_right; rr++ )
1333 integral[ current ] += points;
1337 for (
int rr = r_left; rr <= r_right; rr++ )
1338 val_min = qMin( val_min, sc->
rvalues[ rr ] );
1342 if ( val_min < 0.0 )
1344 double val_bias = (double)qCeil( -val_min );
1346 for (
int scx = 0; scx < included.size(); scx++ )
1353 for (
int rad = r_left; rad <= r_right; rad++ )
1355 sc->
rvalues[ rad ] += val_bias;
1363 Scan& dest,
const QVector< double >& origx )
1374 int index_L =
index( origx, left );
1375 int index_R =
index( origx, right );
1377 dest.
interpolated.fill( (
char)0, ( index_R - index_L ) / 8 + 1 );
1379 int current_bit = 0;
1381 for (
int ii = index_L; ii <= index_R; ii++ )
1391 unsigned char old_bit = (
unsigned char)( 1 << ( 7 - ii % 8 ) );
1395 unsigned char new_bit = (
unsigned char)( 1 << ( 7 - current_bit % 8 ) );
1396 unsigned char byte = dest.
interpolated[ current_bit / 8 ];
1407 for (
int ii = 0; ii < dest.
stddevs.count(); ii++ )
1408 if ( dest.
stddevs[ ii ] != 0.0 )
1417 const QVector< double >& origx,
1418 QVector< double >& destx )
1420 for (
int ii =
index( origx, left ); ii <=
index( origx, right ); ii++ )
1422 destx << origx[ ii ];
1428 const QVector< double >& xvalues,
1429 int point,
int start,
int end,
double* value )
1431 static double rr[ 20 ];
1432 static double vv[ 20 ];
1434 double* xx = &rr[ 0 ];
1435 double* yy = &vv[ 0 ];
1444 const double threshold = 10.0;
1446 unsigned char interpolated;
1450 if ( point < ( start + end ) / 2 )
1457 if ( index < start )
break;
1460 interpolated = (
unsigned char)( cc & ( 1 << ( 7 - index % 8 ) ) );
1462 if ( ! interpolated )
1464 rr[ count ] = xvalues [
index ];
1475 while ( count < 10 )
1477 if ( index >= end )
break;
1480 interpolated = (
unsigned char)( cc & ( 1 << ( 7 - index % 8 ) ) );
1482 if ( ! interpolated )
1484 rr[ count ] = xvalues [
index ];
1499 if ( index >= end )
break;
1502 interpolated = (
unsigned char)( cc & ( 1 << ( 7 - index % 8 ) ) );
1504 if ( ! interpolated )
1506 rr[ count ] = xvalues [
index ];
1517 while ( count < 10 )
1519 if ( index < start )
break;
1522 interpolated = (
unsigned char)( cc & ( 1 << ( 7 - index % 8 ) ) );
1524 if ( ! interpolated )
1526 rr[ count ] = xvalues [
index ];
1536 &correlation, count );
1539 double current = sc.
rvalues[ point ];
1540 double radius = xvalues [ point ];
1541 double projected = slope * radius + intercept;
1543 if ( fabs( projected - current ) > threshold * sigma )
1554 const QVector< Scan >& sl )
1556 int scan_count = sl.size();
1558 QVector< double > cov( order );
1559 QVector< double > aiv( scan_count );
1560 QVector< double > fiv( scan_count );
1561 QVector< double > tmv( scan_count );
1562 double* coeffs = cov.data();
1563 double* absorbance_integral = aiv.data();
1564 double* scan_time = tmv.data();
1570 for (
int ii = 0; ii < scan_count; ii++ )
1572 absorbance_integral[ ii ] = 0;
1574 const Scan* sc = &sl[ ii ];
1575 int value_count = sc->
rvalues.size();
1580 for (
int jj = 1; jj < value_count; jj++ )
1582 double avg = ( sc->
rvalues[ jj ] + sc->
rvalues[ jj - 1 ] ) / 2.0;
1583 absorbance_integral[ ii ] += avg * delta_r;
1587 for (
int ii = 0; ii < scan_count; ii++ )
1588 scan_time[ ii ] = sl[ ii ].seconds;
1590 US_Matrix::lsfit( coeffs, scan_time, absorbance_integral, scan_count, order );
1592 QList< double > residuals;
1594 for (
int ii = 0; ii < scan_count; ii++ )
1598 for (
int jj = 0; jj < order; jj++ )
1599 fit += coeffs[ jj ] * pow( sl[ ii ].seconds, jj );
1601 residuals << absorbance_integral[ ii ] - fit;
1622 int npoint = xvals.size();
1623 int last = npoint - 1;
1626 if ( xvalue <= xvals[ 0 ] )
return 0;
1628 if ( xvalue >= xvals[ last ] )
return last;
1631 double rdmin = qAbs( xvalue - xvals[ 0 ] );
1634 for (
int ii = 1; ii < npoint; ii++ )
1636 double rdiff = qAbs( xvalue - xvals[ ii ] );
1638 if ( rdiff == 0.0 )
return ii;
1640 if ( rdiff < rdmin )
1656 :
return QObject::tr(
"The operation completed successully" );
1657 case CANTOPEN :
return QObject::tr(
"The file cannot be opened" );
1658 case BADCRC :
return QObject::tr(
"The file was corrupted" );
1659 case NOT_USDATA:
return QObject::tr(
"The file was not valid scan data" );
1660 case BADTYPE :
return QObject::tr(
"The filetype was not recognized" );
1661 case BADXML :
return QObject::tr(
"The XML file was invalid" );
1662 case NODATA :
return QObject::tr(
"No legacy data files suitable for import were found" );
1664 :
return QObject::tr(
"The file version is not supported" );
1666 :
return QObject::tr(
"GUIDs in raw data and edit data do not match" );
1669 return QObject::tr(
"Unknown error code" );