aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/detector.c34
-rw-r--r--libcrystfel/src/detector.h5
-rw-r--r--libcrystfel/src/hdf5-file.c39
-rw-r--r--libcrystfel/src/hdf5-file.h2
4 files changed, 48 insertions, 32 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index a7829474..e17c51a0 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -497,13 +497,13 @@ static struct panel *new_panel(struct detector *det, const char *name)
}
/* Create a new copy of the data location if needed */
- if ( new->data_from != NULL ) {
- new->data_from = strdup(new->data_from);
+ if ( new->data != NULL ) {
+ new->data = strdup(new->data);
}
/* Create a new copy of the bad pixel mask location */
if ( new->mask != NULL ) {
- new->mask = strdup(new->data_from);
+ new->mask = strdup(new->mask);
}
return new;
@@ -676,12 +676,12 @@ static int parse_field_for_panel(struct panel *panel, const char *key,
panel->clen_from = NULL;
}
- } else if ( strcmp(key, "data_from") == 0 ) {
+ } else if ( strcmp(key, "data") == 0 ) {
if ( strncmp(val,"/",1) != 0 ) {
ERROR("Invalid data location '%s'\n", val);
reject = -1;
}
- panel->data_from = strdup(val);
+ panel->data = strdup(val);
} else if ( strcmp(key, "mask") == 0 ) {
if ( strncmp(val,"/",1) != 0 ) {
@@ -911,7 +911,7 @@ struct detector *get_detector_geometry(const char *filename)
det->defaults.adu_per_eV = NAN;
det->defaults.max_adu = +INFINITY;
det->defaults.mask = NULL;
- det->defaults.data_from = NULL;
+ det->defaults.data = NULL;
strncpy(det->defaults.name, "", 1023);
do {
@@ -1100,7 +1100,7 @@ out:
det->max_ss = max_ss;
free(det->defaults.clen_from);
- free(det->defaults.data_from);
+ free(det->defaults.data);
free(det->defaults.mask);
/* Calculate matrix inverses and other stuff */
@@ -1190,8 +1190,8 @@ struct detector *copy_geom(const struct detector *in)
p->clen_from = strdup(p->clen_from);
}
- if ( p->data_from != NULL ) {
- /* Make a copy of the data_from fields unique to this
+ if ( p->data != NULL ) {
+ /* Make a copy of the data fields unique to this
* copy of the structure. */
p->clen_from = strdup(p->clen_from);
}
@@ -1436,9 +1436,9 @@ int write_detector_geometry(const char *filename, struct detector *det)
p->name, p->rigid_group->name);
}
- if ( p->data_from != NULL ) {
- fprintf(fh, "%s/data_from = %s\n",
- p->name, p->data_from);
+ if ( p->data != NULL ) {
+ fprintf(fh, "%s/data = %s\n",
+ p->name, p->data);
}
if ( p->mask != NULL ) {
@@ -1490,32 +1490,32 @@ void mark_resolution_range_as_bad(struct image *image,
}
-extern int single_source (struct detector *det, char *element)
+extern int single_panel_data_source (struct detector *det, const char *element)
{
int pi;
char *first_datafrom = NULL;
char *curr_datafrom = NULL;
- if ( det->panels[0].data_from == NULL ) {
+ if ( det->panels[0].data == NULL ) {
if ( element != NULL ) {
first_datafrom = strdup(element);
} else {
first_datafrom = strdup("/data/data");
}
} else {
- first_datafrom = strdup(det->panels[0].data_from);
+ first_datafrom = strdup(det->panels[0].data);
}
for ( pi=1;pi<det->n_panels;pi++ ) {
- if ( det->panels[pi].data_from == NULL ) {
+ if ( det->panels[pi].data == NULL ) {
if ( element != NULL ) {
curr_datafrom = strdup(element);
} else {
curr_datafrom = strdup("/data/data");
}
} else {
- curr_datafrom = strdup(det->panels[pi].data_from);
+ curr_datafrom = strdup(det->panels[pi].data);
}
if ( strcmp(curr_datafrom, first_datafrom) != 0 ) {
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index 6dc398d7..9245849f 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -87,7 +87,7 @@ struct panel
struct rigid_group *rigid_group; /* Rigid group */
double adu_per_eV; /* Number of ADU per eV */
double max_adu; /* Treat pixel as unreliable if higher than this */
- char *data_from;
+ char *data;
double fsx;
double fsy;
@@ -209,7 +209,8 @@ extern int write_detector_geometry(const char *filename, struct detector *det);
extern void mark_resolution_range_as_bad(struct image *image,
double min, double max);
-extern int single_source (struct detector *det, char *element);
+
+extern int single_panel_data_source (struct detector *det, const char *element);
#ifdef __cplusplus
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 3f90117d..a0fa8866 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -365,8 +365,8 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
}
locations[0].max_ss = 0;
locations[0].max_fs = 0;
- if ( image->det->panels[0].data_from != NULL ) {
- locations[0].location = image->det->panels[0].data_from;
+ if ( image->det->panels[0].data != NULL ) {
+ locations[0].location = image->det->panels[0].data;
} else {
locations[0].location = default_location;
}
@@ -383,10 +383,10 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
p = image->det->panels[pi];
- if ( p.data_from == NULL ) {
+ if ( p.data == NULL ) {
p_location = default_location;
} else {
- p_location = p.data_from;
+ p_location = p.data;
}
panel_processed = 0;
@@ -846,6 +846,12 @@ static int unpack_panels(struct image *image, struct detector *det)
int hdf5_read(struct hdfile *f, struct image *image, const char* element, int satcorr)
{
+ return hdf5_read2(f, image, element, satcorr, 0);
+}
+
+
+int hdf5_read2(struct hdfile *f, struct image *image, const char* element, int satcorr, int override_data_and_mask)
+{
herr_t r;
float *buf;
uint16_t *flags;
@@ -857,6 +863,7 @@ int hdf5_read(struct hdfile *f, struct image *image, const char* element, int sa
int pi;
hid_t mask_dh = NULL;
+
if ( image->det == NULL ) {
ERROR("Geometry not available\n");
return 1;
@@ -908,12 +915,16 @@ int hdf5_read(struct hdfile *f, struct image *image, const char* element, int sa
if ( p->orig_min_ss == -1 ) p->orig_min_ss = p->min_ss;
if ( p->orig_max_ss == -1 ) p->orig_max_ss = p->max_ss;
- if ( p->data_from != NULL ) {
- fail = hdfile_set_image(f, p->data_from);
- } else if ( element != NULL ) {
+ if ( override_data_and_mask ) {
fail = hdfile_set_image(f, element);
} else {
- fail = hdfile_set_first_image(f,"/");
+ if ( p->data != NULL ) {
+ fail = hdfile_set_image(f, p->data);
+ } else if ( element != NULL ) {
+ fail = hdfile_set_image(f, element);
+ } else {
+ fail = hdfile_set_first_image(f,"/");
+ }
}
if ( fail ) {
ERROR("Couldn't select path for panel %s\n",
@@ -974,10 +985,8 @@ int hdf5_read(struct hdfile *f, struct image *image, const char* element, int sa
H5Dclose(f->dh);
f->data_open = 0;
H5Sclose(dataspace);
- H5Sclose(memspace);
if ( p->mask != NULL ) {
-
mask_dh = H5Dopen2(f->fh, p->mask, H5P_DEFAULT);
if ( mask_dh <= 0 ) {
ERROR("Couldn't open flags for panel %s\n",
@@ -985,7 +994,7 @@ int hdf5_read(struct hdfile *f, struct image *image, const char* element, int sa
image->flags = NULL;
} else {
- mask_dataspace = H5Dget_space(H5Dget_space(mask_dh));
+ mask_dataspace = H5Dget_space(mask_dh);
check = H5Sselect_hyperslab(mask_dataspace, H5S_SELECT_SET,
f_offset, NULL, f_count, NULL);
if ( check < 0 ) {
@@ -1000,12 +1009,16 @@ int hdf5_read(struct hdfile *f, struct image *image, const char* element, int sa
} else {
no_mask_loaded = 0;
}
- H5Dclose(mask_dataspace);
+
+ H5Sclose(mask_dataspace);
H5Dclose(mask_dh);
- }
+
+ }
}
+ H5Sclose(memspace);
+
p->min_fs = m_min_fs;
p->max_fs = m_max_fs;
p->min_ss = curr_ss;
diff --git a/libcrystfel/src/hdf5-file.h b/libcrystfel/src/hdf5-file.h
index 1cac71a5..b5159fcf 100644
--- a/libcrystfel/src/hdf5-file.h
+++ b/libcrystfel/src/hdf5-file.h
@@ -52,6 +52,8 @@ extern int hdf5_write_image(const char *filename, struct image *image, char *ele
extern int hdf5_read(struct hdfile *f, struct image *image, const char *element, int satcorr);
+extern int hdf5_read2(struct hdfile *f, struct image *image, const char* element, int satcorr, int override_data_and_mask);
+
extern struct hdfile *hdfile_open(const char *filename);
extern int hdfile_set_image(struct hdfile *f, const char *path);
extern int16_t *hdfile_get_image_binned(struct hdfile *hdfile,