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
857cc8c9
Commit
857cc8c9
authored
Nov 12, 2009
by
Thomas White
Browse files
Add 'detector' module
parent
c9a551b8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
857cc8c9
EXTRA_DIST
=
configure src/cell.h src/hdf5-file.h src/image.h src/relrod.h
\
src/utils.h src/diffraction.h
src/utils.h src/diffraction.h
src/detector.h src/ewald.h
SUBDIRS
=
src
src/Makefile.am
View file @
857cc8c9
...
...
@@ -3,5 +3,5 @@ bin_PROGRAMS = pattern_sim
AM_CFLAGS
=
-Wall
-g
@CFLAGS@
pattern_sim_SOURCES
=
main.c diffraction.c utils.c image.c cell.c hdf5-file.c
\
ewald.c
ewald.c
detector.c
pattern_sim_LDADD
=
@LIBS@
src/detector.c
0 → 100644
View file @
857cc8c9
/*
* detector.c
*
* Detector properties
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
* pattern_sim - Simulate diffraction patterns from small crystals
*
*/
#include
<stdlib.h>
#include
<math.h>
#include
<stdio.h>
#include
"image.h"
void
record_image
(
struct
image
*
image
)
{
int
x
,
y
;
image
->
data
=
malloc
(
image
->
width
*
image
->
height
*
sizeof
(
uint16_t
));
for
(
x
=
0
;
x
<
image
->
width
;
x
++
)
{
for
(
y
=
0
;
y
<
image
->
height
;
y
++
)
{
uint16_t
counts
;
double
val
;
double
intensity
;
val
=
image
->
sfacs
[
x
+
image
->
width
*
y
];
intensity
=
pow
(
val
,
2
.
0
);
counts
=
intensity
*
16
;
image
->
data
[
x
+
image
->
width
*
y
]
=
counts
;
}
}
}
src/detector.h
0 → 100644
View file @
857cc8c9
/*
* detector.h
*
* Detector properties
*
* (c) 2007-2009 Thomas White <thomas.white@desy.de>
*
* pattern_sim - Simulate diffraction patterns from small crystals
*
*/
#ifdef HAVE_CONFIG_H
#include
<config.h>
#endif
#ifndef DETECTOR_H
#define DETECTOR_H
#include
"image.h"
extern
void
record_image
(
struct
image
*
image
);
#endif
/* DETECTOR_H */
src/hdf5-file.c
View file @
857cc8c9
...
...
@@ -22,7 +22,7 @@
#include
"image.h"
int
hdf5_write
(
const
char
*
filename
,
const
double
*
data
,
int
hdf5_write
(
const
char
*
filename
,
const
uint16_t
*
data
,
int
width
,
int
height
)
{
hid_t
fh
,
gh
,
sh
,
dh
;
/* File, group, dataspace and data handles */
...
...
@@ -49,7 +49,7 @@ int hdf5_write(const char *filename, const double *data,
max_size
[
1
]
=
height
;
sh
=
H5Screate_simple
(
2
,
size
,
max_size
);
dh
=
H5Dcreate
(
gh
,
"data"
,
H5T_NATIVE_
FLOAT
,
sh
,
dh
=
H5Dcreate
(
gh
,
"data"
,
H5T_NATIVE_
UINT16
,
sh
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
if
(
dh
<
0
)
{
fprintf
(
stderr
,
"Couldn't create dataset
\n
"
);
...
...
@@ -63,7 +63,7 @@ int hdf5_write(const char *filename, const double *data,
(
int
)
size
[
1
],
(
int
)
size
[
0
],
(
int
)
max_size
[
1
],
(
int
)
max_size
[
0
]);
r
=
H5Dwrite
(
dh
,
H5T_NATIVE_
DOUBLE
,
H5S_ALL
,
r
=
H5Dwrite
(
dh
,
H5T_NATIVE_
UINT16
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
data
);
if
(
r
<
0
)
{
fprintf
(
stderr
,
"Couldn't write data
\n
"
);
...
...
src/hdf5-file.h
View file @
857cc8c9
...
...
@@ -18,7 +18,7 @@
#include
<stdint.h>
extern
int
hdf5_write
(
const
char
*
filename
,
const
double
*
data
,
extern
int
hdf5_write
(
const
char
*
filename
,
const
uint16_t
*
data
,
int
width
,
int
height
);
extern
int
hdf5_read
(
struct
image
*
image
,
const
char
*
filename
);
...
...
src/main.c
View file @
857cc8c9
...
...
@@ -23,6 +23,7 @@
#include
"cell.h"
#include
"utils.h"
#include
"hdf5-file.h"
#include
"detector.h"
/* Crystal size in metres */
...
...
@@ -80,9 +81,10 @@ int main(int argc, char *argv[])
image
.
data
=
NULL
;
get_diffraction
(
&
image
,
cell
);
record_image
(
&
image
);
/* Write the output file */
hdf5_write
(
"results/sim.h5"
,
image
.
sfacs
,
image
.
width
,
image
.
height
);
hdf5_write
(
"results/sim.h5"
,
image
.
data
,
image
.
width
,
image
.
height
);
return
0
;
}
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