aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-02-17 12:48:55 +0100
committerThomas White <taw@bitwiz.org.uk>2014-02-17 12:48:55 +0100
commitb2d65cb9b307a321e88fb5ff88197580ca0c59e4 (patch)
tree0079295d30501835f19161221ec6d84f1ec799f5 /libcrystfel
parent021ddf275adf896de795ffad662f8debc6857317 (diff)
parent7551e70603982392c2b7d9f4287fd431ecccc7c9 (diff)
Merge branch 'master' of ssh://git.bitwiz.org.uk/crystfel
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/hdf5-file.c89
-rw-r--r--libcrystfel/src/image.h3
-rw-r--r--libcrystfel/src/integration.c13
3 files changed, 59 insertions, 46 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index ad9495b5..ed3b1e29 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -384,57 +384,60 @@ int hdf5_write_image(const char *filename, struct image *image)
H5Dclose(dh);
- arr = malloc(image->spectrum_size*sizeof(double));
- if ( arr == NULL ) {
- H5Fclose(fh);
- return 1;
- }
- for ( i=0; i<image->spectrum_size; i++ ) {
- arr[i] = 1.0e10/image->spectrum[i].k;
- }
+ if ( image->spectrum_size > 0 ) {
- size[0] = image->spectrum_size;
- sh = H5Screate_simple(1, size, NULL);
+ arr = malloc(image->spectrum_size*sizeof(double));
+ if ( arr == NULL ) {
+ H5Fclose(fh);
+ return 1;
+ }
+ for ( i=0; i<image->spectrum_size; i++ ) {
+ arr[i] = 1.0e10/image->spectrum[i].k;
+ }
- dh = H5Dcreate2(gh, "spectrum_wavelengths_A", H5T_NATIVE_DOUBLE, sh,
- H5P_DEFAULT, H5S_ALL, H5P_DEFAULT);
- if ( dh < 0 ) {
- H5Fclose(fh);
- return 1;
- }
- r = H5Dwrite(dh, H5T_NATIVE_DOUBLE, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, arr);
- H5Dclose(dh);
+ size[0] = image->spectrum_size;
+ sh = H5Screate_simple(1, size, NULL);
- for ( i=0; i<image->spectrum_size; i++ ) {
- arr[i] = image->spectrum[i].weight;
- }
- dh = H5Dcreate2(gh, "spectrum_weights", H5T_NATIVE_DOUBLE, sh,
- H5P_DEFAULT, H5S_ALL, H5P_DEFAULT);
- if ( dh < 0 ) {
- H5Fclose(fh);
- return 1;
- }
- r = H5Dwrite(dh, H5T_NATIVE_DOUBLE, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, arr);
+ dh = H5Dcreate2(gh, "spectrum_wavelengths_A", H5T_NATIVE_DOUBLE,
+ sh, H5P_DEFAULT, H5S_ALL, H5P_DEFAULT);
+ if ( dh < 0 ) {
+ H5Fclose(fh);
+ return 1;
+ }
+ r = H5Dwrite(dh, H5T_NATIVE_DOUBLE, H5S_ALL,
+ H5S_ALL, H5P_DEFAULT, arr);
+ H5Dclose(dh);
- H5Dclose(dh);
- free(arr);
+ for ( i=0; i<image->spectrum_size; i++ ) {
+ arr[i] = image->spectrum[i].weight;
+ }
+ dh = H5Dcreate2(gh, "spectrum_weights", H5T_NATIVE_DOUBLE, sh,
+ H5P_DEFAULT, H5S_ALL, H5P_DEFAULT);
+ if ( dh < 0 ) {
+ H5Fclose(fh);
+ return 1;
+ }
+ r = H5Dwrite(dh, H5T_NATIVE_DOUBLE, H5S_ALL,
+ H5S_ALL, H5P_DEFAULT, arr);
- size[0] = 1;
- sh = H5Screate_simple(1, size, NULL);
+ H5Dclose(dh);
+ free(arr);
- dh = H5Dcreate2(gh, "number_of_samples", H5T_NATIVE_INT, sh,
- H5P_DEFAULT, H5S_ALL, H5P_DEFAULT);
- if ( dh < 0 ) {
- H5Fclose(fh);
- return 1;
- }
+ size[0] = 1;
+ sh = H5Screate_simple(1, size, NULL);
+
+ dh = H5Dcreate2(gh, "number_of_samples", H5T_NATIVE_INT, sh,
+ H5P_DEFAULT, H5S_ALL, H5P_DEFAULT);
+ if ( dh < 0 ) {
+ H5Fclose(fh);
+ return 1;
+ }
- r = H5Dwrite(dh, H5T_NATIVE_INT, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, &image->nsamples);
+ r = H5Dwrite(dh, H5T_NATIVE_INT, H5S_ALL,
+ H5S_ALL, H5P_DEFAULT, &image->nsamples);
- H5Dclose(dh);
+ H5Dclose(dh);
+ }
H5Gclose(gh);
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 0c189cad..6b49ad91 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -46,7 +46,8 @@
typedef enum {
SPECTRUM_TOPHAT,
- SPECTRUM_SASE
+ SPECTRUM_SASE,
+ SPECTRUM_TWOCOLOUR
} SpectrumType;
/* Structure describing a feature in an image */
diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c
index 1b2193fa..b86399e9 100644
--- a/libcrystfel/src/integration.c
+++ b/libcrystfel/src/integration.c
@@ -3,11 +3,11 @@
*
* Integration of intensities
*
- * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2010-2013 Thomas White <taw@physics.org>
+ * 2010-2014 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -1483,6 +1483,15 @@ static void integrate_prof2d(IntegrationMethod meth, Crystal *cr,
setup_profile_boxes(&ic, list);
calculate_reference_profiles(&ic);
+ for ( i=0; i<ic.n_reference_profiles; i++ ) {
+ if ( ic.n_profiles_in_reference[i] == 0 ) {
+ ERROR("Reference profile %i has no contributions.\n",
+ i);
+ free_intcontext(&ic);
+ return;
+ }
+ }
+
for ( i=0; i<ic.n_boxes; i++ ) {
struct peak_box *bx;
bx = &ic.boxes[i];