aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image-hdf5.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-06-16 17:07:32 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:44 +0200
commit4c6da430ec5b62c1bf2637308710b7d72cca6459 (patch)
treef616244ea207422c3af8d9a3a89ee39eaecb6c42 /libcrystfel/src/image-hdf5.c
parent482cb6ec8245efddcc130838dce4b5a3c4eb8fe9 (diff)
Fix image_hdf5_read_peaks_cxi
Diffstat (limited to 'libcrystfel/src/image-hdf5.c')
-rw-r--r--libcrystfel/src/image-hdf5.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 088fd8e0..a59154fc 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -917,13 +917,13 @@ ImageFeatureList *image_hdf5_read_peaks_cxi(const DataTemplate *dtempl,
int r;
int pk;
char *subst_name;
-
- int line = 0;
+ int line;
int num_peaks;
-
float *buf_x;
float *buf_y;
float *buf_i;
+ int *dim_vals;
+ int n_dim_vals;
double peak_offset = half_pixel_shift ? 0.5 : 0.0;
@@ -933,24 +933,38 @@ ImageFeatureList *image_hdf5_read_peaks_cxi(const DataTemplate *dtempl,
return NULL;
}
- fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
- if ( fh < 0 ) {
- ERROR("Couldn't open file: %s\n", filename);
- return NULL;
- }
-
subst_name = substitute_path(event, dtempl->peak_list);
if ( subst_name == NULL ) {
ERROR("Invalid peak path %s\n", subst_name);
- H5Fclose(fh);
return NULL;
}
+ dim_vals = read_dim_parts(event, &n_dim_vals);
+ if ( dim_vals == NULL ) {
+ ERROR("Couldn't parse event '%s'\n");
+ return NULL;
+ }
+
+ if ( n_dim_vals < 1 ) {
+ ERROR("Not enough dimensions in event ID to use CXI "
+ "peak lists (%i)\n", n_dim_vals);
+ return NULL;
+ }
+
+ line = dim_vals[0];
+ free(dim_vals);
+
snprintf(path_n, 1024, "%s/nPeaks", subst_name);
snprintf(path_x, 1024, "%s/peakXPosRaw", subst_name);
snprintf(path_y, 1024, "%s/peakYPosRaw", subst_name);
snprintf(path_i, 1024, "%s/peakTotalIntensity", subst_name);
+ fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
+ if ( fh < 0 ) {
+ ERROR("Couldn't open file: %s\n", filename);
+ return NULL;
+ }
+
r = read_peak_count(fh, path_n, line, &num_peaks);
if ( r != 0 ) return NULL;