From 789c59678ab556c46c043328eca9f4b5443bff44 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Wed, 9 Dec 2020 21:17:22 +0100
Subject: [PATCH] rename SpectrumUtils -> ImageUtils

---
 .../ImageUtils.cpp}                           |  8 +++---
 .../SpectrumUtils.h => Histo/ImageUtils.h}    |  8 ++++--
 Tests/UnitTests/Core/Other/SpectrumTest.cpp   |  4 +--
 Wrap/Swig/libBornAgainDevice.i                |  4 +--
 auto/Wrap/doxygenDevice.i                     | 28 ++++++++++---------
 auto/Wrap/libBornAgainDevice.py               |  4 ++-
 auto/Wrap/libBornAgainDevice_wrap.cpp         | 22 ++++++++-------
 7 files changed, 43 insertions(+), 35 deletions(-)
 rename Device/{Instrument/SpectrumUtils.cpp => Histo/ImageUtils.cpp} (88%)
 rename Device/{Instrument/SpectrumUtils.h => Histo/ImageUtils.h} (82%)

diff --git a/Device/Instrument/SpectrumUtils.cpp b/Device/Histo/ImageUtils.cpp
similarity index 88%
rename from Device/Instrument/SpectrumUtils.cpp
rename to Device/Histo/ImageUtils.cpp
index 87b192fcd57..aeee4b4296c 100644
--- a/Device/Instrument/SpectrumUtils.cpp
+++ b/Device/Histo/ImageUtils.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      Device/Instrument/SpectrumUtils.cpp
+//! @file      Device/Histo/ImageUtils.cpp
 //! @brief     PyObvject forward declaration.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,11 +12,11 @@
 //
 //  ************************************************************************************************
 
-#include "Device/Instrument/SpectrumUtils.h"
+#include "Device/Histo/ImageUtils.h"
 #include <cmath>
-#include <tspectrum.h>
+#include <tspectrum.h> // third-party code, extracted from CERN ROOT (class TSpectrum2)
 
