aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-11-14 15:47:33 +0100
committerThomas White <taw@physics.org>2014-11-14 15:47:33 +0100
commite0a717ebe6981cd14f268056bdcdc7ba53dfe029 (patch)
tree1564a1a9b360a3f888c360950f5f178f7c9e6648
parentf98c55524c74647ac999746929b8206f1ab178c0 (diff)
Allow geometry files to not contain photon_energy
-rw-r--r--libcrystfel/src/detector.c18
-rw-r--r--src/partial_sim.c6
-rw-r--r--src/pattern_sim.c9
3 files changed, 16 insertions, 17 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index a7da92bb..486fb32e 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -828,11 +828,7 @@ static void parse_toplevel(struct detector *det, struct beam_params *beam,
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 ) {
+ if ( strncmp(val, "/", 1) == 0 ) {
beam->photon_energy = 0.0;
beam->photon_energy_from = strdup(val);
} else {
@@ -841,11 +837,7 @@ static void parse_toplevel(struct detector *det, struct beam_params *beam,
}
} else if ( strcmp(key, "photon_energy_scale") == 0 ) {
- if ( beam == NULL ) {
- ERROR("Geometry file contains a reference to "
- "photon_energy_scale, which is inappropriate in "
- "this situation.\n");
- } else {
+ if ( beam != NULL ) {
beam->photon_energy_scale = atof(val);
}
@@ -1282,12 +1274,6 @@ struct detector *get_detector_geometry(const char *filename,
}
}
- if ( (beam != NULL) && (beam->photon_energy < -0.5) ) {
- STATUS("Photon energy must be specified (note: this is now "
- "done in the 'geometry' file)\n");
- reject = 1;
- }
-
for ( x=0; x<=max_fs; x++ ) {
for ( y=0; y<=max_ss; y++ ) {
if ( find_panel(det, x, y) == NULL ) {
diff --git a/src/partial_sim.c b/src/partial_sim.c
index 504abf52..d2229f39 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -697,6 +697,12 @@ int main(int argc, char *argv[])
ERROR("Failed to read geometry from '%s'\n", geomfile);
return 1;
}
+ if ( (beam.photon_energy > 0.0) && (beam.photon_energy_from == NULL) ) {
+ ERROR("WARNING: An explicit photon energy was found in the "
+ "geometry file. It will be ignored!\n");
+ ERROR("The value given on the command line "
+ "(with --photon-energy) will be used instead.\n");
+ }
if ( sym_str == NULL ) sym_str = strdup("1");
sym = get_pointgroup(sym_str);
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index af8fd4a4..fe30ae4c 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -270,6 +270,7 @@ int main(int argc, char *argv[])
double beam_radius = 1e-6; /* metres */
double bandwidth = 0.01;
double photon_energy = 9000.0;
+ struct beam_params beam;
/* Long options */
const struct option longopts[] = {
@@ -537,12 +538,18 @@ 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, NULL);
+ image.det = get_detector_geometry(geometry, &beam);
if ( image.det == NULL ) {
ERROR("Failed to read detector geometry from '%s'\n", geometry);
return 1;
}
free(geometry);
+ if ( (beam.photon_energy > 0.0) && (beam.photon_energy_from == NULL) ) {
+ ERROR("WARNING: An explicit photon energy was found in the "
+ "geometry file. It will be ignored!\n");
+ ERROR("The value given on the command line "
+ "(with --photon-energy) will be used instead.\n");
+ }
if ( spectrum_str == NULL ) {
STATUS("You didn't specify a spectrum type, so"