NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
plugin_histogram.cpp File Reference
#include "plugins.hpp"
#include "../kernel.hpp"
Include dependency graph for plugin_histogram.cpp:

Go to the source code of this file.

Classes

struct  Ranges
 This structure defines the available ranges for the histograms. More...
 
struct  HistogramParameters
 This structure gathers all necessary parameters for the histograms. More...
 

Enumerations

enum  HistBinMethod { STURGES , SCOTT , FREEDMAN_DIACONIS }
 This enumeration defines the available bin determination methods for 1D and 2D histograms. More...
 

Functions

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 representations) as a std::string. More...
 
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. More...
 
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 values. More...
 
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<double>> instance. The data for the plotting is filled in this function as well. More...
 
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. More...
 
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. More...
 
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 case. More...
 
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. More...
 
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. More...
 
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. More...
 
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. Has to be called for each plot indepently. More...
 
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 table, if desired. More...
 
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. More...
 
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. More...
 
void plugin_histogram (std::string &sCmd)
 This function is the interface to both the 1D and the 2D histogram generation. More...
 

Variables

const std::string PI_HIST = "1.1.2"
 
mglGraph _fontData
 

Enumeration Type Documentation

◆ HistBinMethod

This enumeration defines the available bin determination methods for 1D and 2D histograms.

Enumerator
STURGES 
SCOTT 
FREEDMAN_DIACONIS 

Definition at line 35 of file plugin_histogram.cpp.

Function Documentation

◆ calculateDataForCenterPlot()

static void calculateDataForCenterPlot ( MemoryManager _data,
const Indices _idx,
const HistogramParameters _histParams,
mglData  _hist2DData[3] 
)
static

This static function calculates the data for the center plot part of the 2D histogram.

Parameters
_dataMemoryManager&
_idxconst Indices&
_histParamsconst HistogramParameters&
_hist2DData[3]mglData
Returns
void

Definition at line 1010 of file plugin_histogram.cpp.

References Indices::col, MemoryManager::getElement(), MemoryManager::isValidElement(), HistogramParameters::ranges, Indices::row, VectorIndex::size(), HistogramParameters::sTable, Ranges::x, and Ranges::y.

Referenced by createHist2D().

Here is the call graph for this function:

◆ calculateHist1dData()

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 
)
static

This static function calculates the data for a 1D histogram. The data is returned as a vector<vector<double>> instance. The data for the plotting is filled in this function as well.

Parameters
_dataMemoryManager&
_idxconst Indices&
_histParamsconst HistogramParameters&
_histDatamglData&
_mAxisValsmglData&
nMaxint&
vLegendsstd::vector<std::string>&
bGridbool
isXLogbool
Returns
std::vector<std::vector<double>>

Definition at line 212 of file plugin_histogram.cpp.

References HistogramParameters::binWidth, Indices::col, date::floor(), MemoryManager::getElement(), MemoryManager::getTopHeadLineElement(), if(), HistogramParameters::nBin, HistogramParameters::ranges, replaceToTeX(), Indices::row, VectorIndex::size(), HistogramParameters::sTable, Ranges::x, Ranges::y, and Ranges::z.

Referenced by createHist1D().

Here is the call graph for this function:

◆ calculateXYHist()

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 
)
static

This static function calculates the data for the both bar plot on top and at right of the center plot. Has to be called for each plot indepently.

Parameters
_dataMemoryManager&
_idxconst Indices&
_histParamsconst HistogramParameters&
_mAxisValsmglData*
dBinMindouble
dMindouble
dMaxdouble
dIntLengthdouble
nMaxint
isLogScalebool
isHbarbool
bSumbool
Returns
mglData

Definition at line 1089 of file plugin_histogram.cpp.

References Indices::col, MemoryManager::getElement(), MemoryManager::isValidElement(), HistogramParameters::nBin, HistogramParameters::ranges, Indices::row, VectorIndex::size(), HistogramParameters::sTable, and Ranges::z.

Referenced by createHist2D().

Here is the call graph for this function:

◆ createHist1D()

static void createHist1D ( const std::string &  sCmd,
const std::string &  sTargettable,
Indices _idx,
Indices _tIdx,
HistogramParameters _histParams,
bool  bWriteToCache,
bool  bSilent,
bool  bGrid 
)
static

◆ createHist2D()

static void createHist2D ( const std::string &  sCmd,
const std::string &  sTargettable,
Indices _idx,
Indices _tIdx,
HistogramParameters _histParams,
bool  bSum,
bool  bWriteToCache,
bool  bSilent 
)
static

◆ createOutputForHist1D()

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 
)
static

◆ createOutputForHist2D()

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 
)
static

This static function creates the textual output for terminal or file and writes the data also to a table, if desired.

Parameters
_dataMemoryManager&
_idxconst Indices&
sTargettableconst std::string&
_tIdxconst Indices&
_histParamsconst HistogramParameters&
_mAxisVals[2]mglData
_barHistDatamglData&
_hBarHistDatamglData&
bSumbool
bWriteToCachebool
shallFormatbool
isSilentbool
Returns
void

Definition at line 1172 of file plugin_histogram.cpp.

References _lang, HistogramParameters::binWidth, Indices::col, Settings::createCompactTables(), Output::format(), VectorIndex::front(), Output::generateFileName(), Language::get(), NumeRe::FileAdapter::getDataFileName(), NumeReKernel::getInstance(), NumeReKernel::getOutput(), NumeReKernel::getSettings(), Output::isFile(), VectorIndex::last(), make_hline(), HistogramParameters::nBin, PI_HIST, NumeReKernel::print(), HistogramParameters::ranges, Indices::row, Output::setCommentLine(), Output::setCompact(), Output::setFileName(), MemoryManager::setHeadLineElement(), Output::setPluginName(), Output::setPrefix(), Output::setStatus(), VectorIndex::size(), HistogramParameters::sSavePath, HistogramParameters::sTable, NumeReKernel::toggleTableStatus(), toString(), toSystemCodePage(), toUpperCase(), MemoryManager::writeToTable(), Ranges::x, and Ranges::y.

Referenced by createHist2D().

Here is the call graph for this function:

◆ createPlotForHist1D()

static void createPlotForHist1D ( HistogramParameters _histParams,
mglData &  _mAxisVals,
mglData &  _histData,
const std::vector< std::string > &  vLegends,
int  nMax,
bool  bSilent,
bool  bGrid 
)
static

◆ createPlotsForHist2D()

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 
)
static

◆ getIntervalDef()

static void getIntervalDef ( const std::string &  sCmd,
const std::string &  sIdentifier,
double &  dMin,
double &  dMax 
)
static

This static function decodes a selected range definition (e.g. x=0:1) into doubles.

Parameters
sCmdconst std::string&
sIdentifierconst std::string&
dMindouble&
dMaxdouble&
Returns
void

Definition at line 123 of file plugin_histogram.cpp.

References findParameter(), getArgAtPos(), and StrToDb().

Referenced by plugin_histogram().

Here is the call graph for this function:

◆ getParameterValue()

static std::string getParameterValue ( const std::string &  sCmd,
const std::string &  sVersion1,
const std::string &  sVersion2,
const std::string &  sDefaultVal 
)
static

This static function returns the value of the selected command line option (passable in two representations) as a std::string.

Parameters
sCmdconst std::string&
sVersion1const std::string&
sVersion2const std::string&
sDefaultValconst std::string&
Returns
std::string

Definition at line 86 of file plugin_histogram.cpp.

References findParameter(), getArgAtPos(), and StripSpaces().

Referenced by plugin_histogram().

Here is the call graph for this function:

◆ plugin_histogram()

void plugin_histogram ( std::string &  sCmd)

This function is the interface to both the 1D and the 2D histogram generation.

Parameters
sCmdstd::string&
Returns
void

Definition at line 1653 of file plugin_histogram.cpp.

