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
1515402d
Commit
1515402d
authored
6 years ago
by
Valerio Mariani
Browse files
Options
Downloads
Plain Diff
Merge branch 'testing'
parents
c727186e
dc61a44e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
crystfel_utils.py
+3
-9
3 additions, 9 deletions
crystfel_utils.py
geometry_utils.py
+11
-31
11 additions, 31 deletions
geometry_utils.py
parameter_utils.py
+3
-17
3 additions, 17 deletions
parameter_utils.py
with
17 additions
and
57 deletions
crystfel_utils.py
+
3
−
9
View file @
1515402d
...
@@ -13,17 +13,11 @@
...
@@ -13,17 +13,11 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
"""
"""
Utilities for interoperability with data formats used in the CrystFEL
CryystFEL utilities.
software package.
Exports:
This module contains the implementation of several functions used to
interact with CrystFEL files and data (geometry files, stream files).
Functions:
load_crystfel_geometry: a python reimplementation of the
get_detector_geometry_2 function from CrystFEL.
"""
"""
from
__future__
import
(
absolute_import
,
division
,
print_function
,
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
unicode_literals
)
...
...
This diff is collapsed.
Click to expand it.
geometry_utils.py
+
11
−
31
View file @
1515402d
...
@@ -13,23 +13,10 @@
...
@@ -13,23 +13,10 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
"""
"""
Utilities to load, manipulate and apply geometry information to
Geometry utilities.
detector pixel data.
Exports:
This module contains the implementation of several functions used to
manipulate geometry information.
"""
Functions:
compute_pix_maps: turn a CrystFEL geometry object into pixel
maps.
compute_min_array_size: compute the minimum array size that
is required to store data to which a geometry has been
applied.
compute_visualization_pix_maps: ajust pixel maps to be used in
a PyQtGraph
'
s ImageView widget.
"""
from
__future__
import
(
absolute_import
,
division
,
print_function
,
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
unicode_literals
)
...
@@ -75,33 +62,29 @@ def compute_pix_maps(geometry):
...
@@ -75,33 +62,29 @@ def compute_pix_maps(geometry):
PixelMaps: A PixelMaps tuple storing the pixel maps (ndarrays
PixelMaps: A PixelMaps tuple storing the pixel maps (ndarrays
of type float).
of type float).
"""
"""
# Determine the max fs and ss in the geometry object.
max_fs_in_slab
=
numpy
.
array
([
max_slab_fs
=
numpy
.
array
([
geometry
[
'
panels
'
][
k
][
'
max_fs
'
]
geometry
[
'
panels
'
][
k
][
'
max_fs
'
]
for
k
in
geometry
[
'
panels
'
]
for
k
in
geometry
[
'
panels
'
]
]).
max
()
]).
max
()
max_slab
_ss
=
numpy
.
array
([
max_s
s_in_s
lab
=
numpy
.
array
([
geometry
[
'
panels
'
][
k
][
'
max_ss
'
]
geometry
[
'
panels
'
][
k
][
'
max_ss
'
]
for
k
in
geometry
[
'
panels
'
]
for
k
in
geometry
[
'
panels
'
]
]).
max
()
]).
max
()
# Create empty arrays, of the same size of the input data, that
# will store the x and y pixel maps.
x_map
=
numpy
.
zeros
(
x_map
=
numpy
.
zeros
(
shape
=
(
max_slab
_ss
+
1
,
max_slab
_fs
+
1
),
shape
=
(
max_s
s_in_s
lab
+
1
,
max_
fs_in_
slab
+
1
),
dtype
=
numpy
.
float32
# pylint: disable=E1101
dtype
=
numpy
.
float32
# pylint: disable=E1101
)
)
y_map
=
numpy
.
zeros
(
y_map
=
numpy
.
zeros
(
shape
=
(
max_slab
_ss
+
1
,
max_slab
_fs
+
1
),
shape
=
(
max_s
s_in_s
lab
+
1
,
max_
fs_in_
slab
+
1
),
dtype
=
numpy
.
float32
# pylint: disable=E1101
dtype
=
numpy
.
float32
# pylint: disable=E1101
)
)
# Iterate over the panels. For each panel, determine the pixel
# Iterate over the panels. For each panel, determine the pixel
# indices, then compute the x,y vectors. Finally, copy the
# indices, then compute the x,y vectors. Finally, copy the
# panel pixel maps into the detector-wide pixel maps.
# panel pixel maps into the detector-wide pixel maps.
# At the end, compute the values for the radius pixel map.
for
pan
in
geometry
[
'
panels
'
]:
for
pan
in
geometry
[
'
panels
'
]:
ss_grid
,
fs_grid
=
numpy
.
meshgrid
(
ss_grid
,
fs_grid
=
numpy
.
meshgrid
(
numpy
.
arange
(
numpy
.
arange
(
...
@@ -178,7 +161,6 @@ def compute_min_array_size(pixel_maps):
...
@@ -178,7 +161,6 @@ def compute_min_array_size(pixel_maps):
y_minimum
=
2
*
int
(
max
(
abs
(
y_map
.
max
()),
abs
(
y_map
.
min
())))
+
2
y_minimum
=
2
*
int
(
max
(
abs
(
y_map
.
max
()),
abs
(
y_map
.
min
())))
+
2
x_minimum
=
2
*
int
(
max
(
abs
(
x_map
.
max
()),
abs
(
x_map
.
min
())))
+
2
x_minimum
=
2
*
int
(
max
(
abs
(
x_map
.
max
()),
abs
(
x_map
.
min
())))
+
2
# Return a numpy-style tuple with the computed shape.
return
(
y_minimum
,
x_minimum
)
return
(
y_minimum
,
x_minimum
)
...
@@ -204,12 +186,10 @@ def compute_visualization_pix_maps(geometry):
...
@@ -204,12 +186,10 @@ def compute_visualization_pix_maps(geometry):
coordinates (as ndarrays of type int). The third field
coordinates (as ndarrays of type int). The third field
(
"
r
"
) is just set to None.
(
"
r
"
) is just set to None.
"""
"""
# Essentially, the origin of the reference system needs to be
# Shift the origin of the reference system from the beam position
# moved from the beam position to the top-left of the image that
# to the top-left of the image that will be displayed. Compute the
# will be displayed. First, compute the normal pixel maps, then
# size of the array needed to display the data, then use this
# compute the size of the array used to display the data, finally
# information to estimate the magnitude of the shift.
# use this information to estimate the magnitude of the shift that
# needs to be applied to the origin of the system.
pixel_maps
=
compute_pix_maps
(
geometry
)
pixel_maps
=
compute_pix_maps
(
geometry
)
min_shape
=
compute_min_array_size
(
pixel_maps
)
min_shape
=
compute_min_array_size
(
pixel_maps
)
new_x_map
=
numpy
.
array
(
new_x_map
=
numpy
.
array
(
...
...
This diff is collapsed.
Click to expand it.
parameter_utils.py
+
3
−
17
View file @
1515402d
...
@@ -13,17 +13,11 @@
...
@@ -13,17 +13,11 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
# along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>.
"""
"""
Utilities for parsing command line options and configuration fil
es.
Parameter parsing utiliti
es.
Exports:
This module contains the implementation of several utilities used
to parse and manipulate dictionaries that store options and parameters.
Functions:
convert_parameters: convert a dictionary returned by the
configparse module to a dictionary containing entries with
the correct type.
"""
"""
from
__future__
import
(
absolute_import
,
division
,
print_function
,
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
unicode_literals
)
...
@@ -91,16 +85,8 @@ def convert_parameters(config_dict):
...
@@ -91,16 +85,8 @@ def convert_parameters(config_dict):
monitor_params
=
{}
monitor_params
=
{}
# Iterate over the sections in the dictionary (first level in the
# configuration file). Add the section to the dictionary that will
# be returned.
for
section
in
config_dict
.
keys
():
for
section
in
config_dict
.
keys
():
monitor_params
[
section
]
=
{}
monitor_params
[
section
]
=
{}
# Iterate then over the content of the section (second level in
# the configuration file). Get each option in turn and perform
# all the checks. If all checks fail, call the parsing_error
# function.
for
option
in
config_dict
[
section
].
keys
():
for
option
in
config_dict
[
section
].
keys
():
recovered_option
=
config_dict
[
section
][
option
]
recovered_option
=
config_dict
[
section
][
option
]
if
(
if
(
...
...
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