// Read the documentation to learn more about C++ code generator // versioning. // %X% %Q% %Z% %W% #include #include #include // PlotData2Panel #include #include #include #include // Class PlotDataResiduals PlotDataResiduals::PlotDataResiduals (Plot* plot, const string& name) : PlotData(plot, name) { modelRequired(Plot::FOLDED); numGraphs(2); } void PlotDataResiduals::manipulate () { PlotGroupContainer::iterator g = plot()->groups().begin(); PlotGroupContainer::iterator gEnd = plot()->groups().end(); // set linestep for models, but not source components. while ( g != gEnd ) { std::vector& data = (*g)->yData.data; std::vector >& dataErrs = (*g)->yData.errors; std::vector& residuals = (*g)->auxData[0].data; std::vector >& resErrs = (*g)->auxData[0].errors; int arraySize = (*g)->n; int errSize = dataErrs.size(); residuals.resize(arraySize); std::vector& model = (*g)->model[0].data; for (int i=0; i(arraySize)); } for ( int j = 0; j < arraySize; ++j) { residuals[j] = data[j] - model[j]; for (int i=0; isetSelectedLabel(1, "trs"); } void PlotDataResiduals::secondaryGraph () { finalizeFirstGraph(); plot()->plotYLog(false); commonSecondary(); } void PlotDataResiduals::finalities () { } // Additional Declarations // Class PlotDataRatio PlotDataRatio::PlotDataRatio (Plot* plot, const string& name) : PlotData(plot, name) { numGraphs(2); modelRequired(Plot::FOLDED); } void PlotDataRatio::manipulate () { plot()->xLine(std::pair(true,1.0)); // set linestep for models, but not source components. PlotGroupContainer::iterator g = plot()->groups().begin(); PlotGroupContainer::iterator gEnd = plot()->groups().end(); while ( g != gEnd ) { std::vector& data = (*g)->yData.data; std::vector >& dataErrs = (*g)->yData.errors; std::vector& ratios = (*g)->auxData[0].data; std::vector >& ratioErrs = (*g)->auxData[0].errors; int arraySize = (*g)->n; int errSize = dataErrs.size(); ratios.resize(arraySize); std::vector& model = (*g)->model[0].data; for (int i = 0; i < errSize; ++i) { ratioErrs.push_back(std::vector(arraySize)); } for ( int j = 0; j < arraySize; ++j) { if (std::abs(model[j]) > 1.E-20) { ratios[j] = data[j]/model[j]; for (int i = 0; i < errSize; ++i) { ratioErrs[i][j] = dataErrs[i][j]/model[j]; } } else { ratios[j] = Plot::NODATA(); for (int i = 0; i < errSize; ++i) { ratioErrs[i][j] = Plot::NODATA(); } } } ++g; } plot()->setSelectedLabel(1, "yr"); } void PlotDataRatio::secondaryGraph () { finalizeFirstGraph(); plot()->plotYLog(false); commonSecondary(); } void PlotDataRatio::finalities () { } // Additional Declarations // Class PlotDataDelchi PlotDataDelchi::PlotDataDelchi (Plot* plot, const string& name) : PlotData(plot, name) { numGraphs(2); modelRequired(Plot::FOLDED); } void PlotDataDelchi::secondaryGraph () { finalizeFirstGraph(); plot()->plotYLog(false); commonSecondary(); } void PlotDataDelchi::finalities () { } void PlotDataDelchi::manipulate () { PlotGroupContainer::iterator g = plot()->groups().begin(); PlotGroupContainer::iterator gEnd = plot()->groups().end(); // set linestep for models, but not source components. StatMethod* stat = XSContainer::fit->statMethod(); // Note: As a result of using StatMethod::plotDeltaChi, this function // currently can only handle 1 error vector. while ( g != gEnd ) { std::vector& x = (*g)->xAxis.data; std::vector& data = (*g)->yData.data; std::vector >& dataErrs = (*g)->yData.errors; std::vector& delchi = (*g)->auxData[0].data; std::vector >& delchiErrs = (*g)->auxData[0].errors; int arraySize = (*g)->n; delchi.resize(arraySize); std::vector& model = (*g)->model[0].data; delchiErrs.push_back(std::vector(arraySize)); for ( int j = 0; j < arraySize; ++j) { if (x[j] != Plot::NODATA()) { Real obs = data[j]; Real mod = model[j]; Real err = dataErrs[0][j]; delchi[j] = stat->plotDeltaChi(obs,mod,err,Plot::NODATA() ); delchiErrs[0][j] = 1.; } } ++g; } plot()->setSelectedLabel(1, "yds"); } // Additional Declarations // Class PlotDataChiSq PlotDataChiSq::PlotDataChiSq (Plot* plot, const string& name) : PlotData(plot, name) { numGraphs(2); modelRequired(Plot::FOLDED); } void PlotDataChiSq::secondaryGraph () { StatMethod* stat = XSContainer::fit->statMethod(); if (stat->fullName() == string("C-Statistic") || stat->fullName() == string("L-statistic")) { tcout <<"Note: When using cstat or lstat, \"plot chisq\" is only valid\n" <<" for data sets with no background files." << std::endl; } finalizeFirstGraph(); plot()->plotYLog(false); commonSecondary(); } void PlotDataChiSq::finalities () { } void PlotDataChiSq::manipulate () { PlotGroupContainer::iterator g = plot()->groups().begin(); PlotGroupContainer::iterator gEnd = plot()->groups().end(); // set linestep for models, but not source components. StatMethod* stat = XSContainer::fit->statMethod(); while ( g != gEnd ) { (*g)->auxData[0].symbolStyle = PlotStyle::BLANK; (*g)->auxData[0].lineStyle = plot()->modelStyle(); (*g)->auxData[0].lineStep = true; const std::vector& x = (*g)->xAxis.data; const std::vector& data = (*g)->yData.data; const std::vector& dataErrs = (*g)->yData.errors[0]; std::vector& chisq = (*g)->auxData[0].data; int arraySize = (*g)->n; chisq.resize(arraySize); std::vector& model = (*g)->model[0].data; for ( int j = 0; j < arraySize; ++j) { if (x[j] != Plot::NODATA()) { Real obs = data[j]; Real mod = model[j]; Real err = dataErrs[j]; Real areaTime = plot()->counts() ? 1.0 : (*g)->saveData[j]; chisq[j] = stat->plotChi(obs,mod,err,areaTime, Plot::NODATA() ); } } ++g; } plot()->setSelectedLabel(1, "ys",stat->scriptName()); } // Additional Declarations