Skip to content
Snippets Groups Projects
Commit 1515402d authored by Valerio Mariani's avatar Valerio Mariani
Browse files

Merge branch 'testing'

parents c727186e dc61a44e
No related branches found
No related tags found
No related merge requests found
...@@ -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)
......
...@@ -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_ss_in_slab = 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_ss_in_slab + 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_ss_in_slab + 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(
......
...@@ -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 files. Parameter parsing utilities.
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 (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment