From 21c67699d352cb95549a225694575db2808d8a91 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 18 Dec 2020 12:17:21 +0100 Subject: Add peak_list_type in geometry file --- libcrystfel/src/datatemplate.c | 25 +++++++++++++++++++++++++ libcrystfel/src/datatemplate_priv.h | 8 ++++++++ libcrystfel/src/image.c | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 4 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index 18b09c12..0da913d4 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -756,6 +756,28 @@ static int parse_photon_energy(const char *val, } +static int parse_peak_layout(const char *val, + enum peak_layout *layout) +{ + if ( strcmp(val, "auto") == 0 ) { + *layout = PEAK_LIST_AUTO; + return 0; + } + + if ( strcmp(val, "cxi") == 0 ) { + *layout = PEAK_LIST_CXI; + return 0; + } + + if ( (strcmp(val, "list3") == 0) ) { + *layout = PEAK_LIST_LIST3; + return 0; + } + + return 1; +} + + static int parse_toplevel(DataTemplate *dt, const char *key, const char *val, @@ -812,6 +834,9 @@ static int parse_toplevel(DataTemplate *dt, } else if ( strcmp(key, "peak_list") == 0 ) { dt->peak_list = strdup(val); + } else if ( strcmp(key, "peak_list_type") == 0 ) { + return parse_peak_layout(val, &dt->peak_list_type); + } else if ( strcmp(key, "bandwidth") == 0 ) { double v; char *end; diff --git a/libcrystfel/src/datatemplate_priv.h b/libcrystfel/src/datatemplate_priv.h index 593ebaa8..5f598184 100644 --- a/libcrystfel/src/datatemplate_priv.h +++ b/libcrystfel/src/datatemplate_priv.h @@ -65,6 +65,13 @@ enum flag_value_type FLAG_LESSTHAN }; +enum peak_layout +{ + PEAK_LIST_AUTO, + PEAK_LIST_CXI, + PEAK_LIST_LIST3 +}; + /* Special values for dimension IDs */ #define DIM_FS (-1) #define DIM_SS (-2) @@ -203,6 +210,7 @@ struct _datatemplate int n_rg_collections; char *peak_list; + enum peak_layout peak_list_type; /* Shift of whole detector, in m */ char * shift_x_from; diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index d50bcf43..54171321 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -938,19 +938,45 @@ ImageFeatureList *image_read_peaks(const DataTemplate *dtempl, { if ( is_hdf5_file(filename) ) { - const char *ext; - ext = filename_extension(filename, NULL); - if ( strcmp(ext, ".cxi") == 0 ) { + enum peak_layout layout; + + if ( dtempl->peak_list_type == PEAK_LIST_AUTO ) { + + const char *ext; + ext = filename_extension(filename, NULL); + + if ( strcmp(ext, ".cxi") == 0 ) { + layout = PEAK_LIST_CXI; + } else if ( strcmp(ext, ".h5") == 0 ) { + layout = PEAK_LIST_LIST3; + } else { + ERROR("Couldn't determine peak list layout.\n"); + ERROR("Specify peak_layout = cxi or list3n in geometry file.\n"); + return NULL; + } + + } else { + layout = dtempl->peak_list_type; + } + + switch ( layout ) { + + case PEAK_LIST_CXI : return image_hdf5_read_peaks_cxi(dtempl, filename, event, half_pixel_shift); - } else { + case PEAK_LIST_LIST3 : return image_hdf5_read_peaks_hdf5(dtempl, filename, event, half_pixel_shift); + + default : + ERROR("Invalid peak list type %i\n", layout); + return NULL; + } } else { -- cgit v1.2.3