aboutsummaryrefslogtreecommitdiff
path: root/src/partial_sim.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-09-22 18:06:07 +0200
committerThomas White <taw@physics.org>2014-09-22 18:06:07 +0200
commit0a5a04cc90619a1973c91489c71585ce127df045 (patch)
treec1903fc77534cd97840330b914b98b7b1187bce0 /src/partial_sim.c
parent142e1ad4e0fad73d223c67a842dfb9728a3bf34c (diff)
Beam file removal, part I
Diffstat (limited to 'src/partial_sim.c')
-rw-r--r--src/partial_sim.c110
1 files changed, 78 insertions, 32 deletions
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=<file> Write partials in stream format to <file>.\n"
" --images=<prefix> Write images to <prefix>NNN.h5.\n"
" -g. --geometry=<file> Get detector geometry from file.\n"
-" -b, --beam=<file> Get beam parameters from file\n"
" -p, --pdb=<file> PDB file from which to get the unit cell.\n"
"\n"
" -y, --symmetry=<sym> 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=<val> Set the standard deviation of the noise.\n"
" --background=<val> 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);