diff options
author | Valerio Mariani <valerio.mariani@desy.de> | 2014-03-25 17:35:07 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-09-05 18:01:52 +0200 |
commit | c194bf7746e3635571808856f29434499eec55b7 (patch) | |
tree | 6e52ae148b10bf46c4ca97badb06b2cfd44a55ed /src | |
parent | c7e4b7acbd624723c5973431c0101fe92bc3089d (diff) |
Refactoring of peaks and reflections I/O
Diffstat (limited to 'src')
-rw-r--r-- | src/dw-hdfsee.c | 113 | ||||
-rw-r--r-- | src/pattern_sim.c | 15 | ||||
-rw-r--r-- | src/process_image.c | 6 |
3 files changed, 35 insertions, 99 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 3a2d24d2..68e1b0a9 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -455,6 +455,7 @@ static int draw_stuff(cairo_surface_t *surf, DisplayWindow *dw) ss = f->ss; p = find_panel(dw->image->det, fs, ss); + if ( p == NULL ) continue; xs = (fs-p->min_fs)*p->fsx + (ss-p->min_ss)*p->ssx; @@ -1008,32 +1009,46 @@ static void load_features_from_file(struct image *image, const char *filename) do { char line[1024]; float intensity, sigma, fs, ss; + float add_fs, add_ss; char phs[1024]; + char pn[32]; int r; float cts; signed int h, k, l; + struct panel *p = NULL; rval = fgets(line, 1023, fh); if ( rval == NULL ) continue; chomp(line); /* Try long format (from stream) */ - r = sscanf(line, "%i %i %i %f %s %f %f %f %f", - &h, &k, &l, &intensity, phs, &sigma, &cts, &fs, &ss); - if ( r == 9 ) { + r = sscanf(line, "%i %i %i %f %s %f %f %f %f %s", + &h, &k, &l, &intensity, phs, &sigma, &cts, &fs, &ss, pn); + + if ( r == 10 ) { char name[32]; snprintf(name, 31, "%i %i %i", h, k, l); - image_add_feature(image->features, fs, ss, image, 1.0, + + p = find_panel_by_name(image->det, pn); + + add_fs = fs-p->orig_min_fs+p->min_fs; + add_ss = ss-p->orig_min_ss+p->min_ss; + image_add_feature(image->features, add_fs, add_ss, image, 1.0, strdup(name)); continue; } - r = sscanf(line, "%f %f", &fs, &ss); - if ( r != 2 ) continue; + r = sscanf(line, "%f %f %s", &fs, &ss, pn); + if ( r != 3 ) continue; + + p = find_panel_by_name(image->det, pn); - image_add_feature(image->features, fs, ss, image, 1.0, "peak"); + add_fs = fs-p->orig_min_fs+p->min_fs; + add_ss = ss-p->orig_min_ss+p->min_ss; + image_add_feature(image->features, add_fs, add_ss, image, 1.0, "peak"); } while ( rval != NULL ); + } @@ -1202,90 +1217,6 @@ static int save_geometry_file(DisplayWindow *dw) // return 0; //} -======= -//static int load_geometry_file(DisplayWindow *dw, struct image *image, -// const char *filename) -//{ -// struct detector *geom; -// GtkWidget *w; -// int using_loaded = 0; -// if ( dw->image->det == dw->loaded_geom ) using_loaded = 1; -// -// geom = get_detector_geometry(filename); -// if ( geom == NULL ) { -// displaywindow_error(dw, "Failed to load geometry file"); -// return -1; -// } -// fill_in_values(geom, dw->hdfile); -// -// if ( (1+geom->max_fs != dw->image->width) -// || (1+geom->max_ss != dw->image->height) ) { -// -// displaywindow_error(dw, "Geometry doesn't match image."); -// return -1; -// -// } -// -// /* Sort out the mess */ -// if ( dw->loaded_geom != NULL ) free_detector_geometry(dw->loaded_geom); -// dw->loaded_geom = geom; -// if ( using_loaded ) { -// dw->image->det = dw->loaded_geom; -// } -// -// w = gtk_ui_manager_get_widget(dw->ui, -// "/ui/displaywindow/view/usegeom"); -// gtk_widget_set_sensitive(GTK_WIDGET(w), TRUE); -// gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE); -// dw->use_geom = 1; -// -// return 0; -//} - - -//static gint displaywindow_loadgeom_response(GtkWidget *d, gint response, -// DisplayWindow *dw) -//{ -// if ( response == GTK_RESPONSE_ACCEPT ) { -// -// char *filename; -// -// filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); -// -// if ( load_geometry_file(dw, dw->image, filename) == 0 ) { -// displaywindow_update(dw); -// } -// -// g_free(filename); -// -// } -// -// gtk_widget_destroy(d); -// -// return 0; -//} - - -//static gint displaywindow_load_geom(GtkWidget *widget, DisplayWindow *dw) -//{ -// GtkWidget *d; - -// d = gtk_file_chooser_dialog_new("Load Geometry File", -// GTK_WINDOW(dw->window), -// GTK_FILE_CHOOSER_ACTION_OPEN, -// GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, -// GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, -// NULL); - -// g_signal_connect(G_OBJECT(d), "response", -// G_CALLBACK(displaywindow_loadgeom_response), dw); - -// gtk_widget_show_all(d); - -// return 0; -//} - - static gint displaywindow_peak_overlay(GtkWidget *widget, DisplayWindow *dw) { GtkWidget *d; diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 361a3bcd..98dee1b6 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -469,6 +469,12 @@ int main(int argc, char *argv[]) ERROR("You need to specify a geometry file with --geometry\n"); return 1; } + image.det = get_detector_geometry(geometry); + if ( image.det == NULL ) { + ERROR("Failed to read detector geometry from '%s'\n", geometry); + return 1; + } + free(geometry); if ( beamfile == NULL ) { ERROR("You need to specify a beam parameter file" @@ -509,7 +515,7 @@ int main(int argc, char *argv[]) RefList *reflections; - reflections = read_reflections(intfile); + reflections = read_reflections2(intfile, image.det); if ( reflections == NULL ) { ERROR("Problem reading input file %s\n", intfile); return 1; @@ -536,13 +542,6 @@ int main(int argc, char *argv[]) } - image.det = get_detector_geometry(geometry); - if ( image.det == NULL ) { - ERROR("Failed to read detector geometry from '%s'\n", geometry); - return 1; - } - free(geometry); - image.beam = get_beam_parameters(beamfile); if ( image.beam == NULL ) { ERROR("Failed to read beam parameters from '%s'\n", beamfile); diff --git a/src/process_image.c b/src/process_image.c index 1e2c7077..71c73357 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -77,6 +77,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, if ( hdfile == NULL ) return; check = hdf5_read(hdfile, &image, iargs->element, 1); + if ( check ) { hdfile_close(hdfile); return; @@ -102,6 +103,11 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, case PEAK_HDF5: /* Get peaks from HDF5 */ + + if ( !single_source(iargs->det, iargs->element)) { + ERROR("Peaks from HDF5 file not supported with multiple panel data sources.\n"); + } + if ( get_peaks(&image, hdfile, iargs->hdf5_peak_path) ) { ERROR("Failed to get peaks from HDF5 file.\n"); } |