diff options
author | Thomas White <taw@physics.org> | 2017-06-21 14:13:23 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-06-21 14:13:23 +0200 |
commit | 5e9137947df9330308e1f66fa4a0701481ba6e06 (patch) | |
tree | 660556fc92663b17b76b7a9d12d6e95bbb928fbb /src | |
parent | bd2d440d4e0db3040ae3a747dcfa55e638e33d42 (diff) | |
parent | 5617c8273e26469689c66fb46d5f7eb34dbf2bf4 (diff) |
Merge branch 'tom/cbf'
Diffstat (limited to 'src')
-rw-r--r-- | src/dw-hdfsee.c | 66 | ||||
-rw-r--r-- | src/dw-hdfsee.h | 8 | ||||
-rw-r--r-- | src/im-sandbox.c | 2 | ||||
-rw-r--r-- | src/indexamajig.c | 18 | ||||
-rw-r--r-- | src/process_image.c | 32 | ||||
-rw-r--r-- | src/process_image.h | 2 |
6 files changed, 79 insertions, 49 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 87c23f4e..0336f25e 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -74,8 +74,8 @@ static void displaywindow_error(DisplayWindow *dw, const char *message) static gint displaywindow_closed(GtkWidget *window, DisplayWindow *dw) { - if ( dw->hdfile != NULL ) { - hdfile_close(dw->hdfile); + if ( dw->imagefile != NULL ) { + imagefile_close(dw->imagefile); } if ( dw->surf != NULL ) cairo_surface_destroy(dw->surf); @@ -725,7 +725,7 @@ static gint displaywindow_set_binning(GtkWidget *widget, DisplayWindow *dw) return 0; } - if ( dw->hdfile == NULL ) { + if ( dw->imagefile == NULL ) { return 0; } @@ -852,8 +852,8 @@ static gint displaywindow_set_boostint(GtkWidget *widget, DisplayWindow *dw) return 0; } - if ( dw->hdfile == NULL ) { - return 0; + if ( dw->imagefile == NULL ) { + return 0; } bd = malloc(sizeof(BoostIntDialog)); @@ -927,8 +927,8 @@ static gint displaywindow_newevent(DisplayWindow *dw, int new_event) float **old_dp = dw->image->dp; int **old_bad = dw->image->bad; - fail = hdf5_read2(dw->hdfile, dw->image, - dw->ev_list->events[new_event], 0); + fail = imagefile_read(dw->imagefile, dw->image, + dw->ev_list->events[new_event]); if ( fail ) { ERROR("Couldn't load image"); dw->image->dp = old_dp; @@ -1046,8 +1046,8 @@ static gint displaywindow_set_newevent(GtkWidget *widget, DisplayWindow *dw) return 0; } - if ( dw->hdfile == NULL ) { - return 0; + if ( dw->imagefile == NULL ) { + return 0; } ed = malloc(sizeof(EventDialog)); @@ -1162,7 +1162,7 @@ static gint displaywindow_set_ringradius(GtkWidget *widget, DisplayWindow *dw) return 0; } - if ( dw->hdfile == NULL ) { + if ( dw->imagefile == NULL ) { return 0; } @@ -1796,7 +1796,7 @@ static gint displaywindow_show_numbers(GtkWidget *widget, DisplayWindow *dw) return 0; } - if ( dw->hdfile == NULL ) { + if ( dw->imagefile == NULL ) { return 0; } @@ -2306,12 +2306,14 @@ struct newhdf { char name[1024]; }; +/* New HDF5 element selected from menu */ static gint displaywindow_newhdf(GtkMenuItem *item, struct newhdf *nh) { gboolean a; int fail; if ( nh->dw->not_ready_yet ) return 0; + assert(imagefile_get_type(nh->dw->imagefile) == IMAGEFILE_HDF5); a = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(nh->widget)); if ( !a ) return 0; @@ -2320,7 +2322,8 @@ static gint displaywindow_newhdf(GtkMenuItem *item, struct newhdf *nh) * one */ free_detector_geometry(nh->dw->image->det); nh->dw->image->det = NULL; - fail = hdf5_read(nh->dw->hdfile, nh->dw->image, nh->name, 0); + fail = hdf5_read(imagefile_get_hdfile(nh->dw->imagefile), + nh->dw->image, nh->name, 0); if ( fail ) { ERROR("Couldn't load image"); return 1; @@ -2456,7 +2459,12 @@ static int displaywindow_update_menus(DisplayWindow *dw, const char *selectme) GtkWidget *ms; GtkWidget *w; - ms = displaywindow_createhdfmenus(dw->hdfile, dw, selectme); + if ( imagefile_get_type(dw->imagefile) != IMAGEFILE_HDF5 ) { + return 0; + } + + ms = displaywindow_createhdfmenus(imagefile_get_hdfile(dw->imagefile), + dw, selectme); if ( ms == NULL ) return 1; @@ -2828,8 +2836,8 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename, dw->image->lambda = 0.0; dw->image->filename = filename; - dw->hdfile = hdfile_open(filename); - if ( dw->hdfile == NULL ) { + dw->imagefile = imagefile_open(filename); + if ( dw->imagefile == NULL ) { ERROR("Couldn't open file: %s\n", filename); free(dw->geom_filename); free(dw); @@ -2842,11 +2850,19 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename, } if ( dw->image->det != NULL && ( dw->image->det->path_dim != 0 || - dw->image->det->dim_dim != 0 )) { + dw->image->det->dim_dim != 0 )) + { + struct hdfile *hdfile; + + if ( imagefile_get_type(dw->imagefile) != IMAGEFILE_HDF5 ) { + ERROR("Multi-event geometry, but not HDF5 file!\n"); + return NULL; + } + hdfile = imagefile_get_hdfile(dw->imagefile); dw->multi_event = 1; - dw->ev_list = fill_event_list(dw->hdfile, dw->image->det); + dw->ev_list = fill_event_list(hdfile, dw->image->det); if ( dw->ev_list == NULL ) { ERROR("Error while parsing file structure\n"); @@ -2883,18 +2899,26 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename, dw->curr_event = 0; ev = dw->ev_list->events[dw->curr_event]; } - check = hdf5_read2(dw->hdfile, dw->image, ev, 0); + check = imagefile_read(dw->imagefile, dw->image, ev); } else { - check = hdf5_read2(dw->hdfile, dw->image, NULL, 0); + check = imagefile_read(dw->imagefile, dw->image, NULL); } } else { - check = hdf5_read(dw->hdfile, dw->image, element, 0); + if ( element != NULL ) { + if ( imagefile_get_type(dw->imagefile) != IMAGEFILE_HDF5 ) { + ERROR("-e/--image requiest an HDF5 file\n"); + return NULL; + } + hdfile_set_image(imagefile_get_hdfile(dw->imagefile), + element); + } + check = imagefile_read_simple(dw->imagefile, dw->image); dw->simple = 1; } if ( check ) { ERROR("Couldn't load file\n"); - hdfile_close(dw->hdfile); + imagefile_close(dw->imagefile); free(dw->geom_filename); return NULL; } diff --git a/src/dw-hdfsee.h b/src/dw-hdfsee.h index 85c82ac7..fdbea231 100644 --- a/src/dw-hdfsee.h +++ b/src/dw-hdfsee.h @@ -3,12 +3,12 @@ * * Quick yet non-crappy HDF viewer * - * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * Copyright © 2012 Richard Kirian * * Authors: - * 2009-2014 Thomas White <taw@physics.org> + * 2009-2017 Thomas White <taw@physics.org> * 2014 Valerio Mariani * 2014 Takanori Nakane <nakane.t@gmail.com> * 2012 Richard Kirian @@ -101,8 +101,8 @@ typedef struct { int simple; - struct hdfile *hdfile; - struct image *image; + struct imagefile *imagefile; + struct image *image; char *geom_filename; char *rg_coll_name; diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 2dabf3e9..60400ad8 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -375,7 +375,7 @@ static void run_work(const struct index_args *iargs, Stream *st, cleanup_indexing(iargs->ipriv); free_detector_geometry(iargs->det); free(iargs->hdf5_peak_path); - free_copy_hdf5_field_list(iargs->copyme); + free_imagefile_field_list(iargs->copyme); cell_free(iargs->cell); if ( iargs->profile ) time_accounts_print(taccs); time_accounts_free(taccs); diff --git a/src/indexamajig.c b/src/indexamajig.c index f48fac17..439f9be3 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -172,9 +172,9 @@ static void show_help(const char *s) } -static void add_geom_beam_stuff_to_copy_hdf5(struct copy_hdf5_field *copyme, - struct detector *det, - struct beam_params *beam) +static void add_geom_beam_stuff_to_field_list(struct imagefile_field_list *copyme, + struct detector *det, + struct beam_params *beam) { int i; @@ -183,12 +183,12 @@ static void add_geom_beam_stuff_to_copy_hdf5(struct copy_hdf5_field *copyme, struct panel *p = &det->panels[i]; if ( p->clen_from != NULL ) { - add_copy_hdf5_field(copyme, p->clen_from); + add_imagefile_field(copyme, p->clen_from); } } if ( beam->photon_energy_from != NULL ) { - add_copy_hdf5_field(copyme, beam->photon_energy_from); + add_imagefile_field(copyme, beam->photon_energy_from); } } @@ -257,7 +257,7 @@ int main(int argc, char *argv[]) iargs.stream_peaks = 1; iargs.stream_refls = 1; iargs.int_diag = INTDIAG_NONE; - iargs.copyme = new_copy_hdf5_field_list(); + iargs.copyme = new_imagefile_field_list(); if ( iargs.copyme == NULL ) { ERROR("Couldn't allocate HDF5 field list.\n"); return 1; @@ -431,7 +431,7 @@ int main(int argc, char *argv[]) break; case 10 : - add_copy_hdf5_field(iargs.copyme, optarg); + add_imagefile_field(iargs.copyme, optarg); break; case 11 : @@ -627,7 +627,7 @@ int main(int argc, char *argv[]) geom_filename); return 1; } - add_geom_beam_stuff_to_copy_hdf5(iargs.copyme, iargs.det, iargs.beam); + add_geom_beam_stuff_to_field_list(iargs.copyme, iargs.det, iargs.beam); /* If no peak path from geometry file, use these (but see later) */ if ( iargs.hdf5_peak_path == NULL ) { @@ -806,7 +806,7 @@ int main(int argc, char *argv[]) create_sandbox(&iargs, n_proc, prefix, config_basename, fh, st, tempdir); - free_copy_hdf5_field_list(iargs.copyme); + free_imagefile_field_list(iargs.copyme); cell_free(iargs.cell); free(iargs.beam->photon_energy_from); free(prefix); diff --git a/src/process_image.c b/src/process_image.c index cd5c0866..d3177d82 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -102,7 +102,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, int serial, struct sb_shm *sb_shared, TimeAccounts *taccs) { int check; - struct hdfile *hdfile; + struct imagefile *imfile; struct image image; int i; int r; @@ -125,15 +125,15 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, time_accounts_set(taccs, TACC_HDF5OPEN); sb_shared->pings[cookie]++; - hdfile = hdfile_open(image.filename); - if ( hdfile == NULL ) { + imfile = imagefile_open(image.filename); + if ( imfile == NULL ) { ERROR("Couldn't open file: %s\n", image.filename); return; } time_accounts_set(taccs, TACC_HDF5READ); sb_shared->pings[cookie]++; - check = hdf5_read2(hdfile, &image, image.event, 0); + check = imagefile_read(imfile, &image, image.event); if ( check ) { return; } @@ -159,9 +159,13 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, sb_shared->pings[cookie]++; switch ( iargs->peaks ) { + struct hdfile *hdfile; + case PEAK_HDF5: - if ( get_peaks_2(&image, hdfile, iargs->hdf5_peak_path, - iargs->half_pixel_shift) ) + hdfile = imagefile_get_hdfile(imfile); + if ( (hdfile == NULL) + || (get_peaks_2(&image, hdfile, iargs->hdf5_peak_path, + iargs->half_pixel_shift)) ) { ERROR("Failed to get peaks from HDF5 file.\n"); } @@ -174,9 +178,11 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, break; case PEAK_CXI: - if ( get_peaks_cxi_2(&image, hdfile, iargs->hdf5_peak_path, - pargs->filename_p_e, - iargs->half_pixel_shift) ) + hdfile = imagefile_get_hdfile(imfile); + if ( (hdfile == NULL) + || (get_peaks_cxi_2(&image, hdfile, iargs->hdf5_peak_path, + pargs->filename_p_e, + iargs->half_pixel_shift)) ) { ERROR("Failed to get peaks from CXI file.\n"); } @@ -227,7 +233,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, if ( r ) { ERROR("Failed to chdir to temporary folder: %s\n", strerror(errno)); - hdfile_close(hdfile); + imagefile_close(imfile); return; } @@ -250,7 +256,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, r = chdir(rn); if ( r ) { ERROR("Failed to chdir: %s\n", strerror(errno)); - hdfile_close(hdfile); + imagefile_close(imfile); return; } free(rn); @@ -288,7 +294,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, time_accounts_set(taccs, TACC_WRITESTREAM); sb_shared->pings[cookie]++; - ret = write_chunk(st, &image, hdfile, + ret = write_chunk(st, &image, imfile, iargs->stream_peaks, iargs->stream_refls, pargs->filename_p_e->ev); if ( ret != 0 ) { @@ -338,5 +344,5 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, image_feature_list_free(image.features); free_detector_geometry(image.det); - hdfile_close(hdfile); + imagefile_close(imfile); } diff --git a/src/process_image.h b/src/process_image.h index d63679cf..14f90c78 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -80,7 +80,7 @@ struct index_args int min_pix_count; int max_pix_count; int local_bg_radius; - struct copy_hdf5_field *copyme; + struct imagefile_field_list *copyme; int integrate_saturated; int use_saturated; int no_revalidate; |