Fix histogram resampling output bin positions
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 15 Aug 2014 11:41:05 +0000 (14:41 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Fri, 19 Sep 2014 14:55:51 +0000 (16:55 +0200)
The reported bin positions were off by half of the original bin size
from what they actually contained.  This was apparent when the RDF code
started actually using the code.

Change-Id: I651c1f1359430047acc83ca15e9c31087b22d845

src/gromacs/analysisdata/modules/histogram.cpp
src/gromacs/analysisdata/modules/histogram.h
src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidth.xml
src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidthWithIntegerBins.xml

index fd6727ff91aa53d4fec623f54db339cde280a4e9..d9e3501f41cd0feb5f790575b24bc8420125739f 100644 (file)
@@ -286,7 +286,7 @@ AbstractAverageHistogram::resampleDoubleBinWidth(bool bIntegerBins) const
 
     AverageHistogramPointer dest(
             new StaticAverageHistogram(
-                    histogramFromBins(xstart(), nbins, 2*xstep())
+                    histogramFromBins(settings().firstEdge(), nbins, 2*xstep())
                         .integerBins(bIntegerBins)));
     dest->setColumnCount(columnCount());
     dest->allocateValues();
index 0717b4b822d1c68b76a5f0397f7700af3cfd90c8..dff0fd7ba26fcd3b319b196511445f7dedfc7463 100644 (file)
@@ -272,6 +272,9 @@ class AbstractAverageHistogram : public AbstractAnalysisArrayData
         /*! \brief
          * Creates a copy of the histogram with double the bin width.
          *
+         * \param[in] bIntegerBins If `true`, the first bin in the result will
+         *     cover the first bin from the source. Otherwise, the first bin
+         *     will cover first two bins from the source.
          * \throws std::bad_alloc if out of memory.
          *
          * The caller is responsible of deleting the returned object.
index c0784a5e4cedc26adcffffb9f8a5b85aaff8c272..02a3193019123f5813a276a0bf72d85b7b8dd3d5 100644 (file)
@@ -75,7 +75,7 @@
   </AnalysisData>
   <AnalysisData Name="ResampledHistogram">
     <DataFrame Name="Frame0">
-      <Real Name="X">1.5</Real>
+      <Real Name="X">1.25</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>
@@ -85,7 +85,7 @@
       </DataValues>
     </DataFrame>
     <DataFrame Name="Frame1">
-      <Real Name="X">2.5</Real>
+      <Real Name="X">2.25</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>
@@ -95,7 +95,7 @@
       </DataValues>
     </DataFrame>
     <DataFrame Name="Frame2">
-      <Real Name="X">3.5</Real>
+      <Real Name="X">3.25</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>
index 211357e775840e5055f7a701d6da691ca898371f..ffebb62053227d41eb5c5de460a9d97d432b53dc 100644 (file)
@@ -75,7 +75,7 @@
   </AnalysisData>
   <AnalysisData Name="ResampledHistogram">
     <DataFrame Name="Frame0">
-      <Real Name="X">1</Real>
+      <Real Name="X">0.75</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>
@@ -85,7 +85,7 @@
       </DataValues>
     </DataFrame>
     <DataFrame Name="Frame1">
-      <Real Name="X">2</Real>
+      <Real Name="X">1.75</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>
@@ -95,7 +95,7 @@
       </DataValues>
     </DataFrame>
     <DataFrame Name="Frame2">
-      <Real Name="X">3</Real>
+      <Real Name="X">2.75</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>
       </DataValues>
     </DataFrame>
     <DataFrame Name="Frame3">
-      <Real Name="X">4</Real>
+      <Real Name="X">3.75</Real>
       <DataValues>
         <Int Name="Count">1</Int>
         <DataValue>