From 96b73616e58dc4a8739ab037d769a4359c3bf85d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 20 Nov 2020 11:17:32 +0100
Subject: [PATCH] Shorter name for essential visualization tool

call it plot_int because files to be plotted have extension int
---
 ...ntensity_data_diff.py => plot_diff_int.py} | 12 +++++------
 .../{plot_intensity_data.py => plot_int.py}   | 20 +++++++++----------
 Examples/cpp/CylindersAndPrisms/README.md     |  2 +-
 Tests/Functional/Python/PyCore/utils.py       |  2 +-
 Tests/ReferenceData/README.md                 | 20 ++++++++++---------
 cmake/BornAgain/Config.cmake                  |  8 ++++----
 6 files changed, 33 insertions(+), 31 deletions(-)
 rename Examples/Python/utils/{plot_intensity_data_diff.py => plot_diff_int.py} (74%)
 rename Examples/Python/utils/{plot_intensity_data.py => plot_int.py} (74%)

diff --git a/Examples/Python/utils/plot_intensity_data_diff.py b/Examples/Python/utils/plot_diff_int.py
similarity index 74%
rename from Examples/Python/utils/plot_intensity_data_diff.py
rename to Examples/Python/utils/plot_diff_int.py
index 78041028b43..2888aeb96e1 100755
--- a/Examples/Python/utils/plot_intensity_data_diff.py
+++ b/Examples/Python/utils/plot_diff_int.py
@@ -1,16 +1,16 @@
 #!/usr/bin/env python3
 '''
 Plots intensity data difference stored in BornAgain "*.int" or "*.int.gz" format
-Usage: python plot_intensity_data_diff.py reference.int.gz new.int.gz
+Usage: python plot_diff_int.py reference.int.gz new.int.gz
 '''
 
 import numpy as np
 import bornagain as ba
-import plot_intensity_data as pid
+import plot_int as pid
 import sys
 
 
-def plot_intensity_data_diff(filename1, filename2):
+def plot_diff_int(filename1, filename2):
     intensity_ref = ba.IntensityDataIOFactory.readIntensityData(filename1)
     intensity_other = ba.IntensityDataIOFactory.readIntensityData(filename2)
     data = 2 * np.abs(intensity_ref.array() - intensity_other.array()) \
@@ -29,11 +29,11 @@ def plot_intensity_data_diff(filename1, filename2):
         axis_values = np.asarray(intensity_ref.xAxis().binCenters())/ba.deg
         pid.plot_raw_data_1d(axis_values, data, log_y=False)
     else:
-        exit("Error in plot_intensity_data_diff: wrong data rank")
+        exit("Error in plot_diff_int: wrong data rank")
 
 
 if __name__ == '__main__':
     if len(sys.argv) != 3:
-        exit("Usage: plot_intensity_data_diff.py reference.int.gz other.int.gz")
+        exit("Usage: plot_diff_int.py reference.int.gz other.int.gz")
 
-    plot_intensity_data_diff(sys.argv[1], sys.argv[2])
+    plot_diff_int(sys.argv[1], sys.argv[2])
diff --git a/Examples/Python/utils/plot_intensity_data.py b/Examples/Python/utils/plot_int.py
similarity index 74%
rename from Examples/Python/utils/plot_intensity_data.py
rename to Examples/Python/utils/plot_int.py
index 250ee13b70d..d97f0ee7a42 100755
--- a/Examples/Python/utils/plot_intensity_data.py
+++ b/Examples/Python/utils/plot_int.py
@@ -2,7 +2,7 @@
 '''
 Plots data stored in BornAgain "*.int" or "*.int.gz" format
 Can handle both 1D and 2D arrays
-Usage: python plot_intensity_data.py intensity_file.int.gz [intensity_max]
+Usage: python plot_int.py intensity_file.int.gz [intensity_max]
 '''
 
 import sys
@@ -14,19 +14,19 @@ rc('font', **{'family': 'sans-serif', 'sans-serif': ['Helvetica']})
 rc('text', usetex=True)
 
 
-def plot_intensity_data(file_name, intensity_max=None):
+def plot_int(file_name, intensity_max=None):
     data = ba.IntensityDataIOFactory.readIntensityData(file_name)
     if intensity_max is None:
         intensity_max = data.getMaximum()
     if data.rank() == 1:
-        plot_intensity_data_1d(data, intensity_max)
+        plot_int_1d(data, intensity_max)
     elif data.rank() == 2:
-        plot_intensity_data_2d(data, intensity_max)
+        plot_int_2d(data, intensity_max)
     else:
