Commit 4bced76de4ff683ecb869156e2fa3b790cd6db8a
1 parent
81caa397
Exists in
master
and in
16 other branches
#11372 - Adding new functions t Histo1D - Done
Showing
6 changed files
with
451 additions
and
96 deletions
Show diff stats
config/xsd/request/histoPlot.xsd
... | ... | @@ -30,22 +30,22 @@ |
30 | 30 | </xs:documentation> |
31 | 31 | </xs:annotation> |
32 | 32 | </xs:element> |
33 | - <xs:element name="histogram1d" | |
34 | - type="Parameter1dhistogramPropertiesType" maxOccurs="unbounded" | |
33 | + <xs:element name="histogram2d" | |
34 | + type="Parameter2dhistogramPropertiesType" maxOccurs="unbounded" | |
35 | 35 | minOccurs="0"> |
36 | 36 | <xs:annotation> |
37 | 37 | <xs:documentation> |
38 | - define drawing properties for 1D histogram. | |
38 | + define drawing properties for 2D histogram. | |
39 | 39 | To be filled. |
40 | 40 | </xs:documentation> |
41 | 41 | </xs:annotation> |
42 | 42 | </xs:element> |
43 | - <xs:element name="histogram2d" | |
44 | - type="Parameter2dhistogramPropertiesType" maxOccurs="unbounded" | |
43 | + <xs:element name="histogram1d" | |
44 | + type="Parameter1dhistogramPropertiesType" maxOccurs="unbounded" | |
45 | 45 | minOccurs="0"> |
46 | 46 | <xs:annotation> |
47 | 47 | <xs:documentation> |
48 | - define drawing properties for 2D histogram. | |
48 | + define drawing properties for 1D histogram. | |
49 | 49 | To be filled. |
50 | 50 | </xs:documentation> |
51 | 51 | </xs:annotation> | ... | ... |
src/ParamOutputImpl/Plot/AxisLegendManager.cc
... | ... | @@ -128,7 +128,7 @@ namespace plot |
128 | 128 | PanelPlotOutput *plot) |
129 | 129 | { |
130 | 130 | SeriesProperties lSeriesProperties; |
131 | - | |
131 | + std::string yAxisTextLegend; | |
132 | 132 | // Compute nb series to draw by y axis |
133 | 133 | std::map<std::string, int> nbSeriesByYAxisMap = plot->getNbSeriesByYAxis(); |
134 | 134 | |
... | ... | @@ -153,16 +153,22 @@ namespace plot |
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | if(pHistogramProperties->getHistogramType() == "histogram1d"){ |
156 | - std::string yAxisTextLegend; | |
157 | - yAxisTextLegend = pHistogramProperties->getHistotypeProperties().getHisto1DFunction()->getTextLegend(); | |
158 | - Label yLabel(lYAxis->_legend.getFont(),lYAxis->_color); | |
159 | - yLabel._text = yAxisTextLegend; | |
160 | - lYAxis->_legend.setLabel(yLabel); | |
156 | + AMDA::Common::ParameterIndexComponent yIndexComp = pHistogramProperties->getHistotypeProperties().getIndex(); | |
157 | + std::string yParamId = pHistogramProperties->getHistotypeProperties().getParamId(); | |
158 | + yAxisTextLegend = yAxisTextLegend = pHistogramProperties->getHistotypeProperties().getHisto1DFunction()->getTextLegend(); | |
159 | + if(pHistogramProperties->getHistotypeProperties().getParamId().empty()) | |
160 | + { | |
161 | + Label yLabel(lYAxis->_legend.getFont(),lYAxis->_color); | |
162 | + yLabel._text = yAxisTextLegend; | |
163 | + lYAxis->_legend.setLabel(yLabel); | |
164 | + continue; | |
165 | + } | |
166 | + Color compLegendColor = lYAxis->_color; | |
167 | + if(param.getHistogramSeriesPropertiesList().size() > 0) | |
168 | + compLegendColor = pHistogramProperties->getColor(); | |
169 | + ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(yIndexComp, compLegendColor); | |
170 | + pushComponentInList(yParamId, yIndex, axesParamsComponents[yAxisId]); | |
161 | 171 | } |
162 | - | |
163 | - Color compLegendColor = lYAxis->_color; | |
164 | - ParameterIndexComponentColor yIndex = ParameterIndexComponentColor(pHistogramProperties->getIndex(), compLegendColor); | |
165 | - pushComponentInList(pHistogramProperties->getParamId(), yIndex, axesParamsComponents[yAxisId]); | |
166 | 172 | } |
167 | 173 | } |
168 | 174 | for (auto lSeriesProperties : param.getYSeriePropertiesList()) |
... | ... | @@ -200,7 +206,7 @@ namespace plot |
200 | 206 | for (auto axisParamsComponents : axesParamsComponents) |
201 | 207 | { |
202 | 208 | boost::shared_ptr<Axis> lYAxis = plot->_panel->getAxis(axisParamsComponents.first); |
203 | - setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second); | |
209 | + setAxisLegendForSeries(plot, lYAxis, axisParamsComponents.second,yAxisTextLegend); | |
204 | 210 | } |
205 | 211 | } |
206 | 212 | ... | ... |
src/ParamOutputImpl/Plot/HistoPlot/Histo1DFunction.cc
... | ... | @@ -14,7 +14,7 @@ namespace plot { |
14 | 14 | |
15 | 15 | |
16 | 16 | // Basically transforms the data to a matrix by keeping all the values needed later |
17 | -std::map<int,std::vector<double>> Histo1DFunction::getGridValues(double* xData, int nbData, Range xRange, double xBinSize) | |
17 | +std::map<int,std::vector<double>> Histo1DFunction::getGridValues(double* xData,double* yData, int nbData, Range xRange, double xBinSize) | |
18 | 18 | { |
19 | 19 | std::map<int,std::vector<double>> allValues; |
20 | 20 | double xMin = xRange.getMin(); |
... | ... | @@ -26,14 +26,14 @@ std::map<int,std::vector<double>> Histo1DFunction::getGridValues(double* xData, |
26 | 26 | continue; |
27 | 27 | |
28 | 28 | int xIndex = (xData[i]- xMin)/xBinSize; |
29 | - | |
30 | - allValues[xIndex].push_back(xData[i]); | |
29 | + if(!std::isnan(yData[i])) | |
30 | + allValues[xIndex].push_back(yData[i]); | |
31 | 31 | } |
32 | 32 | return allValues; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Density function for 1DHistogram |
36 | -void Density1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, int nbData, Range xRange, | |
36 | +void Density1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* /*yData*/, int nbData, Range xRange, | |
37 | 37 | double& xBinSize, bool yIsLog, double& yMin, double& yMax) |
38 | 38 | { |
39 | 39 | bool yMaxToModify=true; |
... | ... | @@ -49,7 +49,7 @@ void Density1DFunction::apply(std::vector<std::pair<double,double>> &grid, doub |
49 | 49 | yMaxToModify = false; |
50 | 50 | std::map<int,std::vector<double>> allValues; |
51 | 51 | |
52 | - allValues = getGridValues(xData,nbData,xRange,xBinSize); | |
52 | + allValues = getGridValues(xData,xData,nbData,xRange,xBinSize); | |
53 | 53 | |
54 | 54 | for (unsigned int i(0); i < allValues.size(); ++i){ |
55 | 55 | if (allValues[i].size() > 0) |
... | ... | @@ -65,7 +65,7 @@ void Density1DFunction::apply(std::vector<std::pair<double,double>> &grid, doub |
65 | 65 | |
66 | 66 | |
67 | 67 | // NormDensity1DFunction function for 1DHistogram |
68 | -void NormDensity1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, int nbData, Range xRange, | |
68 | +void NormDensity1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* /*yData*/, int nbData, Range xRange, | |
69 | 69 | double& xBinSize, bool yIsLog, double& yMin, double& yMax) |
70 | 70 | { |
71 | 71 | |
... | ... | @@ -82,7 +82,7 @@ void NormDensity1DFunction::apply(std::vector<std::pair<double,double>> &grid, |
82 | 82 | yMaxToModify = false; |
83 | 83 | std::map<int,std::vector<double>> allValues; |
84 | 84 | |
85 | - allValues = getGridValues(xData,nbData,xRange,xBinSize); | |
85 | + allValues = getGridValues(xData,xData,nbData,xRange,xBinSize); | |
86 | 86 | |
87 | 87 | int nbRecord = 0; |
88 | 88 | for(unsigned int i(0); i < allValues.size();++i){ |
... | ... | @@ -103,5 +103,246 @@ void NormDensity1DFunction::apply(std::vector<std::pair<double,double>> &grid, |
103 | 103 | yMin = allValues[i].size()/(double)nbRecord; |
104 | 104 | } |
105 | 105 | } |
106 | + | |
107 | + grid = _cacheGrid; | |
108 | +} | |
109 | + | |
110 | +void Mean1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
111 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax) | |
112 | +{ | |
113 | + bool yMaxToModify=true; | |
114 | + if(!_cacheGrid.empty()){ | |
115 | + grid = _cacheGrid; | |
116 | + return; | |
117 | + } | |
118 | + if(std::isnan(yMin)) | |
119 | + yMin = (yIsLog) ? 1 : 0; | |
120 | + if(std::isnan(yMax)) | |
121 | + yMax = 0; | |
122 | + else | |
123 | + yMaxToModify = false; | |
124 | + std::map<int,std::vector<double>> allValues; | |
125 | + allValues = getGridValues(xData,yData,nbData,xRange,xBinSize); | |
126 | + | |
127 | + for (unsigned int i(0); i < allValues.size(); ++i){ | |
128 | + | |
129 | + if (allValues[i].size() > 0){ | |
130 | + double mean = Histo1DFunction::mean(allValues[i]); | |
131 | + _cacheGrid.push_back(std::make_pair(xRange.getMin()+xBinSize*i, | |
132 | + (yIsLog)? log10(mean) : mean)); | |
133 | + | |
134 | + if(yMaxToModify){ | |
135 | + if(yMax < mean) | |
136 | + yMax =mean; | |
137 | + if(yMin > mean) | |
138 | + yMin = mean; | |
139 | + } | |
140 | + if(yIsLog){ | |
141 | + yMin = log10(yMin); | |
142 | + } | |
143 | + } | |
144 | + } | |
145 | + | |
146 | + grid = _cacheGrid; | |
147 | + | |
148 | +} | |
149 | + | |
150 | +void Min1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
151 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax) | |
152 | +{ | |
153 | + bool yMaxToModify=true; | |
154 | + if(!_cacheGrid.empty()){ | |
155 | + grid = _cacheGrid; | |
156 | + return; | |
157 | + } | |
158 | + if(std::isnan(yMin)) | |
159 | + yMin = (yIsLog) ? 1 : 0; | |
160 | + if(std::isnan(yMax)) | |
161 | + yMax = 0; | |
162 | + else | |
163 | + yMaxToModify = false; | |
164 | + std::map<int,std::vector<double>> allValues; | |
165 | + allValues = getGridValues(xData,yData,nbData,xRange,xBinSize); | |
166 | + | |
167 | + for (unsigned int i(0); i < allValues.size(); ++i){ | |
168 | + | |
169 | + if (allValues[i].size() > 0){ | |
170 | + double min = Histo1DFunction::min(allValues[i]); | |
171 | + _cacheGrid.push_back(std::make_pair(xRange.getMin()+xBinSize*i, | |
172 | + (yIsLog)? log10(min) : min)); | |
173 | + | |
174 | + if(yMaxToModify){ | |
175 | + if(yMax < min) | |
176 | + yMax =min; | |
177 | + if(yMin > min) | |
178 | + yMin = min; | |
179 | + } | |
180 | + if(yIsLog){ | |
181 | + yMin = log10(yMin); | |
182 | + } | |
183 | + } | |
184 | + } | |
185 | + grid = _cacheGrid; | |
186 | +} | |
187 | + | |
188 | +void Max1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
189 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax) | |
190 | +{ | |
191 | + bool yMaxToModify=true; | |
192 | + if(!_cacheGrid.empty()){ | |
193 | + grid = _cacheGrid; | |
194 | + return; | |
195 | + } | |
196 | + if(std::isnan(yMin)) | |
197 | + yMin = (yIsLog) ? 1 : 0; | |
198 | + if(std::isnan(yMax)) | |
199 | + yMax = 0; | |
200 | + else | |
201 | + yMaxToModify = false; | |
202 | + std::map<int,std::vector<double>> allValues; | |
203 | + allValues = getGridValues(xData,yData,nbData,xRange,xBinSize); | |
204 | + | |
205 | + for (unsigned int i(0); i < allValues.size(); ++i){ | |
206 | + | |
207 | + if (allValues[i].size() > 0){ | |
208 | + double max = Histo1DFunction::max(allValues[i]); | |
209 | + _cacheGrid.push_back(std::make_pair(xRange.getMin()+xBinSize*i, | |
210 | + (yIsLog)? log10(max) : max)); | |
211 | + | |
212 | + if(yMaxToModify){ | |
213 | + if(yMax < max) | |
214 | + yMax =max; | |
215 | + if(yMin > max) | |
216 | + yMin = max; | |
217 | + } | |
218 | + if(yIsLog){ | |
219 | + yMin = log10(yMin); | |
220 | + } | |
221 | + } | |
222 | + } | |
223 | + grid = _cacheGrid; | |
224 | +} | |
225 | + | |
226 | +void Median1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
227 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax) | |
228 | +{ | |
229 | + bool yMaxToModify=true; | |
230 | + if(!_cacheGrid.empty()){ | |
231 | + grid = _cacheGrid; | |
232 | + return; | |
233 | + } | |
234 | + if(std::isnan(yMin)) | |
235 | + yMin = (yIsLog) ? 1 : 0; | |
236 | + if(std::isnan(yMax)) | |
237 | + yMax = 0; | |
238 | + else | |
239 | + yMaxToModify = false; | |
240 | + std::map<int,std::vector<double>> allValues; | |
241 | + allValues = getGridValues(xData,yData,nbData,xRange,xBinSize); | |
242 | + | |
243 | + for (unsigned int i(0); i < allValues.size(); ++i){ | |
244 | + if (allValues[i].size() > 0){ | |
245 | + double median = Histo1DFunction::median(allValues[i]); | |
246 | + _cacheGrid.push_back(std::make_pair(xRange.getMin()+xBinSize*i, | |
247 | + (yIsLog)? log10(median) : median)); | |
248 | + | |
249 | + if(yMaxToModify){ | |
250 | + if(yMax < median) | |
251 | + yMax = median; | |
252 | + if(yMin > median) | |
253 | + yMin = median; | |
254 | + } | |
255 | + if(yIsLog){ | |
256 | + yMin = log10(yMin); | |
257 | + } | |
258 | + } | |
259 | + } | |
260 | + grid = _cacheGrid; | |
261 | +} | |
262 | + | |
263 | +void StandardDeviation1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
264 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax) | |
265 | +{ | |
266 | + bool yMaxToModify=true; | |
267 | + if(!_cacheGrid.empty()){ | |
268 | + grid = _cacheGrid; | |
269 | + return; | |
270 | + } | |
271 | + if(std::isnan(yMin)) | |
272 | + yMin = (yIsLog) ? 1 : 0; | |
273 | + if(std::isnan(yMax)) | |
274 | + yMax = 0; | |
275 | + else | |
276 | + yMaxToModify = false; | |
277 | + std::map<int,std::vector<double>> allValues; | |
278 | + allValues = getGridValues(xData,yData,nbData,xRange,xBinSize); | |
279 | + | |
280 | + for (unsigned int i(0); i < allValues.size(); ++i){ | |
281 | + if (allValues[i].size() > 0){ | |
282 | + double mean = Histo1DFunction::mean(allValues[i]); | |
283 | + double stddev = Histo1DFunction::standardDeviation(allValues[i], mean); | |
284 | + | |
285 | + _cacheGrid.push_back(std::make_pair(xRange.getMin()+xBinSize*i, | |
286 | + (yIsLog)? log10(stddev) : stddev)); | |
287 | + | |
288 | + if(yMaxToModify){ | |
289 | + if(yMax < stddev) | |
290 | + yMax = stddev; | |
291 | + if(yMin > stddev) | |
292 | + yMin = stddev; | |
293 | + } | |
294 | + if(yIsLog){ | |
295 | + yMin = log10(yMin); | |
296 | + } | |
297 | + } | |
298 | + } | |
299 | + grid = _cacheGrid; | |
106 | 300 | } |
301 | + | |
302 | +void Kurtosis1DFunction::apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
303 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax) | |
304 | +{ | |
305 | + bool yMaxToModify=true; | |
306 | + if(!_cacheGrid.empty()){ | |
307 | + grid = _cacheGrid; | |
308 | + return; | |
309 | + } | |
310 | + if(std::isnan(yMin)) | |
311 | + yMin = (yIsLog) ? 1 : 0; | |
312 | + if(std::isnan(yMax)) | |
313 | + yMax = 0; | |
314 | + else | |
315 | + yMaxToModify = false; | |
316 | + std::map<int,std::vector<double>> allValues; | |
317 | + allValues = getGridValues(xData,yData,nbData,xRange,xBinSize); | |
318 | + | |
319 | + for (unsigned int i(0); i < allValues.size(); ++i){ | |
320 | + unsigned int n = allValues[i].size(); | |
321 | + if (n >= 4){ | |
322 | + double mean = Histo1DFunction::mean(allValues[i]); | |
323 | + double stddev = Histo1DFunction::standardDeviation(allValues[i], mean); | |
324 | + double sum = 0.0; | |
325 | + for (const auto& value : allValues[i]) { | |
326 | + sum += std::pow((value - mean) / stddev, 4); | |
327 | + } | |
328 | + double kurtosis = (n * (n + 1.0) / ((n - 1.0) * (n - 2.0) * (n - 3.0))) * sum | |
329 | + - (3.0 * std::pow(n - 1.0, 2) / ((n - 2.0) * (n - 3.0))); | |
330 | + | |
331 | + _cacheGrid.push_back(std::make_pair(xRange.getMin()+xBinSize*i, | |
332 | + (yIsLog)? log10(kurtosis) | |
333 | + : kurtosis)); | |
334 | + if(yMaxToModify){ | |
335 | + if(yMax < kurtosis) | |
336 | + yMax = kurtosis; | |
337 | + if(yMin > kurtosis) | |
338 | + yMin = kurtosis; | |
339 | + } | |
340 | + if(yIsLog){ | |
341 | + yMin = log10(yMin); | |
342 | + } | |
343 | + } | |
344 | + } | |
345 | + grid = _cacheGrid; | |
346 | +} | |
347 | + | |
107 | 348 | } /* namespace plot */ | ... | ... |
src/ParamOutputImpl/Plot/HistoPlot/Histo1DFunction.hh
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | #include <iostream> |
12 | 12 | #include <map> |
13 | 13 | #include <string> |
14 | +#include <algorithm> | |
14 | 15 | #include "Matrix.hh" |
15 | 16 | #include "Range.hh" |
16 | 17 | |
... | ... | @@ -27,15 +28,75 @@ class Histo1DFunction { |
27 | 28 | } |
28 | 29 | ~Histo1DFunction(){} |
29 | 30 | |
30 | - virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, int nbData, Range xRange, double& xBinSize, | |
31 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, double& xBinSize, | |
31 | 32 | bool yIsLog, double& yMin, double& yMax) = 0; |
32 | 33 | |
33 | 34 | virtual std::string getTextLegend() |
34 | 35 | { |
35 | 36 | return ""; |
36 | 37 | } |
38 | + double mean(const std::vector<double>& data) { | |
39 | + double sum = 0.0; | |
40 | + for (const auto& value : data) { | |
41 | + sum += value; | |
42 | + } | |
43 | + return sum / data.size(); | |
44 | + } | |
45 | + | |
46 | + double standardDeviation(const std::vector<double>& data, double mean) { | |
47 | + double sum = 0.0; | |
48 | + for (const auto& value : data) { | |
49 | + sum += std::pow(value - mean, 2); | |
50 | + } | |
51 | + return std::sqrt(sum / data.size()); | |
52 | + } | |
53 | + | |
54 | + double sum(const std::vector<double>& data) { | |
55 | + double sum = 0.0; | |
56 | + for (const auto& value : data) { | |
57 | + sum += value; | |
58 | + } | |
59 | + return sum; | |
60 | + } | |
61 | + | |
62 | + double max(const std::vector<double>& data) { | |
63 | + if (data.empty()) { | |
64 | + std::cerr << "Error: Empty data for max calculation." << std::endl; | |
65 | + return 0.0; | |
66 | + } | |
67 | + | |
68 | + return *std::max_element(data.begin(), data.end()); | |
69 | + } | |
70 | + | |
71 | + double min(const std::vector<double>& data) { | |
72 | + if (data.empty()) { | |
73 | + std::cerr << "Error: Empty data for min calculation." << std::endl; | |
74 | + return 0.0; | |
75 | + } | |
37 | 76 | |
38 | - std::map<int,std::vector<double>> getGridValues(double* xData, int nbData, Range xRange, double xBinSize); | |
77 | + return *std::min_element(data.begin(), data.end()); | |
78 | + } | |
79 | + | |
80 | + double median(const std::vector<double>& data) { | |
81 | + if (data.empty()) { | |
82 | + std::cerr << "Error: Empty data for median calculation." << std::endl; | |
83 | + return 0.0; | |
84 | + } | |
85 | + | |
86 | + std::vector<double> sortedData = data; | |
87 | + std::sort(sortedData.begin(), sortedData.end()); | |
88 | + | |
89 | + size_t size = sortedData.size(); | |
90 | + if (size % 2 == 0) { | |
91 | + // If the size is even, take the average of the two middle elements. | |
92 | + return (sortedData[size / 2 - 1] + sortedData[size / 2]) / 2.0; | |
93 | + } else { | |
94 | + // If the size is odd, return the middle element. | |
95 | + return sortedData[size / 2]; | |
96 | + } | |
97 | + } | |
98 | + | |
99 | + std::map<int,std::vector<double>> getGridValues(double* xData, double* yData, int nbData, Range xRange, double xBinSize); | |
39 | 100 | |
40 | 101 | void resetCache() { |
41 | 102 | _cacheGrid.clear(); |
... | ... | @@ -54,7 +115,7 @@ public: |
54 | 115 | Density1DFunction() {} |
55 | 116 | ~Density1DFunction() {} |
56 | 117 | |
57 | - virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, int nbData, Range xRange, | |
118 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* /* yData */, int nbData, Range xRange, | |
58 | 119 | double& xBinSize, bool yIsLog, double& yMin, double& yMax); |
59 | 120 | virtual std::string getTextLegend() |
60 | 121 | { |
... | ... | @@ -67,79 +128,91 @@ public: |
67 | 128 | NormDensity1DFunction() {} |
68 | 129 | ~NormDensity1DFunction() {} |
69 | 130 | |
70 | - virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, int nbData, Range xRange, | |
71 | - double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
131 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* /* yData */, int nbData, Range xRange, | |
132 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
72 | 133 | virtual std::string getTextLegend() |
73 | 134 | { |
74 | 135 | return "Frequency"; |
75 | 136 | } |
76 | 137 | }; |
77 | 138 | |
78 | -// class Mean1DFunction : public Histo1DFunction { | |
79 | -// public: | |
80 | -// Mean1DFunction() {} | |
81 | -// ~Mean1DFunction() {} | |
82 | - | |
83 | -// virtual void apply(MatrixGrid &matrixGrid, double* xData, double* yData, double* zData, int nbData, Range xRange, Range yRange, | |
84 | -// int xBinNumber,int yBinNumber, double& zMin, double& zMax,int smoothFactor); | |
85 | -// virtual std::string getTextLegend() | |
86 | -// { | |
87 | -// return "Mean on bins for "; | |
88 | -// } | |
89 | -// }; | |
90 | - | |
91 | -// class Max1DFunction : public Histo1DFunction { | |
92 | -// public: | |
93 | -// Max1DFunction() {} | |
94 | -// ~Max1DFunction() {} | |
95 | - | |
96 | -// virtual void apply(MatrixGrid &matrixGrid, double* xData, double* yData, double* zData, int nbData, Range xRange, Range yRange, | |
97 | -// int xBinNumber,int yBinNumber, double& zMin, double& zMax,int smoothFactor); | |
98 | -// virtual std::string getTextLegend() | |
99 | -// { | |
100 | -// return "Max on bins for "; | |
101 | -// } | |
102 | -// }; | |
103 | - | |
104 | -// class Min1DFunction : public Histo1DFunction { | |
105 | -// public: | |
106 | -// Min1DFunction() {} | |
107 | -// ~Min1DFunction() {} | |
108 | - | |
109 | -// virtual void apply(MatrixGrid &matrixGrid, double* xData, double* yData, double* zData, int nbData, Range xRange, Range yRange, | |
110 | -// int xBinNumber,int yBinNumber, double& zMin, double& zMax,int smoothFactor); | |
111 | -// virtual std::string getTextLegend() | |
112 | -// { | |
113 | -// return "Min on bins for "; | |
114 | -// } | |
115 | -// }; | |
116 | - | |
117 | -// class Median1DFunction : public Histo1DFunction { | |
118 | -// public: | |
119 | -// Median1DFunction() {} | |
120 | -// ~Median1DFunction() {} | |
121 | - | |
122 | -// virtual void apply(MatrixGrid &matrixGrid, double* xData, double* yData, double* zData, int nbData, Range xRange, Range yRange, | |
123 | -// int xBinNumber,int yBinNumber, double& zMin, double& zMax,int smoothFactor); | |
124 | -// virtual std::string getTextLegend() | |
125 | -// { | |
126 | -// return "Median on bins for "; | |
127 | -// } | |
128 | -// }; | |
129 | - | |
130 | -// class StandardDeviation1DFunction : public Histo1DFunction { | |
131 | -// public: | |
132 | -// StandardDeviation1DFunction() {} | |
133 | -// ~StandardDeviation1DFunction() {} | |
134 | - | |
135 | -// virtual void apply(MatrixGrid &matrixGrid, double* xData, double* yData, double* zData, int nbData, Range xRange, Range yRange, | |
136 | -// int xBinNumber,int yBinNumber, double& zMin, double& zMax,int smoothFactor); | |
137 | -// virtual std::string getTextLegend() | |
138 | -// { | |
139 | -// return "Sta. deviation on bins for "; | |
140 | -// } | |
141 | -// }; | |
139 | +class Mean1DFunction : public Histo1DFunction { | |
140 | +public: | |
141 | + Mean1DFunction() {} | |
142 | + ~Mean1DFunction() {} | |
142 | 143 | |
144 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
145 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
146 | + virtual std::string getTextLegend() | |
147 | + { | |
148 | + return "Mean for "; | |
149 | + } | |
150 | +}; | |
151 | + | |
152 | +class Max1DFunction : public Histo1DFunction { | |
153 | +public: | |
154 | + Max1DFunction() {} | |
155 | + ~Max1DFunction() {} | |
156 | + | |
157 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
158 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
159 | + virtual std::string getTextLegend() | |
160 | + { | |
161 | + return "Max for "; | |
162 | + } | |
163 | +}; | |
164 | + | |
165 | +class Min1DFunction : public Histo1DFunction { | |
166 | +public: | |
167 | + Min1DFunction() {} | |
168 | + ~Min1DFunction() {} | |
169 | + | |
170 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
171 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
172 | + virtual std::string getTextLegend() | |
173 | + { | |
174 | + return "Min for "; | |
175 | + } | |
176 | +}; | |
177 | + | |
178 | +class Median1DFunction : public Histo1DFunction { | |
179 | +public: | |
180 | + Median1DFunction() {} | |
181 | + ~Median1DFunction() {} | |
182 | + | |
183 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
184 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
185 | + virtual std::string getTextLegend() | |
186 | + { | |
187 | + return "Median for "; | |
188 | + } | |
189 | +}; | |
190 | + | |
191 | +class StandardDeviation1DFunction : public Histo1DFunction { | |
192 | +public: | |
193 | + StandardDeviation1DFunction() {} | |
194 | + ~StandardDeviation1DFunction() {} | |
195 | + | |
196 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
197 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
198 | + virtual std::string getTextLegend() | |
199 | + { | |
200 | + return "Sta. dev. for "; | |
201 | + } | |
202 | +}; | |
203 | + | |
204 | +class Kurtosis1DFunction : public Histo1DFunction { | |
205 | +public: | |
206 | + Kurtosis1DFunction() {} | |
207 | + ~Kurtosis1DFunction() {} | |
208 | + | |
209 | + virtual void apply(std::vector<std::pair<double,double>> &grid, double* xData, double* yData, int nbData, Range xRange, | |
210 | + double& xBinSize, bool yIsLog, double& yMin, double& yMax); | |
211 | + virtual std::string getTextLegend() | |
212 | + { | |
213 | + return "Kurtosis for "; | |
214 | + } | |
215 | +}; | |
143 | 216 | |
144 | 217 | } /* namespace plot */ |
145 | 218 | ... | ... |
src/ParamOutputImpl/Plot/HistoPlot/HistoPlot.cc
... | ... | @@ -121,9 +121,16 @@ void HistoPlot::createParameters(std::list<std::string>& usedParametersId_) |
121 | 121 | { |
122 | 122 | if(pHistogramProperties != nullptr){ |
123 | 123 | if(pHistogramProperties->getHistogramType() == "histogram1d"){ |
124 | + AMDA::Parameters::ParameterSPtr originalColorParam; | |
125 | + if(!pHistogramProperties->getHistotypeProperties().getParamId().empty()) | |
126 | + originalColorParam =_parameterManager.getParameter(pHistogramProperties->getHistotypeProperties().getParamId()); | |
124 | 127 | if (std::find (usedParametersId_.begin(),usedParametersId_.end(),originalYParam->getId()) == usedParametersId_.end()) |
125 | 128 | usedParametersId_.push_back(originalYParam->getId()); |
126 | 129 | pHistogramProperties->setParamId(originalYParam->getId()); |
130 | + | |
131 | + if(originalColorParam != nullptr) | |
132 | + pHistogramProperties->getHistotypeProperties().setParamId(originalColorParam->getId()); | |
133 | + | |
127 | 134 | } |
128 | 135 | else if(pHistogramProperties->getHistogramType() == "histogram2d"){ |
129 | 136 | ParameterAxes* xSerieParameterAxes = getParameterAxesByXSerieId(pHistogramProperties->getXId()); |
... | ... | @@ -135,7 +142,7 @@ void HistoPlot::createParameters(std::list<std::string>& usedParametersId_) |
135 | 142 | originalColorParam = _parameterManager.getParameter(pHistogramProperties->getHistotypeProperties().getParamId()); |
136 | 143 | } |
137 | 144 | |
138 | - getUsedParameters(originalXSerieParam,originalYParam,originalColorParam,pHistogramProperties->getResamplingProperties(),-1, | |
145 | + getUsedParameters(originalXSerieParam,originalYParam,nullptr,pHistogramProperties->getResamplingProperties(),-1, | |
139 | 146 | usedXParam,usedYParam,usedColorParam ); |
140 | 147 | |
141 | 148 | if (std::find (usedParametersId_.begin(),usedParametersId_.end(),usedXParam->getId()) == usedParametersId_.end()) |
... | ... | @@ -340,21 +347,37 @@ void HistoPlot::histo1DUtils(double startDate, double stopDate, HistogramSeriesP |
340 | 347 | |
341 | 348 | xBinSize = (lXRange.getMax() - lXRange.getMin())/ xBinNumber; |
342 | 349 | |
350 | + //std::cout << pHistogramProperties.getHistotypeProperties().getParamId() << std::endl; | |
343 | 351 | ParameterData &xData = (*_pParameterValues)[pHistogramProperties.getParamId()]; |
352 | + | |
344 | 353 | |
345 | 354 | int xStartIndex; |
346 | 355 | int xNbValues; |
347 | 356 | |
348 | 357 | xData.getIntervalBounds(startDate, stopDate, xStartIndex, xNbValues); |
349 | - double* xValues; | |
358 | + double* xValues =nullptr; | |
359 | + double* yValues =nullptr; | |
350 | 360 | |
351 | 361 | if(lXAxis->_scale==Axis::Scale::LOGARITHMIC) |
352 | 362 | xValues = lXAxis->getComputedValues(xData.getValues(pHistogramProperties.getIndex(), xStartIndex),xNbValues,exp10(lXRange.getMin()), exp10(lXRange.getMax())); |
353 | 363 | else |
354 | 364 | xValues = xData.getValues(pHistogramProperties.getIndex(), xStartIndex); |
355 | 365 | |
356 | - pHistogramProperties.getHistotypeProperties().getHisto1DFunction()->apply(grid,xValues,xNbValues,lXRange, xBinSize, | |
366 | + | |
367 | + | |
368 | + if(!pHistogramProperties.getHistotypeProperties().getParamId().empty()){ | |
369 | + ParameterData &yData = (*_pParameterValues)[pHistogramProperties.getHistotypeProperties().getParamId()]; | |
370 | + int yStartIndex; | |
371 | + int yNbValues; | |
372 | + | |
373 | + xData.getIntervalBounds(startDate, stopDate, yStartIndex, yNbValues); | |
374 | + yValues = yData.getValues(pHistogramProperties.getHistotypeProperties().getIndex(), yStartIndex); | |
375 | + } | |
376 | + | |
377 | + pHistogramProperties.getHistotypeProperties().getHisto1DFunction()->apply(grid,xValues,yValues,xNbValues,lXRange, xBinSize, | |
357 | 378 | (lYAxis->_scale==Axis::Scale::LOGARITHMIC) ,yMin, yMax); |
379 | + | |
380 | + | |
358 | 381 | |
359 | 382 | if(lXAxis->_scale==Axis::Scale::LOGARITHMIC) |
360 | 383 | free(xValues); | ... | ... |
src/ParamOutputImpl/Plot/HistoPlot/HistotypeNode.hh
... | ... | @@ -51,6 +51,18 @@ public: |
51 | 51 | histo1DFunction = new Density1DFunction(); |
52 | 52 | else if (valueStr.compare("normdensity") == 0) |
53 | 53 | histo1DFunction = new NormDensity1DFunction(); |
54 | + else if (valueStr.compare("mean") == 0) | |
55 | + histo1DFunction = new Mean1DFunction(); | |
56 | + else if (valueStr.compare("max") == 0) | |
57 | + histo1DFunction = new Max1DFunction(); | |
58 | + else if (valueStr.compare("min") == 0) | |
59 | + histo1DFunction = new Min1DFunction(); | |
60 | + else if (valueStr.compare("median") == 0) | |
61 | + histo1DFunction = new Median1DFunction(); | |
62 | + else if (valueStr.compare("stadev") == 0) | |
63 | + histo1DFunction = new StandardDeviation1DFunction(); | |
64 | + else if (valueStr.compare("kurtosis") == 0) | |
65 | + histo1DFunction = new Kurtosis1DFunction(); | |
54 | 66 | else |
55 | 67 | histo1DFunction = new Density1DFunction(); |
56 | 68 | ... | ... |