From 0a5a04cc90619a1973c91489c71585ce127df045 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 22 Sep 2014 18:06:07 +0200 Subject: Beam file removal, part I --- doc/man/crystfel_geometry.5 | 51 +---------- doc/man/partial_sim.1 | 25 +++++- doc/man/pattern_sim.1 | 37 ++++++-- doc/reference/libcrystfel/CrystFEL-sections.txt | 8 -- libcrystfel/Makefile.am | 4 +- libcrystfel/src/beam-parameters.h | 76 ---------------- libcrystfel/src/detector.c | 24 ++++-- libcrystfel/src/detector.h | 4 +- libcrystfel/src/dirax.c | 3 +- libcrystfel/src/dirax.h | 6 +- libcrystfel/src/geometry.c | 1 - libcrystfel/src/grainspotter.c | 9 +- libcrystfel/src/grainspotter.h | 1 - libcrystfel/src/hdf5-file.c | 15 ++++ libcrystfel/src/image.h | 15 ++++ libcrystfel/src/index.c | 22 ++--- libcrystfel/src/index.h | 4 +- libcrystfel/src/mosflm.c | 7 +- libcrystfel/src/mosflm.h | 7 +- libcrystfel/src/peaks.c | 1 - libcrystfel/src/reax.c | 3 +- libcrystfel/src/reax.h | 7 +- libcrystfel/src/xds.c | 4 +- libcrystfel/src/xds.h | 3 +- src/diffraction-gpu.c | 1 - src/diffraction.c | 12 ++- src/dw-hdfsee.c | 6 +- src/dw-hdfsee.h | 3 +- src/get_hkl.c | 14 +-- src/hdfsee.c | 20 ++--- src/im-sandbox.c | 1 - src/indexamajig.c | 41 +++------ src/partial_sim.c | 110 +++++++++++++++++------- src/pattern_sim.c | 89 ++++++++++++++----- src/process_image.c | 1 - tests/gpu_sim_check.c | 1 - tests/integration_check.c | 1 - tests/prof2d_check.c | 1 - tests/ring_check.c | 1 - 39 files changed, 310 insertions(+), 329 deletions(-) delete mode 100644 libcrystfel/src/beam-parameters.h diff --git a/doc/man/crystfel_geometry.5 b/doc/man/crystfel_geometry.5 index 462b0e98..7886fd25 100644 --- a/doc/man/crystfel_geometry.5 +++ b/doc/man/crystfel_geometry.5 @@ -8,9 +8,7 @@ .TH CRYSTFEL\_GEOMETRY 5 .SH NAME -CRYSTFEL DETECTOR GEOMETRY AND BEAM DESCRIPTION FILES - -See below for information about CrystFEL's beam description files. +CRYSTFEL DETECTOR GEOMETRY DESCRIPTION FILES .SH CRYSTFEL DETECTOR GEOMETRY FILES The detector geometry is taken from a text file rather than hardcoded into the @@ -178,53 +176,6 @@ badregionB/max_ss = 512 .PP See the "examples" folder for some examples (look at the ones ending in .geom). -.SH CRYSTFEL BEAM DESCRIPTION FILES -CrystFEL beam description files, usually given with \fB--beam=\fR\fIfilename\fR, -describe the beam parameters. The syntax of each line in the beam file is simply this: - -.IP -\fIparameter\fB = \fIvalue\fR - -.PP -The possible parameters are: - -.PD 0 -.IP \fBbeam/fluence\fR -.PD -The number of photons per pulse. - -.PD 0 -.IP \fBbeam/radius\fR -.PD -The radius of X-ray beam, in metres. - -.PD 0 -.IP \fBbeam/photon_energy\fR -.PD -The photon energy in electron-Volts, or an HDF5 path to a stored wavelength value, also in eV. - -.PD 0 -.IP \fBbeam/photon_energy_scale\fR -.PD -Scaling factor for the photon energy, used if the photon energy itself is taken from the HDF5 file. This can be useful to correct old data sets which have systematically wrong energies. - -.PD 0 -.IP \fBbeam/bandwidth\fR -.PD -Bandwidth: FWHM(wavelength) over wavelength. Note: current simulation code just uses a rectangular distribution with this as its (full) width. - -.PD 0 -.IP \fBbeam/divergence\fR -Beam divergence (full convergence angle, \fBnot\fR the half-angle) in radians. - -.PD 0 -.IP \fBprofile_radius\fR -.PD -Reciprocal space 3D profile radius in m^-1. A sphere of this radius surrounds each reciprocal space, and if any part of the sphere is inside the excited volume of reciprocal space, the reflection will be predicted. You can change the prediction of spots by altering this value - larger numbers give more spots; - -.PP -The parameters \fBbeam/fluence\fR and \fBbeam/radius\fR are only relevant when simulations, e.g. with pattern_sim. \fBbeam/bandwidth\fR, \fBbeam/divergence\fR and \fBprofile_radius\fR affect which spots are predicted for the final stages of integration. - .SH AUTHOR This page was written by Thomas White and Valerio Mariani. diff --git a/doc/man/partial_sim.1 b/doc/man/partial_sim.1 index 0c30ba73..1521b410 100644 --- a/doc/man/partial_sim.1 +++ b/doc/man/partial_sim.1 @@ -25,7 +25,7 @@ partial_sim \- calculate partial reflections partial_sim calculates the intensities of idealised partial reflections from crystals in random orientations, which is useful for testing the convergence of Monte Carlo integration or scaling/post-refinement techniques. .P -You need to provide a CrystFEL geometry file (with \fB--geometry=\fR\fImy.geom\fR or \fB-g\fR \fImy.geom\fR), a beam description file (with \fB--beam=\fR\fImy.beam\fR or \fB-b\fR \fImy.beam\fR), a file containing the unit cell to use for the simulation (with \fB--pdb=\fR\fImy.pdb\fR or \fB-p\fR \fImy.pdb\fR), and an output filename with \fB--output=\fR\fImy.stream\fR or \fB-o\fR \fImy.stream\fR. +You need to provide a CrystFEL geometry file (with \fB--geometry=\fR\fImy.geom\fR or \fB-g\fR \fImy.geom\fR), a file containing the unit cell to use for the simulation (with \fB--pdb=\fR\fImy.pdb\fR or \fB-p\fR \fImy.pdb\fR), and an output filename with \fB--output=\fR\fImy.stream\fR or \fB-o\fR \fImy.stream\fR. For each randomly generated orientation, partial_sim calculates which reflections would appear on the detector with the specified beam parameters. It calculates the partiality for each reflection and multiplies it by the fully integrated intensity to produce a partial intensity. The fully integrated intensities can be taken from a file you provide (see below), otherwise they will be randomly generated (by taking the absolute value of a Gaussian random number, mean zero and standard deviation 1000). All the partial intensities for the orientation are multiplied by an overall scaling factor, which is randomly generated with a Gaussian distribution with mean 1 and standard deviation 0.3. The partial intensities are written to the output stream, and the process repeated for as many different orientations as you ask for (see below, default: 2). @@ -120,6 +120,29 @@ For each chunk in the output stream, write a 'sketch' image in HDF5 format to \f .PD Add a Poisson-distributed background with \fIval\fR photons to the sketches (see \fB--images\fR). The default is \fB--background=3000\fR.\fR. +.PD 0 +.B +.IP "\fB--beam-divergence=\fIval\fR" +.PD +Set the convergence angle (the full angle, not "half-angle"/"semi-angle") for the incident beam. The default is \fB--beam-divergence=0.001\fR, i.e. 1 mrad.\fR. + +.PD 0 +.B +.IP "\fB--beam-bandwidth=\fIval\fR" +.PD +Set the bandwidth, expressed as a decimal fraction applying to to wavelengths (not the photon energies), for the incident beam. The default is \fB--beam-bandwidth=0.01\fR, i.e. 1%.\fR. + +.PD 0 +.B +.IP "\fB--profile-radius=\fIval\fR" +.PD +Set the radius of the scattering density surrounding each reciprocal lattice point, in m^-1. The default is \fB--profile-radius=0.001e9\fR m^-1. + +.PD 0 +.B +.IP "\fB--photon-energy=\fIval\fR" +.PD +Set the central photon energy, in eV, for the incident beam. The default is \fB--photon-energy=9000\fR, i.e. 9 keV X-rays.\fR. .SH AUTHOR This page was written by Thomas White. diff --git a/doc/man/pattern_sim.1 b/doc/man/pattern_sim.1 index 1c3a3b41..b709ed3e 100644 --- a/doc/man/pattern_sim.1 +++ b/doc/man/pattern_sim.1 @@ -13,7 +13,7 @@ pattern_sim \- Simulation of nanocrystal diffraction patterns .SH SYNOPSIS .PP .B pattern_sim -\fB-g\fR \fIdetector.geom\fR \fB-b\fR \fImy.beam\fR \fB-p\fR \fImy.pdb\fR +\fB-g\fR \fIdetector.geom\fR \fB-p\fR \fImy.pdb\fR [\fBoptions\fR] \fB...\fR .PP .B pattern_sim @@ -23,9 +23,9 @@ pattern_sim \- Simulation of nanocrystal diffraction patterns pattern_sim simulates diffraction patterns from small crystals probed with femtosecond pulses of X-rays from a free electron laser. Typical use might be of the form: -pattern_sim -g mydetector.geom -b my.beam -p my.pdb -r -i myintensities.hkl +pattern_sim -g mydetector.geom -p my.pdb -r -i myintensities.hkl -The unit cell geometry will be taken from the unit cell file you provide, and the intensities of the reflections will be interpolated from the reflection list file you provide. The reflection list format is the same as that output by process_hkl and handled by get_hkl. You also need beam and geometry description files (-b and -g respectively). See `man crystfel_geometry' for details of how to create a geometry file. Examples of both files can be found in the installation directory, which is normally /usr/local/share/doc/crystfel. +The unit cell geometry will be taken from the unit cell file you provide, and the intensities of the reflections will be interpolated from the reflection list file you provide. The reflection list format is the same as that output by process_hkl and handled by get_hkl. You also need a geometry description file (-g). See `man crystfel_geometry' for details of how to create a geometry file. Examples of both files can be found in the installation directory, which is normally /usr/local/share/doc/crystfel. The result will be written to an HDF5 file in the current directory with the name `sim.h5'. @@ -54,12 +54,6 @@ Use GPU device number \fIn\fR. If you omit this option, the list of GPU devices .PD Read the detector geometry description from \fIfilename\fR. See \fBman crystfel_geometry\fR for more information. -.PD 0 -.IP "\fB-b\fR \fIfilename\fR" -.IP \fB--beam=\fR\fIfilename\fR -.PD -Read the beam description from \fIfilename\fR. See \fBman crystfel_geometry\fR for more information. - .PD 0 .IP "\fB-n\fR \fn\fR" .IP \fB--number=\fR\fIn\fR @@ -144,6 +138,31 @@ Add \fIn\fR photons of Poisson-distributed background uniformly over the detecto .PD Suppress the subsidiary maxima of the shape transforms by setting I_latt(q) to zero beyond the first minimum of the function. +.PD 0 +.B +.IP "\fB--beam-divergence=\fIval\fR" +.PD +Set the convergence angle (the full angle, not "half-angle"/"semi-angle") for the incident beam. The default is \fB--beam-divergence=0.001\fR, i.e. 1 mrad.\fR. + +.PD 0 +.B +.IP "\fB--beam-bandwidth=\fIval\fR" +.PD +Set the bandwidth, expressed as a decimal fraction applying to to wavelengths (not the photon energies), for the incident beam. The default is \fB--beam-bandwidth=0.01\fR, i.e. 1%.\fR. +.PD +Note: When using the two-colour or SASE spectrum, the spectrum calculation actually takes this value to be the bandwidth applying to the photon energies instead of the wavelengths. For small bandwidths, the difference should be very small. Sorry for the horrifying inconsistency. + +.PD 0 +.B +.IP "\fB--profile-radius=\fIval\fR" +.PD +Set the radius of the scattering density surrounding each reciprocal lattice point, in m^-1. The default is \fB--profile-radius=0.001e9\fR m^-1. + +.PD 0 +.B +.IP "\fB--photon-energy=\fIval\fR" +.PD +Set the central photon energy, in eV, for the incident beam. The default is \fB--photon-energy=9000\fR, i.e. 9 keV X-rays.\fR. .SH REFLECTION LISTS diff --git a/doc/reference/libcrystfel/CrystFEL-sections.txt b/doc/reference/libcrystfel/CrystFEL-sections.txt index 3b06d417..3bebed64 100644 --- a/doc/reference/libcrystfel/CrystFEL-sections.txt +++ b/doc/reference/libcrystfel/CrystFEL-sections.txt @@ -378,14 +378,6 @@ set_dim_structure_entry free_dim_structure_entry -
-beam-params -beam_params -get_beam_parameters -fill_in_beam_parameters -free_beam_parameters -
-
crystal
diff --git a/libcrystfel/Makefile.am b/libcrystfel/Makefile.am index 1be1d952..2cdfba10 100644 --- a/libcrystfel/Makefile.am +++ b/libcrystfel/Makefile.am @@ -4,7 +4,7 @@ libcrystfel_la_LDFLAGS = -version-info 5:0:0 libcrystfel_la_SOURCES = src/reflist.c src/utils.c src/cell.c src/detector.c \ src/thread-pool.c src/image.c src/hdf5-file.c \ - src/beam-parameters.c src/geometry.c src/statistics.c \ + src/geometry.c src/statistics.c \ src/symmetry.c src/stream.c src/peaks.c \ src/reflist-utils.c src/filters.c \ src/render.c src/index.c src/dirax.c src/mosflm.c \ @@ -18,7 +18,7 @@ endif libcrystfel_la_includedir=$(includedir)/crystfel/ -libcrystfel_la_include_HEADERS = ${top_srcdir}/version.h src/beam-parameters.h \ +libcrystfel_la_include_HEADERS = ${top_srcdir}/version.h \ src/hdf5-file.h src/reflist.h src/symmetry.h \ src/cell.h src/reflist-utils.h \ src/thread-pool.h src/statistics.h \ diff --git a/libcrystfel/src/beam-parameters.h b/libcrystfel/src/beam-parameters.h deleted file mode 100644 index 245c7c16..00000000 --- a/libcrystfel/src/beam-parameters.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * beam-parameters.h - * - * Beam parameters - * - * Copyright © 2013-2014 Deutsches Elektronen-Synchrotron DESY, - * a research centre of the Helmholtz Association. - * - * Authors: - * 2010,2012-2014 Thomas White - * 2014 Valerio Mariani - * 2012 Chunhong Yoon - * - * 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 . - * - */ - -#ifndef BEAM_PARAMETERS_H -#define BEAM_PARAMETERS_H - -#ifdef HAVE_CONFIG_H -#include -#endif - -struct beam_params; -struct event; -struct hdfile; - -#include "events.h" -#include "hdf5-file.h" - -struct beam_params -{ - double fluence; /* photons per pulse */ - double beam_radius; /* metres */ - double photon_energy; /* eV per photon */ - char *photon_energy_from; /* HDF5 dataset name */ - double photon_energy_scale; /* Scale factor for photon energy, if the - * energy is to be from the HDF5 file */ - double bandwidth; /* FWHM(wavelength) over wavelength. - * Note: current simulation code just uses - * a rectangular distribution with this as - * its (full) width. */ - double divergence; /* divergence (radians) */ - - double profile_radius; /* Reciprocal space size of a reflection */ -}; - -#ifdef __cplusplus -extern "C" { -#endif - -extern struct beam_params *get_beam_parameters(const char *filename); -extern void free_beam_parameters(struct beam_params *beam); - -extern void fill_in_beam_parameters(struct beam_params *beam, struct hdfile *f, - struct event* ev); - -#ifdef __cplusplus -} -#endif - -#endif /* BEAM_PARAMETERS_H */ diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 4cf6dac9..3cf59786 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -43,7 +43,6 @@ #include "image.h" #include "utils.h" #include "detector.h" -#include "beam-parameters.h" #include "hdf5-file.h" @@ -784,8 +783,8 @@ static int parse_field_bad(struct badregion *panel, const char *key, } -static void parse_toplevel(struct detector *det, const char *key, - const char *val) +static void parse_toplevel(struct detector *det, struct beam_params *beam, + const char *key, const char *val) { if ( strcmp(key, "mask_bad") == 0 ) { @@ -807,6 +806,20 @@ static void parse_toplevel(struct detector *det, const char *key, } else if ( strcmp(key, "coffset") == 0 ) { det->defaults.coffset = atof(val); + + } else if ( strcmp(key, "photon_energy") == 0 ) { + if ( beam == NULL ) { + ERROR("Geometry file contains a reference to " + "photon_energy, which is inappropriate in this " + "situation.\n"); + } else if ( strncmp(val, "/", 1) == 0 ) { + beam->photon_energy = 0.0; + beam->photon_energy_from = strdup(val); + } else { + beam->photon_energy = atof(val); + beam->photon_energy_from = NULL; + } + } else if ( parse_field_for_panel(&det->defaults, key, val, det) ) { ERROR("Unrecognised top level field '%s'\n", key); } @@ -871,7 +884,8 @@ static void find_min_max_d(struct detector *det) } -struct detector *get_detector_geometry(const char *filename) +struct detector *get_detector_geometry(const char *filename, + struct beam_params *beam) { FILE *fh; struct detector *det; @@ -971,7 +985,7 @@ struct detector *get_detector_geometry(const char *filename) n2 = assplode(bits[0], "/\\.", &path, ASSPLODE_NONE); if ( n2 < 2 ) { /* This was a top-level option, not handled above. */ - parse_toplevel(det, bits[0], bits[2]); + parse_toplevel(det, beam, bits[0], bits[2]); for ( i=0; i + * 2010,2012-2014 Thomas White * * This file is part of CrystFEL. * @@ -43,7 +43,7 @@ extern int run_dirax(struct image *image, IndexingPrivate *ipriv); extern IndexingPrivate *dirax_prepare(IndexingMethod *indm, UnitCell *cell, struct detector *det, - struct beam_params *beam, float *ltl); + float *ltl); extern void dirax_cleanup(IndexingPrivate *pp); diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 21f81915..aff19198 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -41,7 +41,6 @@ #include "cell-utils.h" #include "image.h" #include "peaks.h" -#include "beam-parameters.h" #include "reflist.h" #include "reflist-utils.h" #include "symmetry.h" diff --git a/libcrystfel/src/grainspotter.c b/libcrystfel/src/grainspotter.c index 5a0130f4..261756d6 100644 --- a/libcrystfel/src/grainspotter.c +++ b/libcrystfel/src/grainspotter.c @@ -3,11 +3,11 @@ * * Invoke GrainSpotter for multi-crystal autoindexing * - * Copyright © 2013 Deutsches Elektronen-Synchrotron DESY, - * a research centre of the Helmholtz Association. + * Copyright © 2013-2014 Deutsches Elektronen-Synchrotron DESY, + * a research centre of the Helmholtz Association. * * Authors: - * 2010-2013 Thomas White + * 2010-2014 Thomas White * * This file is part of CrystFEL. * @@ -468,8 +468,7 @@ int grainspotter_index(struct image *image, IndexingPrivate *ipriv) IndexingPrivate *grainspotter_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl) + struct detector *det, float *ltl) { struct grainspotter_private *gp; diff --git a/libcrystfel/src/grainspotter.h b/libcrystfel/src/grainspotter.h index b6a83725..3ab823ad 100644 --- a/libcrystfel/src/grainspotter.h +++ b/libcrystfel/src/grainspotter.h @@ -42,7 +42,6 @@ extern "C" { extern IndexingPrivate *grainspotter_prepare(IndexingMethod *indm, UnitCell *cell, struct detector *det, - struct beam_params *beam, float *ltl); extern void grainspotter_cleanup(IndexingPrivate *pp); diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 5093ed84..3fe088d6 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -900,6 +900,21 @@ static int unpack_panels(struct image *image, struct detector *det) } +void fill_in_beam_parameters(struct beam_params *beam, struct hdfile *f, + struct event* ev) +{ + if ( beam->photon_energy_from == NULL ) return; + + if ( ev != NULL ) { + beam->photon_energy = get_ev_based_value(f, + beam->photon_energy_from, ev); + } else { + beam->photon_energy = get_value(f, beam->photon_energy_from); + } + beam->photon_energy *= beam->photon_energy_scale; +} + + int hdf5_read(struct hdfile *f, struct image *image, const char *element, int satcorr) { diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h index 10e1eef7..0a64e081 100644 --- a/libcrystfel/src/image.h +++ b/libcrystfel/src/image.h @@ -98,6 +98,21 @@ struct sample }; +struct beam_params +{ + double fluence; /* photons per pulse */ + double beam_radius; /* metres */ + double photon_energy; /* eV per photon */ + char *photon_energy_from; /* HDF5 dataset name */ + double photon_energy_scale; /* Scale factor for photon energy, if the + * energy is to be from the HDF5 file */ + double bandwidth; /* FWHM(wavelength) over wavelength. */ + double divergence; /* divergence (radians) */ + + double profile_radius; /* Reciprocal space size of a reflection */ +}; + + /** * image: * diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 241d9311..07f563b7 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -3,12 +3,12 @@ * * Perform indexing (somehow) * - * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Lorenzo Galli * * Authors: - * 2010-2013 Thomas White + * 2010-2014 Thomas White * 2010-2011 Richard Kirian * 2012 Lorenzo Galli * 2013 Cornelius Gati @@ -56,8 +56,7 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl) + struct detector *det, float *ltl) { int n; int nm = 0; @@ -77,27 +76,24 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, switch ( indm[n] & INDEXING_METHOD_MASK ) { case INDEXING_DIRAX : - iprivs[n] = dirax_prepare(&indm[n], cell, - det, beam, ltl); + iprivs[n] = dirax_prepare(&indm[n], cell, det, ltl); break; case INDEXING_MOSFLM : - iprivs[n] = mosflm_prepare(&indm[n], cell, - det, beam, ltl); + iprivs[n] = mosflm_prepare(&indm[n], cell, det, ltl); break; case INDEXING_XDS : - iprivs[n] = xds_prepare(&indm[n], cell, det, beam, ltl); + iprivs[n] = xds_prepare(&indm[n], cell, det, ltl); break; case INDEXING_REAX : - iprivs[n] = reax_prepare(&indm[n], cell, - det, beam, ltl); + iprivs[n] = reax_prepare(&indm[n], cell, det, ltl); break; case INDEXING_GRAINSPOTTER : iprivs[n] = grainspotter_prepare(&indm[n], cell, - det, beam, ltl); + det, ltl); break; default : @@ -477,4 +473,4 @@ IndexingMethod *build_indexer_list(const char *str) list[++nmeth] = INDEXING_NONE; return list; -} \ No newline at end of file +} diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h index 76ecfad4..0e105aeb 100644 --- a/libcrystfel/src/index.h +++ b/libcrystfel/src/index.h @@ -125,14 +125,12 @@ typedef void *IndexingPrivate; extern IndexingMethod *build_indexer_list(const char *str); extern char *indexer_str(IndexingMethod indm); -#include "beam-parameters.h" #include "detector.h" #include "cell.h" #include "image.h" extern IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl); + struct detector *det, float *ltl); extern void index_pattern(struct image *image, IndexingMethod *indms, IndexingPrivate **iprivs); diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c index cf0852bf..3319a261 100644 --- a/libcrystfel/src/mosflm.c +++ b/libcrystfel/src/mosflm.c @@ -3,13 +3,13 @@ * * Invoke the DPS auto-indexing algorithm through MOSFLM * - * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Richard Kirian * * Authors: * 2010 Richard Kirian - * 2010-2013 Thomas White + * 2010-2014 Thomas White * * This file is part of CrystFEL. * @@ -831,8 +831,7 @@ int run_mosflm(struct image *image, IndexingPrivate *ipriv) IndexingPrivate *mosflm_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, struct beam_params *beam, - float *ltl) + struct detector *det, float *ltl) { struct mosflm_private *mp; int need_cell = 0; diff --git a/libcrystfel/src/mosflm.h b/libcrystfel/src/mosflm.h index 40282cec..572741dd 100644 --- a/libcrystfel/src/mosflm.h +++ b/libcrystfel/src/mosflm.h @@ -3,13 +3,13 @@ * * Invoke the DPS auto-indexing algorithm through MOSFLM * - * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Richard Kirian * * Authors: * 2010 Richard Kirian - * 2012-2013 Thomas White + * 2012-2014 Thomas White * * This file is part of CrystFEL. * @@ -44,8 +44,7 @@ extern "C" { extern int run_mosflm(struct image *image, IndexingPrivate *ipriv); extern IndexingPrivate *mosflm_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl); + struct detector *det, float *ltl); extern void mosflm_cleanup(IndexingPrivate *pp); diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 90ac9334..9e3c5e77 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -50,7 +50,6 @@ #include "detector.h" #include "filters.h" #include "reflist-utils.h" -#include "beam-parameters.h" #include "cell-utils.h" #include "geometry.h" diff --git a/libcrystfel/src/reax.c b/libcrystfel/src/reax.c index 5448d1a7..4313b058 100644 --- a/libcrystfel/src/reax.c +++ b/libcrystfel/src/reax.c @@ -1103,8 +1103,7 @@ int reax_index(IndexingPrivate *pp, struct image *image) IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, struct beam_params *beam, - float *ltl) + struct detector *det, float *ltl) { struct reax_private *p; int samp; diff --git a/libcrystfel/src/reax.h b/libcrystfel/src/reax.h index b5c6d058..0bc96d9e 100644 --- a/libcrystfel/src/reax.h +++ b/libcrystfel/src/reax.h @@ -35,7 +35,6 @@ #include "index.h" #include "cell.h" -#include "beam-parameters.h" #include "detector.h" #ifdef __cplusplus @@ -45,8 +44,7 @@ extern "C" { #ifdef HAVE_FFTW extern IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl); + struct detector *det, float *ltl); extern void reax_cleanup(IndexingPrivate *pp); @@ -55,8 +53,7 @@ extern int reax_index(IndexingPrivate *pp, struct image *image); #else /* HAVE_FFTW */ static IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl) + struct detector *det, float *ltl) { return NULL; } diff --git a/libcrystfel/src/xds.c b/libcrystfel/src/xds.c index 4a8ef30e..b4f66740 100644 --- a/libcrystfel/src/xds.c +++ b/libcrystfel/src/xds.c @@ -56,7 +56,6 @@ #include "utils.h" #include "peaks.h" #include "detector.h" -#include "beam-parameters.h" #include "cell-utils.h" @@ -619,8 +618,7 @@ int run_xds(struct image *image, IndexingPrivate *priv) IndexingPrivate *xds_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, struct beam_params *beam, - float *ltl) + struct detector *det, float *ltl) { struct xds_private *xp; diff --git a/libcrystfel/src/xds.h b/libcrystfel/src/xds.h index b42d8dbf..a0db2054 100644 --- a/libcrystfel/src/xds.h +++ b/libcrystfel/src/xds.h @@ -45,8 +45,7 @@ extern "C" { extern int run_xds(struct image *image, IndexingPrivate *ipriv); extern IndexingPrivate *xds_prepare(IndexingMethod *indm, UnitCell *cell, - struct detector *det, - struct beam_params *beam, float *ltl); + struct detector *det, float *ltl); extern void xds_cleanup(IndexingPrivate *pp); diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c index f031e07f..e31d7b0f 100644 --- a/src/diffraction-gpu.c +++ b/src/diffraction-gpu.c @@ -49,7 +49,6 @@ #include "cell.h" #include "diffraction.h" #include "cl-utils.h" -#include "beam-parameters.h" #include "pattern_sim.h" diff --git a/src/diffraction.c b/src/diffraction.c index 261761a0..1fb63ea3 100644 --- a/src/diffraction.c +++ b/src/diffraction.c @@ -41,7 +41,6 @@ #include "utils.h" #include "cell.h" #include "diffraction.h" -#include "beam-parameters.h" #include "symmetry.h" #include "pattern_sim.h" @@ -566,9 +565,10 @@ struct sample *generate_SASE(struct image *image, gsl_rng *rng) eV_cen = gaussian_noise(rng, ph_lambda_to_eV(image->lambda), jitter_sigma_eV); - /* Convert FWHM to standard deviation. Note that bandwidth is taken to - * be "delta E over E" (E = photon energy), not the bandwidth in terms - * of wavelength, but the difference should be very small */ + /* Convert FWHM to standard deviation. Note that bandwidth is taken + * here to be "delta E over E" (E = photon energy), not the bandwidth in + * terms of wavelength (as it is everywhere else), but the difference + * should be very small */ double sigma = (image->bw*eV_cen) / (2.0*sqrt(2.0*log(2.0))); /* The spectrum will be calculated to a resolution which spreads six @@ -613,6 +613,10 @@ struct sample *generate_twocolour(struct image *image) eV_cen = ph_lambda_to_eV(image->lambda); + /* Convert FWHM to standard deviation. Note that bandwidth is taken + * here to be "delta E over E" (E = photon energy), not the bandwidth in + * terms of wavelength (as it is everywhere else), but the difference + * should be very small */ double halfwidth = eV_cen*image->bw/2.0; /* eV */ eV_cen1 = eV_cen - halfwidth; diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 6b49d3f7..03509c75 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -2383,7 +2383,7 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks, int noisefilter, int calibmode, int colscale, const char *element, struct detector *det_geom, - const char *beam, + struct beam_params *beam, int show_rings, double *ring_radii, int n_rings, double ring_size, int median_filter) @@ -2429,10 +2429,6 @@ DisplayWindow *displaywindow_open(char *filename, const char *peaks, dw->curr_event = 0; dw->ev_list = NULL; - if ( beam != NULL ) { - dw->image->beam = get_beam_parameters(beam); - } - dw->image->det = det_geom; dw->hdfile = hdfile_open(filename); diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h index b3521702..fc16594d 100644 --- a/src/dw-hdfsee.h +++ b/src/dw-hdfsee.h @@ -143,7 +143,8 @@ extern DisplayWindow *displaywindow_open(char *filename, int noisefilter, int calibmode, int colscale, const char *element, struct detector *det_geom, - const char *beam, int show_rings, + struct beam_params *beam, + int show_rings, double *ring_radii, int n_rings, double ring_size, int median_filter); diff --git a/src/get_hkl.c b/src/get_hkl.c index 72b73041..52798a89 100644 --- a/src/get_hkl.c +++ b/src/get_hkl.c @@ -42,7 +42,6 @@ #include "utils.h" #include "reflist-utils.h" #include "symmetry.h" -#include "beam-parameters.h" #include "cell.h" #include "cell-utils.h" @@ -411,8 +410,6 @@ int main(int argc, char *argv[]) char *input_file = NULL; char *template = NULL; char *output = NULL; - char *beamfile = NULL; - struct beam_params *beam = NULL; RefList *input; double adu_per_photon = 0.0; int have_adu_per_photon = 0; @@ -448,7 +445,7 @@ int main(int argc, char *argv[]) }; /* Short options */ - while ((c = getopt_long(argc, argv, "ht:o:i:w:y:e:b:p:", + while ((c = getopt_long(argc, argv, "ht:o:i:w:y:e:p:", longopts, NULL)) != -1) { switch (c) { @@ -553,15 +550,6 @@ int main(int argc, char *argv[]) return 1; } - if ( beamfile != NULL ) { - beam = get_beam_parameters(beamfile); - if ( beam == NULL ) { - ERROR("Failed to load beam parameters from '%s'\n", - beamfile); - return 1; - } - } - if ( holo_str != NULL ) { holo = get_pointgroup(holo_str); free(holo_str); diff --git a/src/hdfsee.c b/src/hdfsee.c index 8ae55f9c..4961c7b0 100644 --- a/src/hdfsee.c +++ b/src/hdfsee.c @@ -81,7 +81,6 @@ static void show_help(const char *s) " -g, --geometry= Use geometry from file for display.\n" " (When this option is used, the value of\n" " of the -e parameter is ignored)" -" -m, --beam= Get beam parameters from .\n" "\n"); } @@ -126,13 +125,13 @@ int main(int argc, char *argv[]) int colscale = SCALE_COLOUR; char *cscale = NULL; char *element = NULL; - char *beam = NULL; double ring_size = 5.0; char *reslist = NULL; double ring_radii[128]; int n_rings = -1; int median_filter = 0; struct detector *det_geom = NULL; + struct beam_params beam; /* Long options */ const struct option longopts[] = { @@ -145,7 +144,6 @@ int main(int argc, char *argv[]) {"colscale", 1, NULL, 'c'}, {"image", 1, NULL, 'e'}, {"geometry", 1, NULL, 'g'}, - {"beam", 1, NULL, 'm'}, {"show-rings", 0, &config_showrings, 1}, {"ring-size", 1, NULL, 2}, {"simple-rings", 1, NULL, 'r'}, @@ -210,16 +208,12 @@ int main(int argc, char *argv[]) break; case 'g' : - det_geom = get_detector_geometry(optarg); + det_geom = get_detector_geometry(optarg, &beam); if ( det_geom == NULL ) { - ERROR("Failed to read detector geometry from " - "'%s'\n", optarg); - return 1; - } - break; - - case 'm' : - beam = strdup(optarg); + ERROR("Failed to read detector geometry from '%s'\n", + optarg); + return 1; + } break; case 2 : @@ -298,7 +292,7 @@ int main(int argc, char *argv[]) config_noisefilter, config_calibmode, colscale, element, - det_geom, beam, + det_geom, &beam, config_showrings, ring_radii, n_rings, diff --git a/src/im-sandbox.c b/src/im-sandbox.c index e7a6e283..75c2624e 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -486,7 +486,6 @@ static void run_work(const struct index_args *iargs, free(iargs->indm); free(iargs->ipriv); free_detector_geometry(iargs->det); - free_beam_parameters(iargs->beam); free(iargs->element); free(iargs->hdf5_peak_path); free_copy_hdf5_field_list(iargs->copyme); diff --git a/src/indexamajig.c b/src/indexamajig.c index ff4b2243..b139f299 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -62,7 +62,6 @@ #include "detector.h" #include "filters.h" #include "thread-pool.h" -#include "beam-parameters.h" #include "geometry.h" #include "stream.h" #include "reflist-utils.h" @@ -90,9 +89,6 @@ static void show_help(const char *s) " methods separated by commas.\n" " See 'man indexamajig' for details.\n" " -g. --geometry= Get detector geometry from file.\n" -" -b, --beam= Get beam parameters from file (provides nominal\n" -" wavelength value if no per-shot value is found in\n" -" the HDF5 files.\n" " -p, --pdb= File (PDB or CrystFEL unit cell format) from which\n" " to get the unit cell. Default: 'molecule.pdb'.\n" " --basename Remove the directory parts of the filenames.\n" @@ -199,6 +195,7 @@ int main(int argc, char *argv[]) char *tempdir = NULL; char *int_diag = NULL; char *geom_filename = NULL; + struct beam_params beam; /* Defaults */ iargs.cell = NULL; @@ -215,7 +212,7 @@ int main(int argc, char *argv[]) iargs.check_hdf5_snr = 0; iargs.det = NULL; iargs.peaks = PEAK_ZAEF; - iargs.beam = NULL; + iargs.beam = &beam; iargs.element = NULL; iargs.hdf5_peak_path = strdup("/processing/hitfinder/peakinfo"); iargs.copyme = NULL; @@ -250,7 +247,6 @@ int main(int argc, char *argv[]) {"output", 1, NULL, 'o'}, {"indexing", 1, NULL, 'z'}, {"geometry", 1, NULL, 'g'}, - {"beam", 1, NULL, 'b'}, {"pdb", 1, NULL, 'p'}, {"prefix", 1, NULL, 'x'}, {"threshold", 1, NULL, 't'}, @@ -300,7 +296,7 @@ int main(int argc, char *argv[]) }; /* Short options */ - while ((c = getopt_long(argc, argv, "hi:o:z:p:x:j:g:t:b:e:", + while ((c = getopt_long(argc, argv, "hi:o:z:p:x:j:g:t:e:v", longopts, NULL)) != -1) { switch (c) { @@ -309,7 +305,7 @@ int main(int argc, char *argv[]) show_help(argv[0]); return 0; - case 99 : + case 'v' : printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n"); printf(CRYSTFEL_BOILERPLATE"\n"); return 0; @@ -340,27 +336,12 @@ int main(int argc, char *argv[]) case 'g' : geom_filename = optarg; - iargs.det = get_detector_geometry(optarg); - if ( iargs.det == NULL ) { - ERROR("Failed to read detector geometry from " - "'%s'\n", optarg); - return 1; - } break; case 't' : iargs.threshold = strtof(optarg, NULL); break; - case 'b' : - iargs.beam = get_beam_parameters(optarg); - if ( iargs.beam == NULL ) { - ERROR("Failed to load beam parameters" - " from '%s'\n", optarg); - return 1; - } - break; - case 'e' : iargs.element = strdup(optarg); break; @@ -514,6 +495,12 @@ int main(int argc, char *argv[]) return 1; } + iargs.det = get_detector_geometry(geom_filename, iargs.beam); + if ( iargs.det == NULL ) { + ERROR("Failed to read detector geometry from '%s'\n", optarg); + return 1; + } + if ( indm_str == NULL ) { STATUS("You didn't specify an indexing method, so I won't try " @@ -598,12 +585,6 @@ int main(int argc, char *argv[]) return 1; } - if ( iargs.beam == NULL ) { - ERROR("You need to provide a beam parameters file (please read" - " the manual for more details).\n"); - return 1; - } - add_geom_beam_stuff_to_copy_hdf5(iargs.copyme, iargs.det, iargs.beam); if ( cellfile != NULL ) { @@ -678,7 +659,7 @@ int main(int argc, char *argv[]) /* Prepare the indexer */ if ( indm != NULL ) { ipriv = prepare_indexing(indm, iargs.cell, iargs.det, - iargs.beam, iargs.tols); + iargs.tols); if ( ipriv == NULL ) { ERROR("Failed to prepare indexing.\n"); return 1; diff --git a/src/partial_sim.c b/src/partial_sim.c index 47d8766e..32c5bb01 100644 --- a/src/partial_sim.c +++ b/src/partial_sim.c @@ -47,7 +47,6 @@ #include "utils.h" #include "reflist-utils.h" #include "symmetry.h" -#include "beam-parameters.h" #include "geometry.h" #include "stream.h" #include "thread-pool.h" @@ -225,7 +224,6 @@ static void show_help(const char *s) " -o, --output= Write partials in stream format to .\n" " --images= Write images to NNN.h5.\n" " -g. --geometry= Get detector geometry from file.\n" -" -b, --beam= Get beam parameters from file\n" " -p, --pdb= PDB file from which to get the unit cell.\n" "\n" " -y, --symmetry= Symmetry of the input reflection list.\n" @@ -238,6 +236,11 @@ static void show_help(const char *s) " generated full intensities, if not using -i.\n" " --noise-stddev= Set the standard deviation of the noise.\n" " --background= Background level in photons. Default 3000.\n" +" --beam-divergence Beam divergence in radians. Default 1 mrad.\n" +" --beam-bandwidth Beam bandwidth as a fraction. Default 1%%.\n" +" --profile-radius Reciprocal space reflection profile radius in m^-1.\n" +" Default 0.001e9 m^-1\n" +" --photon-energy Photon energy in eV. Default 9000.\n" "\n" ); } @@ -411,11 +414,10 @@ int main(int argc, char *argv[]) int c; char *input_file = NULL; char *output_file = NULL; - char *beamfile = NULL; char *geomfile = NULL; char *cellfile = NULL; struct detector *det = NULL; - struct beam_params *beam = NULL; + struct beam_params beam; RefList *full = NULL; char *sym_str = NULL; SymOpList *sym; @@ -440,13 +442,23 @@ int main(int argc, char *argv[]) int config_random = 0; char *image_prefix = NULL; + /* Default beam parameters */ + beam.divergence = 0.001; + beam.bandwidth = 0.01; + beam.profile_radius = 0.001e9; + beam.photon_energy = 9000.0; + + /* Beam parameters which it doesn't make sense to use here */ + beam.fluence = -1.0; + beam.beam_radius = -1.0; + beam.photon_energy_scale = 1.0; + /* Long options */ const struct option longopts[] = { {"help", 0, NULL, 'h'}, - {"version", 0, NULL, 8 }, + {"version", 0, NULL, 'v'}, {"output", 1, NULL, 'o'}, {"input", 1, NULL, 'i'}, - {"beam", 1, NULL, 'b'}, {"pdb", 1, NULL, 'p'}, {"geometry", 1, NULL, 'g'}, {"symmetry", 1, NULL, 'y'}, @@ -459,6 +471,10 @@ int main(int argc, char *argv[]) {"noise-stddev", 1, NULL, 5}, {"images", 1, NULL, 6}, {"background", 1, NULL, 7}, + {"beam-divergence", 1, NULL, 8}, + {"beam-bandwidth", 1, NULL, 9}, + {"profile-radius", 1, NULL, 10}, + {"photon-energy", 1, NULL, 11}, {"really-random", 0, &config_random, 1}, @@ -466,7 +482,7 @@ int main(int argc, char *argv[]) }; /* Short options */ - while ((c = getopt_long(argc, argv, "hi:o:b:p:g:y:n:r:j:c:", + while ((c = getopt_long(argc, argv, "hi:o:p:g:y:n:r:j:c:v", longopts, NULL)) != -1) { switch (c) { @@ -475,7 +491,7 @@ int main(int argc, char *argv[]) show_help(argv[0]); return 0; - case 8 : + case 'v' : printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n"); printf(CRYSTFEL_BOILERPLATE"\n"); return 0; @@ -488,10 +504,6 @@ int main(int argc, char *argv[]) output_file = strdup(optarg); break; - case 'b' : - beamfile = strdup(optarg); - break; - case 'p' : cellfile = strdup(optarg); break; @@ -578,8 +590,55 @@ int main(int argc, char *argv[]) return 1; } if ( background < 0.0 ) { - ERROR("Invalid background level."); - ERROR(" (must be positive).\n"); + ERROR("Background level must be positive.\n"); + return 1; + } + break; + + case 8 : + beam.divergence = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid beam divergence.\n"); + return 1; + } + if ( beam.divergence < 0.0 ) { + ERROR("Beam divergence must be positive.\n"); + return 1; + } + break; + + case 9 : + beam.bandwidth = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid beam bandwidth.\n"); + return 1; + } + if ( beam.bandwidth < 0.0 ) { + ERROR("Beam bandwidth must be positive.\n"); + return 1; + } + break; + + case 10 : + beam.profile_radius = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid profile radius.\n"); + return 1; + } + if ( beam.divergence < 0.0 ) { + ERROR("Profile radius must be positive.\n"); + return 1; + } + break; + + case 11 : + beam.photon_energy = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid photon energy.\n"); + return 1; + } + if ( beam.photon_energy < 0.0 ) { + ERROR("Photon energy must be positive.\n"); return 1; } break; @@ -607,18 +666,6 @@ int main(int argc, char *argv[]) return 1; } - /* Load beam */ - if ( beamfile == NULL ) { - ERROR("You need to provide a beam parameters file.\n"); - return 1; - } - beam = get_beam_parameters(beamfile); - if ( beam == NULL ) { - ERROR("Failed to load beam parameters from '%s'\n", beamfile); - return 1; - } - free(beamfile); - /* Load cell */ if ( cellfile == NULL ) { ERROR("You need to give a PDB file with the unit cell.\n"); @@ -642,7 +689,7 @@ int main(int argc, char *argv[]) ERROR("You need to give a geometry file.\n"); return 1; } - det = get_detector_geometry(geomfile); + det = get_detector_geometry(geomfile, &beam); if ( det == NULL ) { ERROR("Failed to read geometry from '%s'\n", geomfile); return 1; @@ -700,10 +747,10 @@ int main(int argc, char *argv[]) image.width = det->max_fs + 1; image.height = det->max_ss + 1; - image.lambda = ph_en_to_lambda(eV_to_J(beam->photon_energy)); - image.div = beam->divergence; - image.bw = beam->bandwidth; - image.beam = beam; + image.lambda = ph_en_to_lambda(eV_to_J(beam.photon_energy)); + image.div = beam.divergence; + image.bw = beam.bandwidth; + image.beam = &beam; image.filename = "dummy.h5"; image.copyme = NULL; image.crystals = NULL; @@ -842,7 +889,6 @@ int main(int argc, char *argv[]) close_stream(stream); cell_free(cell); free_detector_geometry(det); - free(beam); free_symoplist(sym); reflist_free(full); free(save_file); diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 8e048b4e..f1892876 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -51,7 +51,6 @@ #include "hdf5-file.h" #include "detector.h" #include "peaks.h" -#include "beam-parameters.h" #include "symmetry.h" #include "reflist.h" #include "reflist-utils.h" @@ -76,7 +75,6 @@ static void show_help(const char *s) " --gpu-dev= Use GPU device . Omit this option to see the\n" " available devices.\n" " -g, --geometry= Get detector geometry from file.\n" -" -b, --beam= Get beam parameters from file.\n" " -n, --number= Generate N images. Default 1.\n" " --no-images Do not output any HDF5 files.\n" " -o, --output= Output HDF5 filename. Default: sim.h5.\n" @@ -96,6 +94,11 @@ static void show_help(const char *s) " --background= Add N photons of Poisson background (default 0).\n" " --template= Take orientations from stream .\n" " --no-fringes Exclude the side maxima of Bragg peaks.\n" +" --beam-divergence Beam divergence in radians. Default 1 mrad.\n" +" --beam-bandwidth Beam bandwidth as a fraction. Default 1%%.\n" +" --profile-radius Reciprocal space reflection profile radius in m^-1.\n" +" Default 0.001e9 m^-1\n" +" --photon-energy Photon energy in eV. Default 9000.\n" ); } @@ -266,11 +269,23 @@ int main(int argc, char *argv[]) char *template_file = NULL; Stream *st = NULL; int no_fringes = 0; + struct beam_params beam; + + /* Default beam parameters */ + beam.bandwidth = 0.01; + beam.profile_radius = 0.001e9; + beam.photon_energy = 9000.0; + + /* Beam parameters which it doesn't make sense to use here */ + beam.fluence = -1.0; + beam.beam_radius = -1.0; + beam.photon_energy_scale = 1.0; + beam.divergence = -1.0; /* (not implemented .. yet?) */ /* Long options */ const struct option longopts[] = { {"help", 0, NULL, 'h'}, - {"version", 0, NULL, 7 }, + {"version", 0, NULL, 'v'}, {"gpu", 0, &config_gpu, 1}, {"random-orientation", 0, NULL, 'r'}, {"number", 1, NULL, 'n'}, @@ -283,22 +298,26 @@ int main(int argc, char *argv[]) {"pdb", 1, NULL, 'p'}, {"output", 1, NULL, 'o'}, {"geometry", 1, NULL, 'g'}, - {"beam", 1, NULL, 'b'}, {"sample-spectrum", 1, NULL, 's'}, {"type-spectrum", 1, NULL, 'x'}, {"spectrum", 1, NULL, 'x'}, {"really-random", 0, &config_random, 1}, {"no-fringes", 0, &no_fringes, 1}, + {"gpu-dev", 1, NULL, 2}, {"min-size", 1, NULL, 3}, {"max-size", 1, NULL, 4}, {"background", 1, NULL, 5}, {"template", 1, NULL, 6}, + {"beam-bandwidth", 1, NULL, 7}, + {"profile-radius", 1, NULL, 8}, + {"photon-energy", 1, NULL, 9}, + {0, 0, NULL, 0} }; /* Short options */ - while ((c = getopt_long(argc, argv, "hrn:i:t:p:o:g:b:y:s:x:", + while ((c = getopt_long(argc, argv, "hrn:i:t:p:o:g:y:s:x:v", longopts, NULL)) != -1) { switch (c) { @@ -307,7 +326,7 @@ int main(int argc, char *argv[]) show_help(argv[0]); return 0; - case 7 : + case 'v' : printf("CrystFEL: " CRYSTFEL_VERSIONSTRING "\n"); printf(CRYSTFEL_BOILERPLATE"\n"); return 0; @@ -402,6 +421,43 @@ int main(int argc, char *argv[]) template_file = strdup(optarg); break; + case 7 : + beam.bandwidth = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid beam bandwidth.\n"); + return 1; + } + if ( beam.bandwidth < 0.0 ) { + ERROR("Beam bandwidth must be positive.\n"); + return 1; + } + break; + + case 8 : + beam.profile_radius = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid profile radius.\n"); + return 1; + } + if ( beam.divergence < 0.0 ) { + ERROR("Profile radius must be positive.\n"); + return 1; + } + break; + + case 9 : + beam.photon_energy = strtod(optarg, &rval); + if ( *rval != '\0' ) { + ERROR("Invalid photon energy.\n"); + return 1; + } + if ( beam.photon_energy < 0.0 ) { + ERROR("Photon energy must be positive.\n"); + return 1; + } + break; + + case 0 : break; @@ -476,19 +532,13 @@ int main(int argc, char *argv[]) ERROR("You need to specify a geometry file with --geometry\n"); return 1; } - image.det = get_detector_geometry(geometry); + image.det = get_detector_geometry(geometry, NULL); if ( image.det == NULL ) { ERROR("Failed to read detector geometry from '%s'\n", geometry); return 1; } free(geometry); - if ( beamfile == NULL ) { - ERROR("You need to specify a beam parameter file" - " with --beam\n"); - return 1; - } - if ( spectrum_str == NULL ) { STATUS("You didn't specify a spectrum type, so" " I'm using a 'tophat' spectrum.\n"); @@ -549,12 +599,6 @@ int main(int argc, char *argv[]) } - image.beam = get_beam_parameters(beamfile); - if ( image.beam == NULL ) { - ERROR("Failed to read beam parameters from '%s'\n", beamfile); - return 1; - } - /* Define image parameters */ image.width = image.det->max_fs + 1; image.height = image.det->max_ss + 1; @@ -564,10 +608,10 @@ int main(int argc, char *argv[]) return 1; } - double wl = ph_en_to_lambda(eV_to_J(image.beam->photon_energy)); + double wl = ph_en_to_lambda(eV_to_J(beam.photon_energy)); image.lambda = wl; - image.bw = image.beam->bandwidth; - image.div = image.beam->divergence; + image.bw = beam.bandwidth; + image.div = beam.divergence; image.nsamples = nsamples; free(beamfile); @@ -786,7 +830,6 @@ skip: free(image.det->panels); free(image.det); - free(image.beam); free(powder->data); free(powder); cell_free(input_cell); diff --git a/src/process_image.c b/src/process_image.c index 8646f535..b78833af 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -43,7 +43,6 @@ #include "detector.h" #include "filters.h" #include "thread-pool.h" -#include "beam-parameters.h" #include "geometry.h" #include "stream.h" #include "reflist-utils.h" diff --git a/tests/gpu_sim_check.c b/tests/gpu_sim_check.c index 1526ac86..7edb180a 100644 --- a/tests/gpu_sim_check.c +++ b/tests/gpu_sim_check.c @@ -43,7 +43,6 @@ #include "../src/diffraction.h" #include "../src/diffraction-gpu.h" #include -#include #include #include #include diff --git a/tests/integration_check.c b/tests/integration_check.c index 06bdd7d8..2d0a6c7a 100644 --- a/tests/integration_check.c +++ b/tests/integration_check.c @@ -32,7 +32,6 @@ #include #include -#include #include #include "../libcrystfel/src/integration.c" diff --git a/tests/prof2d_check.c b/tests/prof2d_check.c index 38abe6f3..8563c7d9 100644 --- a/tests/prof2d_check.c +++ b/tests/prof2d_check.c @@ -36,7 +36,6 @@ #include #include -#include #include #include "../libcrystfel/src/integration.c" diff --git a/tests/ring_check.c b/tests/ring_check.c index 10299fe0..8ced12d5 100644 --- a/tests/ring_check.c +++ b/tests/ring_check.c @@ -37,7 +37,6 @@ #include #include -#include #include "../libcrystfel/src/peaks.c" -- cgit v1.2.3