diff options
author | Thomas White <taw@physics.org> | 2020-06-10 15:34:22 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:44 +0200 |
commit | c8693a9af33849be40a94e9c437d87c068fce740 (patch) | |
tree | 957369f29f0d557f954d13500deb1e9d33ae4529 | |
parent | 9de2a50dea4c81cc728bd61a678c074dbe702e2d (diff) |
Update tests for detgeom
-rw-r--r-- | tests/integration_check.c | 44 | ||||
-rw-r--r-- | tests/polarisation_check.c | 54 | ||||
-rw-r--r-- | tests/prof2d_check.c | 48 | ||||
-rw-r--r-- | tests/ring_check.c | 70 |
4 files changed, 88 insertions, 128 deletions
diff --git a/tests/integration_check.c b/tests/integration_check.c index 50e99d65..b7deb5ca 100644 --- a/tests/integration_check.c +++ b/tests/integration_check.c @@ -7,7 +7,7 @@ * a research centre of the Helmholtz Association. * * Authors: - * 2013-2016 Thomas White <taw@physics.org> + * 2013-2020 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -73,30 +73,24 @@ int main(int argc, char *argv[]) } fclose(fh); - image.beam = NULL; image.lambda = ph_eV_to_lambda(9000.0); - image.det = calloc(1, sizeof(struct detector)); - image.det->n_panels = 1; - image.det->panels = calloc(1, sizeof(struct panel)); - - image.det->panels[0].w = w; - image.det->panels[0].h = h; - image.det->panels[0].fsx = 1.0; - image.det->panels[0].fsy = 0.0; - image.det->panels[0].ssx = 0.0; - image.det->panels[0].ssy = 1.0; - image.det->panels[0].xfs = 1.0; - image.det->panels[0].yfs = 0.0; - image.det->panels[0].xss = 0.0; - image.det->panels[0].yss = 1.0; - image.det->panels[0].cnx = -w/2; - image.det->panels[0].cny = -h/2; - image.det->panels[0].clen = 60.0e-3; - image.det->panels[0].res = 100000; /* 10 px per mm */ - image.det->panels[0].adu_per_eV = NAN; - image.det->panels[0].adu_per_photon = 10; - image.det->panels[0].max_adu = +INFINITY; /* No cutoff */ + image.detgeom = calloc(1, sizeof(struct detgeom)); + image.detgeom->n_panels = 1; + image.detgeom->panels = calloc(1, sizeof(struct detgeom_panel)); + + image.detgeom->panels[0].w = w; + image.detgeom->panels[0].h = h; + image.detgeom->panels[0].fsx = 1.0; + image.detgeom->panels[0].fsy = 0.0; + image.detgeom->panels[0].ssx = 0.0; + image.detgeom->panels[0].ssy = 1.0; + image.detgeom->panels[0].cnx = -w/2; + image.detgeom->panels[0].cny = -h/2; + image.detgeom->panels[0].cnz = 60.0e-3 / 100e-6; + image.detgeom->panels[0].pixel_pitch = 100e-6; /* 10 px per mm */ + image.detgeom->panels[0].adu_per_photon = 10; + image.detgeom->panels[0].max_adu = +INFINITY; /* No cutoff */ image.dp = malloc(sizeof(float *)); image.dp[0] = malloc(w*h*sizeof(float)); @@ -163,9 +157,7 @@ int main(int argc, char *argv[]) histogram_show(hi); histogram_free(hi); - free(image.beam); - free(image.det->panels); - free(image.det); + detgeom_free(image.detgeom); free(image.dp[0]); free(image.dp); diff --git a/tests/polarisation_check.c b/tests/polarisation_check.c index f8660e32..dcad4304 100644 --- a/tests/polarisation_check.c +++ b/tests/polarisation_check.c @@ -7,7 +7,7 @@ * a research centre of the Helmholtz Association. * * Authors: - * 2019 Thomas White <taw@physics.org> + * 2019-2020 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -71,43 +71,30 @@ int main(int argc, char *argv[]) } fclose(fh); - image.beam = NULL; image.lambda = ph_eV_to_lambda(9000.0); image.bw = 0.000001; image.div = 0.0; image.spectrum = spectrum_generate_gaussian(image.lambda, image.bw); - image.det = calloc(1, sizeof(struct detector)); - image.det->n_panels = 1; - image.det->panels = calloc(1, sizeof(struct panel)); + image.detgeom = calloc(1, sizeof(struct detgeom)); + image.detgeom->n_panels = 1; + image.detgeom->panels = calloc(1, sizeof(struct detgeom_panel)); image.dp = calloc(1, sizeof(float *)); image.bad = calloc(1, sizeof(int *)); - image.det->panels[0].w = w; - image.det->panels[0].h = h; - image.det->panels[0].fsx = 1.0; - image.det->panels[0].fsy = 0.0; - image.det->panels[0].ssx = 0.0; - image.det->panels[0].ssy = 1.0; - image.det->panels[0].xfs = 1.0; - image.det->panels[0].yfs = 0.0; - image.det->panels[0].xss = 0.0; - image.det->panels[0].yss = 1.0; - image.det->panels[0].cnx = -w/2; - image.det->panels[0].cny = -h/2; - image.det->panels[0].clen = 50.0e-3; - image.det->panels[0].res = 10000; /* 10 micron pixels */ - image.det->panels[0].adu_per_eV = 10.0/9000.0; /* 10 adu/ph */ - image.det->panels[0].max_adu = +INFINITY; /* No cutoff */ - image.det->panels[0].orig_min_fs = 0; - image.det->panels[0].orig_min_ss = 0; - image.det->panels[0].orig_max_fs = w-1; - image.det->panels[0].orig_max_ss = h-1; - - image.det->furthest_out_panel = &image.det->panels[0]; - image.det->furthest_out_fs = 0; - image.det->furthest_out_ss = 0; + image.detgeom->panels[0].w = w; + image.detgeom->panels[0].h = h; + image.detgeom->panels[0].fsx = 1.0; + image.detgeom->panels[0].fsy = 0.0; + image.detgeom->panels[0].ssx = 0.0; + image.detgeom->panels[0].ssy = 1.0; + image.detgeom->panels[0].cnx = -w/2; + image.detgeom->panels[0].cny = -h/2; + image.detgeom->panels[0].cnz = 50.0e-3 / 10e-6; + image.detgeom->panels[0].pixel_pitch = 10e-6; + image.detgeom->panels[0].adu_per_photon = 1.0; + image.detgeom->panels[0].max_adu = +INFINITY; /* No cutoff */ image.dp[0] = malloc(w*h*sizeof(float)); memset(image.dp[0], 0, w*h*sizeof(float)); @@ -143,7 +130,8 @@ int main(int argc, char *argv[]) ncell = cell_rotate(cell, random_quaternion(rng)); crystal_set_cell(cr, ncell); - list = predict_to_res(cr, largest_q(&image)); + list = predict_to_res(cr, detgeom_max_resolution(image.detgeom, + image.lambda)); crystal_set_reflections(cr, list); for ( refl = first_refl(list, &iter); @@ -183,11 +171,9 @@ int main(int argc, char *argv[]) image.dp[0][i] = 1000.0 * map[i] / nmap[i]; if ( isnan(image.dp[0][i]) ) image.dp[0][i] = 0.0; } - hdf5_write_image("test.h5", &image, "/data/data"); + //hdf5_write_image("test.h5", &image, "/data/data"); - free(image.beam); - free(image.det->panels); - free(image.det); + detgeom_free(image.detgeom); free(image.dp[0]); free(image.dp); gsl_rng_free(rng); diff --git a/tests/prof2d_check.c b/tests/prof2d_check.c index d6b1d475..3d202d51 100644 --- a/tests/prof2d_check.c +++ b/tests/prof2d_check.c @@ -7,7 +7,7 @@ * a research centre of the Helmholtz Association. * * Authors: - * 2013-2014,2016 Thomas White <taw@physics.org> + * 2013-2020 Thomas White <taw@physics.org> * * This file is part of CrystFEL. * @@ -81,39 +81,30 @@ int main(int argc, char *argv[]) } fclose(fh); - image.beam = NULL; image.lambda = ph_eV_to_lambda(9000.0); image.bw = 0.000001; image.div = 0.0; image.spectrum = spectrum_generate_gaussian(image.lambda, image.bw); - image.det = calloc(1, sizeof(struct detector)); - image.det->n_panels = 1; - image.det->panels = calloc(1, sizeof(struct panel)); + image.detgeom = calloc(1, sizeof(struct detgeom)); + image.detgeom->n_panels = 1; + image.detgeom->panels = calloc(1, sizeof(struct detgeom_panel)); image.dp = calloc(1, sizeof(float *)); image.bad = calloc(1, sizeof(int *)); - image.det->panels[0].w = w; - image.det->panels[0].h = h; - image.det->panels[0].fsx = 1.0; - image.det->panels[0].fsy = 0.0; - image.det->panels[0].ssx = 0.0; - image.det->panels[0].ssy = 1.0; - image.det->panels[0].xfs = 1.0; - image.det->panels[0].yfs = 0.0; - image.det->panels[0].xss = 0.0; - image.det->panels[0].yss = 1.0; - image.det->panels[0].cnx = -w/2; - image.det->panels[0].cny = -h/2; - image.det->panels[0].clen = 60.0e-3; - image.det->panels[0].res = 100000; /* 10 px per mm */ - image.det->panels[0].adu_per_eV = 10.0/9000.0; /* 10 adu/ph */ - image.det->panels[0].max_adu = +INFINITY; /* No cutoff */ - - image.det->furthest_out_panel = &image.det->panels[0]; - image.det->furthest_out_fs = 0; - image.det->furthest_out_ss = 0; + image.detgeom->panels[0].w = w; + image.detgeom->panels[0].h = h; + image.detgeom->panels[0].fsx = 1.0; + image.detgeom->panels[0].fsy = 0.0; + image.detgeom->panels[0].ssx = 0.0; + image.detgeom->panels[0].ssy = 1.0; + image.detgeom->panels[0].cnx = -w/2; + image.detgeom->panels[0].cny = -h/2; + image.detgeom->panels[0].cnz = 60.0e-3 / 100e-6; + image.detgeom->panels[0].pixel_pitch = 100e-6; /* 10 px per mm */ + image.detgeom->panels[0].adu_per_photon = 10.0; + image.detgeom->panels[0].max_adu = +INFINITY; /* No cutoff */ image.dp[0] = malloc(w*h*sizeof(float)); memset(image.dp[0], 0, w*h*sizeof(float)); @@ -137,7 +128,8 @@ int main(int argc, char *argv[]) image.n_crystals = 1; image.crystals = &cr; - list = predict_to_res(cr, largest_q(&image)); + list = predict_to_res(cr, detgeom_max_resolution(image.detgeom, + image.lambda)); crystal_set_reflections(cr, list); for ( fs=0; fs<w; fs++ ) { @@ -226,9 +218,7 @@ int main(int argc, char *argv[]) histogram_show(hi); histogram_free(hi); - free(image.beam); - free(image.det->panels); - free(image.det); + detgeom_free(image.detgeom); free(image.dp[0]); free(image.dp); gsl_rng_free(rng); diff --git a/tests/ring_check.c b/tests/ring_check.c index f286d5e7..89978ad8 100644 --- a/tests/ring_check.c +++ b/tests/ring_check.c @@ -7,7 +7,7 @@ * a research centre of the Helmholtz Association. * * Authors: - * 2011-2016 Thomas White <taw@physics.org> + * 2011-2020 Thomas White <taw@physics.org> * 2012 Andrew Martin <andrew.martin@desy.de> * * This file is part of CrystFEL. @@ -60,9 +60,9 @@ static void third_integration_check(struct image *image, int n_trials, double fsp, ssp; int r; - for ( fs=0; fs<image->det->panels[0].w; fs++ ) { - for ( ss=0; ss<image->det->panels[0].h; ss++ ) { - image->dp[0][fs+image->det->panels[0].w*ss] + for ( fs=0; fs<image->detgeom->panels[0].w; fs++ ) { + for ( ss=0; ss<image->detgeom->panels[0].h; ss++ ) { + image->dp[0][fs+image->detgeom->panels[0].w*ss] = poisson_noise(rng, 1000.0); } } @@ -119,9 +119,9 @@ static void fourth_integration_check(struct image *image, int n_trials, double fsp, ssp; int r; - for ( fs=0; fs<image->det->panels[0].w; fs++ ) { - for ( ss=0; ss<image->det->panels[0].h; ss++ ) { - int idx = fs+image->det->panels[0].w*ss; + for ( fs=0; fs<image->detgeom->panels[0].w; fs++ ) { + for ( ss=0; ss<image->detgeom->panels[0].h; ss++ ) { + int idx = fs+image->detgeom->panels[0].w*ss; image->dp[0][idx] = poisson_noise(rng, 1000.0); if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 9*9 ) continue; image->dp[0][idx] += 1000.0; @@ -188,30 +188,24 @@ int main(int argc, char *argv[]) image.dp[0] = malloc(128*128*sizeof(float)); image.bad = malloc(sizeof(uint16_t *)); image.bad[0] = calloc(128*128, sizeof(int)); - image.beam = NULL; image.lambda = ph_eV_to_lambda(1000.0); - image.det = calloc(1, sizeof(struct detector)); - image.det->n_panels = 1; - image.det->panels = calloc(1, sizeof(struct panel)); - - image.det->panels[0].fsx = 1.0; - image.det->panels[0].fsy = 0.0; - image.det->panels[0].ssx = 0.0; - image.det->panels[0].ssy = 1.0; - image.det->panels[0].xfs = 1.0; - image.det->panels[0].yfs = 0.0; - image.det->panels[0].xss = 0.0; - image.det->panels[0].yss = 1.0; - image.det->panels[0].cnx = -64.0; - image.det->panels[0].cny = -64.0; - image.det->panels[0].clen = 1.0; - image.det->panels[0].res = 1.0; - image.det->panels[0].w = 128; - image.det->panels[0].h = 128; - image.det->panels[0].adu_per_eV = NAN; - image.det->panels[0].adu_per_photon = 1.0; - image.det->panels[0].max_adu = +INFINITY; /* No cutoff */ + image.detgeom = calloc(1, sizeof(struct detgeom)); + image.detgeom->n_panels = 1; + image.detgeom->panels = calloc(1, sizeof(struct detgeom_panel)); + + image.detgeom->panels[0].fsx = 1.0; + image.detgeom->panels[0].fsy = 0.0; + image.detgeom->panels[0].ssx = 0.0; + image.detgeom->panels[0].ssy = 1.0; + image.detgeom->panels[0].cnx = -64.0; + image.detgeom->panels[0].cny = -64.0; + image.detgeom->panels[0].cnz = 1.0; + image.detgeom->panels[0].pixel_pitch = 1.0; + image.detgeom->panels[0].w = 128; + image.detgeom->panels[0].h = 128; + image.detgeom->panels[0].adu_per_photon = 1.0; + image.detgeom->panels[0].max_adu = +INFINITY; /* No cutoff */ memset(image.dp[0], 0, 128*128*sizeof(float)); @@ -238,10 +232,10 @@ int main(int argc, char *argv[]) /* Second check: uniform peak gives correct I and low sigma(I) */ npx = 0; - for ( fs=0; fs<image.det->panels[0].w; fs++ ) { - for ( ss=0; ss<image.det->panels[0].h; ss++ ) { + for ( fs=0; fs<image.detgeom->panels[0].w; fs++ ) { + for ( ss=0; ss<image.detgeom->panels[0].h; ss++ ) { if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 9*9 ) continue; - image.dp[0][fs+image.det->panels[0].w*ss] = 1000.0; + image.dp[0][fs+image.detgeom->panels[0].w*ss] = 1000.0; npx++; } } @@ -280,11 +274,11 @@ int main(int argc, char *argv[]) /* Fifth check: uniform peak on uniform background */ npx = 0; - for ( fs=0; fs<image.det->panels[0].w; fs++ ) { - for ( ss=0; ss<image.det->panels[0].h; ss++ ) { - image.dp[0][fs+image.det->panels[0].w*ss] = 1000.0; + for ( fs=0; fs<image.detgeom->panels[0].w; fs++ ) { + for ( ss=0; ss<image.detgeom->panels[0].h; ss++ ) { + image.dp[0][fs+image.detgeom->panels[0].w*ss] = 1000.0; if ( (fs-64)*(fs-64) + (ss-64)*(ss-64) > 9*9 ) continue; - image.dp[0][fs+image.det->panels[0].w*ss] += 1000.0; + image.dp[0][fs+image.detgeom->panels[0].w*ss] += 1000.0; npx++; } } @@ -315,9 +309,7 @@ int main(int argc, char *argv[]) } - free(image.beam); - free(image.det->panels); - free(image.det); + detgeom_free(image.detgeom); free(image.dp[0]); free(image.dp); gsl_rng_free(rng); |