-        exit("Error in plot_intensity_data: wrong data rank")
+        exit("Error in plot_int: wrong data rank")
 
 
-def plot_intensity_data_2d(histogram, intensity_max):
+def plot_int_2d(histogram, intensity_max):
     plot_raw_data_2d(histogram.array(), [
         histogram.getXmin()/ba.deg,
         histogram.getXmax()/ba.deg,
@@ -47,7 +47,7 @@ def plot_raw_data_2d(values, extent_array, intensity_max):
     plt.show()
 
 
-def plot_intensity_data_1d(histogram, intensity_max):
+def plot_int_1d(histogram, intensity_max):
     axis_values = np.asarray(histogram.xAxis().binCenters())/ba.deg
     array_values = histogram.array()*intensity_max/histogram.getMaximum()
     plot_raw_data_1d(axis_values, array_values)
@@ -65,9 +65,9 @@ def plot_raw_data_1d(axis, values, log_y=True):
 
 if __name__ == '__main__':
     if len(sys.argv) < 2 or len(sys.argv) > 3:
-        exit("Usage: plot_intensity_data.py intensity_file.int.gz [intensity_max]")
+        exit("Usage: plot_int.py intensity_file.int.gz [intensity_max]")
 
     if len(sys.argv) == 2:
-        plot_intensity_data(sys.argv[1])
+        plot_int(sys.argv[1])
     else:
-        plot_intensity_data(sys.argv[1], float(sys.argv[2]))
+        plot_int(sys.argv[1], float(sys.argv[2]))
diff --git a/Examples/cpp/CylindersAndPrisms/README.md b/Examples/cpp/CylindersAndPrisms/README.md
index 87e6971fc2a..aedc4667174 100644
--- a/Examples/cpp/CylindersAndPrisms/README.md
+++ b/Examples/cpp/CylindersAndPrisms/README.md
@@ -40,4 +40,4 @@ cd <build_dir>
 -------------------------------------------------------------------------------
 5) Inspect result
 -------------------------------------------------------------------------------
-<bornagain>/Examples/python/utils/plot_intensity_data.py result.int
\ No newline at end of file
+<bornagain>/Examples/python/utils/plot_int.py result.int
\ No newline at end of file
diff --git a/Tests/Functional/Python/PyCore/utils.py b/Tests/Functional/Python/PyCore/utils.py
index 7b279cd6a60..446dca9fcc5 100644
--- a/Tests/Functional/Python/PyCore/utils.py
+++ b/Tests/Functional/Python/PyCore/utils.py
@@ -60,7 +60,7 @@ def get_simulation_BasicGISAS(sample=None):
     return simulation
 
 
-def plot_intensity_data(intensity):
+def plot_int(intensity):
     import matplotlib, pylab
     data = intensity.getArray() + 1
     # data = numpy.abs(intensity.getArray())
diff --git a/Tests/ReferenceData/README.md b/Tests/ReferenceData/README.md
index c0b2fb6ef7d..6e089231c3a 100644
--- a/Tests/ReferenceData/README.md
+++ b/Tests/ReferenceData/README.md
@@ -1,16 +1,18 @@
 #### Reference data for functional tests
 
-Core
-: used by Tests/Functional/Core/CoreSpecial
+`Core`
+: used by `Tests/Functional/Core/CoreSpecial`
 
-PyCore
-: used by Tests/Functional/Tests/Functional/Python/PyCore
+`PyCore`
+: used by `Tests/Functional/Tests/Functional/Python/PyCore`
 
-PyPersist
-: used by Tests/Functional/Tests/Functional/Python/PyPersist
+`PyPersist`
+: used by `Tests/Functional/Tests/Functional/Python/PyPersist`
 
-Std
+`Std`
 : used by Core, Python, and GUI standard tests
 
-To visualize one data file, call
-> python3 Examples/Python/utils/plot_intensity_data.py <reference.int.gz>
+To visualize one data file, run
+> `plot_int.py <reference.int.gz>`
+
+This script is provided in `Examples/Python/utils`, and copied verbatim to `<build>/bin`.
diff --git a/cmake/BornAgain/Config.cmake b/cmake/BornAgain/Config.cmake
index 36a0e80f044..072c1cd8660 100644
--- a/cmake/BornAgain/Config.cmake
+++ b/cmake/BornAgain/Config.cmake
@@ -23,10 +23,10 @@ configure_file(${CONFIGURABLES_DIR}/BABuild.h.in  ${BUILD_INC_DIR}/BABuild.h @ON
 configure_file(${CONFIGURABLES_DIR}/BATesting.h.in  ${BUILD_INC_DIR}/BATesting.h @ONLY)
 string(APPEND CMAKE_CXX_FLAGS " -I${BUILD_INC_DIR}")
 
-configure_file(${CMAKE_SOURCE_DIR}/Examples/Python/utils/plot_intensity_data.py
-    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plot_intensity_data.py COPYONLY)
-configure_file(${CMAKE_SOURCE_DIR}/Examples/Python/utils/plot_intensity_data_diff.py
-    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plot_intensity_data_diff.py COPYONLY)
+configure_file(${CMAKE_SOURCE_DIR}/Examples/Python/utils/plot_int.py
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plot_int.py COPYONLY)
+configure_file(${CMAKE_SOURCE_DIR}/Examples/Python/utils/plot_diff_int.py
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plot_diff_int.py COPYONLY)
 
 # -----------------------------------------------------------------------------
 # configure BornAgain launch scripts
-- 
GitLab