Commit 27da7fc3 authored by Chun Hong Yoon's avatar Chun Hong Yoon
Browse files

more user options for beam photon energy

parent 7e704453
......@@ -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;
}
}
......@@ -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 */
......@@ -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",
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment