aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hdf5-file.c8
-rw-r--r--src/hdf5-file.h5
-rw-r--r--src/indexamajig.c3
-rw-r--r--src/pattern_sim.c29
4 files changed, 36 insertions, 9 deletions
diff --git a/src/hdf5-file.c b/src/hdf5-file.c
index d8aee21d..130be3a0 100644
--- a/src/hdf5-file.c
+++ b/src/hdf5-file.c
@@ -100,8 +100,8 @@ void hdfile_close(struct hdfile *f)
}
-int hdf5_write(const char *filename, const int16_t *data,
- int width, int height)
+int hdf5_write(const char *filename, const void *data,
+ int width, int height, int type)
{
hid_t fh, gh, sh, dh; /* File, group, dataspace and data handles */
herr_t r;
@@ -127,7 +127,7 @@ int hdf5_write(const char *filename, const int16_t *data,
max_size[1] = height;
sh = H5Screate_simple(2, size, max_size);
- dh = H5Dcreate(gh, "data", H5T_NATIVE_INT16, sh,
+ dh = H5Dcreate(gh, "data", type, sh,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if ( dh < 0 ) {
ERROR("Couldn't create dataset\n");
@@ -138,7 +138,7 @@ int hdf5_write(const char *filename, const int16_t *data,
/* Muppet check */
H5Sget_simple_extent_dims(sh, size, max_size);
- r = H5Dwrite(dh, H5T_NATIVE_UINT16, H5S_ALL,
+ r = H5Dwrite(dh, type, H5S_ALL,
H5S_ALL, H5P_DEFAULT, data);
if ( r < 0 ) {
ERROR("Couldn't write data\n");
diff --git a/src/hdf5-file.h b/src/hdf5-file.h
index e1e9d2a1..455628bd 100644
--- a/src/hdf5-file.h
+++ b/src/hdf5-file.h
@@ -17,14 +17,15 @@
#define HDF5_H
#include <stdint.h>
+#include <hdf5.h>
#include "image.h"
struct hdfile;
-extern int hdf5_write(const char *filename, const int16_t *data,
- int width, int height);
+extern int hdf5_write(const char *filename, const void *data,
+ int width, int height, int type);
extern int hdf5_read(struct hdfile *f, struct image *image);
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 43127e66..daf37fc9 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -264,7 +264,8 @@ int main(int argc, char *argv[])
record_image(&image, 0, 0, 0);
hdf5_write("simulated.h5", image.data,
- image.width, image.height);
+ image.width, image.height,
+ H5T_NATIVE_INT16);
}
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index e3d675d2..eb626f32 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -42,6 +42,7 @@ static void show_help(const char *s)
" --gpu Use the GPU to speed up the calculation.\n"
"\n"
" --near-bragg Output h,k,l,I near Bragg conditions.\n"
+" --powder Output a powder pattern as results/powder.h5.\n"
" -n, --number=<N> Generate N images. Default 1.\n"
" --no-images Do not output any HDF5 files.\n"
" -r, --random-orientation Use a randomly generated orientation\n"
@@ -151,6 +152,7 @@ int main(int argc, char *argv[])
{
int c;
struct image image;
+ long long int *powder;
int config_simdetails = 0;
int config_nearbragg = 0;
int config_randomquat = 0;
@@ -160,6 +162,7 @@ int main(int argc, char *argv[])
int config_nobloom = 0;
int config_nosfac = 0;
int config_gpu = 0;
+ int config_powder = 0;
int ndone = 0; /* Number of simulations done (images or not) */
int number = 1; /* Number used for filename of image */
int n_images = 1; /* Generate one image by default */
@@ -177,7 +180,8 @@ int main(int argc, char *argv[])
{"no-water", 0, &config_nowater, 1},
{"no-noise", 0, &config_nonoise, 1},
{"no-bloom", 0, &config_nobloom, 1},
- {"no-sfac", 0, &config_nosfac, 1},
+ {"no-sfac", 0, &config_nosfac, 1},
+ {"powder", 0, &config_powder, 1},
{0, 0, NULL, 0}
};
@@ -245,6 +249,8 @@ int main(int argc, char *argv[])
image.det.panels[1].cx = 492.0;
image.det.panels[1].cy = 779.7;
+ powder = calloc(image.width*image.height, sizeof(*powder));
+
/* Splurge a few useful numbers */
STATUS("Wavelength is %f nm\n", image.lambda/1.0e-9);
@@ -299,6 +305,25 @@ int main(int argc, char *argv[])
output_intensities(&image, image.molecule->cell);
}
+ if ( config_powder ) {
+
+ int x, y, w;
+
+ w = image.width;
+
+ for ( x=0; x<image.width; x++ ) {
+ for ( y=0; y<image.height; y++ ) {
+ powder[x+w*y] += image.data[x+w*y];
+ }
+ }
+
+ if ( !(ndone % 10) ) {
+ hdf5_write("results/integr-bw.h5", powder,
+ image.width, image.height,
+ H5T_NATIVE_LLONG);
+ }
+ }
+
if ( !config_noimages ) {
char filename[1024];
@@ -308,7 +333,7 @@ int main(int argc, char *argv[])
/* Write the output file */
hdf5_write(filename, image.data,
- image.width, image.height);
+ image.width, image.height, H5T_NATIVE_INT16);
}