diff options
author | Thomas White <taw@physics.org> | 2014-02-12 15:18:36 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-02-12 15:18:36 +0100 |
commit | cae96eaf563f6698b69e142cbf19da0f2888b2bb (patch) | |
tree | 7a152c89df7ceb0effc605ccd036ab1ac5edf0a8 /libcrystfel/src/hdf5-file.c | |
parent | 9065eba92208feb5d0ea0f64e0b5ff353d932dc2 (diff) |
partial_sim: Add --images
Diffstat (limited to 'libcrystfel/src/hdf5-file.c')
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 89 |
1 files changed, 46 insertions, 43 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); |