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
ca7215bc
Commit
ca7215bc
authored
Apr 16, 2010
by
Thomas White
Browse files
Push output stream mutex down, and improve output of --near-bragg and --dump-peaks
parent
d0ef10cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/indexamajig.c
View file @
ca7215bc
...
...
@@ -189,6 +189,7 @@ static struct image *get_simage(struct image *template, int alternate)
image
->
lambda
=
ph_en_to_lambda
(
eV_to_J
(
1.8e3
));
image
->
features
=
template
->
features
;
image
->
filename
=
template
->
filename
;
image
->
indexed_cell
=
template
->
indexed_cell
;
return
image
;
}
...
...
@@ -296,7 +297,7 @@ static void *process_image(void *pargsv)
search_peaks
(
&
image
);
if
(
image_feature_count
(
image
.
features
)
<
5
)
goto
done
;
if
(
config_dumpfound
)
dump_peaks
(
&
image
);
if
(
config_dumpfound
)
dump_peaks
(
&
image
,
pargs
->
output_mutex
);
/* Not indexing nor writing xfel.drx?
* Then there's nothing left to do. */
...
...
@@ -319,9 +320,8 @@ static void *process_image(void *pargsv)
if
(
config_nearbragg
)
{
/* Use original data (temporarily) */
simage
->
data
=
data_for_measurement
;
pthread_mutex_lock
(
pargs
->
output_mutex
);
output_intensities
(
simage
,
image
.
indexed_cell
);
pthread_mutex_unlock
(
pargs
->
output_mutex
);
output_intensities
(
simage
,
image
.
indexed_cell
,
pargs
->
output_mutex
);
simage
->
data
=
NULL
;
}
...
...
src/pattern_sim.c
View file @
ca7215bc
...
...
@@ -308,7 +308,7 @@ int main(int argc, char *argv[])
record_image
(
&
image
,
!
config_nonoise
);
if
(
config_nearbragg
)
{
output_intensities
(
&
image
,
cell
);
output_intensities
(
&
image
,
cell
,
NULL
);
}
if
(
config_powder
)
{
...
...
src/peaks.c
View file @
ca7215bc
...
...
@@ -20,6 +20,7 @@
#include
<string.h>
#include
<assert.h>
#include
<gsl/gsl_statistics_int.h>
#include
<pthread.h>
#include
"image.h"
#include
"utils.h"
...
...
@@ -329,11 +330,15 @@ void search_peaks(struct image *image)
}
void
dump_peaks
(
struct
image
*
image
)
void
dump_peaks
(
struct
image
*
image
,
pthread_mutex_t
*
mutex
)
{
int
i
;
printf
(
"x/px
\t
y/px
\t
(1/d)/nm^-1
\n
"
);
/* Get exclusive access to the output stream if necessary */
if
(
mutex
!=
NULL
)
pthread_mutex_lock
(
mutex
);
printf
(
"Peaks from peak search in %s
\n
"
,
image
->
filename
);
printf
(
" x/px y/px (1/d)/nm^-1 Intensity
\n
"
);
for
(
i
=
0
;
i
<
image_feature_count
(
image
->
features
);
i
++
)
{
...
...
@@ -346,18 +351,25 @@ void dump_peaks(struct image *image)
map_position
(
image
,
f
->
x
,
f
->
y
,
&
rx
,
&
ry
,
&
rz
);
q
=
modulus
(
rx
,
ry
,
rz
);
printf
(
"%7.3f
\t
%7.3f
\t
%7.3f
\t
%7.3f
\n
"
,
f
->
x
,
f
->
y
,
q
/
1.0e9
,
1
.
0
);
printf
(
"%8.3f %8.3f %8.3f %12.3f
\n
"
,
f
->
x
,
f
->
y
,
q
/
1.0e9
,
f
->
intensity
);
}
printf
(
"
\n
"
);
if
(
mutex
!=
NULL
)
pthread_mutex_unlock
(
mutex
);
}
void
output_intensities
(
struct
image
*
image
,
UnitCell
*
cell
)
void
output_intensities
(
struct
image
*
image
,
UnitCell
*
cell
,
pthread_mutex_t
*
mutex
)
{
int
x
,
y
;
double
ax
,
ay
,
az
;
double
bx
,
by
,
bz
;
double
cx
,
cy
,
cz
;
double
a
,
b
,
c
,
al
,
be
,
ga
;
struct
reflhit
hits
[
MAX_HITS
];
int
n_hits
=
0
;
int
i
;
...
...
@@ -422,11 +434,19 @@ void output_intensities(struct image *image, UnitCell *cell)
STATUS
(
"Found %i reflections
\n
"
,
n_hits
);
/* Get exclusive access to the output stream if necessary */
if
(
mutex
!=
NULL
)
pthread_mutex_lock
(
mutex
);
/* Explicit printf() used here (not normally allowed) because
* we really want to output to stdout */
printf
(
"New pattern: %s %7.5f %7.5f %7.5f %7.5f
\n
"
,
image
->
filename
,
printf
(
"Reflections from indexing in %s
\n
"
,
image
->
filename
);
printf
(
"Orientation (wxyz): %7.5f %7.5f %7.5f %7.5f
\n
"
,
image
->
orientation
.
w
,
image
->
orientation
.
x
,
image
->
orientation
.
y
,
image
->
orientation
.
z
);
cell_get_parameters
(
image
->
indexed_cell
,
&
a
,
&
b
,
&
c
,
&
al
,
&
be
,
&
ga
);
printf
(
"Cell parameters %7.5f %7.5f %7.5f nm, %7.5f %7.5f %7.5f deg
\n
"
,
a
*
1.0e9
,
b
*
1.0e9
,
c
*
1.0e9
,
rad2deg
(
al
),
rad2deg
(
be
),
rad2deg
(
ga
));
for
(
i
=
0
;
i
<
n_hits
;
i
++
)
{
float
x
,
y
,
intensity
;
...
...
@@ -456,4 +476,6 @@ void output_intensities(struct image *image, UnitCell *cell)
/* Blank line at end */
printf
(
"
\n
"
);
if
(
mutex
!=
NULL
)
pthread_mutex_unlock
(
mutex
);
}
src/peaks.h
View file @
ca7215bc
...
...
@@ -17,8 +17,11 @@
#include
<config.h>
#endif
#include
<pthread.h>
extern
void
search_peaks
(
struct
image
*
image
);
extern
void
dump_peaks
(
struct
image
*
image
);
extern
void
output_intensities
(
struct
image
*
image
,
UnitCell
*
cell
);
extern
void
dump_peaks
(
struct
image
*
image
,
pthread_mutex_t
*
mutex
);
extern
void
output_intensities
(
struct
image
*
image
,
UnitCell
*
cell
,
pthread_mutex_t
*
mutex
);
#endif
/* PEAKS_H */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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