-std::vector<std::pair<double, double>> SpectrumUtils::FindPeaks(const Histogram2D& hist,
+std::vector<std::pair<double, double>> ImageUtils::FindPeaks(const Histogram2D& hist,
                                                                 double sigma,
                                                                 const std::string& option,
                                                                 double threshold) {
diff --git a/Device/Instrument/SpectrumUtils.h b/Device/Histo/ImageUtils.h
similarity index 82%
rename from Device/Instrument/SpectrumUtils.h
rename to Device/Histo/ImageUtils.h
index a8c897386d0..21554bf29d7 100644
--- a/Device/Instrument/SpectrumUtils.h
+++ b/Device/Histo/ImageUtils.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit scattering at grazing incidence
 //
-//! @file      Device/Instrument/SpectrumUtils.h
+//! @file      Device/Histo/ImageUtils.h
 //! @brief     PyObvject forward declaration.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -21,9 +21,11 @@
 
 class Histogram2D;
 
-//! Collection of utils for 1D and 2D spectrum processing (background, peaks, ets).
+//! Collection of utils for 1D and 2D image processing (background, peaks, ets).
 
-namespace SpectrumUtils {
+namespace ImageUtils {
+
+//! Returns vector of peak center coordinates, for peaks in given histogram.
 
 std::vector<std::pair<double, double>> FindPeaks(const Histogram2D& hist, double sigma = 2,
                                                  const std::string& option = {},
diff --git a/Tests/UnitTests/Core/Other/SpectrumTest.cpp b/Tests/UnitTests/Core/Other/SpectrumTest.cpp
index 61a29e150f4..ccac8f1e97b 100644
--- a/Tests/UnitTests/Core/Other/SpectrumTest.cpp
+++ b/Tests/UnitTests/Core/Other/SpectrumTest.cpp
@@ -1,4 +1,4 @@
-#include "Device/Instrument/SpectrumUtils.h"
+#include "Device/Histo/ImageUtils.h"
 #include "Tests/GTestWrapper/google_test.h"
 #include <iostream>
 #include <tspectrum.h>
@@ -33,7 +33,7 @@ TEST_F(SpectrumTest, histogramPeaks) {
 
     EXPECT_EQ(hist.binContent(4, 2), 10.0);
 
-    auto peaks = SpectrumUtils::FindPeaks(hist, 3, "nomarkov", 0.1);
+    auto peaks = ImageUtils::FindPeaks(hist, 3, "nomarkov", 0.1);
     EXPECT_NEAR(peaks[0].first, 55.0, 0.01);  // center of histogram x-axis bin with index=4
     EXPECT_NEAR(peaks[0].second, 25.0, 0.01); // center of histogram y-axis bin with index=2
 }
diff --git a/Wrap/Swig/libBornAgainDevice.i b/Wrap/Swig/libBornAgainDevice.i
index e795c309a36..98c2a203806 100644
--- a/Wrap/Swig/libBornAgainDevice.i
+++ b/Wrap/Swig/libBornAgainDevice.i
@@ -53,7 +53,7 @@
 #include "Device/Instrument/IChiSquaredModule.h"
 #include "Device/Instrument/IntensityDataFunctions.h"
 #include "Device/Instrument/PyArrayImportUtils.h"
-#include "Device/Instrument/SpectrumUtils.h"
+#include "Device/Histo/ImageUtils.h"
 #include "Device/Instrument/VarianceFunctions.h"
 #include "Device/Intensity/IIntensityFunction.h"
 #include "Device/Intensity/IIntensityFunction.h"
@@ -114,7 +114,7 @@
 %include "Device/Instrument/ChiSquaredModule.h"
 %include "Device/Instrument/IntensityDataFunctions.h"
 %include "Device/Instrument/PyArrayImportUtils.h"
-%include "Device/Instrument/SpectrumUtils.h"
+%include "Device/Histo/ImageUtils.h"
 %include "Device/Instrument/VarianceFunctions.h"
 
 %include "Device/Unit/IUnitConverter.h"
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index c8ac5259fd5..741d6701659 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -3016,10 +3016,10 @@ Returns true if area defined by two bins is inside or on border of polygon (more
 // File: namespace_0d35.xml
 
 
-// File: namespace_0d58.xml
+// File: namespace_0d60.xml
 
 
-// File: namespace_0d64.xml
+// File: namespace_0d66.xml
 
 
 // File: namespaceArrayUtils.xml
@@ -3138,6 +3138,13 @@ Parse double values from string to vector of double.
 ";
 
 
+// File: namespaceImageUtils.xml
+%feature("docstring")  ImageUtils::FindPeaks "std::vector< std::pair< double, double > > ImageUtils::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)
+
+Returns vector of peak center coordinates, for peaks in given histogram. 
+";
+
+
 // File: namespaceIntensityDataFunctions.xml
 %feature("docstring")  IntensityDataFunctions::RelativeDifference "double IntensityDataFunctions::RelativeDifference(const SimulationResult &dat, const SimulationResult &ref)
 
@@ -3225,11 +3232,6 @@ for importing 2D array of doubles from python into  OutputData
 ";
 
 
-// File: namespaceSpectrumUtils.xml
-%feature("docstring")  SpectrumUtils::FindPeaks "std::vector< std::pair< double, double > > SpectrumUtils::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)
-";
-
-
 // File: Beam_8cpp.xml
 
 
@@ -3395,6 +3397,12 @@ make Swappable
 // File: IHistogram_8h.xml
 
 
+// File: ImageUtils_8cpp.xml
+
+
+// File: ImageUtils_8h.xml
+
+
 // File: IntensityDataIOFactory_8cpp.xml
 
 
@@ -3476,12 +3484,6 @@ make Swappable
 // File: PyArrayImportUtils_8h.xml
 
 
-// File: SpectrumUtils_8cpp.xml
-
-
-// File: SpectrumUtils_8h.xml
-
-
 // File: VarianceFunctions_8cpp.xml
 
 
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index 07b86e6e7fd..496c7e4749a 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -3953,7 +3953,9 @@ def importArrayToOutputData(*args):
 def FindPeaks(*args):
     r"""
     FindPeaks(Histogram2D hist, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t
-    std::vector< std::pair< double, double > > SpectrumUtils::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)
+    std::vector< std::pair< double, double > > ImageUtils::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)
+
+    Returns vector of peak center coordinates, for peaks in given histogram. 
 
     """
     return _libBornAgainDevice.FindPeaks(*args)
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 6dfc8607e0e..c1fa45c44e7 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -6730,7 +6730,7 @@ SWIGINTERN void std_vector_Sl_std_pair_Sl_double_Sc_double_Sg__Sg__insert__SWIG_
 #include "Device/Instrument/IChiSquaredModule.h"
 #include "Device/Instrument/IntensityDataFunctions.h"
 #include "Device/Instrument/PyArrayImportUtils.h"
-#include "Device/Instrument/SpectrumUtils.h"
+#include "Device/Histo/ImageUtils.h"
 #include "Device/Instrument/VarianceFunctions.h"
 #include "Device/Intensity/IIntensityFunction.h"
 #include "Device/Intensity/IIntensityFunction.h"
@@ -35690,7 +35690,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_
     SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "FindPeaks" "', argument " "4"" of type '" "double""'");
   } 
   arg4 = static_cast< double >(val4);
-  result = SpectrumUtils::FindPeaks((Histogram2D const &)*arg1,arg2,(std::string const &)*arg3,arg4);
+  result = ImageUtils::FindPeaks((Histogram2D const &)*arg1,arg2,(std::string const &)*arg3,arg4);
   resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result));
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
@@ -35737,7 +35737,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_
     }
     arg3 = ptr;
   }
