9 #include <qwt_legend.h>
12 QVector< double >& divsedcs,
const double tconc )
16 setWindowTitle( tr(
"van Holde - Weischet Distribution Plot" ) );
19 QGridLayout*
main =
new QGridLayout(
this );
20 main->setSpacing ( 2 );
21 main->setContentsMargins( 2, 2, 2, 2 );
31 DbgLv(1) <<
"DisPl: isedsSize " <<
dsedcs.size() << divsedcs.size();
34 DbgLv(1) <<
"DisPl: sed1 sed-" << dsedcs[1] << dsedcs[
divsCount-2];
35 DbgLv(1) <<
"DisPl: sed2 sed-" << dsedcs[2] << dsedcs[
divsCount-3];
42 tr(
"Sedimentation Coefficient Distribution" ),
43 tr(
"Sedimentation Coefficient" ),
44 tr(
"Boundary Fraction" ) );
46 data_plot->setCanvasBackground( Qt::black );
48 data_plot->setAxisScale( QwtPlot::yLeft, 0.0, 100.0, 20.0 );
50 data_plot->setAxisAutoScale( QwtPlot::xBottom );
53 grid->enableXMin(
true );
54 grid->enableYMin(
true );
58 pick->setTrackerPen( QColor( Qt::white ) );
60 main->addLayout( plot, row, 0, 15, 4 );
68 main->addWidget(
pb_help, row, 1, 1, 1 );
69 main->addWidget(
pb_close, row++, 2, 1, 1 );
93 main->addWidget(
ct_smoothing, row++, 2, 1, 1, Qt::AlignLeft );
99 connect(
pb_help, SIGNAL( clicked() ),
100 this, SLOT (
help() ) );
101 connect(
pb_close, SIGNAL( clicked() ),
109 connect(
ct_smoothing, SIGNAL( valueChanged(
double ) ),
119 grid->enableXMin(
true );
120 grid->enableYMin(
true );
132 grid->enableXMin(
true );
133 grid->enableYMin(
true );
142 QString runID = plot1File.section(
"/", -2, -2 );
144 if ( runID ==
"tmp" )
return;
148 + plot1File.section(
"/", -1, -1 ).section(
".", 0, 1 )
149 +
".s-c-envelope.csv";
161 grid->enableXMin(
true );
162 grid->enableYMin(
true );
169 data_plot->setTitle( tr(
"G(s) Distribution" ) );
175 data_plot->setTitle( tr(
"g(s) Distribution" ) );
181 data_plot->setTitle( tr(
"g(s) Distribution" ) );
187 data_plot->setTitle( tr(
"g(s) Distribution" ) );
286 tr(
"Boundary Fraction" ) );
287 data_plot->setAxisTitle( QwtPlot::xBottom,
288 tr(
"Sedimentation Coefficient" ) );
289 data_plot->setAxisScale( QwtPlot::yLeft, 0.0, 100.0, 20.0 );
293 double* xx =
dsedcs.data();
294 double* yy =
bfracs.data();
302 maxx =
max( maxx, xx[ jj ] );
303 minx =
min( minx, xx[ jj ] );
307 minx = minx - rngx * 0.1;
308 maxx = maxx + rngx * 0.1;
312 data_plot->setAxisAutoScale( QwtPlot::xBottom );
316 dcurve->setPen( QPen( QBrush( Qt::yellow ), 1.0 ) );
317 dcurve->setData( xx, yy, divsCount );
322 sym.setStyle( QwtSymbol::Ellipse );
323 sym.setPen ( QPen( Qt::blue ) );
324 sym.setBrush( QBrush( Qt::white ) );
326 dcurve->setStyle( QwtPlotCurve::NoCurve );
328 dcurve->setData ( xx, yy, divsCount );
336 QVector< double > xvec;
337 QVector< double > yvec;
338 double minx =
dsedcs[ 0 ];
347 tr(
"Relative Concentration" ) );
348 data_plot->setAxisTitle( QwtPlot::xBottom,
349 tr(
"Sedimentation Coefficient" ) );
353 double* xx = xvec.data();
354 double* yy = yvec.data();
357 for (
int jj = 0; jj < npoints; jj++ )
370 minx = qMin( minx, xval );
371 maxx = qMax( maxx, xval );
375 minx = minx - rngx * 0.10;
376 maxx = maxx + rngx * 0.10;
380 data_plot->setAxisAutoScale( QwtPlot::yLeft );
381 data_plot->setAxisAutoScale( QwtPlot::xBottom );
385 for (
int jj = 0; jj < npoints; jj++ )
389 DbgLv(2) <<
"HISTO_DAT:" << npoints;
390 for(
int jj=0;jj<npoints;jj++)
DbgLv(2) << jj << xx[jj] << yy[jj];
392 for (
int jj = 0; jj < npoints; jj++ )
397 hcurve->setPen( QPen( QBrush( Qt::red ), 5.0 ) );
398 hcurve->setStyle( QwtPlotCurve::Sticks );
399 hcurve->setData( xx, yy, npoints );
411 QVector< double > xvec;
412 QVector< double > yvec;
415 double minx =
dsedcs[ 0 ];
425 minx = qMin( minx, xval );
426 maxx = qMax( maxx, xval );
430 minx = minx - rngx * 0.10;
431 maxx = maxx + rngx * 0.10;
436 tr(
"Relative Concentration" ) );
437 data_plot->setAxisTitle( QwtPlot::xBottom,
438 tr(
"Sedimentation Coefficient" ) );
447 data_plot->setAxisAutoScale( QwtPlot::yLeft );
448 data_plot->setAxisAutoScale( QwtPlot::xBottom );
459 for (
int jj = 0; jj < npoints; jj++ )
464 for (
int jj = 0; jj < npoints; jj++ )
469 ecurve->setPen( QPen( QBrush( Qt::cyan ), 3.0 ) );
470 ecurve->setData( xx, yy, npoints );
484 QVector< double >& yvec )
488 double max_cept = 1.0e-6;
489 double min_cept = 1.0e+6;
490 double sed_bin =
dsedcs.at( 0 );
499 max_cept =
max( max_cept,
dsedcs.at( jj ) );
500 min_cept =
min( min_cept,
dsedcs.at( jj ) );
504 sed_bin = ( max_cept - min_cept ) / div_scl;
505 max_step = max_cept * 4.0 / 3.0;
506 steps = (int)( max_step / sed_bin );
507 stoff = (int)( min_cept / sed_bin ) - 1;
508 stoff = qMax( stoff, 0 );
511 xvec.fill( 0.0, steps );
512 yvec.fill( 0.0, steps );
513 double* sval = xvec.data();
514 double* bink = yvec.data();
516 for (
int jj = 0; jj < steps; jj++ )
519 sed_lo = sed_bin * (double)( jj + stoff );
520 sed_hi = sed_lo + sed_bin;
521 sval[ jj ] = ( sed_lo + sed_hi ) * 0.5;
527 if ( sedc >= sed_lo && sedc < sed_hi )
531 bink[ jj ] = (double)kbin;
539 QVector< double >& yvec )
543 double max_cept = 1.0e-6;
544 double min_cept = 1.0e+6;
545 double sed_bin =
dsedcs.at( 0 );
546 double his_sum = 0.0;
547 double env_sum = 0.0;
557 max_cept =
max( max_cept,
dsedcs.at( jj ) );
558 min_cept =
min( min_cept,
dsedcs.at( jj ) );
562 sed_bin = ( max_cept - min_cept ) / div_scl;
563 max_step = max_cept * 4.0 / 3.0;
564 steps = (int)( max_step / sed_bin );
565 DbgLv(2) <<
"ED: steps" << steps <<
"sed_bin" << sed_bin;
567 if ( array <= steps )
572 xvec.fill( 0.0, array );
573 yvec.fill( 0.0, array );
576 double pisqr = sqrt( M_PI * 2.0 );
577 double* xval = xvec.data();
578 double* yval = yvec.data();
579 double scale = max_step / (double)array;
580 DbgLv(2) <<
"ED: max_step array scale" << max_step << array << scale;
582 for (
int jj = 0; jj < array; jj++ )
584 xval[ jj ] = scale * (double)( jj );
588 sigma = sed_bin * 0.02 * (double)
nSmooth;
589 DbgLv(2) <<
"ED: sed_bin sigma" << sed_bin << sigma;
591 for (
int jj = 0; jj < steps; jj++ )
594 sed_lo = sed_bin * (double)( jj );
595 sed_hi = sed_lo + sed_bin;
596 sval = ( sed_lo + sed_hi ) * 0.5;
602 if ( sedc >= sed_lo && sedc < sed_hi )
607 his_sum += ( bink * sed_bin );
611 for (
int kk = 0; kk < array; kk++ )
613 double xdif = ( xval[ kk ] - sval ) / sigma;
614 yval[ kk ] += ( ( bink / ( sigma * pisqr ) )
615 * exp( -( xdif * xdif ) / 2.0 ) );
616 DbgLv(2) <<
"ED: kk" << kk <<
"xdif bink yval" << xdif << bink << yval[kk];
619 DbgLv(2) <<
"ED: jj" << jj <<
"sval his_sum" << sval << his_sum;
622 for (
int kk = 0; kk < array; kk++ )
624 env_sum += yval[ kk ];
628 scale = his_sum / env_sum;
629 DbgLv(2) <<
"ED: hsum esum scale " << his_sum << env_sum << scale;
631 for (
int kk = 0; kk < array; kk++ )
643 QString tplot1File = basename +
"s-c-distrib.svg";
644 QString tplot2File = basename +
"s-c-histo.svg";
645 QString tdata2File = basename +
"s-c-envelope.csv";
656 QVector< double > hseds;
657 QVector< double > hfrqs;
658 QVector< double > eseds;
659 QVector< double > efrqs;
663 DbgLv(1) <<
"SaveDat: file" << data2File <<
"nhpts nepts" << nhpts << nepts;
665 QFile datf( data2File );
667 if ( ! datf.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
670 QTextStream ts( &datf );
672 ts << tr(
"\"S-value(Envelope)\",\"Frequency(E)\","
673 "\"S-value(Histogram)\",\"Frequency(H)\","
674 "\"TotalConcentration\"\n" );
676 for (
int ii = 0; ii < nepts; ii++ )
680 line = QString().sprintf(
681 "\"%.6f\",\"%.6f\",\"%.6f\",\"%9.2f\",\"%9.2f\"\n",
682 eseds[ ii ], efrqs[ ii ], hseds[ ii ], hfrqs[ ii ],
685 line = QString().sprintf(
686 "\"%.6f\",\"%.6f\",\"\",\"\",\"\"\n",
687 eseds[ ii ], efrqs[ ii ] );
689 line.replace(
" ",
"" );
692 DbgLv(1) <<
"SaveDat: file written";