diff --git a/crystfel_utils.py b/crystfel_utils.py index 01aa3b673b830961412bc6744bc311757e117de9..63566103b3082637e756d089abe04b358453c5a2 100644 --- a/crystfel_utils.py +++ b/crystfel_utils.py @@ -13,17 +13,11 @@ # You should have received a copy of the GNU General Public License # along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>. """ -Utilities for interoperability with data formats used in the CrystFEL -software package. +CryystFEL utilities. -Exports: - - Functions: - - load_crystfel_geometry: a python reimplementation of the - get_detector_geometry_2 function from CrystFEL. +This module contains the implementation of several functions used to +interact with CrystFEL files and data (geometry files, stream files). """ - from __future__ import (absolute_import, division, print_function, unicode_literals) diff --git a/geometry_utils.py b/geometry_utils.py index 6265cff6e47f34af77e74e6c25b6bacccd827daa..c280f73154e9438c071e33ba66683b0044c7c319 100644 --- a/geometry_utils.py +++ b/geometry_utils.py @@ -13,23 +13,10 @@ # You should have received a copy of the GNU General Public License # along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>. """ -Utilities to load, manipulate and apply geometry information to -detector pixel data. +Geometry utilities. -Exports: - - 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. -""" +This module contains the implementation of several functions used to +manipulate geometry information.""" from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -75,33 +62,29 @@ def compute_pix_maps(geometry): PixelMaps: A PixelMaps tuple storing the pixel maps (ndarrays of type float). """ - # Determine the max fs and ss in the geometry object. - max_slab_fs = numpy.array([ + max_fs_in_slab = numpy.array([ geometry['panels'][k]['max_fs'] for k in geometry['panels'] ]).max() - max_slab_ss = numpy.array([ + max_ss_in_slab = numpy.array([ geometry['panels'][k]['max_ss'] for k in geometry['panels'] ]).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( - 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 ) 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 ) # Iterate over the panels. For each panel, determine the pixel # indices, then compute the x,y vectors. Finally, copy the # 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']: ss_grid, fs_grid = numpy.meshgrid( numpy.arange( @@ -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 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) @@ -204,12 +186,10 @@ def compute_visualization_pix_maps(geometry): coordinates (as ndarrays of type int). The third field ("r") is just set to None. """ - # Essentially, the origin of the reference system needs to be - # moved from the beam position to the top-left of the image that - # will be displayed. First, compute the normal pixel maps, then - # compute the size of the array used to display the data, finally - # use this information to estimate the magnitude of the shift that - # needs to be applied to the origin of the system. + # Shift the origin of the reference system from the beam position + # to the top-left of the image that will be displayed. Compute the + # size of the array needed to display the data, then use this + # information to estimate the magnitude of the shift. pixel_maps = compute_pix_maps(geometry) min_shape = compute_min_array_size(pixel_maps) new_x_map = numpy.array( diff --git a/parameter_utils.py b/parameter_utils.py index 18c33be74e374d8a8c0eb6276bf995dc016453e6..dd5a0392320be2fb50f69e2e4b788e19bcb5347c 100644 --- a/parameter_utils.py +++ b/parameter_utils.py @@ -13,17 +13,11 @@ # You should have received a copy of the GNU General Public License # along with cfelpyutils. If not, see <http://www.gnu.org/licenses/>. """ -Utilities for parsing command line options and configuration files. +Parameter parsing utilities. -Exports: - - Functions: - - convert_parameters: convert a dictionary returned by the - configparse module to a dictionary containing entries with - the correct type. +This module contains the implementation of several utilities used +to parse and manipulate dictionaries that store options and parameters. """ - from __future__ import (absolute_import, division, print_function, unicode_literals) @@ -91,16 +85,8 @@ def convert_parameters(config_dict): 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(): 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(): recovered_option = config_dict[section][option] if (