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
4e0fe58f
Commit
4e0fe58f
authored
May 30, 2012
by
Thomas White
Browse files
Formatting
parent
781b32aa
Changes
18
Hide whitespace changes
Inline
Side-by-side
libcrystfel/src/cell.c
View file @
4e0fe58f
...
...
@@ -424,7 +424,7 @@ int cell_get_parameters(UnitCell *cell, double *a, double *b, double *c,
switch
(
cell
->
rep
)
{
case
CELL_REP_CRYST
:
case
CELL_REP_CRYST
:
/* Direct response */
*
a
=
cell
->
a
;
*
b
=
cell
->
b
;
...
...
@@ -434,7 +434,7 @@ int cell_get_parameters(UnitCell *cell, double *a, double *b, double *c,
*
gamma
=
cell
->
gamma
;
return
0
;
case
CELL_REP_CART
:
case
CELL_REP_CART
:
/* Convert cartesian -> crystallographic */
*
a
=
modulus
(
cell
->
ax
,
cell
->
ay
,
cell
->
az
);
*
b
=
modulus
(
cell
->
bx
,
cell
->
by
,
cell
->
bz
);
...
...
@@ -448,7 +448,7 @@ int cell_get_parameters(UnitCell *cell, double *a, double *b, double *c,
cell
->
bx
,
cell
->
by
,
cell
->
bz
);
return
0
;
case
CELL_REP_RECIP
:
case
CELL_REP_RECIP
:
/* Convert reciprocal -> crystallographic.
* Start by converting reciprocal -> cartesian */
cell_invert
(
cell
->
axs
,
cell
->
ays
,
cell
->
azs
,
...
...
@@ -480,21 +480,21 @@ int cell_get_cartesian(UnitCell *cell,
switch
(
cell
->
rep
)
{
case
CELL_REP_CRYST
:
case
CELL_REP_CRYST
:
/* Convert crystallographic -> cartesian. */
return
cell_crystallographic_to_cartesian
(
cell
,
ax
,
ay
,
az
,
bx
,
by
,
bz
,
cx
,
cy
,
cz
);
case
CELL_REP_CART
:
case
CELL_REP_CART
:
/* Direct response */
*
ax
=
cell
->
ax
;
*
ay
=
cell
->
ay
;
*
az
=
cell
->
az
;
*
bx
=
cell
->
bx
;
*
by
=
cell
->
by
;
*
bz
=
cell
->
bz
;
*
cx
=
cell
->
cx
;
*
cy
=
cell
->
cy
;
*
cz
=
cell
->
cz
;
return
0
;
case
CELL_REP_RECIP
:
case
CELL_REP_RECIP
:
/* Convert reciprocal -> cartesian */
return
cell_invert
(
cell
->
axs
,
cell
->
ays
,
cell
->
azs
,
cell
->
bxs
,
cell
->
bys
,
cell
->
bzs
,
...
...
@@ -518,7 +518,7 @@ int cell_get_reciprocal(UnitCell *cell,
switch
(
cell
->
rep
)
{
case
CELL_REP_CRYST
:
case
CELL_REP_CRYST
:
/* Convert crystallographic -> reciprocal */
r
=
cell_crystallographic_to_cartesian
(
cell
,
&
ax
,
&
ay
,
&
az
,
...
...
@@ -528,7 +528,7 @@ int cell_get_reciprocal(UnitCell *cell,
return
cell_invert
(
ax
,
ay
,
az
,
bx
,
by
,
bz
,
cx
,
cy
,
cz
,
asx
,
asy
,
asz
,
bsx
,
bsy
,
bsz
,
csx
,
csy
,
csz
);
case
CELL_REP_CART
:
case
CELL_REP_CART
:
/* Convert cartesian -> reciprocal */
cell_invert
(
cell
->
ax
,
cell
->
ay
,
cell
->
az
,
cell
->
bx
,
cell
->
by
,
cell
->
bz
,
...
...
@@ -536,7 +536,7 @@ int cell_get_reciprocal(UnitCell *cell,
asx
,
asy
,
asz
,
bsx
,
bsy
,
bsz
,
csx
,
csy
,
csz
);
return
0
;
case
CELL_REP_RECIP
:
case
CELL_REP_RECIP
:
/* Direct response */
*
asx
=
cell
->
axs
;
*
asy
=
cell
->
ays
;
*
asz
=
cell
->
azs
;
*
bsx
=
cell
->
bxs
;
*
bsy
=
cell
->
bys
;
*
bsz
=
cell
->
bzs
;
...
...
@@ -569,12 +569,16 @@ const char *cell_get_spacegroup(UnitCell *cell)
static
const
char
*
cell_rep
(
UnitCell
*
cell
)
{
switch
(
cell
->
rep
)
{
case
CELL_REP_CRYST
:
case
CELL_REP_CRYST
:
return
"crystallographic, direct space"
;
case
CELL_REP_CART
:
case
CELL_REP_CART
:
return
"cartesian, direct space"
;
case
CELL_REP_RECIP
:
case
CELL_REP_RECIP
:
return
"cartesian, reciprocal space"
;
}
return
"unknown"
;
...
...
libcrystfel/src/dirax.c
View file @
4e0fe58f
...
...
@@ -226,37 +226,37 @@ static void dirax_send_next(struct image *image, struct dirax_data *dirax)
switch
(
dirax
->
step
)
{
case
1
:
case
1
:
dirax_sendline
(
"
\\
echo off
\n
"
,
dirax
);
break
;
case
2
:
case
2
:
snprintf
(
tmp
,
31
,
"read xfel-%i.drx
\n
"
,
image
->
id
);
dirax_sendline
(
tmp
,
dirax
);
break
;
case
3
:
case
3
:
dirax_sendline
(
"dmax 1000
\n
"
,
dirax
);
break
;
case
4
:
case
4
:
dirax_sendline
(
"indexfit 2
\n
"
,
dirax
);
break
;
case
5
:
case
5
:
dirax_sendline
(
"levelfit 1000
\n
"
,
dirax
);
break
;
case
6
:
case
6
:
dirax_sendline
(
"go
\n
"
,
dirax
);
dirax
->
finished_ok
=
1
;
break
;
case
7
:
case
7
:
dirax_sendline
(
"acl
\n
"
,
dirax
);
break
;
case
8
:
case
8
:
if
(
dirax
->
best_acl_nh
==
0
)
{
/* At this point, DirAx is presenting its ACL prompt
* and waiting for a single number. Use an extra
...
...
@@ -270,11 +270,11 @@ static void dirax_send_next(struct image *image, struct dirax_data *dirax)
dirax_sendline
(
tmp
,
dirax
);
break
;
case
9
:
case
9
:
dirax_sendline
(
"cell
\n
"
,
dirax
);
break
;
case
10
:
case
10
:
if
(
dirax
->
n_acls_tried
==
MAX_DIRAX_CELL_CANDIDATES
)
{
dirax_sendline
(
"exit
\n
"
,
dirax
);
}
else
{
...
...
@@ -285,7 +285,7 @@ static void dirax_send_next(struct image *image, struct dirax_data *dirax)
}
break
;
default:
default:
dirax_sendline
(
"exit
\n
"
,
dirax
);
return
;
...
...
libcrystfel/src/hdf5-file.c
View file @
4e0fe58f
...
...
@@ -719,6 +719,9 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name)
hsize_t
max_size
;
hid_t
type
;
hid_t
class
;
herr_t
r
;
int
buf
;
char
*
tmp
;
dh
=
H5Dopen2
(
f
->
fh
,
name
,
H5P_DEFAULT
);
if
(
dh
<
0
)
return
NULL
;
...
...
@@ -761,11 +764,8 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name)
}
switch
(
class
)
{
case
H5T_FLOAT
:
{
herr_t
r
;
double
buf
;
char
*
tmp
;
case
H5T_FLOAT
:
r
=
H5Dread
(
dh
,
H5T_NATIVE_DOUBLE
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
&
buf
);
...
...
@@ -776,12 +776,8 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name)
return
tmp
;
}
case
H5T_INTEGER
:
{
case
H5T_INTEGER
:
herr_t
r
;
int
buf
;
char
*
tmp
;
r
=
H5Dread
(
dh
,
H5T_NATIVE_INT
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
&
buf
);
...
...
@@ -791,6 +787,7 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name)
snprintf
(
tmp
,
255
,
"%d"
,
buf
);
return
tmp
;
}
default
:
{
goto
fail
;
...
...
libcrystfel/src/index.c
View file @
4e0fe58f
...
...
@@ -83,18 +83,23 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell,
for
(
n
=
0
;
n
<
nm
;
n
++
)
{
switch
(
indm
[
n
]
)
{
case
INDEXING_NONE
:
case
INDEXING_NONE
:
ERROR
(
"Tried to prepare INDEXING_NONE!
\n
"
);
break
;
case
INDEXING_DIRAX
:
case
INDEXING_DIRAX
:
iprivs
[
n
]
=
indexing_private
(
indm
[
n
]);
break
;
case
INDEXING_MOSFLM
:
case
INDEXING_MOSFLM
:
iprivs
[
n
]
=
indexing_private
(
indm
[
n
]);
break
;
case
INDEXING_REAX
:
case
INDEXING_REAX
:
iprivs
[
n
]
=
reax_prepare
();
break
;
}
}
...
...
@@ -113,18 +118,23 @@ void cleanup_indexing(IndexingPrivate **priv)
while
(
priv
[
n
]
!=
NULL
)
{
switch
(
priv
[
n
]
->
indm
)
{
case
INDEXING_NONE
:
case
INDEXING_NONE
:
free
(
priv
[
n
]);
break
;
case
INDEXING_DIRAX
:
case
INDEXING_DIRAX
:
free
(
priv
[
n
]);
break
;
case
INDEXING_MOSFLM
:
case
INDEXING_MOSFLM
:
free
(
priv
[
n
]);
break
;
case
INDEXING_REAX
:
case
INDEXING_REAX
:
reax_cleanup
(
priv
[
n
]);
break
;
}
n
++
;
...
...
@@ -173,17 +183,22 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm,
/* Index as appropriate */
switch
(
indm
[
n
]
)
{
case
INDEXING_NONE
:
case
INDEXING_NONE
:
return
;
case
INDEXING_DIRAX
:
case
INDEXING_DIRAX
:
run_dirax
(
image
);
break
;
case
INDEXING_MOSFLM
:
case
INDEXING_MOSFLM
:
run_mosflm
(
image
,
cell
);
break
;
case
INDEXING_REAX
:
case
INDEXING_REAX
:
reax_index
(
ipriv
[
n
],
image
,
cell
);
break
;
}
if
(
image
->
ncells
==
0
)
{
n
++
;
...
...
@@ -205,20 +220,25 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod *indm,
/* Match or reduce the cell as appropriate */
switch
(
cellr
)
{
case
CELLR_NONE
:
case
CELLR_NONE
:
new_cell
=
cell_new_from_cell
(
cand
);
break
;
case
CELLR_REDUCE
:
case
CELLR_REDUCE
:
new_cell
=
match_cell
(
cand
,
cell
,
verbose
,
ltl
,
1
);
break
;
case
CELLR_COMPARE
:
case
CELLR_COMPARE
:
new_cell
=
match_cell
(
cand
,
cell
,
verbose
,
ltl
,
0
);
break
;
case
CELLR_COMPARE_AB
:
case
CELLR_COMPARE_AB
:
new_cell
=
match_cell_ab
(
cand
,
cell
);
break
;
}
/* No cell? Move on to the next candidate */
...
...
libcrystfel/src/mosflm.c
View file @
4e0fe58f
...
...
@@ -283,13 +283,13 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm)
switch
(
mosflm
->
step
)
{
case
1
:
case
1
:
mosflm_sendline
(
"DETECTOR ROTATION HORIZONTAL"
" ANTICLOCKWISE ORIGIN LL FAST HORIZONTAL"
" RECTANGULAR
\n
"
,
mosflm
);
break
;
case
2
:
case
2
:
if
(
mosflm
->
target_cell
!=
NULL
)
{
cell_get_parameters
(
mosflm
->
target_cell
,
&
a
,
&
b
,
&
c
,
&
alpha
,
&
beta
,
&
gamma
);
...
...
@@ -303,7 +303,7 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm)
}
break
;
case
3
:
case
3
:
if
(
mosflm
->
target_cell
!=
NULL
)
{
sg
=
cell_get_spacegroup
(
mosflm
->
target_cell
);
/* Remove white space from space group */
...
...
@@ -321,31 +321,31 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm)
}
break
;
case
4
:
case
4
:
mosflm_sendline
(
"DISTANCE 67.8
\n
"
,
mosflm
);
break
;
case
5
:
case
5
:
mosflm_sendline
(
"BEAM 0.0 0.0
\n
"
,
mosflm
);
break
;
case
6
:
case
6
:
wavelength
=
image
->
lambda
*
1e10
;
snprintf
(
tmp
,
255
,
"WAVELENGTH %10.5f
\n
"
,
wavelength
);
mosflm_sendline
(
tmp
,
mosflm
);
break
;
case
7
:
case
7
:
snprintf
(
tmp
,
255
,
"NEWMAT %s
\n
"
,
mosflm
->
newmatfile
);
mosflm_sendline
(
tmp
,
mosflm
);
break
;
case
8
:
case
8
:
snprintf
(
tmp
,
255
,
"IMAGE %s phi 0 0
\n
"
,
mosflm
->
imagefile
);
mosflm_sendline
(
tmp
,
mosflm
);
break
;
case
9
:
case
9
:
snprintf
(
tmp
,
255
,
"AUTOINDEX DPS FILE %s"
" IMAGE 1 MAXCELL 1000 REFINE
\n
"
,
mosflm
->
sptfile
);
...
...
@@ -357,7 +357,7 @@ static void mosflm_send_next(struct image *image, struct mosflm_data *mosflm)
mosflm_sendline
(
tmp
,
mosflm
);
break
;
case
10
:
case
10
:
mosflm_sendline
(
"GO
\n
"
,
mosflm
);
mosflm
->
finished_ok
=
1
;
break
;
...
...
libcrystfel/src/render.c
View file @
4e0fe58f
...
...
@@ -64,34 +64,35 @@ static void render_rgb(double val, double max,
s
=
6
;
}
switch
(
s
)
{
case
0
:
{
/* Black to blue */
r
=
0
;
g
=
0
;
b
=
p
;
break
;
}
case
1
:
{
/* Blue to pink */
r
=
p
;
g
=
0
;
b
=
1
.
0
;
break
;
}
case
2
:
{
/* Pink to red */
r
=
1
.
0
;
g
=
0
;
b
=
(
1
.
0
-
p
)
*
1
.
0
;
break
;
}
case
3
:
{
/* Red to Orange */
r
=
1
.
0
;
g
=
0
.
5
*
p
;
b
=
0
;
break
;
}
case
4
:
{
/* Orange to Yellow */
r
=
1
.
0
;
g
=
0
.
5
+
0
.
5
*
p
;
b
=
0
;
break
;
}
case
5
:
{
/* Yellow to White */
r
=
1
.
0
;
g
=
1
.
0
;
b
=
1
.
0
*
p
;
break
;
}
case
6
:
{
/* Pixel has hit the maximum value */
r
=
1
.
0
;
g
=
1
.
0
;
b
=
1
.
0
;
break
;
}
case
0
:
/* Black to blue */
r
=
0
;
g
=
0
;
b
=
p
;
break
;
case
1
:
/* Blue to pink */
r
=
p
;
g
=
0
;
b
=
1
.
0
;
break
;
case
2
:
/* Pink to red */
r
=
1
.
0
;
g
=
0
;
b
=
(
1
.
0
-
p
)
*
1
.
0
;
break
;
case
3
:
/* Red to Orange */
r
=
1
.
0
;
g
=
0
.
5
*
p
;
b
=
0
;
break
;
case
4
:
/* Orange to Yellow */
r
=
1
.
0
;
g
=
0
.
5
+
0
.
5
*
p
;
b
=
0
;
break
;
case
5
:
/* Yellow to White */
r
=
1
.
0
;
g
=
1
.
0
;
b
=
1
.
0
*
p
;
break
;
case
6
:
/* Pixel has hit the maximum value */
r
=
1
.
0
;
g
=
1
.
0
;
b
=
1
.
0
;
break
;
}
*
rp
=
r
;
...
...
@@ -144,16 +145,20 @@ void render_scale(double val, double max, int scale,
double
*
rp
,
double
*
gp
,
double
*
bp
)
{
switch
(
scale
)
{
case
SCALE_COLOUR
:
case
SCALE_COLOUR
:
render_rgb
(
val
,
max
,
rp
,
gp
,
bp
);
break
;
case
SCALE_MONO
:
case
SCALE_MONO
:
render_mono
(
val
,
max
,
rp
,
gp
,
bp
);
break
;
case
SCALE_INVMONO
:
case
SCALE_INVMONO
:
render_invmono
(
val
,
max
,
rp
,
gp
,
bp
);
break
;
case
SCALE_RATIO
:
case
SCALE_RATIO
:
render_ratio
(
val
,
max
,
rp
,
gp
,
bp
);
break
;
}
...
...
libcrystfel/src/statistics.c
View file @
4e0fe58f
...
...
@@ -407,22 +407,28 @@ static double calc_r(double scale, void *params)
struct
r_params
*
rp
=
params
;
switch
(
rp
->
fom
)
{
case
R_1_ZERO
:
case
R_1_ZERO
:
return
internal_r1_negstozero
(
rp
->
list1
,
rp
->
list2
,
scale
);
case
R_1_IGNORE
:
case
R_1_IGNORE
:
return
internal_r1_ignorenegs
(
rp
->
list1
,
rp
->
list2
,
scale
);
case
R_2
:
case
R_2
:
return
internal_r2
(
rp
->
list1
,
rp
->
list2
,
scale
);
case
R_1_I
:
case
R_1_I
:
return
internal_r_i
(
rp
->
list1
,
rp
->
list2
,
scale
);
case
R_DIFF_ZERO
:
case
R_DIFF_ZERO
:
return
internal_rdiff_negstozero
(
rp
->
list1
,
rp
->
list2
,
scale
);
case
R_DIFF_IGNORE
:
case
R_DIFF_IGNORE
:
return
internal_rdiff_ignorenegs
(
rp
->
list1
,
rp
->
list2
,
scale
);
case
R_DIFF_INTENSITY
:
case
R_DIFF_INTENSITY
:
return
internal_rdiff_intensity
(
rp
->
list1
,
rp
->
list2
,
scale
);
}
ERROR
(
"No such FoM!
\n
"
);
...
...
@@ -457,17 +463,20 @@ static double r_minimised(RefList *list1, RefList *list2, double *scalep, int fo
/* Initial guess */
switch
(
fom
)
{
case
R_1_ZERO
:
case
R_1_IGNORE
:
case
R_DIFF_ZERO
:
case
R_DIFF_IGNORE
:
case
R_1_ZERO
:
case
R_1_IGNORE
:
case
R_DIFF_ZERO
:
case
R_DIFF_IGNORE
:
scale
=
stat_scale_sqrti
(
list1
,
list2
);
break
;
case
R_2
:
case
R_1_I
:
case
R_DIFF_INTENSITY
:
case
R_2
:
case
R_1_I
:
case
R_DIFF_INTENSITY
:
scale
=
stat_scale_intensity
(
list1
,
list2
);
break
;
}
//STATUS("Initial scale factor estimate: %5.2e\n", scale);
...
...
src/check_hkl.c
View file @
4e0fe58f
...
...
@@ -339,43 +339,44 @@ int main(int argc, char *argv[])
while
((
c
=
getopt_long
(
argc
,
argv
,
"hy:p:"
,
longopts
,
NULL
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
case
'h'
:
show_help
(
argv
[
0
]);
return
0
;
case
'y'
:
case
'y'
:
sym_str
=
strdup
(
optarg
);
break
;
case
'p'
:
case
'p'
:
pdb
=
strdup
(
optarg
);
break
;
case
0
:
case
0
:
break
;
case
2
:
case
2
:
if
(
sscanf
(
optarg
,
"%e"
,
&
rmin_fix
)
!=
1
)
{
ERROR
(
"Invalid value for --rmin
\n
"
);
return
1
;
}
break
;
case
3
:
case
3
:
if
(
sscanf
(
optarg
,
"%e"
,
&
rmax_fix
)
!=
1
)
{
ERROR
(
"Invalid value for --rmax
\n
"
);
return
1
;
}
break
;
case
4
:
case
4
:
if
(
sscanf
(
optarg
,
"%f"
,
&
sigma_cutoff
)
!=
1
)
{
ERROR
(
"Invalid value for --sigma-cutoff
\n
"
);
return
1
;
}
break
;
default
:
default
:
return
1
;
}
...
...
src/cl-utils.c
View file @
4e0fe58f
...
...
@@ -46,28 +46,71 @@
const
char
*
clError
(
cl_int
err
)
{
switch
(
err
)
{
case
CL_SUCCESS
:
return
"no error"
;
case
CL_INVALID_PLATFORM
:
return
"invalid platform"
;
case
CL_INVALID_KERNEL
:
return
"invalid kernel"
;
case
CL_INVALID_ARG_INDEX
:
return
"invalid argument index"
;
case
CL_INVALID_ARG_VALUE
:
return
"invalid argument value"
;
case
CL_INVALID_MEM_OBJECT
:
return
"invalid memory object"
;
case
CL_INVALID_SAMPLER
:
return
"invalid sampler"
;
case
CL_INVALID_ARG_SIZE
:
return
"invalid argument size"
;
case
CL_INVALID_COMMAND_QUEUE
:
return
"invalid command queue"
;
case
CL_INVALID_CONTEXT
:
return
"invalid context"
;
case
CL_INVALID_VALUE
:
return
"invalid value"
;
case
CL_INVALID_EVENT_WAIT_LIST
:
return
"invalid wait list"
;
case
CL_MAP_FAILURE
:
return
"map failure"
;
case
CL_MEM_OBJECT_ALLOCATION_FAILURE
:
return
"object allocation failure"
;
case
CL_OUT_OF_HOST_MEMORY
:
return
"out of host memory"
;
case
CL_OUT_OF_RESOURCES
:
return
"out of resources"
;
case
CL_INVALID_KERNEL_NAME
:
return
"invalid kernel name"
;
case
CL_INVALID_KERNEL_ARGS
:
return
"invalid kernel arguments"
;
case
CL_INVALID_WORK_GROUP_SIZE
:
return
"invalid work group size"
;
case
CL_IMAGE_FORMAT_NOT_SUPPORTED
:
return
"image format not supported"
;
case
CL_INVALID_WORK_DIMENSION
:
return
"invalid work dimension"
;
default
:
case
CL_SUCCESS
:
return
"no error"
;