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
8bb2c7e3
Commit
8bb2c7e3
authored
Sep 24, 2010
by
Thomas White
Browse files
Move stream handling functions to a separate module
parent
7b3e7208
Changes
9
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
8bb2c7e3
...
...
@@ -9,5 +9,6 @@ EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h \
src/povray.h src/index-priv.h src/geometry.h src/templates.h
\
data/sfac/Ca.nff data/sfac/C.nff data/sfac/Fe.nff data/sfac/H.nff
\
data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff data/sfac/P.nff
\
data/sfac/S.nff data/sfac/f0_WaasKirf.dat src/render_hkl.h
data/sfac/S.nff data/sfac/f0_WaasKirf.dat src/render_hkl.h
\
src/stream.h
SUBDIRS
=
src data doc scripts
Makefile.in
View file @
8bb2c7e3
...
...
@@ -207,7 +207,8 @@ EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h \
src/povray.h src/index-priv.h src/geometry.h src/templates.h
\
data/sfac/Ca.nff data/sfac/C.nff data/sfac/Fe.nff data/sfac/H.nff
\
data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff data/sfac/P.nff
\
data/sfac/S.nff data/sfac/f0_WaasKirf.dat src/render_hkl.h
data/sfac/S.nff data/sfac/f0_WaasKirf.dat src/render_hkl.h
\
src/stream.h
SUBDIRS
=
src data doc scripts
all
:
config.h
...
...
src/Makefile.am
View file @
8bb2c7e3
...
...
@@ -18,7 +18,7 @@ endif
pattern_sim_LDADD
=
@LIBS@
process_hkl_SOURCES
=
process_hkl.c sfac.c statistics.c cell.c utils.c
\
reflections.c symmetry.c
reflections.c symmetry.c
stream.c
process_hkl_LDADD
=
@LIBS@
indexamajig_SOURCES
=
indexamajig.c hdf5-file.c utils.c cell.c image.c
\
...
...
@@ -62,11 +62,11 @@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \
facetron_LDADD
=
@LIBS@
cubeit_SOURCES
=
cubeit.c cell.c hdf5-file.c utils.c detector.c diffraction.c
\
sfac.c render.c filters.c image.c symmetry.c
sfac.c render.c filters.c image.c symmetry.c
stream.c
cubeit_LDADD
=
@LIBS@
reintegrate_SOURCES
=
reintegrate.c cell.c hdf5-file.c utils.c detector.c
\
peaks.c image.c diffraction.c sfac.c geometry.c
peaks.c image.c diffraction.c sfac.c geometry.c
stream.c
reintegrate_LDADD
=
@LIBS@
INCLUDES
=
"-I
$(top_srcdir)
/data"
src/Makefile.in
View file @
8bb2c7e3
...
...
@@ -67,7 +67,8 @@ compare_hkl_DEPENDENCIES =
am_cubeit_OBJECTS
=
cubeit.
$(OBJEXT)
cell.
$(OBJEXT)
\
hdf5-file.
$(OBJEXT)
utils.
$(OBJEXT)
detector.
$(OBJEXT)
\
diffraction.
$(OBJEXT)
sfac.
$(OBJEXT)
render.
$(OBJEXT)
\
filters.
$(OBJEXT)
image.
$(OBJEXT)
symmetry.
$(OBJEXT)
filters.
$(OBJEXT)
image.
$(OBJEXT)
symmetry.
$(OBJEXT)
\
stream.
$(OBJEXT)
cubeit_OBJECTS
=
$(am_cubeit_OBJECTS)
cubeit_DEPENDENCIES
=
am_facetron_OBJECTS
=
facetron.
$(OBJEXT)
cell.
$(OBJEXT)
\
...
...
@@ -118,13 +119,13 @@ powder_plot_OBJECTS = $(am_powder_plot_OBJECTS)
powder_plot_DEPENDENCIES
=
am_process_hkl_OBJECTS
=
process_hkl.
$(OBJEXT)
sfac.
$(OBJEXT)
\
statistics.
$(OBJEXT)
cell.
$(OBJEXT)
utils.
$(OBJEXT)
\
reflections.
$(OBJEXT)
symmetry.
$(OBJEXT)
reflections.
$(OBJEXT)
symmetry.
$(OBJEXT)
stream.
$(OBJEXT)
process_hkl_OBJECTS
=
$(am_process_hkl_OBJECTS)
process_hkl_DEPENDENCIES
=
am_reintegrate_OBJECTS
=
reintegrate.
$(OBJEXT)
cell.
$(OBJEXT)
\
hdf5-file.
$(OBJEXT)
utils.
$(OBJEXT)
detector.
$(OBJEXT)
\
peaks.
$(OBJEXT)
image.
$(OBJEXT)
diffraction.
$(OBJEXT)
\
sfac.
$(OBJEXT)
geometry.
$(OBJEXT)
sfac.
$(OBJEXT)
geometry.
$(OBJEXT)
stream.
$(OBJEXT)
reintegrate_OBJECTS
=
$(am_reintegrate_OBJECTS)
reintegrate_DEPENDENCIES
=
am_render_hkl_OBJECTS
=
render_hkl.
$(OBJEXT)
cell.
$(OBJEXT)
\
...
...
@@ -265,7 +266,7 @@ pattern_sim_SOURCES = pattern_sim.c diffraction.c utils.c image.c \
$(am__append_2)
pattern_sim_LDADD
=
@LIBS@
process_hkl_SOURCES
=
process_hkl.c sfac.c statistics.c cell.c utils.c
\
reflections.c symmetry.c
reflections.c symmetry.c
stream.c
process_hkl_LDADD
=
@LIBS@
indexamajig_SOURCES
=
indexamajig.c hdf5-file.c utils.c cell.c image.c
\
...
...
@@ -301,11 +302,11 @@ facetron_SOURCES = facetron.c cell.c hdf5-file.c utils.c detector.c peaks.c \
facetron_LDADD
=
@LIBS@
cubeit_SOURCES
=
cubeit.c cell.c hdf5-file.c utils.c detector.c diffraction.c
\
sfac.c render.c filters.c image.c symmetry.c
sfac.c render.c filters.c image.c symmetry.c
stream.c
cubeit_LDADD
=
@LIBS@
reintegrate_SOURCES
=
reintegrate.c cell.c hdf5-file.c utils.c detector.c
\
peaks.c image.c diffraction.c sfac.c geometry.c
peaks.c image.c diffraction.c sfac.c geometry.c
stream.c
reintegrate_LDADD
=
@LIBS@
INCLUDES
=
"-I
$(top_srcdir)
/data"
...
...
@@ -453,6 +454,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/render_hkl.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/sfac.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/statistics.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/stream.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/symmetry.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/templates.Po@am__quote@
@AMDEP_TRUE@@am__include@
@am__quote@./$(DEPDIR)/utils.Po@am__quote@
...
...
src/cubeit.c
View file @
8bb2c7e3
...
...
@@ -31,6 +31,7 @@
#include
"diffraction.h"
#include
"render.h"
#include
"symmetry.h"
#include
"stream.h"
#define MAX_THREADS (256)
...
...
@@ -383,75 +384,6 @@ static void write_slice(const char *filename, double *vals, int z,
}
static
UnitCell
*
read_orientation_matrix
(
FILE
*
fh
)
{
float
u
,
v
,
w
;
struct
rvec
as
,
bs
,
cs
;
UnitCell
*
cell
;
char
line
[
1024
];
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"astar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read a-star
\n
"
);
return
NULL
;
}
as
.
u
=
u
*
1e9
;
as
.
v
=
v
*
1e9
;
as
.
w
=
w
*
1e9
;
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"bstar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read b-star
\n
"
);
return
NULL
;
}
bs
.
u
=
u
*
1e9
;
bs
.
v
=
v
*
1e9
;
bs
.
w
=
w
*
1e9
;
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"cstar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read c-star
\n
"
);
return
NULL
;
}
cs
.
u
=
u
*
1e9
;
cs
.
v
=
v
*
1e9
;
cs
.
w
=
w
*
1e9
;
cell
=
cell_new_from_axes
(
as
,
bs
,
cs
);
return
cell
;
}
static
int
find_chunk
(
FILE
*
fh
,
UnitCell
**
cell
,
char
**
filename
)
{
char
line
[
1024
];
char
*
rval
=
NULL
;
do
{
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
chomp
(
line
);
if
(
strncmp
(
line
,
"Reflections from indexing"
,
25
)
!=
0
)
{
continue
;
}
*
filename
=
strdup
(
line
+
29
);
/* Skip two lines (while checking for errors) */
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
*
cell
=
read_orientation_matrix
(
fh
);
if
(
*
cell
==
NULL
)
{
STATUS
(
"Got filename but no cell for %s
\n
"
,
*
filename
);
continue
;
}
return
0
;
}
while
(
rval
!=
NULL
);
return
1
;
}
static
void
add_to_mean
(
UnitCell
*
cell
,
double
*
ast
,
double
*
bst
,
double
*
cst
,
double
*
alst
,
double
*
best
,
double
*
gast
)
{
...
...
src/process_hkl.c
View file @
8bb2c7e3
...
...
@@ -26,6 +26,7 @@
#include
"sfac.h"
#include
"reflections.h"
#include
"symmetry.h"
#include
"stream.h"
/* Number of divisions for intensity histograms */
...
...
@@ -535,26 +536,6 @@ static void merge_all(FILE *fh, double **pmodel, ReflItemList **pobserved,
}
static
int
count_patterns
(
FILE
*
fh
)
{
char
*
rval
;
int
n_total_patterns
=
0
;
do
{
char
line
[
1024
];
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
if
(
(
strncmp
(
line
,
"Reflections from indexing"
,
25
)
==
0
)
||
(
strncmp
(
line
,
"New pattern"
,
11
)
==
0
)
)
{
n_total_patterns
++
;
}
}
while
(
rval
!=
NULL
);
return
n_total_patterns
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
c
;
...
...
src/reintegrate.c
View file @
8bb2c7e3
...
...
@@ -28,6 +28,7 @@
#include
"hdf5-file.h"
#include
"symmetry.h"
#include
"peaks.h"
#include
"stream.h"
#define MAX_THREADS (256)
...
...
@@ -147,75 +148,6 @@ static void *worker_thread(void *pargsv)
}
static
UnitCell
*
read_orientation_matrix
(
FILE
*
fh
)
{
float
u
,
v
,
w
;
struct
rvec
as
,
bs
,
cs
;
UnitCell
*
cell
;
char
line
[
1024
];
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"astar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read a-star
\n
"
);
return
NULL
;
}
as
.
u
=
u
*
1e9
;
as
.
v
=
v
*
1e9
;
as
.
w
=
w
*
1e9
;
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"bstar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read b-star
\n
"
);
return
NULL
;
}
bs
.
u
=
u
*
1e9
;
bs
.
v
=
v
*
1e9
;
bs
.
w
=
w
*
1e9
;
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"cstar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read c-star
\n
"
);
return
NULL
;
}
cs
.
u
=
u
*
1e9
;
cs
.
v
=
v
*
1e9
;
cs
.
w
=
w
*
1e9
;
cell
=
cell_new_from_axes
(
as
,
bs
,
cs
);
return
cell
;
}
static
int
find_chunk
(
FILE
*
fh
,
UnitCell
**
cell
,
char
**
filename
)
{
char
line
[
1024
];
char
*
rval
=
NULL
;
do
{
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
chomp
(
line
);
if
(
strncmp
(
line
,
"Reflections from indexing"
,
25
)
!=
0
)
{
continue
;
}
*
filename
=
strdup
(
line
+
29
);
/* Skip two lines (while checking for errors) */
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
*
cell
=
read_orientation_matrix
(
fh
);
if
(
*
cell
==
NULL
)
{
STATUS
(
"Got filename but no cell for %s
\n
"
,
*
filename
);
continue
;
}
return
0
;
}
while
(
rval
!=
NULL
);
return
1
;
}
static
void
integrate_all
(
int
nthreads
,
struct
detector
*
det
,
FILE
*
fh
,
int
config_basename
,
const
char
*
prefix
)
{
...
...
src/stream.c
0 → 100644
View file @
8bb2c7e3
/*
* stream.c
*
* Indexed stream tools
*
* (c) 2006-2010 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#ifdef HAVE_CONFIG_H
#include
<config.h>
#endif
#include
<stdlib.h>
#include
<stdio.h>
#include
<string.h>
#include
"cell.h"
#include
"utils.h"
int
count_patterns
(
FILE
*
fh
)
{
char
*
rval
;
int
n_total_patterns
=
0
;
do
{
char
line
[
1024
];
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
if
(
(
strncmp
(
line
,
"Reflections from indexing"
,
25
)
==
0
)
||
(
strncmp
(
line
,
"New pattern"
,
11
)
==
0
)
)
{
n_total_patterns
++
;
}
}
while
(
rval
!=
NULL
);
return
n_total_patterns
;
}
static
UnitCell
*
read_orientation_matrix
(
FILE
*
fh
)
{
float
u
,
v
,
w
;
struct
rvec
as
,
bs
,
cs
;
UnitCell
*
cell
;
char
line
[
1024
];
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"astar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read a-star
\n
"
);
return
NULL
;
}
as
.
u
=
u
*
1e9
;
as
.
v
=
v
*
1e9
;
as
.
w
=
w
*
1e9
;
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"bstar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read b-star
\n
"
);
return
NULL
;
}
bs
.
u
=
u
*
1e9
;
bs
.
v
=
v
*
1e9
;
bs
.
w
=
w
*
1e9
;
if
(
fgets
(
line
,
1023
,
fh
)
==
NULL
)
return
NULL
;
if
(
sscanf
(
line
,
"cstar = %f %f %f"
,
&
u
,
&
v
,
&
w
)
!=
3
)
{
ERROR
(
"Couldn't read c-star
\n
"
);
return
NULL
;
}
cs
.
u
=
u
*
1e9
;
cs
.
v
=
v
*
1e9
;
cs
.
w
=
w
*
1e9
;
cell
=
cell_new_from_axes
(
as
,
bs
,
cs
);
return
cell
;
}
int
find_chunk
(
FILE
*
fh
,
UnitCell
**
cell
,
char
**
filename
)
{
char
line
[
1024
];
char
*
rval
=
NULL
;
do
{
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
chomp
(
line
);
if
(
strncmp
(
line
,
"Reflections from indexing"
,
25
)
!=
0
)
{
continue
;
}
*
filename
=
strdup
(
line
+
29
);
/* Skip two lines (while checking for errors) */
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
rval
=
fgets
(
line
,
1023
,
fh
);
if
(
rval
==
NULL
)
continue
;
*
cell
=
read_orientation_matrix
(
fh
);
if
(
*
cell
==
NULL
)
{
STATUS
(
"Got filename but no cell for %s
\n
"
,
*
filename
);
continue
;
}
return
0
;
}
while
(
rval
!=
NULL
);
return
1
;
}
src/stream.h
0 → 100644
View file @
8bb2c7e3
/*
* stream.h
*
* Indexed stream tools
*
* (c) 2006-2010 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#ifndef STREAM_H
#define STREAM_H
#ifdef HAVE_CONFIG_H
#include
<config.h>
#endif
extern
int
count_patterns
(
FILE
*
fh
);
extern
int
find_chunk
(
FILE
*
fh
,
UnitCell
**
cell
,
char
**
filename
);
#endif
/* STREAM_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