diff options
author | Chun Hong Yoon <chun.hong.yoon@desy.de> | 2012-12-13 23:01:54 +0100 |
---|---|---|
committer | Chun Hong Yoon <chun.hong.yoon@desy.de> | 2012-12-13 23:01:54 +0100 |
commit | 27da7fc3b8c4ae479305d5de996bf8c729fabac3 (patch) | |
tree | d93549fe17ffa318f65d6fd7be1487f7b3778f5c /libcrystfel/src | |
parent | 7e7044535bf08943771c611785e4e16f3be0257b (diff) |
more user options for beam photon energy
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/beam-parameters.c | 20 | ||||
-rw-r--r-- | libcrystfel/src/beam-parameters.h | 5 |
2 files changed, 23 insertions, 2 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 */ |