aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Mariani <valerio.mariani@desy.de>2015-01-26 16:34:46 +0100
committervalerio.mariani@desy.de <vmariani@cfeld-valerio2.desy.de>2015-01-27 14:11:25 +0100
commit32aa9fdf2cd23cd2d7f9fc6574ffec59b629a7f3 (patch)
tree230f8ae0c8436152790662d8dc852d0011c020dc
parentec97a9b53bc56ec7789a5449959a9a7722abf681 (diff)
Formatting
-rw-r--r--libcrystfel/src/detector.c29
-rw-r--r--libcrystfel/src/hdf5-file.c40
-rw-r--r--libcrystfel/src/image.c3
-rw-r--r--libcrystfel/src/stream.c25
-rw-r--r--src/dw-hdfsee.c10
-rw-r--r--src/hdfsee.c1
6 files changed, 68 insertions, 40 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index 1e160f7d..f5f6bb57 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -496,7 +496,8 @@ void fill_in_values(struct detector *det, struct hdfile *f, struct event* ev)
if (det->path_dim !=0 || det->dim_dim !=0 ){
- p->clen = get_ev_based_value(f, p->clen_from, ev) * 1.0e-3;
+ p->clen = get_ev_based_value(f, p->clen_from,
+ ev) * 1.0e-3;
} else {
p->clen = get_value(f, p->clen_from) * 1.0e-3;
}
@@ -1031,6 +1032,7 @@ struct detector *get_detector_geometry(const char *filename,
n2 = assplode(bits[0], "/\\.", &path, ASSPLODE_NONE);
if ( n2 < 2 ) {
+
/* This was a top-level option, not handled above. */
parse_toplevel(det, beam, bits[0], bits[2]);
for ( i=0; i<n1; i++ ) free(bits[i]);
@@ -1134,8 +1136,8 @@ struct detector *get_detector_geometry(const char *filename,
}
if ( dim_reject == 1) {
- ERROR("All panels' data and mask entries must have the same number "\
- "of placeholders\n");
+ ERROR("All panels' data and mask entries must have the same "
+ "number of placeholders\n");
reject = 1;
}
@@ -1157,16 +1159,20 @@ struct detector *get_detector_geometry(const char *filename,
for ( di=0; di<det->panels[i].dim_structure->num_dims; di++ ) {
- if ( det->panels[i].dim_structure->dims[di] == HYSL_UNDEFINED ) {
+ if ( det->panels[i].dim_structure->dims[di] ==
+ HYSL_UNDEFINED ) {
dim_dim_reject = 1;
}
- if ( det->panels[i].dim_structure->dims[di] == HYSL_PLACEHOLDER ) {
+ if ( det->panels[i].dim_structure->dims[di] ==
+ HYSL_PLACEHOLDER ) {
panel_dim_dim += 1;
}
- if ( det->panels[i].dim_structure->dims[di] == HYSL_SS ) {
+ if ( det->panels[i].dim_structure->dims[di] ==
+ HYSL_SS ) {
found_ss += 1;
}
- if ( det->panels[i].dim_structure->dims[di] == HYSL_FS ) {
+ if ( det->panels[i].dim_structure->dims[di] ==
+ HYSL_FS ) {
found_fs += 1;
}
@@ -1183,7 +1189,8 @@ struct detector *get_detector_geometry(const char *filename,
}
if ( panel_dim_dim > 1 ) {
- ERROR("Maximum one placeholder dim coordinate is allowed\n");
+ ERROR("Maximum one placeholder dim coordinate is "
+ "allowed\n");
dim_dim_reject = 1;
}
@@ -1269,8 +1276,10 @@ struct detector *get_detector_geometry(const char *filename,
det->panels[i].orig_max_ss = det->panels[i].max_ss;
det->panels[i].orig_min_ss = det->panels[i].min_ss;
- det->panels[i].w = det->panels[i].max_fs-det->panels[i].min_fs+1;
- det->panels[i].h = det->panels[i].max_ss-det->panels[i].min_ss+1;
+ det->panels[i].w =
+ det->panels[i].max_fs-det->panels[i].min_fs+1;
+ det->panels[i].h =
+ det->panels[i].max_ss-det->panels[i].min_ss+1;
det->panels[i].min_fs = 0;
det->panels[i].max_fs = det->panels[i].w-1;
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 41fbc17c..e38ae67b 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -530,7 +530,8 @@ int get_peaks(struct image *image, struct hdfile *f, const char *p,
fs = fs - p->orig_min_fs + p->min_fs;
ss = ss - p->orig_min_ss + p->min_ss;
- image_add_feature(image->features, fs, ss, image, val, NULL);
+ image_add_feature(image->features, fs, ss, image, val,
+ NULL);
}
@@ -807,12 +808,13 @@ static void write_location(hid_t fh, struct image *image,
m_offset[1] = p.min_fs;
m_count[0] = p.max_ss - p.min_ss +1;
m_count[1] = p.max_fs - p.min_fs +1;
+
dimsm[0] = image->height;
dimsm[1] = image->width;
memspace = H5Screate_simple(2, dimsm, NULL);
+
r = H5Sselect_hyperslab(memspace, H5S_SELECT_SET,
m_offset, NULL, m_count, NULL);
-
r = H5Dwrite(dh, H5T_NATIVE_FLOAT, memspace,
dh_dataspace, H5P_DEFAULT, image->data);
if ( r < 0 ) {
@@ -978,15 +980,18 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
write_location(fh, image, &locations[li]);
}
- if ( image->beam->photon_energy_from == NULL ) {
+ if ( image->beam == NULL || image->beam->photon_energy_from == NULL ) {
ph_en_loc = "photon_energy_eV";
} else {
ph_en_loc = image->beam->photon_energy_from;
}
+
write_photon_energy(fh, ph_lambda_to_eV(image->lambda), ph_en_loc);
- if ( image->spectrum_size > 0 ) {
+
+ if ( image->spectrum != NULL && image->spectrum_size > 0 ) {
+
write_spectrum(fh, image->spectrum, image->spectrum_size,
- image->nsamples);
+ image->nsamples);
}
H5Fclose(fh);
@@ -994,8 +999,8 @@ int hdf5_write_image(const char *filename, struct image *image, char *element)
for ( li=0; li<num_locations; li ++ ) {
free(locations[li].panel_idxs);
}
- free(locations);
+ free(locations);
return 0;
}
@@ -2334,7 +2339,8 @@ struct event_list *fill_event_list(struct hdfile *hdfile, struct detector *det)
int fail_add;
- fail_add = add_non_existing_event_to_event_list(master_el,
+ fail_add = add_non_existing_event_to_event_list(
+ master_el,
panel_ev_list->events[ei]);
if ( fail_add ) {
@@ -2380,19 +2386,23 @@ struct event_list *fill_event_list(struct hdfile *hdfile, struct detector *det)
int hsdi;
int panel_path_dim = 0;
- full_panel_path = retrieve_full_path(master_el->events[evi],
- det->panels[pai].data);
+ full_panel_path = retrieve_full_path(
+ master_el->events[evi],
+ det->panels[pai].data);
- dh = H5Dopen2(hdfile->fh, full_panel_path, H5P_DEFAULT);
+ dh = H5Dopen2(hdfile->fh, full_panel_path,
+ H5P_DEFAULT);
sh = H5Dget_space(dh);
dims = H5Sget_simple_extent_ndims(sh);
size = malloc(dims*sizeof(hsize_t));
max_size = malloc(dims*sizeof(hsize_t));
- dims = H5Sget_simple_extent_dims(sh, size, max_size);
+ dims = H5Sget_simple_extent_dims(sh, size,
+ max_size);
- for ( hsdi=0; hsdi<det->panels[pai].dim_structure->num_dims;
+ for ( hsdi=0;
+ hsdi<det->panels[pai].dim_structure->num_dims;
hsdi++ ) {
if (det->panels[pai].dim_structure->dims[hsdi] ==
HYSL_PLACEHOLDER ) {
@@ -2408,8 +2418,8 @@ struct event_list *fill_event_list(struct hdfile *hdfile, struct detector *det)
} else if ( panel_path_dim != global_path_dim ) {
- ERROR("Data blocks paths for panels must have the same "
- "number of placeholders");
+ ERROR("Data blocks paths for panels must "
+ "have the same number of placeholders");
free(size);
free(max_size);
return NULL;
@@ -2424,7 +2434,7 @@ struct event_list *fill_event_list(struct hdfile *hdfile, struct detector *det)
mlwd_ev = copy_event(master_el->events[evi]);
push_dim_entry_to_event(mlwd_ev, mlwd);
append_event_to_event_list(master_el_with_dims,
- mlwd_ev);
+ mlwd_ev);
free(mlwd_ev);
}
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 3cabef96..3dfccea3 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -121,7 +121,8 @@ struct imagefeature *image_feature_closest(ImageFeatureList *flist,
double ds;
struct panel *p2;
- p2 = find_panel(det, flist->features[i].fs, flist->features[i].ss);
+ p2 = find_panel(det, flist->features[i].fs,
+ flist->features[i].ss);
if ( p1 != p2 ) {
continue;
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 6d741d9d..17c0619a 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -59,7 +59,6 @@
#define AT_LEAST_VERSION(st, a, b) ((st->major_version>=(a)) \
&& (st->minor_version>=(b)))
-
struct _stream
{
FILE *fh;
@@ -211,8 +210,8 @@ static int write_peaks(struct image *image, FILE *ofh)
return 1;
}
- /* Convert coordinates to match arrangement of panels in HDF5
- * file */
+ /* Convert coordinates to match arrangement of panels in
+ * HDF5 file */
write_fs = f->fs - p->min_fs + p->orig_min_fs;
write_ss = f->ss - p->min_ss + p->orig_min_ss;
@@ -588,7 +587,8 @@ static int write_stream_reflections_2_2(FILE *fh, RefList *list,
fprintf(fh, "%4i %4i %4i %10.2f %10.2f %10.2f %10.2f"
" %6.1f %6.1f\n",
- h, k, l, intensity, esd_i, pk, bg, write_fs, write_ss);
+ h, k, l, intensity, esd_i, pk, bg, write_fs,
+ write_ss);
} else {
@@ -735,14 +735,19 @@ static int write_crystal(Stream *st, Crystal *cr, int include_reflections)
fprintf(st->fh, REFLECTION_START_MARKER"\n");
if ( AT_LEAST_VERSION(st, 2, 3) ) {
- ret = write_stream_reflections_2_3(st->fh, reflist,
+ ret = write_stream_reflections_2_3(st->fh,
+ reflist,
image);
} else if ( AT_LEAST_VERSION(st, 2, 2) ) {
- ret = write_stream_reflections_2_2(st->fh, reflist, image);
+ ret = write_stream_reflections_2_2(st->fh,
+ reflist,
+ image);
} else {
/* This function writes like a normal reflection
* list was written in stream 2.1 */
- ret = write_stream_reflections_2_1(st->fh, reflist, image);
+ ret = write_stream_reflections_2_1(st->fh,
+ reflist,
+ image);
}
fprintf(st->fh, REFLECTION_END_MARKER"\n");
@@ -983,9 +988,11 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf)
reflist = read_stream_reflections_2_3(st->fh,
image->det);
} else if ( AT_LEAST_VERSION(st, 2, 2) ) {
- reflist = read_stream_reflections_2_2(st->fh, image->det);
+ reflist = read_stream_reflections_2_2(st->fh,
+ image->det);
} else {
- reflist = read_stream_reflections_2_1(st->fh, image->det);
+ reflist = read_stream_reflections_2_1(st->fh,
+ image->det);
}
if ( reflist == NULL ) {
ERROR("Failed while reading reflections\n");
diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c
index d86d70cc..ea15077f 100644
--- a/src/dw-hdfsee.c
+++ b/src/dw-hdfsee.c
@@ -329,7 +329,8 @@ static void maybe_draw_focus(DisplayWindow *dw, cairo_t *cr, int i,
break;
case CALIBMODE_GROUPS:
- if ( dw->image->det->panels[i].rigid_group == dw->calib_mode_curr_rg )
+ if ( dw->image->det->panels[i].rigid_group ==
+ dw->calib_mode_curr_rg )
{
draw_calib_focus_rectangle(cr, basic_m, dw, i);
cairo_stroke(cr);
@@ -1096,8 +1097,8 @@ static void load_features_from_file(struct image *image, const char *filename)
"(no geometry file given?)\n", pn);
} else {
- /* Convert coordinates to match rearranged panels in
- * memory */
+ /* Convert coordinates to match rearranged panels
+ * in memory */
fs = fs - p->orig_min_fs + p->min_fs;
ss = ss - p->orig_min_ss + p->min_ss;
@@ -1847,7 +1848,8 @@ static GtkWidget *displaywindow_addhdfgroup(struct hdfile *hdfile,
item = gtk_menu_item_new_with_label(names[i]);
if ( hdfile_is_scalar(hdfile, names[i], 0) ) {
- tmp = hdfile_get_string_value(hdfile, names[i], NULL);
+ tmp = hdfile_get_string_value(hdfile, names[i],
+ NULL);
} else {
tmp = NULL;
}
diff --git a/src/hdfsee.c b/src/hdfsee.c
index 56f1e6f1..b9394d33 100644
--- a/src/hdfsee.c
+++ b/src/hdfsee.c
@@ -219,7 +219,6 @@ int main(int argc, char *argv[])
case 'g' :
geom_filename = strdup(optarg);
det_geom = get_detector_geometry(geom_filename, &cbeam);
-
if ( det_geom == NULL ) {
ERROR("Failed to read detector geometry "
"from '%s'\n", optarg);