Commit fb54afd0 authored by Thomas White's avatar Thomas White Committed by Thomas White
Browse files

Add -b option to powder_plot, make hdf5_read() not use nominal energy

parent 806844b1
......@@ -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 \
......
......@@ -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 \
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 ) {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
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