Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cfel_fmt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dataAnalysis
cfel_fmt
Commits
6aecae71
Commit
6aecae71
authored
6 years ago
by
Valerio Mariani
Browse files
Options
Downloads
Patches
Plain Diff
Fixed parsing of dim entries in load_crystfel_geometry
parent
42c528bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cfelpyutils/crystfel_utils.py
+45
-43
45 additions, 43 deletions
cfelpyutils/crystfel_utils.py
with
45 additions
and
43 deletions
cfelpyutils/crystfel_utils.py
+
45
−
43
View file @
6aecae71
...
@@ -27,6 +27,8 @@ import copy
...
@@ -27,6 +27,8 @@ import copy
import
math
import
math
import
re
import
re
from
future.utils
import
viewitems
def
_assplode_algebraic
(
value
):
def
_assplode_algebraic
(
value
):
# Reimplementation of assplode_algegraic from
# Reimplementation of assplode_algegraic from
...
@@ -112,6 +114,7 @@ def _set_dim_structure_entry(key, value, panel):
...
@@ -112,6 +114,7 @@ def _set_dim_structure_entry(key, value, panel):
dim
[
dim_index
]
=
int
(
value
)
dim
[
dim_index
]
=
int
(
value
)
else
:
else
:
raise
RuntimeError
(
"
Invalid dim entry: {}.
"
.
format
(
value
))
raise
RuntimeError
(
"
Invalid dim entry: {}.
"
.
format
(
value
))
panel
[
'
dim_structure
'
]
=
dim
def
_parse_field_for_panel
(
key
,
value
,
panel
):
def
_parse_field_for_panel
(
key
,
value
,
panel
):
...
@@ -229,7 +232,7 @@ def _parse_field_for_panel(key, value, panel):
...
@@ -229,7 +232,7 @@ def _parse_field_for_panel(key, value, panel):
panel
=
panel
panel
=
panel
)
)
else
:
else
:
raise
RuntimeError
(
"
Unrecognised field: {}
"
.
format
(
key
))
RuntimeError
(
"
Unrecognised field: {}
"
.
format
(
key
))
def
_parse_toplevel
(
key
,
value
,
detector
,
beam
,
panel
):
def
_parse_toplevel
(
key
,
value
,
detector
,
beam
,
panel
):
...
@@ -464,7 +467,6 @@ def load_crystfel_geometry(filename):
...
@@ -464,7 +467,6 @@ def load_crystfel_geometry(filename):
'
satmap_file
'
:
None
,
'
satmap_file
'
:
None
,
'
data
'
:
None
,
'
data
'
:
None
,
'
dim_structure
'
:
None
,
'
dim_structure
'
:
None
,
'
name
'
:
''
}
}
default_bad_region
=
{
default_bad_region
=
{
...
@@ -477,7 +479,6 @@ def load_crystfel_geometry(filename):
...
@@ -477,7 +479,6 @@ def load_crystfel_geometry(filename):
'
min_ss
'
:
0
,
'
min_ss
'
:
0
,
'
max_ss
'
:
0
,
'
max_ss
'
:
0
,
'
is_fsss
'
:
99
,
'
is_fsss
'
:
99
,
'
name
'
:
''
}
}
default_dim
=
[
default_dim
=
[
...
@@ -552,7 +553,7 @@ def load_crystfel_geometry(filename):
...
@@ -552,7 +553,7 @@ def load_crystfel_geometry(filename):
num_placeholders_in_panels
=
None
num_placeholders_in_panels
=
None
for
panel
in
detector
[
'
panels
'
].
values
():
for
panel
in
detector
[
'
panels
'
].
values
():
if
panel
[
'
dim_structure
'
]
is
not
None
:
if
panel
[
'
dim_structure
'
]
is
not
None
:
curr_num_placeholders
=
panel
[
'
dim_structure
'
].
values
().
count
(
'
%
'
)
curr_num_placeholders
=
panel
[
'
dim_structure
'
].
count
(
'
%
'
)
else
:
else
:
curr_num_placeholders
=
0
curr_num_placeholders
=
0
...
@@ -588,7 +589,7 @@ def load_crystfel_geometry(filename):
...
@@ -588,7 +589,7 @@ def load_crystfel_geometry(filename):
)
)
dim_length
=
None
dim_length
=
None
for
panel
in
detector
[
'
panels
'
]
.
values
(
):
for
panel
_name
,
panel
in
viewitems
(
detector
[
'
panels
'
]):
if
panel
[
'
dim_structure
'
]
is
None
:
if
panel
[
'
dim_structure
'
]
is
None
:
panel
[
'
dim_structure
'
]
=
copy
.
deepcopy
(
default_dim
)
panel
[
'
dim_structure
'
]
=
copy
.
deepcopy
(
default_dim
)
...
@@ -600,40 +601,41 @@ def load_crystfel_geometry(filename):
...
@@ -600,40 +601,41 @@ def load_crystfel_geometry(filename):
raise
RuntimeError
(
raise
RuntimeError
(
"
Dimension {} for panel {} is undefined.
"
.
format
(
"
Dimension {} for panel {} is undefined.
"
.
format
(
dim_index
,
dim_index
,
panel
[
'
name
'
]
panel
_
name
)
)
)
)
elif
entry
==
'
ss
'
:
elif
entry
==
'
ss
'
:
found_ss
+=
1
found_ss
+=
1
if
found_ss
!=
1
:
raise
RuntimeError
(
"
Exactly one slow scan dim coordinate is needed
"
"
(found {} for panel {})
"
.
format
(
found_ss
,
panel
[
'
name
'
]
)
)
elif
entry
==
'
fs
'
:
elif
entry
==
'
fs
'
:
found_fs
+=
1
found_fs
+=
1
if
found_fs
!=
1
:
raise
RuntimeError
(
"
Exactly one fast scan dim coordinate is needed
"
"
(found {} for panel {})
"
.
format
(
found_fs
,
panel
[
'
name
'
]
)
)
elif
entry
==
'
%
'
:
elif
entry
==
'
%
'
:
found_placeholder
+=
1
found_placeholder
+=
1
if
found_placeholder
!=
1
:
raise
RuntimeError
(
if
found_ss
!=
1
:
"
Only one placeholder dim coordinate is allowed.
"
raise
RuntimeError
(
"
Maximum one placeholder dim coordinate is
"
"
Exactly one slow scan dim coordinate is needed
"
"
allowed (found {} for panel {})
"
.
format
(
"
(found {} for panel {})
"
.
format
(
found_placeholder
,
found_ss
,
panel
[
'
name
'
]
panel_name
)
)
)
)
if
found_fs
!=
1
:
raise
RuntimeError
(
"
Exactly one fast scan dim coordinate is needed
"
"
(found {} for panel {})
"
.
format
(
found_fs
,
panel_name
)
)
if
found_placeholder
!=
1
:
raise
RuntimeError
(
"
Only one placeholder dim coordinate is allowed.
"
"
Maximum one placeholder dim coordinate is
"
"
allowed (found {} for panel {})
"
.
format
(
found_placeholder
,
panel_name
)
)
if
dim_length
is
None
:
if
dim_length
is
None
:
dim_length
=
len
(
panel
[
'
dim_structure
'
])
dim_length
=
len
(
panel
[
'
dim_structure
'
])
...
@@ -647,59 +649,59 @@ def load_crystfel_geometry(filename):
...
@@ -647,59 +649,59 @@ def load_crystfel_geometry(filename):
"
Number of dim coordinates must be at least two.
"
"
Number of dim coordinates must be at least two.
"
)
)
for
panel
in
detector
[
'
panels
'
]
.
values
(
):
for
panel
_name
,
panel
in
viewitems
(
detector
[
'
panels
'
]):
if
panel
[
'
origin_min_fs
'
]
<
0
:
if
panel
[
'
origin_min_fs
'
]
<
0
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the minimum fs coordinate for
"
"
Please specify the minimum fs coordinate for
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
origin_max_fs
'
]
<
0
:
if
panel
[
'
origin_max_fs
'
]
<
0
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the maximum fs coordinate for
"
"
Please specify the maximum fs coordinate for
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
origin_min_ss
'
]
<
0
:
if
panel
[
'
origin_min_ss
'
]
<
0
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the minimum ss coordinate for
"
"
Please specify the minimum ss coordinate for
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
origin_max_ss
'
]
<
0
:
if
panel
[
'
origin_max_ss
'
]
<
0
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the maximum ss coordinate for
"
"
Please specify the maximum ss coordinate for
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
cnx
'
]
is
None
:
if
panel
[
'
cnx
'
]
is
None
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the corner X coordinate for
"
"
Please specify the corner X coordinate for
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
clen
'
]
is
None
and
panel
[
'
clen_from
'
]
is
None
:
if
panel
[
'
clen
'
]
is
None
and
panel
[
'
clen_from
'
]
is
None
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the camera length for
"
"
Please specify the camera length for
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
res
'
]
<
0
:
if
panel
[
'
res
'
]
<
0
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the resolution or
"
"
Please specify the resolution or
"
"
panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
adu_per_eV
'
]
is
None
and
panel
[
'
adu_per_photon
'
]
is
None
:
if
panel
[
'
adu_per_eV
'
]
is
None
and
panel
[
'
adu_per_photon
'
]
is
None
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify either adu_per_eV or adu_per_photon
"
"
Please specify either adu_per_eV or adu_per_photon
"
"
for panel {}.
"
.
format
(
panel
[
'
name
'
]
)
"
for panel {}.
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
clen_for_centering
'
]
is
None
and
panel
[
'
rail_x
'
]
is
not
None
:
if
panel
[
'
clen_for_centering
'
]
is
None
and
panel
[
'
rail_x
'
]
is
not
None
:
raise
RuntimeError
(
raise
RuntimeError
(
"
You must specify clen_for_centering if you specify the
"
"
You must specify clen_for_centering if you specify the
"
"
rail direction (panel {})
"
.
format
(
panel
[
'
name
'
]
)
"
rail direction (panel {})
"
.
format
(
panel
_
name
)
)
)
if
panel
[
'
rail_x
'
]
is
None
:
if
panel
[
'
rail_x
'
]
is
None
:
...
@@ -713,11 +715,11 @@ def load_crystfel_geometry(filename):
...
@@ -713,11 +715,11 @@ def load_crystfel_geometry(filename):
panel
[
'
w
'
]
=
panel
[
'
origin_max_fs
'
]
-
panel
[
'
origin_min_fs
'
]
+
1
panel
[
'
w
'
]
=
panel
[
'
origin_max_fs
'
]
-
panel
[
'
origin_min_fs
'
]
+
1
panel
[
'
h
'
]
=
panel
[
'
origin_max_ss
'
]
-
panel
[
'
origin_min_ss
'
]
+
1
panel
[
'
h
'
]
=
panel
[
'
origin_max_ss
'
]
-
panel
[
'
origin_min_ss
'
]
+
1
for
bad_region
in
detector
[
'
bad
'
]
.
values
(
):
for
bad_region
_name
,
bad_region
in
viewitems
(
detector
[
'
bad
'
]):
if
bad_region
[
'
is_fsss
'
]
==
99
:
if
bad_region
[
'
is_fsss
'
]
==
99
:
raise
RuntimeError
(
raise
RuntimeError
(
"
Please specify the coordinate ranges for bad
"
"
Please specify the coordinate ranges for bad
"
"
region {}.
"
.
format
(
bad_region
[
'
name
'
]
)
"
region {}.
"
.
format
(
bad_region
_
name
)
)
)
for
group
in
detector
[
'
rigid_groups
'
]:
for
group
in
detector
[
'
rigid_groups
'
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment