Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Oleksii Turkot
CrystFEL
Commits
6563de76
Commit
6563de76
authored
Feb 10, 2010
by
Thomas White
Browse files
Add --powder option for generating powder patterns directly
parent
1b5c5d98
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/hdf5-file.c
View file @
6563de76
...
...
@@ -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
"
);
...
...
src/hdf5-file.h
View file @
6563de76
...
...
@@ -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
);
...
...
src/indexamajig.c
View file @
6563de76
...
...
@@ -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
);
}
...
...
src/pattern_sim.c
View file @
6563de76
...
...
@@ -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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment