Commit 2acc7d49d3d65558b490ecc5251bc55a7932393e
1 parent
0be91da0
Exists in
master
and in
74 other branches
progress
Showing
2 changed files
with
42 additions
and
32 deletions
Show diff stats
src/ParamOutputImpl/Plot/Time/TimePlot.cc
@@ -17,6 +17,8 @@ | @@ -17,6 +17,8 @@ | ||
17 | #include "ShadesTools.hh" | 17 | #include "ShadesTools.hh" |
18 | #include "AxisLegendManager.hh" | 18 | #include "AxisLegendManager.hh" |
19 | #include <fstream> | 19 | #include <fstream> |
20 | +#include <limits> | ||
21 | +#include <cstddef> | ||
20 | 22 | ||
21 | #include "DefaultTimeAxisDecorator.hh" | 23 | #include "DefaultTimeAxisDecorator.hh" |
22 | #include "TickMarkDecorator.hh" | 24 | #include "TickMarkDecorator.hh" |
@@ -961,24 +963,21 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam | @@ -961,24 +963,21 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam | ||
961 | continue; | 963 | continue; |
962 | } | 964 | } |
963 | } | 965 | } |
964 | - std::string normalistion = pSpectro pSpectro.getNormalisation; | ||
965 | - if (pSpectro != nullptr){ | ||
966 | - double usedValues[] = normalise(data.getValues(index, startIndex) ,normalistion); | ||
967 | - }else{ | ||
968 | - double usedValues[] = data.getValues(index, startIndex); | ||
969 | - } | ||
970 | - | 966 | + |
971 | for (int i = 0; i < nbValues - 1; ++i) | 967 | for (int i = 0; i < nbValues - 1; ++i) |
972 | { | 968 | { |
973 | part.x[0] = data.getTimes()[startIndex+i]; | 969 | part.x[0] = data.getTimes()[startIndex+i]; |
974 | part.x[1] = data.getTimes()[startIndex+i+1]; | 970 | part.x[1] = data.getTimes()[startIndex+i+1]; |
975 | part.isColorIndex = false; | 971 | part.isColorIndex = false; |
976 | - part.value = usedValues[i]; | 972 | + part.value = data.getValues(index, startIndex)[i]; |
977 | matrixGrid.push_back(part); | 973 | matrixGrid.push_back(part); |
978 | } | 974 | } |
979 | 975 | ||
980 | //draw spectro | 976 | //draw spectro |
981 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid - " << matrixGrid.size()); | 977 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid - " << matrixGrid.size()); |
978 | + std::string normalistion = pSpectro.getNormalisation(); | ||
979 | + if (!normalistion.empty()) | ||
980 | + normalise(matrixGrid, normalistion); | ||
982 | drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(), | 981 | drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(), |
983 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin()); | 982 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin()); |
984 | matrixGrid.clear(); | 983 | matrixGrid.clear(); |
@@ -1042,39 +1041,48 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam | @@ -1042,39 +1041,48 @@ void TimePlot::drawSpectro(double startDate, double stopDate, std::string pParam | ||
1042 | } | 1041 | } |
1043 | //draw spectro | 1042 | //draw spectro |
1044 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid - " << matrixGrid.size()); | 1043 | LOG4CXX_DEBUG(gLogger, "TimePlot::drawSpectro - Draw data grid - " << matrixGrid.size()); |
1044 | + std::string normalistion = pSpectro.getNormalisation(); | ||
1045 | + if (!normalistion.empty()) | ||
1046 | + normalise(matrixGrid, normalistion); | ||
1047 | + | ||
1045 | drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(), | 1048 | drawMatrix(matrixGrid, pSpectro.getMin(), pSpectro.getMax(), |
1046 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin()); | 1049 | minValColor, maxValColor, lZAxis->_color._colorMapIndex, pSpectro.getUseLog0AsMin()); |
1047 | matrixGrid.clear(); | 1050 | matrixGrid.clear(); |
1048 | } | 1051 | } |
1049 | } | 1052 | } |
1050 | } | 1053 | } |
1051 | -double * normalise(double values [], std::string normalisationType){ | ||
1052 | - max = std::max_element(std::begin(rawValues), std::end(rawValues)); | ||
1053 | - min = std::min_element(std::begin(rawValues), std::end(rawValues)); | ||
1054 | - int len = std::sizeof(values)/std::sizeof(values[0]); | ||
1055 | - double res [len] ; | 1054 | +void TimePlot::normalise(MatrixGrid & matrixGrid, std::string normalisationType){ |
1055 | + double min = DBL_MAX; | ||
1056 | + double max = DBL_MIN; | ||
1057 | + int len = matrixGrid.size(); | ||
1058 | + for(auto val :matrixGrid){ | ||
1059 | + if(val.value <min) | ||
1060 | + min = val.value; | ||
1061 | + if(val.value > max) | ||
1062 | + max = val.value; | ||
1063 | + } | ||
1064 | + if (min <= 0) | ||
1065 | + min = DBL_MIN; | ||
1056 | if(std::isnan(min) || std::isnan(max)){ | 1066 | if(std::isnan(min) || std::isnan(max)){ |
1057 | - return values; | 1067 | + return; |
1058 | }else if(min == max){ | 1068 | }else if(min == max){ |
1059 | - for (itn i =0; i < len; i++) | ||
1060 | - res[i] = values[i]/max; | ||
1061 | - return res; | 1069 | + for (int i =0; i < len; i++) |
1070 | + matrixGrid[i].value= matrixGrid[i].value/max; | ||
1062 | }else{ | 1071 | }else{ |
1063 | - switch(normalisationType){ | ||
1064 | - case 'log': | ||
1065 | - for (itn i =0; i < len; i++) | ||
1066 | - res[i] = (std::log10(values[i])-std::log10(min))/(std::log10(max)-std::log10(min)); | ||
1067 | - return res; | ||
1068 | - break; | ||
1069 | - case 'linear': | ||
1070 | - for (itn i =0; i < len; i++) | ||
1071 | - res[i] = (values[i]-min)/(max-min); | ||
1072 | - return res; | ||
1073 | - break; | ||
1074 | - default: | ||
1075 | - BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg("Unknwon normalisation "<<normalisationType)); | ||
1076 | - break; | ||
1077 | - } | 1072 | + if(normalisationType == "log"){ |
1073 | + for (int i =0; i < len; i++) | ||
1074 | + matrixGrid[i].value = (std::log10(matrixGrid[i].value)-std::log10(min))/(std::log10(max)-std::log10(min)); | ||
1075 | + return; | ||
1076 | + }else if (normalisationType == "linear"){ | ||
1077 | + for (int i =0; i < len; i++) | ||
1078 | + matrixGrid[i].value = (matrixGrid[i].value-min)/(max-min); | ||
1079 | + return; | ||
1080 | + }else{ | ||
1081 | + std::stringstream lError; | ||
1082 | + lError << "Unknwon normalisation " << normalisationType; | ||
1083 | + BOOST_THROW_EXCEPTION(PanelPlotOutputException() << AMDA::ex_msg(lError.str())); | ||
1084 | + } | ||
1085 | + | ||
1078 | } | 1086 | } |
1079 | 1087 | ||
1080 | } | 1088 | } |
src/ParamOutputImpl/Plot/Time/TimePlot.hh
@@ -68,6 +68,8 @@ public: | @@ -68,6 +68,8 @@ public: | ||
68 | std::shared_ptr<TimeAxisDecorator> getTimeAxisDecorator(){ | 68 | std::shared_ptr<TimeAxisDecorator> getTimeAxisDecorator(){ |
69 | return _xdecoratorPtr; | 69 | return _xdecoratorPtr; |
70 | } | 70 | } |
71 | + | ||
72 | + void normalise(MatrixGrid & matrixGrid, std::string normalisationType); | ||
71 | 73 | ||
72 | /** | 74 | /** |
73 | * @brief QSAS time configuration for time formatting | 75 | * @brief QSAS time configuration for time formatting |