aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-03-31 13:21:31 +0200
committerThomas White <taw@physics.org>2016-03-31 13:23:56 +0200
commit4a4d3dedf618656f55c3e268b08fa5c987ee8ba8 (patch)
tree20ec620baa725081f5a874370221a29d7f047805
parent3fed2c21204cb431ae043258b3d7b198ed475e95 (diff)
Handle placeholders in --hdf5-peaks
-rw-r--r--doc/man/indexamajig.12
-rw-r--r--libcrystfel/src/hdf5-file.c18
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);