aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun Hong Yoon <chun.hong.yoon@desy.de>2012-12-13 23:01:54 +0100
committerChun Hong Yoon <chun.hong.yoon@desy.de>2012-12-13 23:01:54 +0100
commit27da7fc3b8c4ae479305d5de996bf8c729fabac3 (patch)
treed93549fe17ffa318f65d6fd7be1487f7b3778f5c
parent7e7044535bf08943771c611785e4e16f3be0257b (diff)
more user options for beam photon energy
-rw-r--r--libcrystfel/src/beam-parameters.c20
-rw-r--r--libcrystfel/src/beam-parameters.h5
-rw-r--r--src/im-sandbox.c5
-rw-r--r--src/pattern_sim.c7
4 files changed, 34 insertions, 3 deletions
diff --git a/libcrystfel/src/beam-parameters.c b/libcrystfel/src/beam-parameters.c
index 4af25261..2e4f5302 100644
--- a/libcrystfel/src/beam-parameters.c
+++ b/libcrystfel/src/beam-parameters.c
@@ -8,6 +8,7 @@
*
* Authors:
* 2010,2012 Thomas White <taw@physics.org>
+ * 2012 Chunhong Yoon
*
* This file is part of CrystFEL.
*
@@ -35,6 +36,7 @@
#include "beam-parameters.h"
#include "utils.h"
+#include "hdf5-file.h"
struct beam_params *get_beam_parameters(const char *filename)
@@ -86,7 +88,12 @@ struct beam_params *get_beam_parameters(const char *filename)
} else if ( strcmp(bits[0], "beam/radius") == 0 ) {
b->beam_radius = atof(bits[2]);
} else if ( strcmp(bits[0], "beam/photon_energy") == 0 ) {
- b->photon_energy = atof(bits[2]);
+ if ( strncmp(bits[2], "/", 1) == 0 ) {
+ b->photon_energy = 0; // 0 means special case
+ b->photon_energy_from = strdup(bits[2]);
+ } else {
+ b->photon_energy = atof(bits[2]);
+ }
} else if ( strcmp(bits[0], "beam/bandwidth") == 0 ) {
b->bandwidth = atof(bits[2]);
} else if ( strcmp(bits[0], "beam/divergence") == 0 ) {
@@ -113,7 +120,7 @@ struct beam_params *get_beam_parameters(const char *filename)
ERROR("Invalid or unspecified value for 'beam/radius'.\n");
reject = 1;
}
- if ( b->photon_energy < 0.0 ) {
+ if ( b->photon_energy < 0.0 ) { // 0 is ok
ERROR("Invalid or unspecified value for"
" 'beam/photon_energy'.\n");
reject = 1;
@@ -141,3 +148,12 @@ struct beam_params *get_beam_parameters(const char *filename)
return b;
}
+
+void fill_in_beamParam(struct beam_params *beam, struct hdfile *f)
+{
+ if ( beam->photon_energy_from != NULL ) {
+ beam->photon_energy = get_value(f, beam->photon_energy_from );
+ free(beam->photon_energy_from);
+ beam->photon_energy_from = NULL;
+ }
+}
diff --git a/libcrystfel/src/beam-parameters.h b/libcrystfel/src/beam-parameters.h
index 133e041b..36cfaa55 100644
--- a/libcrystfel/src/beam-parameters.h
+++ b/libcrystfel/src/beam-parameters.h
@@ -8,6 +8,7 @@
*
* Authors:
* 2010,2012 Thomas White <taw@physics.org>
+ * 2012 Chunhong Yoon
*
* This file is part of CrystFEL.
*
@@ -33,6 +34,7 @@
#include <config.h>
#endif
+#include "hdf5-file.h"
struct beam_params
{
@@ -46,10 +48,13 @@ struct beam_params
double divergence; /* divergence (radians) */
double profile_radius; /* Reciprocal space size of a reflection */
+
+ char *photon_energy_from; /* hdf5 group name */
};
extern struct beam_params *get_beam_parameters(const char *filename);
+extern void fill_in_beamParam(struct beam_params *beam, struct hdfile *f);
#endif /* BEAM_PARAMETERS_H */
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 1b460d4e..706dfa7b 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -235,6 +235,11 @@ static void process_image(const struct index_args *iargs,
return;
}
+ if (beam->photon_energy == 0) { // read from existing hdf5
+ fill_in_beamParam(beam, hdfile);
+ }
+ image.lambda = ph_en_to_lambda(eV_to_J(beam->photon_energy));
+
if ( image.lambda < 0.0 ) {
if ( beam != NULL ) {
ERROR("Using nominal photon energy of %.2f eV\n",
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index 06a1f5e5..17aa8030 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -498,7 +498,12 @@ int main(int argc, char *argv[])
/* Define image parameters */
image.width = image.det->max_fs + 1;
image.height = image.det->max_ss + 1;
- image.lambda = ph_en_to_lambda(eV_to_J(image.beam->photon_energy));
+ if (image.beam->photon_energy == 0) {
+ ERROR("Invalid photon_energy format in beam file\n")
+ return 1;
+ } else {
+ image.lambda = ph_en_to_lambda(eV_to_J(image.beam->photon_energy));
+ }
image.bw = image.beam->bandwidth;
image.div = image.beam->divergence;