From 882d05e8420ff0f2d7c48a6979bb355242f28a68 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 26 Oct 2020 14:08:36 +0100 Subject: Remove polarisation_check It takes far too long (over a minute) and didn't actually test anything. Contribution of a better polarisation unit test would be very welcome! --- tests/CMakeLists.txt | 6 -- tests/meson.build | 8 --- tests/polarisation_check.c | 164 ------------------------------------------ tests/polarisation_check.geom | 15 ---- 4 files changed, 193 deletions(-) delete mode 100644 tests/polarisation_check.c delete mode 100644 tests/polarisation_check.geom diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5d365583..8c730e45 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -87,12 +87,6 @@ target_include_directories(cellcompare_check PRIVATE ${COMMON_INCLUDES}) target_link_libraries(cellcompare_check ${COMMON_LIBRARIES}) add_test(cellcompare_check cellcompare_check) -add_executable(polarisation_check polarisation_check.c) -target_include_directories(polarisation_check PRIVATE ${COMMON_INCLUDES}) -target_link_libraries(polarisation_check ${COMMON_LIBRARIES}) -add_test(NAME polarisation_check - COMMAND polarisation_check ${CMAKE_CURRENT_SOURCE_DIR}/polarisation_check.geom) - add_executable(evparse1 evparse1.c) target_include_directories(evparse1 PRIVATE ${COMMON_INCLUDES}) target_link_libraries(evparse1 ${COMMON_LIBRARIES} ${HDF5_C_LIBRARIES}) diff --git a/tests/meson.build b/tests/meson.build index 7c7c7519..5c5f3d4e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -75,14 +75,6 @@ if opencldep.found() test('gpu_sim_check', exe, args: [geom]) endif -exe = executable('polarisation_check', - ['polarisation_check.c'], - dependencies : [libcrystfeldep, mdep, gsldep]) -geom = files('polarisation_check.geom') -test('polarisation_check', exe, args: [geom], - timeout: 60) - - # Event enumeration tests ev_enum_tests = ['ev_enum1', 'ev_enum2', diff --git a/tests/polarisation_check.c b/tests/polarisation_check.c deleted file mode 100644 index 3f4d57e4..00000000 --- a/tests/polarisation_check.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * polarisation_check.c - * - * Check polarisation correction - * - * Copyright © 2019-2020 Deutsches Elektronen-Synchrotron DESY, - * a research centre of the Helmholtz Association. - * - * Authors: - * 2019-2020 Thomas White - * - * 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 . - * - */ - -#include -#include - -#include -#include -#include -#include -#include - - -int main(int argc, char *argv[]) -{ - DataTemplate *dtempl; - struct image *image; - FILE *fh; - unsigned long int seed; - int fail = 0; - RefList *list; - RefListIterator *iter; - Reflection *refl; - UnitCell *cell; - Crystal *cr; - gsl_rng *rng; - struct polarisation p; - int i; - double *map; - int *nmap; - const int ntrial = 1000; - - /* NB must match polarisation_check.geom */ - const int w = 256; - const int h = 256; - - rng = gsl_rng_alloc(gsl_rng_mt19937); - - fh = fopen("/dev/urandom", "r"); - if ( fread(&seed, sizeof(seed), 1, fh) == 1 ) { - gsl_rng_set(rng, seed); - } else { - ERROR("Failed to seed RNG\n"); - } - fclose(fh); - - dtempl = data_template_new_from_file(argv[1]); - if ( dtempl == NULL ) return 1; - - image = image_create_for_simulation(dtempl); - if ( image == NULL ) return 1; - - cell = cell_new(); - cell_set_lattice_type(cell, L_CUBIC); - cell_set_centering(cell, 'P'); - cell_set_parameters(cell, 50.0e-10, 50.0e-10, 50.0e-10, - deg2rad(90.0), deg2rad(90.0), deg2rad(90.0)); - - cr = crystal_new(); - crystal_set_profile_radius(cr, 0.001e9); - crystal_set_mosaicity(cr, 0.0); /* radians */ - crystal_set_image(cr, image); - crystal_set_cell(cr, cell); - - image->n_crystals = 1; - image->crystals = &cr; - - map = malloc(w*h*sizeof(double)); - nmap = malloc(w*h*sizeof(int)); - for ( i=0; idetgeom, - image->lambda)); - crystal_set_reflections(cr, list); - - for ( refl = first_refl(list, &iter); - refl != NULL; - refl = next_refl(refl, iter) ) - { - set_intensity(refl, 1.0); - } - - p.angle = deg2rad(105.0); - p.fraction = 1.0; - p.disable = 0; - polarisation_correction(list, ncell, p); - - for ( refl = first_refl(list, &iter); - refl != NULL; - refl = next_refl(refl, iter) ) - { - double fs, ss; - int nfs, nss; - get_detector_pos(refl, &fs, &ss); - nfs = fs; nss = ss; /* Explicit truncation */ - - /* Intensity in reflist is corrected, - * but we want "un-correction" */ - map[nfs + nss*w] += 1.0/get_intensity(refl); - nmap[nfs + nss*w] += 1; - } - - cell_free(ncell); - reflist_free(list); - - crystal_set_cell(cr, NULL); - crystal_set_reflections(cr, NULL); - - progress_bar(i+1, ntrial, "Calculating"); - - } - - for ( i=0; i 0 ) { - image->dp[0][i] = 1000.0 * map[i] / nmap[i]; - } - } - image_write(image, dtempl, "test.h5"); - - image->crystals = NULL; - image->n_crystals = 0; - - data_template_free(dtempl); - image_free(image); - gsl_rng_free(rng); - - if ( fail ) return 1; - - return 0; -} diff --git a/tests/polarisation_check.geom b/tests/polarisation_check.geom deleted file mode 100644 index db733131..00000000 --- a/tests/polarisation_check.geom +++ /dev/null @@ -1,15 +0,0 @@ -photon_energy = 9 keV -bandwidth = 0.0001 - -panel0/min_fs = 0 -panel0/max_fs = 255 -panel0/min_ss = 0 -panel0/max_ss = 255 -panel0/corner_x = -128.0 -panel0/corner_y = -128.0 -panel0/clen = 20 mm -panel0/res = 9090.91 -panel0/adu_per_photon = 1 -panel0/data = /data/panel0 -panel0/fs = x -panel0/ss = y \ No newline at end of file -- cgit v1.2.3