aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-09 12:01:43 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commitfbef32528d3b4b2b2f694aa16d60c53511b1d402 (patch)
tree73fce3701cfc50f2a519fcb0a62de9e9db5f4be7 /tests
parente19507ae14b5b9456d6c3379b43ba1ad1b2cc527 (diff)
Add wavelength and electron_voltage, plus units, to geometry file
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt40
-rw-r--r--tests/gen-ev-test.py14
-rw-r--r--tests/wavelength_geom.c72
-rw-r--r--tests/wavelength_geom.h5bin0 -> 7048 bytes
-rw-r--r--tests/wavelength_geom1.geom11
-rw-r--r--tests/wavelength_geom10.geom11
-rw-r--r--tests/wavelength_geom11.geom11
-rw-r--r--tests/wavelength_geom12.geom11
-rw-r--r--tests/wavelength_geom2.geom11
-rw-r--r--tests/wavelength_geom3.geom11
-rw-r--r--tests/wavelength_geom4.geom11
-rw-r--r--tests/wavelength_geom5.geom11
-rw-r--r--tests/wavelength_geom6.geom11
-rw-r--r--tests/wavelength_geom7.geom11
-rw-r--r--tests/wavelength_geom8.geom11
-rw-r--r--tests/wavelength_geom9.geom11
16 files changed, 258 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7c1a7836..23a0c95d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -158,3 +158,43 @@ target_link_libraries(ev_enum3 ${COMMON_LIBRARIES})
add_test(NAME ev_enum3
COMMAND ev_enum3 ${CMAKE_CURRENT_SOURCE_DIR}/ev_enum3.h5
${CMAKE_CURRENT_SOURCE_DIR}/ev_enum3.geom)
+
+add_executable(wavelength_geom wavelength_geom.c)
+target_include_directories(wavelength_geom PRIVATE ${COMMON_INCLUDES})
+target_link_libraries(wavelength_geom ${COMMON_LIBRARIES})
+add_test(NAME wavelength_geom1
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom1.geom 1e-10)
+add_test(NAME wavelength_geom2
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom2.geom 1.3776e-10)
+add_test(NAME wavelength_geom3
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom3.geom 1.3776e-10)
+add_test(NAME wavelength_geom4
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom4.geom 1.9687e-12)
+add_test(NAME wavelength_geom5
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom5.geom 1.9687e-12)
+add_test(NAME wavelength_geom6
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom6.geom 1.3776e-10)
+add_test(NAME wavelength_geom7
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom7.geom 1.3776e-10)
+add_test(NAME wavelength_geom8
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom8.geom 1.9687e-12)
+add_test(NAME wavelength_geom9
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom9.geom 1.3776e-10)
+add_test(NAME wavelength_geom10
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom10.geom 1.3776e-10)
+add_test(NAME wavelength_geom11
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom11.geom 1.125e-10)
+add_test(NAME wavelength_geom12
+ COMMAND wavelength_geom ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom.h5
+ ${CMAKE_CURRENT_SOURCE_DIR}/wavelength_geom12.geom 1.125e-10)
diff --git a/tests/gen-ev-test.py b/tests/gen-ev-test.py
index 7300f604..e3cb9924 100644
--- a/tests/gen-ev-test.py
+++ b/tests/gen-ev-test.py
@@ -32,3 +32,17 @@ array = numpy.zeros((1,1), dtype=float)
with h5py.File('tests/ev_enum3.h5', 'w') as fh:
fh.create_dataset('/data/data_array', data=array)
+
+array = numpy.zeros((2,2), dtype=float)
+with h5py.File('tests/wavelength_geom.h5', 'w') as fh:
+ fh.create_dataset('/data/data_array', data=array)
+ dh = fh.create_dataset('/LCLS/photon_energy', (), 'f')
+ dh[()] = 9000.0
+ dh = fh.create_dataset('/LCLS/photon_energyK', (), 'f')
+ dh[()] = 9.0
+ dh = fh.create_dataset('/LCLS/electron_energy', (), 'f')
+ dh[()] = 300000
+ dh = fh.create_dataset('/LCLS/electron_energy2', (), 'f')
+ dh[()] = 300
+ dh = fh.create_dataset('/LCLS/wavelength', (), 'f')
+ dh[()] = 1e-10
diff --git a/tests/wavelength_geom.c b/tests/wavelength_geom.c
new file mode 100644
index 00000000..814e2eb3
--- /dev/null
+++ b/tests/wavelength_geom.c
@@ -0,0 +1,72 @@
+/*
+ * wavelength_geom.c
+ *
+ * Check that wavelength reading works
+ *
+ * Copyright © 2020 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2020 Thomas White <taw@physics.org>
+ *
+ * This file is part of CrystFEL.
+ *
+ * CrystFEL is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CrystFEL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <image.h>
+
+int main(int argc, char *argv[])
+{
+ DataTemplate *dtempl;
+ struct image *image;
+ const char *geom_filename;
+ const char *image_filename;
+ double expected_wavelength_m;
+
+ image_filename = argv[1];
+ geom_filename = argv[2];
+ expected_wavelength_m = atof(argv[3]);
+
+ dtempl = data_template_new_from_file(geom_filename);
+ if ( dtempl == NULL ) {
+ ERROR("Failed to load data template\n");
+ return 1;
+ }
+
+ image = image_read(dtempl, image_filename, NULL);
+ if ( image == NULL ) return 1;
+
+ printf("wavelength = %e\n", image->lambda);
+ printf("should be %e\n", expected_wavelength_m);
+
+ if ( !within_tolerance(image->lambda,
+ expected_wavelength_m,
+ 0.1) ) return 1;
+
+ data_template_free(dtempl);
+
+ return 0;
+}
diff --git a/tests/wavelength_geom.h5 b/tests/wavelength_geom.h5
new file mode 100644
index 00000000..f3b37e0f
--- /dev/null
+++ b/tests/wavelength_geom.h5
Binary files differ
diff --git a/tests/wavelength_geom1.geom b/tests/wavelength_geom1.geom
new file mode 100644
index 00000000..91b87385
--- /dev/null
+++ b/tests/wavelength_geom1.geom
@@ -0,0 +1,11 @@
+wavelength = /LCLS/wavelength m
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom10.geom b/tests/wavelength_geom10.geom
new file mode 100644
index 00000000..a315c458
--- /dev/null
+++ b/tests/wavelength_geom10.geom
@@ -0,0 +1,11 @@
+photon_energy = 9e3 eV
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom11.geom b/tests/wavelength_geom11.geom
new file mode 100644
index 00000000..676dc68a
--- /dev/null
+++ b/tests/wavelength_geom11.geom
@@ -0,0 +1,11 @@
+wavelength = 1.125 A
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom12.geom b/tests/wavelength_geom12.geom
new file mode 100644
index 00000000..b47eb243
--- /dev/null
+++ b/tests/wavelength_geom12.geom
@@ -0,0 +1,11 @@
+wavelength = 1.125e-10 m
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom2.geom b/tests/wavelength_geom2.geom
new file mode 100644
index 00000000..73ef91cc
--- /dev/null
+++ b/tests/wavelength_geom2.geom
@@ -0,0 +1,11 @@
+photon_energy = /LCLS/photon_energy
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom3.geom b/tests/wavelength_geom3.geom
new file mode 100644
index 00000000..bcd890bd
--- /dev/null
+++ b/tests/wavelength_geom3.geom
@@ -0,0 +1,11 @@
+photon_energy = /LCLS/photon_energyK keV
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom4.geom b/tests/wavelength_geom4.geom
new file mode 100644
index 00000000..fa03b724
--- /dev/null
+++ b/tests/wavelength_geom4.geom
@@ -0,0 +1,11 @@
+electron_voltage = /LCLS/electron_energy2 kV
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom5.geom b/tests/wavelength_geom5.geom
new file mode 100644
index 00000000..de26de3b
--- /dev/null
+++ b/tests/wavelength_geom5.geom
@@ -0,0 +1,11 @@
+electron_voltage = /LCLS/electron_energy V
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom6.geom b/tests/wavelength_geom6.geom
new file mode 100644
index 00000000..9ee5dc87
--- /dev/null
+++ b/tests/wavelength_geom6.geom
@@ -0,0 +1,11 @@
+photon_energy = /LCLS/photon_energy eV
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom7.geom b/tests/wavelength_geom7.geom
new file mode 100644
index 00000000..a1c311cf
--- /dev/null
+++ b/tests/wavelength_geom7.geom
@@ -0,0 +1,11 @@
+photon_energy = 9000
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom8.geom b/tests/wavelength_geom8.geom
new file mode 100644
index 00000000..00bdb45a
--- /dev/null
+++ b/tests/wavelength_geom8.geom
@@ -0,0 +1,11 @@
+electron_voltage = 300 kV
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array
diff --git a/tests/wavelength_geom9.geom b/tests/wavelength_geom9.geom
new file mode 100644
index 00000000..9012b5d6
--- /dev/null
+++ b/tests/wavelength_geom9.geom
@@ -0,0 +1,11 @@
+photon_energy = 9 keV
+panel/min_fs = 0
+panel/min_ss = 1
+panel/max_fs = 0
+panel/max_ss = 1
+panel/corner_x = -100
+panel/corner_y = -100
+panel/clen = 50 mm
+panel/res = 1000000
+panel/adu_per_photon = 1
+panel/data = /data/data_array