References MemoryManager::addTable(), HistogramParameters::binWidth, Indices::col, createHist1D(), createHist2D(), DataAccessParser::evalIndices(), evaluateTargetOptionInCommand(), findCommand(), findParameter(), FREEDMAN_DIACONIS, getArgAtPos(), MemoryManager::getCols(), DataAccessParser::getDataObject(), DataAccessParser::getIndices(), NumeReKernel::getInstance(), getIntervalDef(), MemoryManager::getLines(), NumeReKernel::getMemoryManager(), NumeReKernel::getOutput(), getParameterValue(), intCast(), VectorIndex::INVALID, SyntaxError::invalid_position, MemoryManager::isEmpty(), MemoryManager::isTable(), MemoryManager::isValid(), isValidIndexSet(), MemoryManager::matchTableAsParameter(), HistogramParameters::nBin, HistogramParameters::nMethod, SyntaxError::NO_CACHED_DATA, SyntaxError::NO_DATA_AVAILABLE, VectorIndex::OPEN_END, HistogramParameters::ranges, Indices::row, HistogramParameters::sAxisLabels, HistogramParameters::sBinLabel, SCOTT, HistogramParameters::sCountLabel, Output::setStatus(), VectorIndex::size(), HistogramParameters::sSavePath, HistogramParameters::sTable, StripSpaces(), StrToDb(), STURGES, SyntaxError::TABLE_DOESNT_EXIST, Ranges::x, Ranges::y, and Ranges::z.

Referenced by cmd_hist().

Here is the call graph for this function:

◆ prepareGraphForHist()

static mglGraph * prepareGraphForHist ( double  dAspect,
PlotData _pData,
bool  bSilent 
)
static

This static function prepares a mglGraph instance for histogram plotting. It's usable in 1D and 2D case.

Parameters
dAspectdouble
_pDataPlotData&
bSilentbool
Returns
mglGraph*

Definition at line 578 of file plugin_histogram.cpp.

References _fontData, PlotData::FLOAT_BARS, PlotData::FLOAT_TEXTSIZE, PlotData::getLogscale(), PlotData::getSettings(), PlotData::INT_HIGHRESLEVEL, PlotData::LOG_SILENTMODE, XRANGE, YRANGE, and ZRANGE.

Referenced by createPlotForHist1D(), and createPlotsForHist2D().

Here is the call graph for this function:

◆ prepareIntervalsForHist()

static void prepareIntervalsForHist ( const std::string &  sCmd,
double &  dMin,
double &  dMax,
double  dDataMin,
double  dDataMax 
)
static

This static function replaces invalid ranges boundaries with the passed minimal and maximal data values.

Parameters
sCmdconst std::string&
dMindouble&
dMaxdouble&
dDataMindouble
dDataMaxdouble
Returns
void

Definition at line 158 of file plugin_histogram.cpp.

References SyntaxError::INVALID_INTERVAL, SyntaxError::invalid_position, and mu::isnan().

Referenced by createHist1D(), and createHist2D().

Here is the call graph for this function:

◆ prepareTicksForHist1d()

static std::string prepareTicksForHist1d ( const HistogramParameters _histParams,
const mglData &  _mAxisVals,
std::string &  sCommonExponent,
bool  bGrid 
)
static

This static function calculates the custom ticks (one for every bin) and formats them accordingly.

Parameters
_histParamsconst HistogramParameters&
_mAxisValsconst mglData&
sCommonExponentstd::string&
bGridbool
Returns
std::string

Definition at line 338 of file plugin_histogram.cpp.

References HistogramParameters::binWidth, HistogramParameters::nBin, HistogramParameters::ranges, StrToDb(), toString(), Ranges::x, and Ranges::z.

Referenced by createPlotForHist1D().

Here is the call graph for this function:

Variable Documentation

◆ _fontData

mglGraph _fontData
extern

Definition at line 40 of file kernel.cpp.

Referenced by prepareGraphForHist(), and NumeReKernel::StartUp().

◆ PI_HIST

const std::string PI_HIST = "1.1.2"

Definition at line 27 of file plugin_histogram.cpp.

Referenced by createOutputForHist1D(), and createOutputForHist2D().