21#include "../kernel.hpp"
86static std::string
getParameterValue(
const std::string& sCmd,
const std::string& sVersion1,
const std::string& sVersion2,
const std::string& sDefaultVal)
96 nPos =
findParameter(sCmd, sVersion1,
'=')+sVersion1.length();
98 nPos =
findParameter(sCmd, sVersion2,
'=')+sVersion2.length();
123static void getIntervalDef(
const std::string& sCmd,
const std::string& sIdentifier,
double& dMin,
double& dMax)
133 if (sTemp.find(
':') != std::string::npos)
135 if (sTemp.substr(0, sTemp.find(
':')).length())
136 dMin =
StrToDb(sTemp.substr(0, sTemp.find(
':')));
138 if (sTemp.substr(sTemp.find(
':') + 1).length())
139 dMax =
StrToDb(sTemp.substr(sTemp.find(
':') + 1));
170 else if (
isnan(dMin))
172 else if (
isnan(dMax))
187 if (dMin > dDataMax || dMax < dDataMin)
215 std::vector<std::vector<double>> vHistMatrix(_histParams.
nBin, std::vector<double>(bGrid ? 1 : _idx.
col.
size(), 0.0));
224 for (
int k = 0; k < _histParams.
nBin; k++)
230 for (
size_t i = 2; i < _idx.
col.
size(); i++)
232 for (
size_t l = 0; l < _idx.
row.
size(); l++)
256 if (i == 2 && !isXLog)
257 _mAxisVals.a[k] = _histParams.
ranges.
z[0] + (k + 0.5) * _histParams.
binWidth[0];
259 _mAxisVals.a[k] = pow(10.0, log10(_histParams.
ranges.
z[0]) + (k + 0.5) * _histParams.
binWidth[0]);
263 vHistMatrix[k][0] = nCount;
264 _histData.a[k] = nCount;
270 vLegends.push_back(
"grid");
277 for (
size_t i = 0; i < _idx.
col.
size(); i++)
280 for (
int k = 0; k < _histParams.
nBin; k++)
286 for (
size_t l = 0; l < _idx.
row.
size(); l++)
293 || (val.real() == std::pow(10.0, _histParams.
ranges.
x[1]) && k+1 == _histParams.
nBin))
299 || (val.real() == _histParams.
ranges.
x[1] && k+1 == _histParams.
nBin))
305 _mAxisVals.a[k] = _histParams.
ranges.
x[0] + (k + 0.5) * _histParams.
binWidth[0];
307 _mAxisVals.a[k] = pow(10.0, log10(_histParams.
ranges.
x[0]) + (k + 0.5) * _histParams.
binWidth[0]);
310 vHistMatrix[k][i] = nCount;
311 _histData.a[k + (_histParams.
nBin * i)] = nCount;
341 double dCommonExponent = 1.0;
350 dCommonExponent =
StrToDb(
"1.0" + sCommonExponent);
352 for (
int i = 0; i < _histParams.
nBin; i++)
354 if (
toString((_histParams.
ranges.
z[0] + i * _histParams.
binWidth[0] + _histParams.
binWidth[0] / 2.0) / dCommonExponent, 3).find(
'e') != std::string::npos)
356 sCommonExponent =
"";
357 dCommonExponent = 1.0;
372 dCommonExponent =
StrToDb(
"1.0" + sCommonExponent);
374 for (
int i = 0; i < _histParams.
nBin; i++)
376 if (
toString((_histParams.
ranges.
x[0] + i * _histParams.
binWidth[0] + _histParams.
binWidth[0] / 2.0) / dCommonExponent, 3).find(
'e') != std::string::npos)
378 sCommonExponent =
"";
379 dCommonExponent = 1.0;
392 for (
int i = 1; i < _histParams.
nBin - 1; i++)
394 if (_histParams.
nBin > 16)
396 if (!((_histParams.
nBin - 1) % 2) && !(i % 2) && _histParams.
nBin - 1 < 33)
397 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
398 else if (!((_histParams.
nBin - 1) % 2) && (i % 2) && _histParams.
nBin - 1 < 33)
400 else if (!((_histParams.
nBin - 1) % 4) && !(i % 4))
401 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
402 else if (!((_histParams.
nBin - 1) % 4) && (i % 4))
404 else if (!((_histParams.
nBin - 1) % 3) && !(i % 3))
405 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
406 else if (!((_histParams.
nBin - 1) % 3) && (i % 3))
408 else if (!((_histParams.
nBin - 1) % 5) && !(i % 5))
409 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
410 else if (!((_histParams.
nBin - 1) % 5) && (i % 5))
412 else if (!((_histParams.
nBin - 1) % 7) && !(i % 7))
413 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
414 else if (!((_histParams.
nBin - 1) % 7) && (i % 7))
416 else if (!((_histParams.
nBin - 1) % 11) && !(i % 11))
417 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
418 else if (!((_histParams.
nBin - 1) % 11) && (i % 11))
420 else if (((_histParams.
nBin - 1) % 2 && (_histParams.
nBin - 1) % 3 && (_histParams.
nBin - 1) % 5 && (_histParams.
nBin - 1) % 7 && (_histParams.
nBin - 1) % 11) && !(i % 3))
421 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
426 sTicks +=
toString(_mAxisVals.a[i] / dCommonExponent, 3) +
"\\n";
429 sTicks +=
toString(_mAxisVals.a[_histParams.
nBin - 1] / dCommonExponent, 3);
432 if (sCommonExponent.length())
434 while (sTicks.find(sCommonExponent) != std::string::npos)
435 sTicks.erase(sTicks.find(sCommonExponent), sCommonExponent.length());
437 if (sCommonExponent.find(
'-') != std::string::npos)
438 sCommonExponent =
"\\times 10^{-" + sCommonExponent.substr(sCommonExponent.find_first_not_of(
'0', 2)) +
"}";
440 sCommonExponent =
"\\times 10^{" + sCommonExponent.substr(sCommonExponent.find_first_not_of(
'0', 2)) +
"}";
466 std::string** sOut =
new std::string*[vHistMatrix.size() + 1];
468 for (
size_t i = 0; i < vHistMatrix.size() + 1; i++)
470 sOut[i] =
new std::string[vHistMatrix[0].size() + 1];
472 for (
size_t j = 0; j < vHistMatrix[0].size() + 1; j++)
485 for (
size_t i = 1; i < vHistMatrix[0].size() + 1; i++)
523 for (
size_t i = 1; i < vHistMatrix.size() + 1; i++)
526 sOut[i][0] =
toString(_mAxisVals.a[i - 1], _option);
528 for (
size_t j = 0; j < vHistMatrix[0].size(); j++)
530 sOut[i][j + 1] =
toString(vHistMatrix[i - 1][j], _option);
547 _out.
format(sOut, vHistMatrix[0].size() + 1, vHistMatrix.size() + 1, _option,
true);
558 for (
size_t i = 0; i < vHistMatrix.size() + 1; i++)
581 mglGraph* _histGraph =
new mglGraph();
587 double dHeight = sqrt(1920.0 * 1440.0 / dAspect);
588 _histGraph->SetSize((
int)lrint(dAspect * dHeight), (
int)lrint(dHeight));
592 double dHeight = sqrt(1280.0 * 960.0 / dAspect);
593 _histGraph->SetSize((
int)lrint(dAspect * dHeight), (
int)lrint(dHeight));
597 double dHeight = sqrt(800.0 * 600.0 / dAspect);
598 _histGraph->SetSize((
int)lrint(dAspect * dHeight), (
int)lrint(dHeight));
607 _histGraph->SetRanges(1, 2, 1, 2, 1, 2);
640 double dAspect = 8.0 / 3.0;
642 const int nStyleMax = 14;
643 std::string sColorStyles[nStyleMax] = {
"r",
"g",
"b",
"q",
"m",
"P",
"u",
"R",
"G",
"B",
"Q",
"M",
"p",
"U"};
646 for (
int i = 0; i < nStyleMax; i++)
655 for (
size_t i = 0; i < vLegends.size(); i++)
657 _histGraph->AddLegend(vLegends[i].c_str(), sColorStyles[nStyle].c_str());
659 if (nStyle == nStyleMax - 1)
666 std::string sCommonExponent;
689 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], 0.1, 1.4 * (
double)nMax);
691 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], 0.0, 1.05 * (
double)nMax);
699 _histGraph->SetTicksVal(
'x', _mAxisVals, sTicks.c_str());
702 && _histParams.
ranges.
x[0] <= 0.0
703 && _histParams.
ranges.
x[1] >= 0.0
707 if (_histParams.
nBin > 40)
708 _histGraph->Axis(
"UAKDTVISO");
710 _histGraph->Axis(
"AKDTVISO");
714 if (_histParams.
nBin > 40)
715 _histGraph->Axis(
"UAKDTVISO");
717 _histGraph->Axis(
"AKDTVISO");
721 if (_histParams.
nBin > 40)
722 _histGraph->Axis(
"U");
735 _histGraph->Label(
'x', _histParams.
sBinLabel.c_str(), 0.0);
739 _histGraph->Puts(mglPoint(_histParams.
ranges.
x[1] + (_histParams.
ranges.
x[1] - _histParams.
ranges.
x[0]) / 10.0),
741 sCommonExponent.c_str(),
":TL", -1.3);
745 _histGraph->Label(
'y', _histParams.
sCountLabel.c_str(), 0.0);
747 _histGraph->Label(
'y', _histParams.
sCountLabel.c_str(), 1.1);
764 _histGraph->Legend(1.25, 1.0);
776 sHistSavePath = sHistSavePath.substr(0, sHistSavePath.length() - 4) +
".png";
778 sHistSavePath = _option.
ValidFileName(
"<plotpath>/histogramm",
".png");
780 std::string sColor =
"";
784 for (
int i = 0; i < _histData.GetNy(); i++)
786 sColor += sColorStyles[nStyle];
788 if (nStyle == nStyleMax - 1)
795 _histGraph->Bars(_mAxisVals, _histData, sColor.c_str());
804 _histGraph =
nullptr;
810 _histGraph->WriteFrame(sHistSavePath.c_str());
873 for (
size_t i = 0; i < _idx.
row.
size(); i++)
875 for (
size_t j = 2 * bGrid; j < _idx.
col.
size(); j++)
882 if (!_histParams.
nBin && _histParams.
binWidth[0] == 0.0)
887 _histParams.
nBin = (int)
rint(1.0 + 3.3 * log10((
double)nMax));
896 _histParams.
nBin = (int)
rint(1.0 + 3.3 * log10((
double)nMax / (double)(_idx.
col.
size())));
905 if (_histParams.
nBin)
908 _histData.Create(_histParams.
nBin);
910 _histData.Create(_histParams.
nBin, _idx.
col.
size());
944 _histParams.
ranges.
x[0] -= dDiff / 2.0;
945 _histParams.
ranges.
x[1] += dDiff / 2.0;
947 if (_histParams.
nBin)
950 _histData.Create(_histParams.
nBin);
952 _histData.Create(_histParams.
nBin, _idx.
col.
size());
956 _mAxisVals.Create(_histParams.
nBin);
959 std::vector<std::string> vLegends;
973 for (
size_t i = 0; i < vHistMatrix.size(); i++)
980 for (
size_t j = 0; j < vHistMatrix[0].size(); j++)
1014 for (
unsigned int i = 0; i < 3; i++)
1016 _hist2DData[i].Create(_idx.
row.
size());
1019 for (
size_t i = 0; i < _idx.
row.
size(); i++)
1035 for (
unsigned int k = 0; k < 3; k++)
1036 _hist2DData[k].a[i] = NAN;
1042 _hist2DData[0].Create(_idx.
row.
size());
1043 _hist2DData[1].Create(_idx.
row.
size());
1046 for (
size_t i = 0; i < _idx.
row.
size(); i++)
1051 for (
size_t j = 0; j < _idx.
col.
size() - 2; j++)
1060 _hist2DData[2].a[i + j * _idx.
row.
size()] = NAN;
1089static mglData
calculateXYHist(
MemoryManager& _data,
const Indices& _idx,
const HistogramParameters& _histParams, mglData* _mAxisVals,
double dBinMin,
double dMin,
double dMax,
double dIntLength,
int nMax,
bool isLogScale,
bool isHbar,
bool bSum)
1091 mglData _histData(_histParams.
nBin);
1093 for (
int k = 0; k < _histParams.
nBin; k++)
1097 for (
size_t i = 0; i < _idx.
row.
size(); i++)
1101 && _data.
getElement(_idx.
row[i], _idx.
col[isHbar], _histParams.
sTable).real() >= dBinMin + k * dIntLength
1102 && _data.
getElement(_idx.
row[i], _idx.
col[isHbar], _histParams.
sTable).real() < dBinMin + (k + 1)*dIntLength)
1104 && _data.
getElement(_idx.
row[i], _idx.
col[isHbar], _histParams.
sTable).real() >= pow(10.0, log10(dBinMin) + k * dIntLength)
1105 && _data.
getElement(_idx.
row[i], _idx.
col[isHbar], _histParams.
sTable).real() < pow(10.0, log10(dBinMin) + (k + 1)*dIntLength))
1126 for (
size_t l = 0; l < _idx.
row.
size(); l++)
1134 dSum += _data.
getElement(_idx.
row[(!isHbar*i+isHbar*l)], _idx.
col[(!isHbar*l+isHbar*i)+2], _histParams.
sTable).real();
1140 _histData.a[k] = dSum;
1143 _mAxisVals->a[k] = dBinMin + (k + 0.5) * dIntLength;
1145 _mAxisVals->a[k] = pow(10.0, log10(dBinMin) + (k + 0.5) * dIntLength);
1172static void createOutputForHist2D(
MemoryManager& _data,
const Indices& _idx,
const std::string& sTargettable,
const Indices& _tIdx,
const HistogramParameters& _histParams, mglData _mAxisVals[2], mglData& _barHistData, mglData& _hBarHistData,
bool bSum,
bool bWriteToCache,
bool shallFormat,
bool isSilent)
1177 std::string** sOut =
new std::string*[_histParams.
nBin + 1];
1179 for (
int k = 0; k < _histParams.
nBin + 1; k++)
1180 sOut[k] =
new std::string[4];
1183 for (
int k = 0; k < _histParams.
nBin; k++)
1185 sOut[k + 1][0] =
toString(_mAxisVals[0].a[k], _option);
1186 sOut[k + 1][1] =
toString(_barHistData.a[k], _option);
1187 sOut[k + 1][2] =
toString(_mAxisVals[1].a[k], _option);
1188 sOut[k + 1][3] =
toString(_hBarHistData.a[k], _option);
1192 sOut[k][0] =
"Bins_[x]";
1193 sOut[k][1] = (bSum ?
"Sum_[x]" :
"Counts_[x]");
1194 sOut[k][2] =
"Bins_[y]";
1195 sOut[k][3] = (bSum ?
"Sum_[y]" :
"Counts_[y]");
1221 _out.
setCommentLine(
_lang.
get(
"HIST_OUT_COMMENTLINE2D",
toString(_histParams.
ranges.
x[0], 5),
toString(_histParams.
ranges.
x[1], 5),
toString(_histParams.
binWidth[0], 5),
toString(_histParams.
ranges.
y[0], 5),
toString(_histParams.
ranges.
y[1], 5),
toString(_histParams.
binWidth[1], 5)));
1241 if (_out.
isFile() || !isSilent)
1251 _out.
format(sOut, 4, _histParams.
nBin + 1, _option,
true);
1262 for (
int k = 0; k < _histParams.
nBin + 1; k++)
1284static void createPlotsForHist2D(
const std::string& sCmd,
HistogramParameters& _histParams, mglData _mAxisVals[2], mglData& _barHistData, mglData& _hBarHistData, mglData _hist2DData[3],
bool isScatterPlot,
bool bSum,
bool bSilent)
1290 double dAspect = 4.0 / 3.0;
1295 _histGraph->MultiPlot(3, 3, 0, 2, 1,
"<>");
1296 _histGraph->SetBarWidth(0.9);
1297 _histGraph->SetTuneTicks(3, 1.05);
1298 _histParams.
binWidth[0] = _barHistData.Maximal() - _barHistData.Minimal();
1299 _histGraph->SetRanges(1, 2, 1, 2, 1, 2);
1304 if (_barHistData.Minimal() >= 0)
1308 if (_barHistData.Minimal() - _histParams.
binWidth[0] / 20.0 > 0)
1309 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], _barHistData.Minimal() - _histParams.
binWidth[0] / 20.0, _barHistData.Maximal() + _histParams.
binWidth[0] / 20.0);
1310 else if (_barHistData.Minimal() > 0)
1311 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], _barHistData.Minimal() / 2.0, _barHistData.Maximal() + _histParams.
binWidth[0] / 20.0);
1313 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], (1e-2 * _barHistData.Maximal() < 1e-2 ? 1e-2 * _barHistData.Maximal() : 1e-2), _barHistData.Maximal() + _histParams.
binWidth[0] / 20.0);
1321 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], 0.0, _barHistData.Maximal() + _histParams.
binWidth[0] / 20.0);
1324 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], _barHistData.Minimal() - _histParams.
binWidth[0] / 20.0, _barHistData.Maximal() + _histParams.
binWidth[0] / 20.0);
1336 _histGraph->Grid(
"xy!", _pData.
getGridStyle().c_str());
1340 _histGraph->Label(
'x', _histParams.
sAxisLabels[0].c_str(), 0);
1343 _histGraph->Label(
'y', _histParams.
sAxisLabels[2].c_str(), 0);
1345 _histGraph->Label(
'y', _histParams.
sCountLabel.c_str(), 0);
1347 _histGraph->Bars(_mAxisVals[0], _barHistData, _pData.
getColors().c_str());
1350 _histGraph->MultiPlot(3, 3, 3, 2, 2,
"<_>");
1351 _histGraph->SetTuneTicks(3, 1.05);
1353 _histGraph->SetRanges(1, 2, 1, 2, 1, 2);
1366 if (_hist2DData[2].Minimal() > 0.0)
1367 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], _histParams.
ranges.
y[0], _histParams.
ranges.
y[1], _hist2DData[2].Minimal(), _hist2DData[2].Maximal());
1369 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], _histParams.
ranges.
y[0], _histParams.
ranges.
y[1], (1e-2 * _hist2DData[2].Maximal() < 1e-2 ? 1e-2 * _hist2DData[2].Maximal() : 1e-2), _hist2DData[2].Maximal());
1372 _histGraph->SetRanges(_histParams.
ranges.
x[0], _histParams.
ranges.
x[1], _histParams.
ranges.
y[0], _histParams.
ranges.
y[1], _hist2DData[2].Minimal(), _hist2DData[2].Maximal());
1381 _histGraph->Axis(
"xy");
1388 _histGraph->Grid(
"xy!", _pData.
getGridStyle().c_str());
1392 _histGraph->Label(
'x', _histParams.
sAxisLabels[0].c_str(), 0);
1393 _histGraph->Label(
'y', _histParams.
sAxisLabels[1].c_str(), 0);
1396 _histGraph->Dots(_hist2DData[0], _hist2DData[1], _hist2DData[2], _pData.
getColorScheme().c_str());
1398 _histGraph->Dens(_hist2DData[0], _hist2DData[1], _hist2DData[2], _pData.
getColorScheme().c_str());
1401 _histGraph->MultiPlot(3, 3, 5, 1, 2,
"_");
1402 _histGraph->SetBarWidth(0.9);
1403 _histGraph->SetTuneTicks(3, 1.05);
1404 _histParams.
binWidth[0] = _hBarHistData.Maximal() - _hBarHistData.Minimal();
1406 _histGraph->SetRanges(1, 2, 1, 2, 1, 2);
1410 if (_hBarHistData.Minimal() >= 0)
1414 if (_hBarHistData.Minimal() - _histParams.
binWidth[0] / 20.0 > 0)
1415 _histGraph->SetRanges(_hBarHistData.Minimal() - _histParams.
binWidth[0] / 20.0, _hBarHistData.Maximal() + _histParams.
binWidth[0] / 20.0, _histParams.
ranges.
y[0], _histParams.
ranges.
y[1]);
1416 else if (_hBarHistData.Minimal() > 0)
1417 _histGraph->SetRanges(_hBarHistData.Minimal() / 2.0, _hBarHistData.Maximal() + _histParams.
binWidth[0] / 20.0, _histParams.
ranges.
y[0], _histParams.
ranges.
y[1]);
1419 _histGraph->SetRanges((1e-2 * _hBarHistData.Maximal() < 1e-2 ? 1e-2 * _hBarHistData.Maximal() : 1e-2), _hBarHistData.Maximal() + _histParams.
binWidth[0] / 10.0, _histParams.
ranges.
y[0], _histParams.
ranges.
y[1]);
1427 _histGraph->SetRanges(0.0, _hBarHistData.Maximal() + _histParams.
binWidth[0] / 20.0, _histParams.
ranges.
y[0], _histParams.
ranges.
y[1]);
1430 _histGraph->SetRanges(_hBarHistData.Minimal() - _histParams.
binWidth[0] / 20.0, _hBarHistData.Maximal() + _histParams.
binWidth[0] / 20.0, _histParams.
ranges.
y[0], _histParams.
ranges.
y[1]);
1436 _histGraph->Axis(
"xy");
1442 _histGraph->Grid(
"xy!", _pData.
getGridStyle().c_str());
1447 _histGraph->Label(
'x', _histParams.
sCountLabel.c_str(), 0);
1449 _histGraph->Label(
'x', _histParams.
sAxisLabels[2].c_str(), 0);
1451 _histGraph->Label(
'y', _histParams.
sAxisLabels[1].c_str(), 0);
1452 _histGraph->Barh(_mAxisVals[1], _hBarHistData, _pData.
getColors().c_str());
1461 sHistSavePath = sHistSavePath.substr(0, sHistSavePath.length() - 4) +
".png";
1463 sHistSavePath = _option.
ValidFileName(
"<plotpath>/histogramm2d",
".png");
1470 _histGraph =
nullptr;
1477 _histGraph->WriteFrame(sHistSavePath.c_str());
1512 mglData _hist2DData[3];
1513 mglData _mAxisVals[2];
1540 if (_histParams.
ranges.
x[0] < 0.0)
1541 _histParams.
ranges.
x[0] = (1e-2 * _histParams.
ranges.
x[1] < 1e-2 ? 1e-2 * _histParams.
ranges.
x[1] : 1e-2);
1548 if (_histParams.
ranges.
y[0] < 0.0)
1549 _histParams.
ranges.
y[0] = (1e-2 * _histParams.
ranges.
y[1] < 1e-2 ? 1e-2 * _histParams.
ranges.
y[1] : 1e-2);
1554 for (
size_t i = 0; i < _idx.
row.
size(); i++)
1556 for (
size_t j = 2; j < _idx.
col.
size(); j++)
1569 if (!_histParams.
nBin && _histParams.
binWidth[0] == 0.0)
1572 _histParams.
nBin = (int)
rint(1.0 + 3.3 * log10((
double)nMax / (double)(_idx.
col.
size()-2)));
1581 if (!_histParams.
nBin)
1592 _histParams.
ranges.
x[0] -= dDiff / 2.0;
1593 _histParams.
ranges.
x[1] += dDiff / 2.0;
1596 _mAxisVals[0].Create(_histParams.
nBin);
1597 _mAxisVals[1].Create(_histParams.
nBin);
1600 if (_histParams.
binWidth[0] == 0.0)
1621 mglData _barHistData =
calculateXYHist(_data, _idx, _histParams, &_mAxisVals[0],
1627 mglData _hBarHistData =
calculateXYHist(_data, _idx, _histParams, &_mAxisVals[1],
1634 createOutputForHist2D(_data, _idx, sTargettable, _tIdx, _histParams, _mAxisVals, _barHistData, _hBarHistData, bSum, bWriteToCache,
1639 createPlotsForHist2D(sCmd, _histParams, _mAxisVals, _barHistData, _hBarHistData, _hist2DData, _idx.
col.
size() == 3, bSum, bSilent);
1661 bool bWriteToCache =
false;
1662 bool bMake2DHist =
false;
1664 bool bSilent =
false;
1670 _histParams.
sTable =
"data";
1675 _histParams.
ranges.
x[0] = NAN;
1676 _histParams.
ranges.
x[1] = NAN;
1677 _histParams.
ranges.
y[0] = NAN;
1678 _histParams.
ranges.
y[1] = NAN;
1679 _histParams.
ranges.
z[0] = NAN;
1680 _histParams.
ranges.
z[1] = NAN;
1708 long long int nDataRowFinal = 0;
1718 std::string sTemp_2 =
"";
1721 if (sTemp.find(
':') != std::string::npos)
1725 for (
unsigned int i = 0; i < sTemp.length(); i++)
1727 if (sTemp[i] ==
':')
1734 sTemp_2 = sTemp.substr(0, nSep);
1735 sTemp = sTemp.substr(nSep + 1);
1739 if (sTemp_2.length())
1748 if (nDataRowFinal > _data.
getCols(_histParams.
sTable) || !nDataRowFinal)
1754 else if (sTemp.length())
1765 if (sTargettable.length())
1767 bWriteToCache =
true;
1769 if (sTargettable.find(
'(') == std::string::npos)
1770 sTargettable +=
"()";
1772 if (!_data.
isTable(sTargettable))
1775 sTargettable.erase(sTargettable.find(
'('));
1783 if (sTargettable.length())
1784 bWriteToCache =
true;
1789 bWriteToCache =
true;
1791 if (!sTargettable.length())
1793 sTargettable =
"table";
1823 if (sMethod ==
"scott")
1825 else if (sMethod ==
"freedman")
1845 createHist2D(sCmd, sTargettable, _idx, _tIdx, _histParams, bSum, bWriteToCache, bSilent);
1847 createHist1D(sCmd, sTargettable, _idx, _tIdx, _histParams, bWriteToCache, bSilent, bGrid);
This class is defined to abstrahize the determination of the correct data object and the calculation ...
Indices & getIndices()
Returns a reference to the stored indices.
void evalIndices()
Evaluates open end indices using the identified data object size.
std::string & getDataObject()
Returns a reference to the data object identifier.
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
This class encapsulates the mglGraph object during transmission from the kernel to the GUI.
void setAspect(double aspect)
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
This class represents the central memory managing instance. It will handle all tables and clusters,...
std::string matchTableAsParameter(const std::string &sExpression, char cFollowing=' ')
mu::value_type getElement(int _nLine, int _nCol, const std::string &_sTable) const
bool isValidElement(long long int _nLine, long long int _nCol, const std::string &_sTable) const
std::vector< mu::value_type > min(const std::string &sTable, std::string sDir) const
std::string getTopHeadLineElement(int _i, const std::string &_sTable) const
std::vector< mu::value_type > pct(const std::string &sTable, std::string sDir, mu::value_type dPct=0.5) const
int getLines(StringView sTable, bool _bFull=false) const
bool isEmpty(const std::string &sTable) const
bool isTable(const std::string &sTable) const
This member function returns, whether the passed table name corresponds to a known table.
std::string getHeadLineElement(int _i, const std::string &_sTable) const
std::vector< mu::value_type > max(const std::string &sTable, std::string sDir) const
bool isValid() const
Evaluates, whether there's at least a single non-empty table.
std::vector< mu::value_type > std(const std::string &sTable, std::string sDir) const
bool addTable(const std::string &sCache, const Settings &_option)
This member function creates a new table. It is checked, whether its name is valid and not already us...
void writeToTable(int _nLine, int _nCol, const std::string &_sCache, const mu::value_type &_dData)
bool setHeadLineElement(int _i, const std::string &_sTable, std::string _sHead)
int getCols(StringView sTable, bool _bFull=false) const
std::string getDataFileName(const std::string &sTable) const
This member function will return the file name of the selected table. Will default to the table name.
size_t createWindow(GraphHelper *graph)
This public member function will create a window object containing the passed graph.
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
PlotData & getPlottingData()
NumeRe::WindowManager & getWindowManager()
static void printPreFmt(const std::string &__sLine, bool printingEnabled=true)
This member function appends the pre- formatted string to the buffer and informs the terminal that we...
MemoryManager & getMemoryManager()
static void print(const std::string &__sLine, bool printingEnabled=true)
This member function appends the passed string as a new output line to the buffer and informs the ter...
static void toggleTableStatus()
Toggles the table writing status, which will reduce the number or events send to the terminal.
void format(std::string **_sMatrix, long long int _nCol, long long int _nLine, const Settings &_option, bool bDontAsk=false, int nHeadLineCount=1)
std::string getFileName() const
void setPrefix(std::string _sPrefix)
void setPluginName(std::string _sPluginName)
void setStatus(bool bStatus)
void setCompact(bool _bCompact)
void setCommentLine(std::string _sCommentLine)
void setFileName(std::string sFile)
This class contains all the plot settings usable by the plotting algorithm.
std::string getGridStyle() const
std::string getColors() const
TimeAxis getTimeAxis(unsigned int i=0) const
bool getSettings(LogicalPlotSetting setting) const
std::string getColorScheme(const std::string &_sAddOpt="") const
std::string getFineGridStyle() const
bool getLogscale(size_t i) const
This class manages the setting values of the internal (kernel) settings of this application.
bool createCompactTables() const
Returns, whether tables shall be displayed in a more compact way (does nothing in the external table ...
bool systemPrints() const
Returns, whether system messages shall be printed to the terminal.
Common exception class for all exceptions thrown in NumeRe.
@ TABLE_DOESNT_EXIST
INSERT HERE.
@ WRONG_PLOT_INTERVAL_FOR_LOGSCALE
static size_t invalid_position
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
VectorIndex subidx(size_t pos, size_t nLen=std::string::npos) const
This member function returns a subset of the internal stored index just like the std::string::substr(...
int last() const
This member function returns the last index value, which can be reached by the values stored internal...
size_t size() const
This member function returns the size of the indices stored in this class.
int & front()
This member function returns a reference to the first index value stored internally.
bool isValidIndexSet(const Indices &_idx)
std::string toSystemCodePage(std::string)
Converts an internal to an external string. Does nothing currently.
if(nReturnType==EIGENVALUES)
CONSTCD14 std::enable_if< detail::no_overflow< Period, typenameTo::period >::value, To >::type floor(const std::chrono::duration< Rep, Period > &d)
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
MUP_BASETYPE value_type
The numeric datatype used by the parser.
bool isnan(const value_type &v)
std::vector< double > real(const std::vector< value_type > &vVec)
value_type rint(value_type v)
string evaluateTargetOptionInCommand(string &sCmd, const string &sDefaultTarget, Indices &_idx, Parser &_parser, MemoryManager &_data, const Settings &_option)
This function evaluates the "target=TABLE()" expression and creates the target table,...
static void calculateDataForCenterPlot(MemoryManager &_data, const Indices &_idx, const HistogramParameters &_histParams, mglData _hist2DData[3])
This static function calculates the data for the center plot part of the 2D histogram.
static void createOutputForHist1D(MemoryManager &_data, const Indices &_idx, const std::vector< std::vector< double > > &vHistMatrix, const HistogramParameters &_histParams, const mglData &_mAxisVals, bool bGrid, bool bFormat, bool bSilent)
This static function creates the terminal and file output for a 1D histogram.
static void createHist1D(const std::string &sCmd, const std::string &sTargettable, Indices &_idx, Indices &_tIdx, HistogramParameters &_histParams, bool bWriteToCache, bool bSilent, bool bGrid)
This static function is the driver code for creating a 1D histogram.
static std::string prepareTicksForHist1d(const HistogramParameters &_histParams, const mglData &_mAxisVals, std::string &sCommonExponent, bool bGrid)
This static function calculates the custom ticks (one for every bin) and formats them accordingly.
void plugin_histogram(std::string &sCmd)
This function is the interface to both the 1D and the 2D histogram generation.
static void createPlotsForHist2D(const std::string &sCmd, HistogramParameters &_histParams, mglData _mAxisVals[2], mglData &_barHistData, mglData &_hBarHistData, mglData _hist2DData[3], bool isScatterPlot, bool bSum, bool bSilent)
This static function creates the three plots for the 2D histogram.
HistBinMethod
This enumeration defines the available bin determination methods for 1D and 2D histograms.
static void getIntervalDef(const std::string &sCmd, const std::string &sIdentifier, double &dMin, double &dMax)
This static function decodes a selected range definition (e.g. x=0:1) into doubles.
static void createHist2D(const std::string &sCmd, const std::string &sTargettable, Indices &_idx, Indices &_tIdx, HistogramParameters &_histParams, bool bSum, bool bWriteToCache, bool bSilent)
This static function is the driver function for creating a 2D histogram.
static mglData calculateXYHist(MemoryManager &_data, const Indices &_idx, const HistogramParameters &_histParams, mglData *_mAxisVals, double dBinMin, double dMin, double dMax, double dIntLength, int nMax, bool isLogScale, bool isHbar, bool bSum)
This static function calculates the data for the both bar plot on top and at right of the center plot...
static void createOutputForHist2D(MemoryManager &_data, const Indices &_idx, const std::string &sTargettable, const Indices &_tIdx, const HistogramParameters &_histParams, mglData _mAxisVals[2], mglData &_barHistData, mglData &_hBarHistData, bool bSum, bool bWriteToCache, bool shallFormat, bool isSilent)
This static function creates the textual output for terminal or file and writes the data also to a ta...
static mglGraph * prepareGraphForHist(double dAspect, PlotData &_pData, bool bSilent)
This static function prepares a mglGraph instance for histogram plotting. It's usable in 1D and 2D ca...
static void prepareIntervalsForHist(const std::string &sCmd, double &dMin, double &dMax, double dDataMin, double dDataMax)
This static function replaces invalid ranges boundaries with the passed minimal and maximal data valu...
static std::string getParameterValue(const std::string &sCmd, const std::string &sVersion1, const std::string &sVersion2, const std::string &sDefaultVal)
This static function returns the value of the selected command line option (passable in two represent...
const std::string PI_HIST
static void createPlotForHist1D(HistogramParameters &_histParams, mglData &_mAxisVals, mglData &_histData, const std::vector< std::string > &vLegends, int nMax, bool bSilent, bool bGrid)
This static function creates the plot for a 1D histogram.
static std::vector< std::vector< double > > calculateHist1dData(MemoryManager &_data, const Indices &_idx, const HistogramParameters &_histParams, mglData &_histData, mglData &_mAxisVals, int &nMax, std::vector< std::string > &vLegends, bool bGrid, bool isXLog)
This static function calculates the data for a 1D histogram. The data is returned as a vector<vector<...
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
int findParameter(const std::string &sCmd, const std::string &sParam, const char cFollowing)
This function searches the passed parameter in the passed command string. If something is found,...
This structure gathers all necessary parameters for the histograms.
std::string sAxisLabels[3]
This structure is central for managing the indices of a table or cluster read or write data access....
This structure defines the available ranges for the histograms.
long long int intCast(const std::complex< double > &)
Casts the real part of the complex number to an integer and avoids rounding errors.
std::string toString(int)
Converts an integer to a string without the Settings bloat.