From 4c23d613a90b6aab7d2abf73e11a4a0c43d35c7c Mon Sep 17 00:00:00 2001 From: Teemu Murtola Date: Fri, 15 Aug 2014 14:41:05 +0300 Subject: [PATCH] Fix histogram resampling output bin positions 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 | 2 +- src/gromacs/analysisdata/modules/histogram.h | 3 +++ ...ractAverageHistogramTest_ResamplesAtDoubleBinWidth.xml | 6 +++--- ...ogramTest_ResamplesAtDoubleBinWidthWithIntegerBins.xml | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gromacs/analysisdata/modules/histogram.cpp b/src/gromacs/analysisdata/modules/histogram.cpp index fd6727ff91..d9e3501f41 100644 --- a/src/gromacs/analysisdata/modules/histogram.cpp +++ b/src/gromacs/analysisdata/modules/histogram.cpp @@ -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(); diff --git a/src/gromacs/analysisdata/modules/histogram.h b/src/gromacs/analysisdata/modules/histogram.h index 0717b4b822..dff0fd7ba2 100644 --- a/src/gromacs/analysisdata/modules/histogram.h +++ b/src/gromacs/analysisdata/modules/histogram.h @@ -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. diff --git a/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidth.xml b/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidth.xml index c0784a5e4c..02a3193019 100644 --- a/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidth.xml +++ b/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidth.xml @@ -75,7 +75,7 @@ - 1.5 + 1.25 1 @@ -85,7 +85,7 @@ - 2.5 + 2.25 1 @@ -95,7 +95,7 @@ - 3.5 + 3.25 1 diff --git a/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidthWithIntegerBins.xml b/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidthWithIntegerBins.xml index 211357e775..ffebb62053 100644 --- a/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidthWithIntegerBins.xml +++ b/src/gromacs/analysisdata/tests/refdata/AbstractAverageHistogramTest_ResamplesAtDoubleBinWidthWithIntegerBins.xml @@ -75,7 +75,7 @@ - 1 + 0.75 1 @@ -85,7 +85,7 @@ - 2 + 1.75 1 @@ -95,7 +95,7 @@ - 3 + 2.75 1 @@ -105,7 +105,7 @@ - 4 + 3.75 1 -- 2.22.0