Skip to content
GitLab
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
1a206036
Commit
1a206036
authored
Feb 06, 2011
by
Thomas White
Committed by
Thomas White
Feb 22, 2012
Browse files
Start work on binary tree
parent
155ca006
Changes
17
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
1a206036
...
...
@@ -23,7 +23,7 @@ src_pattern_sim_SOURCES = src/pattern_sim.c src/diffraction.c src/utils.c \
src/image.c src/cell.c src/hdf5-file.c
\
src/detector.c src/sfac.c src/peaks.c
\
src/reflections.c src/beam-parameters.c
\
src/symmetry.c src/thread-pool.c
src/symmetry.c src/thread-pool.c
src/reflist.c
if
HAVE_OPENCL
src_pattern_sim_SOURCES
+=
src/diffraction-gpu.c src/cl-utils.c
endif
...
...
@@ -38,7 +38,8 @@ src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c src/utils.c \
src/filters.c src/diffraction.c src/detector.c
\
src/sfac.c src/dirax.c src/mosflm.c
\
src/reflections.c src/templates.c src/symmetry.c
\
src/geometry.c src/thread-pool.c src/beam-parameters.c
src/geometry.c src/thread-pool.c
\
src/beam-parameters.c src/reflist.c
if
HAVE_OPENCL
src_indexamajig_SOURCES
+=
src/diffraction-gpu.c src/cl-utils.c
endif
...
...
@@ -73,14 +74,14 @@ src_render_hkl_SOURCES = src/render_hkl.c src/cell.c src/reflections.c \
src_calibrate_detector_SOURCES
=
src/calibrate_detector.c src/utils.c
\
src/hdf5-file.c src/image.c src/filters.c
\
src/peaks.c src/detector.c src/cell.c
\
src/thread-pool.c
src/thread-pool.c
src/reflist.c
src_partialator_SOURCES
=
src/partialator.c src/cell.c src/hdf5-file.c
\
src/utils.c src/detector.c src/peaks.c src/image.c
\
src/geometry.c src/reflections.c src/stream.c
\
src/thread-pool.c src/beam-parameters.c
\
src/symmetry.c src/post-refinement.c
\
src/hrs-scaling.c
src/hrs-scaling.c
src/reflist.c
if
HAVE_CAIRO
src_cubeit_SOURCES
=
src/cubeit.c src/cell.c src/hdf5-file.c src/utils.c
\
...
...
Makefile.in
View file @
1a206036
...
...
@@ -83,7 +83,7 @@ am_src_calibrate_detector_OBJECTS = src/calibrate_detector.$(OBJEXT) \
src/utils.
$(OBJEXT)
src/hdf5-file.
$(OBJEXT)
\
src/image.
$(OBJEXT)
src/filters.
$(OBJEXT)
src/peaks.
$(OBJEXT)
\
src/detector.
$(OBJEXT)
src/cell.
$(OBJEXT)
\
src/thread-pool.
$(OBJEXT)
src/thread-pool.
$(OBJEXT)
src/reflist.
$(OBJEXT)
src_calibrate_detector_OBJECTS
=
$(am_src_calibrate_detector_OBJECTS)
src_calibrate_detector_LDADD
=
$(LDADD)
src_calibrate_detector_DEPENDENCIES
=
$(top_builddir)
/lib/libgnu.a
...
...
@@ -145,7 +145,8 @@ am__src_indexamajig_SOURCES_DIST = src/indexamajig.c src/hdf5-file.c \
src/filters.c src/diffraction.c src/detector.c src/sfac.c
\
src/dirax.c src/mosflm.c src/reflections.c src/templates.c
\
src/symmetry.c src/geometry.c src/thread-pool.c
\
src/beam-parameters.c src/diffraction-gpu.c src/cl-utils.c
src/beam-parameters.c src/reflist.c src/diffraction-gpu.c
\
src/cl-utils.c
@HAVE_OPENCL_TRUE@
am__objects_1
=
src/diffraction-gpu.
$(OBJEXT)
\
@HAVE_OPENCL_TRUE@ src/cl-utils.
$(OBJEXT)
am_src_indexamajig_OBJECTS
=
src/indexamajig.
$(OBJEXT)
\
...
...
@@ -156,7 +157,8 @@ am_src_indexamajig_OBJECTS = src/indexamajig.$(OBJEXT) \
src/mosflm.
$(OBJEXT)
src/reflections.
$(OBJEXT)
\
src/templates.
$(OBJEXT)
src/symmetry.
$(OBJEXT)
\
src/geometry.
$(OBJEXT)
src/thread-pool.
$(OBJEXT)
\
src/beam-parameters.
$(OBJEXT)
$(am__objects_1)
src/beam-parameters.
$(OBJEXT)
src/reflist.
$(OBJEXT)
\
$(am__objects_1)
src_indexamajig_OBJECTS
=
$(am_src_indexamajig_OBJECTS)
src_indexamajig_LDADD
=
$(LDADD)
src_indexamajig_DEPENDENCIES
=
$(top_builddir)
/lib/libgnu.a
...
...
@@ -166,7 +168,8 @@ am_src_partialator_OBJECTS = src/partialator.$(OBJEXT) \
src/geometry.
$(OBJEXT)
src/reflections.
$(OBJEXT)
\
src/stream.
$(OBJEXT)
src/thread-pool.
$(OBJEXT)
\
src/beam-parameters.
$(OBJEXT)
src/symmetry.
$(OBJEXT)
\
src/post-refinement.
$(OBJEXT)
src/hrs-scaling.
$(OBJEXT)
src/post-refinement.
$(OBJEXT)
src/hrs-scaling.
$(OBJEXT)
\
src/reflist.
$(OBJEXT)
src_partialator_OBJECTS
=
$(am_src_partialator_OBJECTS)
src_partialator_LDADD
=
$(LDADD)
src_partialator_DEPENDENCIES
=
$(top_builddir)
/lib/libgnu.a
...
...
@@ -174,14 +177,14 @@ am__src_pattern_sim_SOURCES_DIST = src/pattern_sim.c src/diffraction.c \
src/utils.c src/image.c src/cell.c src/hdf5-file.c
\
src/detector.c src/sfac.c src/peaks.c src/reflections.c
\
src/beam-parameters.c src/symmetry.c src/thread-pool.c
\
src/diffraction-gpu.c src/cl-utils.c
src/reflist.c
src/diffraction-gpu.c src/cl-utils.c
am_src_pattern_sim_OBJECTS
=
src/pattern_sim.
$(OBJEXT)
\
src/diffraction.
$(OBJEXT)
src/utils.
$(OBJEXT)
\
src/image.
$(OBJEXT)
src/cell.
$(OBJEXT)
src/hdf5-file.
$(OBJEXT)
\
src/detector.
$(OBJEXT)
src/sfac.
$(OBJEXT)
src/peaks.
$(OBJEXT)
\
src/reflections.
$(OBJEXT)
src/beam-parameters.
$(OBJEXT)
\
src/symmetry.
$(OBJEXT)
src/thread-pool.
$(OBJEXT)
\
$(am__objects_1)
src/reflist.
$(OBJEXT)
$(am__objects_1)
src_pattern_sim_OBJECTS
=
$(am_src_pattern_sim_OBJECTS)
src_pattern_sim_LDADD
=
$(LDADD)
src_pattern_sim_DEPENDENCIES
=
$(top_builddir)
/lib/libgnu.a
...
...
@@ -564,7 +567,7 @@ src_pattern_sim_SOURCES = src/pattern_sim.c src/diffraction.c \
src/utils.c src/image.c src/cell.c src/hdf5-file.c
\
src/detector.c src/sfac.c src/peaks.c src/reflections.c
\
src/beam-parameters.c src/symmetry.c src/thread-pool.c
\
$(am__append_3)
src/reflist.c
$(am__append_3)
src_process_hkl_SOURCES
=
src/process_hkl.c src/sfac.c src/statistics.c
\
src/cell.c src/utils.c src/reflections.c
\
src/symmetry.c src/stream.c src/beam-parameters.c
\
...
...
@@ -575,7 +578,7 @@ src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c \
src/filters.c src/diffraction.c src/detector.c src/sfac.c
\
src/dirax.c src/mosflm.c src/reflections.c src/templates.c
\
src/symmetry.c src/geometry.c src/thread-pool.c
\
src/beam-parameters.c
$(am__append_4)
src/beam-parameters.c
src/reflist.c
$(am__append_4)
@HAVE_GTK_TRUE@
src_hdfsee_SOURCES
=
src/hdfsee.c src/displaywindow.c src/render.c
\
@HAVE_GTK_TRUE@ src/hdf5-file.c src/utils.c src/image.c src/filters.c
\
@HAVE_GTK_TRUE@ src/thread-pool.c
...
...
@@ -603,14 +606,14 @@ src_render_hkl_SOURCES = src/render_hkl.c src/cell.c src/reflections.c \
src_calibrate_detector_SOURCES
=
src/calibrate_detector.c src/utils.c
\
src/hdf5-file.c src/image.c src/filters.c
\
src/peaks.c src/detector.c src/cell.c
\
src/thread-pool.c
src/thread-pool.c
src/reflist.c
src_partialator_SOURCES
=
src/partialator.c src/cell.c src/hdf5-file.c
\
src/utils.c src/detector.c src/peaks.c src/image.c
\
src/geometry.c src/reflections.c src/stream.c
\
src/thread-pool.c src/beam-parameters.c
\
src/symmetry.c src/post-refinement.c
\
src/hrs-scaling.c
src/hrs-scaling.c
src/reflist.c
@HAVE_CAIRO_TRUE@
src_cubeit_SOURCES
=
src/cubeit.c src/cell.c src/hdf5-file.c src/utils.c
\
@HAVE_CAIRO_TRUE@ src/detector.c src/render.c src/filters.c src/image.c
\
...
...
@@ -770,6 +773,8 @@ src/detector.$(OBJEXT): src/$(am__dirstamp) \
src/cell.$(OBJEXT)
:
src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
src/thread-pool.$(OBJEXT)
:
src/$(am__dirstamp)
\
src/$(DEPDIR)/$(am__dirstamp)
src/reflist.$(OBJEXT)
:
src/$(am__dirstamp)
\
src/$(DEPDIR)/$(am__dirstamp)
src/calibrate_detector$(EXEEXT)
:
$(src_calibrate_detector_OBJECTS) $(src_calibrate_detector_DEPENDENCIES) src/$(am__dirstamp)
@
rm
-f
src/calibrate_detector
$(EXEEXT)
$(AM_V_CCLD)$(LINK)
$(src_calibrate_detector_OBJECTS)
$(src_calibrate_detector_LDADD)
$(LIBS)
...
...
@@ -907,6 +912,7 @@ mostlyclean-compile:
-
rm
-f
src/powder_plot.
$(OBJEXT)
-
rm
-f
src/process_hkl.
$(OBJEXT)
-
rm
-f
src/reflections.
$(OBJEXT)
-
rm
-f
src/reflist.
$(OBJEXT)
-
rm
-f
src/reintegrate.
$(OBJEXT)
-
rm
-f
src/render.
$(OBJEXT)
-
rm
-f
src/render_hkl.
$(OBJEXT)
...
...
@@ -952,6 +958,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/powder_plot.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/process_hkl.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/reflections.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/reflist.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/reintegrate.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/render.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@src/$(DEPDIR)/render_hkl.Po@am__quote@
...
...
src/calibrate_detector.c
View file @
1a206036
...
...
@@ -168,8 +168,7 @@ static void add_image(void *args, int cookie)
image
.
flags
=
NULL
;
image
.
indexed_cell
=
NULL
;
image
.
filename
=
pargs
->
filename
;
image
.
cpeaks
=
NULL
;
image
.
n_cpeaks
=
0
;
image
.
reflections
=
NULL
;
image
.
det
=
NULL
;
STATUS
(
"%3i: Processing '%s'
\n
"
,
cookie
,
pargs
->
filename
);
...
...
src/cubeit.c
View file @
1a206036
...
...
@@ -218,8 +218,7 @@ static void sum_image(void *pg, int cookie)
image
.
flags
=
NULL
;
image
.
indexed_cell
=
NULL
;
image
.
filename
=
apargs
->
filename
;
image
.
cpeaks
=
NULL
;
image
.
n_cpeaks
=
0
;
image
.
reflections
=
NULL
;
image
.
det
=
pargs
->
det
;
STATUS
(
"Processing '%s'
\n
"
,
apargs
->
filename
);
...
...
src/geometry.c
View file @
1a206036
...
...
@@ -22,6 +22,7 @@
#include
"image.h"
#include
"peaks.h"
#include
"beam-parameters.h"
#include
"reflist.h"
#define MAX_CPEAKS (256 * 256)
...
...
@@ -117,7 +118,7 @@ static double partiality(double r1, double r2, double r)
static
int
check_reflection
(
struct
image
*
image
,
double
mres
,
int
output
,
struct
cpeak
*
cpeaks
,
int
np
,
RefList
*
reflections
,
signed
int
h
,
signed
int
k
,
signed
int
l
,
double
asx
,
double
asy
,
double
asz
,
double
bsx
,
double
bsy
,
double
bsz
,
...
...
@@ -136,6 +137,7 @@ static int check_reflection(struct image *image, double mres, int output,
double
divergence
=
image
->
div
;
double
lambda
=
image
->
lambda
;
double
klow
,
kcen
,
khigh
;
/* Wavenumber */
Reflection
*
refl
;
/* "low" gives the largest Ewald sphere,
* "high" gives the smallest Ewald sphere. */
...
...
@@ -207,17 +209,9 @@ static int check_reflection(struct image *image, double mres, int output,
if
(
p
==
-
1
)
return
0
;
/* Add peak to list */
cpeaks
[
np
].
h
=
h
;
cpeaks
[
np
].
k
=
k
;
cpeaks
[
np
].
l
=
l
;
cpeaks
[
np
].
x
=
xda
;
cpeaks
[
np
].
y
=
yda
;
cpeaks
[
np
].
r1
=
rlow
;
cpeaks
[
np
].
r2
=
rhigh
;
cpeaks
[
np
].
p
=
part
;
cpeaks
[
np
].
clamp1
=
clamp_low
;
cpeaks
[
np
].
clamp2
=
clamp_high
;
np
++
;
refl
=
add_refl
(
reflections
,
h
,
k
,
l
);
set_detector_pos
(
refl
,
0
.
0
,
xda
,
yda
);
set_partial
(
refl
,
rlow
,
rhigh
,
part
,
clamp_low
,
clamp_high
);
if
(
output
)
{
printf
(
"%3i %3i %3i %6f (at %5.2f,%5.2f) %5.2f
\n
"
,
...
...
@@ -228,23 +222,18 @@ static int check_reflection(struct image *image, double mres, int output,
}
struct
cpeak
*
find_intersections
(
struct
image
*
image
,
UnitCell
*
cell
,
int
*
n
,
int
output
)
RefList
*
find_intersections
(
struct
image
*
image
,
UnitCell
*
cell
,
int
output
)
{
double
asx
,
asy
,
asz
;
double
bsx
,
bsy
,
bsz
;
double
csx
,
csy
,
csz
;
struct
cpeak
*
cpeaks
;
int
np
=
0
;
RefList
*
reflections
;
int
hmax
,
kmax
,
lmax
;
double
mres
;
signed
int
h
,
k
,
l
;
cpeaks
=
malloc
(
sizeof
(
struct
cpeak
)
*
MAX_CPEAKS
);
if
(
cpeaks
==
NULL
)
{
*
n
=
0
;
return
NULL
;
}
reflections
=
reflist_new
();
cell_get_reciprocal
(
cell
,
&
asx
,
&
asy
,
&
asz
,
&
bsx
,
&
bsy
,
&
bsz
,
...
...
@@ -260,29 +249,30 @@ struct cpeak *find_intersections(struct image *image, UnitCell *cell,
for
(
l
=-
lmax
;
l
<
lmax
;
l
++
)
{
/* Ignore central beam */
if
(
(
h
==
0
)
&&
(
k
==
0
)
&&
(
l
==
0
)
)
continue
;
np
+=
check_reflection
(
image
,
mres
,
output
,
cpeaks
,
np
,
h
,
k
,
l
,
asx
,
asy
,
asz
,
bsx
,
bsy
,
bsz
,
csx
,
csy
,
csz
);
if
(
np
==
MAX_CPEAKS
)
goto
out
;
check_reflection
(
image
,
mres
,
output
,
reflections
,
h
,
k
,
l
,
asx
,
asy
,
asz
,
bsx
,
bsy
,
bsz
,
csx
,
csy
,
csz
);
}
}
}
out:
*
n
=
np
;
return
cpeaks
;
return
reflections
;
}
double
integrate_all
(
struct
image
*
image
,
struct
cpeak
*
cpeaks
,
int
n
)
double
integrate_all
(
struct
image
*
image
,
RefList
*
reflections
)
{
double
itot
=
0
.
0
;
int
i
;
Reflection
*
refl
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
refl
=
first_refl
(
reflections
);
refl
!=
NULL
;
refl
=
next_refl
(
refl
)
)
{
float
x
,
y
,
intensity
;
double
xp
,
yp
;
get_detector_pos
(
refl
,
&
xp
,
&
yp
);
if
(
integrate_peak
(
image
,
cpeaks
[
i
].
x
,
cpeaks
[
i
].
y
,
&
x
,
&
y
,
if
(
integrate_peak
(
image
,
xp
,
yp
,
&
x
,
&
y
,
&
intensity
,
NULL
,
NULL
,
0
,
0
)
)
continue
;
itot
+=
intensity
;
...
...
src/geometry.h
View file @
1a206036
...
...
@@ -17,10 +17,12 @@
#include
<config.h>
#endif
extern
struct
cpeak
*
find_intersections
(
struct
image
*
image
,
UnitCell
*
cell
,
int
*
n
,
int
output
);
#include
"reflist.h"
extern
double
integrate_all
(
struct
image
*
image
,
struct
cpeak
*
cpeaks
,
int
n
);
extern
RefList
*
find_intersections
(
struct
image
*
image
,
UnitCell
*
cell
,
int
output
);
extern
double
integrate_all
(
struct
image
*
image
,
RefList
*
reflections
);
#endif
/* GEOMETRY_H */
src/image.h
View file @
1a206036
...
...
@@ -24,6 +24,7 @@
#include
"utils.h"
#include
"cell.h"
#include
"detector.h"
#include
"reflist.h"
#define MAX_CELL_CANDIDATES (32)
...
...
@@ -52,35 +53,6 @@ struct imagefeature {
typedef
struct
_imagefeaturelist
ImageFeatureList
;
/* This structure represents a predicted peak in an image */
struct
cpeak
{
/* Indices */
signed
int
h
;
signed
int
k
;
signed
int
l
;
double
min_distance
;
int
valid
;
/* Partiality */
double
r1
;
/* First excitation error */
double
r2
;
/* Second excitation error */
double
p
;
/* Partiality */
int
clamp1
;
/* Clamp status for r1 */
int
clamp2
;
/* Clamp status for r2 */
/* Location in image */
int
x
;
int
y
;
int
scalable
;
/* Intensity */
double
intensity
;
};
/* Structure describing an image */
struct
image
{
...
...
@@ -93,8 +65,7 @@ struct image {
struct
detector
*
det
;
struct
beam_params
*
beam
;
/* The nominal beam parameters */
char
*
filename
;
struct
cpeak
*
cpeaks
;
int
n_cpeaks
;
RefList
*
reflections
;
int
id
;
/* ID number of the thread
* handling this image */
...
...
src/indexamajig.c
View file @
1a206036
...
...
@@ -263,8 +263,7 @@ static struct image *get_simage(struct image *template, int alternate)
image
->
f0
=
template
->
f0
;
/* Prevent muppetry */
image
->
cpeaks
=
NULL
;
image
->
n_cpeaks
=
0
;
image
->
reflections
=
NULL
;
return
image
;
}
...
...
@@ -326,8 +325,7 @@ static void process_image(void *pp, int cookie)
image
.
indexed_cell
=
NULL
;
image
.
id
=
cookie
;
image
.
filename
=
filename
;
image
.
cpeaks
=
NULL
;
image
.
n_cpeaks
=
0
;
image
.
reflections
=
NULL
;
image
.
det
=
pargs
->
static_args
.
det
;
STATUS
(
"Processing '%s'
\n
"
,
image
.
filename
);
...
...
@@ -434,7 +432,7 @@ done:
free
(
image
.
data
);
free
(
image
.
flags
);
image_feature_list_free
(
image
.
features
);
free
(
image
.
cpeak
s
);
reflist_
free
(
image
.
reflection
s
);
hdfile_close
(
hdfile
);
}
...
...
src/partialator.c
View file @
1a206036
...
...
@@ -34,6 +34,7 @@
#include
"beam-parameters.h"
#include
"post-refinement.h"
#include
"hrs-scaling.h"
#include
"reflist.h"
/* Maximum number of iterations of NLSq to do for each image per macrocycle. */
...
...
@@ -84,9 +85,9 @@ static void refine_image(int mytask, void *tasks)
struct
image
*
image
=
pargs
->
image
;
double
nominal_photon_energy
=
pargs
->
image
->
beam
->
photon_energy
;
struct
hdfile
*
hdfile
;
struct
cpeak
*
spots
;
int
n
,
i
;
int
i
;
double
dev
,
last_dev
;
RefList
*
reflections
;
hdfile
=
hdfile_open
(
image
->
filename
);
if
(
hdfile
==
NULL
)
{
...
...
@@ -110,16 +111,17 @@ static void refine_image(int mytask, void *tasks)
a
/
1.0e-9
,
b
/
1.0e-9
,
c
/
1.0e-9
,
rad2deg
(
al
),
rad2deg
(
be
),
rad2deg
(
ga
));
spots
=
find_intersections
(
image
,
image
->
indexed_cell
,
&
n
,
0
);
/* FIXME: Don't do this each time */
reflections
=
find_intersections
(
image
,
image
->
indexed_cell
,
0
);
dev
=
+
INFINITY
;
i
=
0
;
do
{
last_dev
=
dev
;
dev
=
pr_iterate
(
image
,
pargs
->
i_full
,
pargs
->
sym
,
&
spots
,
&
n
);
dev
=
pr_iterate
(
image
,
pargs
->
i_full
,
pargs
->
sym
,
reflections
);
STATUS
(
"Iteration %2i: mean dev = %5.2f
\n
"
,
i
,
dev
);
i
++
;
}
while
(
(
fabs
(
last_dev
-
dev
)
>
1
.
0
)
&&
(
i
<
MAX_CYCLES
)
);
mean_partial_dev
(
image
,
spots
,
n
,
pargs
->
sym
,
mean_partial_dev
(
image
,
reflections
,
pargs
->
sym
,
pargs
->
i_full
,
pargs
->
graph
);
if
(
pargs
->
pgraph
)
{
fprintf
(
pargs
->
pgraph
,
"%5i %5.2f
\n
"
,
mytask
,
dev
);
...
...
@@ -128,7 +130,7 @@ static void refine_image(int mytask, void *tasks)
free
(
image
->
data
);
if
(
image
->
flags
!=
NULL
)
free
(
image
->
flags
);
hdfile_close
(
hdfile
);
free
(
spot
s
);
reflist_free
(
reflection
s
);
/* Muppet proofing */
image
->
data
=
NULL
;
...
...
@@ -163,22 +165,23 @@ static void refine_all(struct image *images, int n_total_patterns,
}
static
void
uniquify
(
struct
cpeak
*
spot
,
const
char
*
sym
)
static
void
uniquify
(
Reflection
*
refl
,
const
char
*
sym
)
{
signed
int
h
,
k
,
l
;
signed
int
ha
,
ka
,
la
;
get_asymm
(
spot
->
h
,
spot
->
k
,
spot
->
l
,
&
ha
,
&
ka
,
&
la
,
sym
);
spot
->
h
=
ha
;
spot
->
k
=
ka
;
spot
->
l
=
la
;
get_indices
(
refl
,
&
h
,
&
k
,
&
l
);
get_asymm
(
h
,
k
,
l
,
&
ha
,
&
ka
,
&
la
,
sym
);
set_indices
(
refl
,
h
,
k
,
l
);
}
/* FIXME: Get rid of this */
static
void
integrate_image
(
struct
image
*
image
,
ReflItemList
*
obs
,
const
char
*
sym
)
{
struct
cpeak
*
spot
s
;
int
j
,
n
;
RefList
*
reflection
s
;
Reflection
*
refl
;
struct
hdfile
*
hdfile
;
double
nominal_photon_energy
=
image
->
beam
->
photon_energy
;
...
...
@@ -199,42 +202,39 @@ static void integrate_image(struct image *image, ReflItemList *obs,
}
/* Figure out which spots should appear in this pattern */
spot
s
=
find_intersections
(
image
,
image
->
indexed_cell
,
&
n
,
0
);
reflection
s
=
find_intersections
(
image
,
image
->
indexed_cell
,
0
);
/* For each reflection, estimate the partiality */
for
(
j
=
0
;
j
<
n
;
j
++
)
{
for
(
refl
=
first_refl
(
reflections
);
refl
!=
NULL
;
refl
=
next_refl
(
refl
)
)
{
signed
int
h
,
k
,
l
;
float
i_partial
;
float
xc
,
yc
;
double
x
,
y
;
uniquify
(
&
spots
[
j
],
sym
);
h
=
spots
[
j
].
h
;
k
=
spots
[
j
].
k
;
l
=
spots
[
j
].
l
;
uniquify
(
refl
,
sym
);
get_indices
(
refl
,
&
h
,
&
k
,
&
l
);
/* Don't attempt to use spots with very small
* partialities, since it won't be accurate. */
if
(
spots
[
j
].
p
<
0
.
1
)
continue
;
if
(
get_partiality
(
refl
)
<
0
.
1
)
continue
;
/* Actual measurement of this reflection from this
* pattern? */
/* FIXME: Coordinates aren't whole numbers */
if
(
integrate_peak
(
image
,
spots
[
j
].
x
,
spots
[
j
].
y
,
/* Actual measurement of this reflection from this pattern? */
get_detector_pos
(
refl
,
&
x
,
&
y
);
if
(
integrate_peak
(
image
,
x
,
y
,
&
xc
,
&
yc
,
&
i_partial
,
NULL
,
NULL
,
1
,
0
)
)
{
spots
[
j
].
valid
=
0
;
delete_refl
(
refl
)
;
continue
;
}
spots
[
j
].
intensity
=
i_partial
;
spots
[
j
].
valid
=
1
;
set_int
(
refl
,
i_partial
);
if
(
!
find_item
(
obs
,
h
,
k
,
l
)
)
add_item
(
obs
,
h
,
k
,
l
);
}
image
->
cpeaks
=
spots
;
image
->
n_cpeaks
=
n
;
image
->
reflections
=
reflections
;
free
(
image
->
data
);
if
(
image
->
flags
!=
NULL
)
free
(
image
->
flags
);
...
...
@@ -253,21 +253,20 @@ static void select_scalable_reflections(struct image *images, int n)
for
(
m
=
0
;
m
<
n
;
m
++
)
{
int
j
;
Reflection
*
refl
;
for
(
j
=
0
;
j
<
images
[
m
].
n_cpeaks
;
j
++
)
{
for
(
refl
=
first_refl
(
images
[
m
].
reflections
);
refl
!=
NULL
;
refl
=
next_refl
(
refl
)
)
{
int
scalable
=
1
;
double
v
;
if
(
images
[
m
].
cpeaks
[
j
].
p
<
0
.
1
)
scalable
=
0
;
if
(
!
images
[
m
].
cpeaks
[
j
].
valid
)
{
scalable
=
0
;
}
else
{
double
v
=
fabs
(
images
[
m
].
cpeaks
[
j
].
intensity
);
if
(
v
<
0
.
1
)
scalable
=
0
;
}
if
(
get_partiality
(
refl
)
<
0
.
1
)
scalable
=
0
;
v
=
fabs
(
get_intensity
(
refl
));
if
(
v
<
0
.
1
)
scalable
=
0
;
images
[
m
].
cpeaks
[
j
].
scalable
=
scalable
;
set_
scalable
(
refl
,
scalable
)
;
}
...
...
@@ -525,7 +524,7 @@ int main(int argc, char *argv[])
/* Clean up */
for
(
i
=
0
;
i
<
n_total_patterns
;
i
++
)
{
free
(
images
[
i
].
cpeak
s
);
reflist_
free
(
images
[
i
].
reflection
s
);
}
free
(
I_full
);
delete_items
(
obs
);
...
...
src/pattern_sim.c
View file @
1a206036
...
...
@@ -567,7 +567,7 @@ int main(int argc, char *argv[])
find_projected_peaks
(
&
image
,
cell
,
0
,
0
.
1
);
output_intensities
(
&
image
,
cell
,
NULL
,
0
,
0
,
stdout
,
0
,
0
.
1
);
free
(
image
.
cpeak
s
);
reflist_
free
(
image
.
reflection
s
);
}
if
(
powder_fn
!=
NULL
)
{
...
...
src/peaks.c
View file @
1a206036
...
...
@@ -32,9 +32,6 @@
#include
"diffraction.h"
/* Maximum number of peaks which may be predicted by find_projected_peaks() */
#define MAX_CPEAKS (8192)
/* How close a peak must be to an indexed position to be considered "close"
* for the purposes of double hit detection and sanity checking. */
#define PEAK_CLOSE (30.0)
...
...
@@ -483,12 +480,11 @@ int find_projected_peaks(struct image *image, UnitCell *cell,
double
ax
,
ay
,
az
;
double
bx
,
by
,
bz
;
double
cx
,
cy
,
cz
;
struct
cpeak
*
cpeaks
;
int
n_cpeaks
=
0
;
RefList
*
reflections
;
double
alen
,
blen
,
clen
;
int
n_reflections
=
0
;
cpeaks
=
malloc
(
sizeof
(
struct
cpeak
)
*
MAX_CPEAKS
);
if
(
cpeaks
==
NULL
)
return
0
;
reflections
=
reflist_new
();
/* "Borrow" direction values to get reciprocal lengths */
cell_get_reciprocal
(
cell
,
&
ax
,
&
ay
,
&
az
,
&
bx
,
&
by
,
&
bz
,
&
cx
,
&
cy
,
&
cz
);
...
...
@@ -507,8 +503,8 @@ int find_projected_peaks(struct image *image, UnitCell *cell,
signed
int
h
,
k
,
l
;
struct
rvec
q
;
double
dist
;
int
found
=
0
;
int
j
;
Reflection
*
refl
;
double
cur_dist
;
q
=
get_q
(
image
,
x
,
y
,
1
,
NULL
,
1
.
0
/
image
->
lambda
);
...
...
@@ -535,44 +531,26 @@ int find_projected_peaks(struct image *image, UnitCell *cell,
if
(
dist
>
domain_r
)
continue
;
}
for
(
j
=
0
;
j
<
n_cpeaks
;
j
++
)
{
if
(
(
cpeaks
[
j
].
h
==
h
)
&&
(
cpeaks
[
j
].
k
==
k
)
&&
(
cpeaks
[
j
].
l
==
l
)
)
{
if
(
dist
<
cpeaks
[
j
].
min_distance
)
{
cpeaks
[
j
].
min_distance
=
dist
;
cpeaks
[
j
].
x
=
x
;
cpeaks
[
j
].
y
=
y
;
}
found
=
1
;
}
}
if
(
!
found
)
{
cpeaks
[
n_cpeaks
].
min_distance
=
dist
;
cpeaks
[
n_cpeaks
].
x
=
x
;
cpeaks
[
n_cpeaks
].
y
=
y
;