aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2014-03-19 10:28:55 +0100
committerThomas White <taw@physics.org>2014-09-05 18:00:53 +0200
commitc7e4b7acbd624723c5973431c0101fe92bc3089d (patch)
tree2fd1caf4fc02280bbfb05e37538731985dd97c12 /src
parent985efc49f5ccdd47ffe37e195970afb6fc289edd (diff)
Refactoring of hdf5 reading and writing functions
Diffstat (limited to 'src')
-rw-r--r--src/dw-hdfsee.c28
-rw-r--r--src/partial_sim.c2
-rw-r--r--src/pattern_sim.c2
-rw-r--r--src/process_image.c24
4 files changed, 14 insertions, 42 deletions
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index 93bedf7f..3a2d24d2 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -1862,8 +1862,8 @@ static gint displaywindow_newhdf(GtkMenuItem *item, struct newhdf *nh)
a = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(nh->widget));
if ( !a ) return 0;
- hdfile_set_image(nh->dw->hdfile, nh->name);
- hdf5_read(nh->dw->hdfile, nh->dw->image, 0);
+ hdf5_read(nh->dw->hdfile, nh->dw->image, nh->name, 0);
+
// /* Check that the geometry still fits */
// if ( !geometry_fits(nh->dw->image, nh->dw->simple_geom) ) {
// int using = 0;
@@ -1991,10 +1991,8 @@ static GtkWidget *displaywindow_addhdfgroup(struct hdfile *hdfile,
gtk_menu_shell_append(GTK_MENU_SHELL(mss), ss);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
mss);
-
}
-
}
gtk_menu_shell_append(GTK_MENU_SHELL(ms), item);
@@ -2500,6 +2498,7 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
DisplayWindow *dw;
char *title;
GtkWidget *vbox;
+ int check;
dw = calloc(1, sizeof(DisplayWindow));
if ( dw == NULL ) return NULL;
@@ -2541,6 +2540,10 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
dw->image->det = det_geom;
+ /* TODO: Move the opening of the file in hd5_read.
+ * Currently not possible because the file handle
+ * must be stored in dw */
+
/* Open the file, if any */
if ( filename != NULL ) {
@@ -2549,19 +2552,10 @@ DisplayWindow *displaywindow_open(const char *filename, const char *peaks,
free(dw);
return NULL;
} else {
- int fail = -1;
-
- if ( element == NULL ) {
- fail = hdfile_set_first_image(dw->hdfile, "/");
- } else {
- fail = hdfile_set_image(dw->hdfile, element);
- }
-
- if ( !fail ) {
- dw->image->filename = strdup(filename);
- hdf5_read(dw->hdfile, dw->image, 0);
- } else {
- ERROR("Couldn't select path\n");
+ dw->image->filename = strdup(filename);
+ check = hdf5_read(dw->hdfile, dw->image, element, 0);
+ if (check) {
+ ERROR("Couldn't load file\n");
free(dw);
return NULL;
}
diff --git a/src/partial_sim.c b/src/partial_sim.c
index ebff2e20..9c876c27 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -204,7 +204,7 @@ static void draw_and_write_image(struct image *image, RefList *reflections,
image->data[i] += poisson_noise(rng, background);
}
- hdf5_write_image(image->filename, image);
+ hdf5_write_image(image->filename, image, NULL);
free(image->data);
}
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index fca12bab..361a3bcd 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -750,7 +750,7 @@ int main(int argc, char *argv[])
number++;
/* Write the output file */
- hdf5_write_image(filename, &image);
+ hdf5_write_image(filename, &image, NULL);
}
diff --git a/src/process_image.c b/src/process_image.c
index 96752832..1e2c7077 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -76,29 +76,7 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
hdfile = hdfile_open(image.filename);
if ( hdfile == NULL ) return;
- if ( iargs->element != NULL ) {
-
- int r;
- r = hdfile_set_image(hdfile, iargs->element);
- if ( r ) {
- ERROR("Couldn't select path '%s'\n", iargs->element);
- hdfile_close(hdfile);
- return;
- }
-
- } else {
-
- int r;
- r = hdfile_set_first_image(hdfile, "/");
- if ( r ) {
- ERROR("Couldn't select first path\n");
- hdfile_close(hdfile);
- return;
- }
-
- }
-
- check = hdf5_read(hdfile, &image, 1);
+ check = hdf5_read(hdfile, &image, iargs->element, 1);
if ( check ) {
hdfile_close(hdfile);
return;