aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-03-06 18:34:54 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:17 +0100
commitfb54afd078e600183e11caeb0713065b94e7968f (patch)
tree201b1f9f8318765362ee140399c1cd817d4fd1b7
parent806844b14db4e87114bc355d2debd9e8f8846c67 (diff)
Add -b option to powder_plot, make hdf5_read() not use nominal energy
-rw-r--r--Makefile.am3
-rw-r--r--Makefile.in5
-rw-r--r--src/calibrate_detector.c2
-rw-r--r--src/cubeit.c3
-rw-r--r--src/dw-hdfsee.c4
-rw-r--r--src/hdf5-file.c7
-rw-r--r--src/hdf5-file.h3
-rw-r--r--src/indexamajig.c13
-rw-r--r--src/powder_plot.c28
-rw-r--r--src/reintegrate.c3
-rw-r--r--src/sum_stack.c3
-rw-r--r--src/templates.c3
12 files changed, 53 insertions, 24 deletions
diff --git a/Makefile.am b/Makefile.am
index 5c1be076..052b9e62 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -68,7 +68,8 @@ src_check_hkl_SOURCES = src/check_hkl.c src/sfac.c src/cell.c src/utils.c \
src/thread-pool.c
src_powder_plot_SOURCES = src/powder_plot.c src/cell.c src/utils.c src/image.c \
- src/hdf5-file.c src/detector.c src/thread-pool.c
+ src/hdf5-file.c src/detector.c src/thread-pool.c \
+ src/beam-parameters.c
src_render_hkl_SOURCES = src/render_hkl.c src/cell.c src/reflections.c \
src/utils.c src/povray.c src/symmetry.c src/render.c \
diff --git a/Makefile.in b/Makefile.in
index adddfa87..3e8f1851 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -192,7 +192,7 @@ src_pattern_sim_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
am_src_powder_plot_OBJECTS = src/powder_plot.$(OBJEXT) \
src/cell.$(OBJEXT) src/utils.$(OBJEXT) src/image.$(OBJEXT) \
src/hdf5-file.$(OBJEXT) src/detector.$(OBJEXT) \
- src/thread-pool.$(OBJEXT)
+ src/thread-pool.$(OBJEXT) src/beam-parameters.$(OBJEXT)
src_powder_plot_OBJECTS = $(am_src_powder_plot_OBJECTS)
src_powder_plot_LDADD = $(LDADD)
src_powder_plot_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
@@ -617,7 +617,8 @@ src_check_hkl_SOURCES = src/check_hkl.c src/sfac.c src/cell.c src/utils.c \
src/thread-pool.c
src_powder_plot_SOURCES = src/powder_plot.c src/cell.c src/utils.c src/image.c \
- src/hdf5-file.c src/detector.c src/thread-pool.c
+ src/hdf5-file.c src/detector.c src/thread-pool.c \
+ src/beam-parameters.c
src_render_hkl_SOURCES = src/render_hkl.c src/cell.c src/reflections.c \
src/utils.c src/povray.c src/symmetry.c src/render.c \
diff --git a/src/calibrate_detector.c b/src/calibrate_detector.c
index ab8b3ecb..e8b5ed37 100644
--- a/src/calibrate_detector.c
+++ b/src/calibrate_detector.c
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
hdfile = hdfile_open(filename);
hdfile_set_image(hdfile, "/data/data");
- hdf5_read(hdfile, &image, 1, 2000.0);
+ hdf5_read(hdfile, &image, 1);
if ( split ) {
split_image(&image);
diff --git a/src/cubeit.c b/src/cubeit.c
index e412c2c1..608f0e48 100644
--- a/src/cubeit.c
+++ b/src/cubeit.c
@@ -231,8 +231,7 @@ static void sum_image(void *pg, int cookie)
return;
}
- /* FIXME: Nominal photon energy */
- hdf5_read(hdfile, &image, 1, 2000.0);
+ hdf5_read(hdfile, &image, 1);
cell_get_cartesian(apargs->cell, &ax, &ay, &az, &bx, &by,
&bz, &cx, &cy, &cz);
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index 1a3f6b7b..abf81e8f 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -1245,7 +1245,7 @@ static gint displaywindow_newhdf(GtkMenuItem *item, struct newhdf *nh)
if ( nh->dw->not_ready_yet ) return 0;
hdfile_set_image(nh->dw->hdfile, nh->name);
- hdf5_read(nh->dw->hdfile, nh->dw->image, 0, 0.0);
+ hdf5_read(nh->dw->hdfile, nh->dw->image, 0);
/* Check that the geometry still fits */
if ( !geometry_fits(nh->dw->image, nh->dw->simple_geom) ) {
@@ -1530,7 +1530,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
if ( !fail ) {
dw->image = calloc(1, sizeof(struct image));
- hdf5_read(dw->hdfile, dw->image, 0, 0.0);
+ hdf5_read(dw->hdfile, dw->image, 0);
} else {
ERROR("Couldn't select path\n");
free(dw);
diff --git a/src/hdf5-file.c b/src/hdf5-file.c
index 313489e4..6db904d4 100644
--- a/src/hdf5-file.c
+++ b/src/hdf5-file.c
@@ -390,8 +390,7 @@ static void debodge_saturation(struct hdfile *f, struct image *image)
}
-int hdf5_read(struct hdfile *f, struct image *image, int satcorr,
- double nominal_photon_energy)
+int hdf5_read(struct hdfile *f, struct image *image, int satcorr)
{
herr_t r;
float *buf;
@@ -434,10 +433,6 @@ int hdf5_read(struct hdfile *f, struct image *image, int satcorr,
/* Read wavelength from file */
image->lambda = get_wavelength(f);
- if ( image->lambda < 0.0 ) {
- ERROR("Couldn't read wavelength - using nominal value.\n");
- image->lambda = ph_en_to_lambda(eV_to_J(nominal_photon_energy));
- }
image->f0 = get_f0(f);
if ( image->f0 < 0.0 ) {
diff --git a/src/hdf5-file.h b/src/hdf5-file.h
index 7a0d4382..f5ee71b3 100644
--- a/src/hdf5-file.h
+++ b/src/hdf5-file.h
@@ -27,8 +27,7 @@ struct hdfile;
extern int hdf5_write(const char *filename, const void *data,
int width, int height, int type);
-extern int hdf5_read(struct hdfile *f, struct image *image, int satcorr,
- double nominal_photon_energy);
+extern int hdf5_read(struct hdfile *f, struct image *image, int satcorr);
extern struct hdfile *hdfile_open(const char *filename);
extern int hdfile_set_image(struct hdfile *f, const char *path);
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 987d026f..1e5fc47a 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -241,8 +241,17 @@ static void process_image(void *pp, int cookie)
}
- hdf5_read(hdfile, &image, pargs->static_args.config_satcorr,
- beam->photon_energy);
+ hdf5_read(hdfile, &image, pargs->static_args.config_satcorr);
+ if ( image.lambda < 0.0 ) {
+ if ( beam != NULL ) {
+ image.lambda = beam->photon_energy;
+ } else {
+ ERROR("No wavelength in file, so you need to give "
+ "a beam parameters file with -b.\n");
+ hdfile_close(hdfile);
+ return;
+ }
+ }
if ( config_cmfilter ) {
filter_cm(&image);
diff --git a/src/powder_plot.c b/src/powder_plot.c
index b1beb414..c6d2f045 100644
--- a/src/powder_plot.c
+++ b/src/powder_plot.c
@@ -26,6 +26,7 @@
#include "detector.h"
#include "index.h"
#include "hdf5-file.h"
+#include "beam-parameters.h"
static void show_help(const char *s)
@@ -37,6 +38,8 @@ static void show_help(const char *s)
" -h, --help Display this help message.\n"
" -g. --geometry=<file> Get detector geometry from file.\n"
" -i, --input=<file> Input filename.\n"
+" -b, --beam=<file> Get beam parameters (specifically, wavelength)"
+" from file if non present in the HDF5 file.\n"
"\n");
}
@@ -49,12 +52,15 @@ int main(int argc, char *argv[])
struct hdfile *hdfile;
char *filename = NULL;
char *geometry = NULL;
+ char *beamf = NULL;
+ struct beam_params *beam = NULL;
/* Long options */
const struct option longopts[] = {
{"help", 0, NULL, 'h'},
{"input", 1, NULL, 'i'},
{"geometry", 1, NULL, 'g'},
+ {"beam", 1, NULL, 'b'},
{0, 0, NULL, 0}
};
@@ -77,6 +83,10 @@ int main(int argc, char *argv[])
geometry = strdup(optarg);
break;
+ case 'b' :
+ beamf = strdup(optarg);
+ break;
+
default :
return 1;
}
@@ -93,6 +103,11 @@ int main(int argc, char *argv[])
return 1;
}
+ if ( beamf != NULL ) {
+ beam = get_beam_parameters(beamf);
+ free(beamf);
+ }
+
image.det = get_detector_geometry(geometry);
if ( image.det == NULL ) {
ERROR("Failed to read detector geometry from '%s'\n", geometry);
@@ -102,7 +117,16 @@ int main(int argc, char *argv[])
hdfile = hdfile_open(filename);
hdfile_set_image(hdfile, "/data/data");
- hdf5_read(hdfile, &image, 1, 2000.0); /* FIXME: Hardcoded */
+ hdf5_read(hdfile, &image, 1);
+ if ( image.lambda < 0.0 ) {
+ if ( beam != NULL ) {
+ image.lambda = beam->photon_energy;
+ } else {
+ ERROR("No wavelength in file, so you need to give "
+ "a beam parameters file with -b.\n");
+ return 1;
+ }
+ }
for ( x=0; x<image.width; x++ ) {
for ( y=0; y<image.height; y++ ) {
@@ -121,5 +145,7 @@ int main(int argc, char *argv[])
}
}
+ free(beamf);
+
return 0;
}
diff --git a/src/reintegrate.c b/src/reintegrate.c
index 8450eaab..67e7b347 100644
--- a/src/reintegrate.c
+++ b/src/reintegrate.c
@@ -123,8 +123,7 @@ static void process_image(void *pg, int cookie)
return;
}
- /* FIXME: Nominal photon energy */
- hdf5_read(hdfile, &image, pargs->config_satcorr, 2000.0);
+ hdf5_read(hdfile, &image, pargs->config_satcorr);
map_all_peaks(&image);
diff --git a/src/sum_stack.c b/src/sum_stack.c
index 3d2388ab..c25a79aa 100644
--- a/src/sum_stack.c
+++ b/src/sum_stack.c
@@ -185,8 +185,7 @@ static void add_image(void *args, int cookie)
return;
}
- /* FIXME: Nominal photon energy */
- hdf5_read(hdfile, &image, 1, 2000.0);
+ hdf5_read(hdfile, &image, 1);
if ( pargs->config_cmfilter ) {
filter_cm(&image);
diff --git a/src/templates.c b/src/templates.c
index 37188145..ed557afa 100644
--- a/src/templates.c
+++ b/src/templates.c
@@ -70,9 +70,10 @@ IndexingPrivate *generate_templates(UnitCell *cell, const char *filename,
ERROR("Couldn't select path\n");
return NULL;
}
- hdf5_read(hdfile, &image, 0, nominal_photon_energy);
+ hdf5_read(hdfile, &image, 0);
hdfile_close(hdfile);
image.det = det;
+ if ( image.lambda < 0.0 ) image.lambda = nominal_photon_energy;
priv = calloc(1, sizeof(struct _indexingprivate_template));
priv->base.indm = INDEXING_TEMPLATE;