-  result = SpectrumUtils::FindPeaks((Histogram2D const &)*arg1,arg2,(std::string const &)*arg3);
+  result = ImageUtils::FindPeaks((Histogram2D const &)*arg1,arg2,(std::string const &)*arg3);
   resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result));
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
@@ -35771,7 +35771,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_
     SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "FindPeaks" "', argument " "2"" of type '" "double""'");
   } 
   arg2 = static_cast< double >(val2);
-  result = SpectrumUtils::FindPeaks((Histogram2D const &)*arg1,arg2);
+  result = ImageUtils::FindPeaks((Histogram2D const &)*arg1,arg2);
   resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result));
   return resultobj;
 fail:
@@ -35795,7 +35795,7 @@ SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py_
     SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "FindPeaks" "', argument " "1"" of type '" "Histogram2D const &""'"); 
   }
   arg1 = reinterpret_cast< Histogram2D * >(argp1);
-  result = SpectrumUtils::FindPeaks((Histogram2D const &)*arg1);
+  result = ImageUtils::FindPeaks((Histogram2D const &)*arg1);
   resultobj = swig::from(static_cast< std::vector< std::pair< double,double >,std::allocator< std::pair< double,double > > > >(result));
   return resultobj;
 fail:
@@ -35879,10 +35879,10 @@ SWIGINTERN PyObject *_wrap_FindPeaks(PyObject *self, PyObject *args) {
 fail:
   SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'FindPeaks'.\n"
     "  Possible C/C++ prototypes are:\n"
-    "    SpectrumUtils::FindPeaks(Histogram2D const &,double,std::string const &,double)\n"
-    "    SpectrumUtils::FindPeaks(Histogram2D const &,double,std::string const &)\n"
-    "    SpectrumUtils::FindPeaks(Histogram2D const &,double)\n"
-    "    SpectrumUtils::FindPeaks(Histogram2D const &)\n");
+    "    ImageUtils::FindPeaks(Histogram2D const &,double,std::string const &,double)\n"
+    "    ImageUtils::FindPeaks(Histogram2D const &,double,std::string const &)\n"
+    "    ImageUtils::FindPeaks(Histogram2D const &,double)\n"
+    "    ImageUtils::FindPeaks(Histogram2D const &)\n");
   return 0;
 }
 
@@ -46523,7 +46523,9 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "FindPeaks", _wrap_FindPeaks, METH_VARARGS, "\n"
 		"FindPeaks(Histogram2D hist, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t\n"
-		"std::vector< std::pair< double, double > > SpectrumUtils::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)\n"
+		"std::vector< std::pair< double, double > > ImageUtils::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)\n"
+		"\n"
+		"Returns vector of peak center coordinates, for peaks in given histogram. \n"
 		"\n"
 		""},
 	 { "delete_IVarianceFunction", _wrap_delete_IVarianceFunction, METH_O, "\n"
-- 
GitLab