From 4a4d3dedf618656f55c3e268b08fa5c987ee8ba8 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 31 Mar 2016 13:21:31 +0200 Subject: Handle placeholders in --hdf5-peaks --- doc/man/indexamajig.1 | 2 +- libcrystfel/src/hdf5-file.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/man/indexamajig.1 b/doc/man/indexamajig.1 index 2690e039..d7f59f9d 100644 --- a/doc/man/indexamajig.1 +++ b/doc/man/indexamajig.1 @@ -242,7 +242,7 @@ Prefix the filenames from the input file with \fIprefix\fR. If \fB--basename\fR .PD 0 .IP \fB--hdf5-peaks=\fR\fIpath\fR .PD -When using \fB--peaks=hdf5\fR or \fB--peaks=cxi\fR, read the peak positions from location \fIpath\fR. See \fBPEAK DETECTION\fR above. +When using \fB--peaks=hdf5\fR or \fB--peaks=cxi\fR, read the peak positions from location \fIpath\fR. The path can include placeholders, e.g. \fB--hdf5-peaks=/%/peaks\fR. See \fBPEAK DETECTION\fR above. .PD 0 .IP \fB--tolerance=\fR\fItol\fR diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 7d2d8b5b..a57719cf 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -464,10 +464,18 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) float *buf; herr_t r; int tw; + char *np; - dh = H5Dopen2(f->fh, p, H5P_DEFAULT); + if ( image->event != NULL ) { + np = retrieve_full_path(image->event, p); + free(np); + } else { + np = strdup(p); + } + + dh = H5Dopen2(f->fh, np, H5P_DEFAULT); if ( dh < 0 ) { - ERROR("Peak list (%s) not found.\n", p); + ERROR("Peak list (%s) not found.\n", np); return 1; } @@ -475,6 +483,7 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) if ( sh < 0 ) { H5Dclose(dh); ERROR("Couldn't get dataspace for peak list.\n"); + free(np); return 1; } @@ -483,6 +492,7 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) H5Sget_simple_extent_ndims(sh)); H5Sclose(sh); H5Dclose(dh); + free(np); return 1; } @@ -493,6 +503,7 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) H5Sclose(sh); H5Dclose(dh); ERROR("Peak list has the wrong dimensions.\n"); + free(np); return 1; } @@ -501,6 +512,7 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) H5Sclose(sh); H5Dclose(dh); ERROR("Couldn't reserve memory for the peak list.\n"); + free(np); return 1; } r = H5Dread(dh, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, @@ -508,6 +520,7 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) if ( r < 0 ) { ERROR("Couldn't read peak list.\n"); free(buf); + free(np); return 1; } @@ -539,6 +552,7 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p) } free(buf); + free(np); H5Sclose(sh); H5Dclose(dh); -- cgit v1.2.3