diff --git a/src/geomtools/sfx/__init__.py b/src/geomtools/sfx/__init__.py index e58dfa85da4b503e77d566af72767bf8649a076c..a9c1675513a14903ca32bfdd28f7d94ec08207bd 100644 --- a/src/geomtools/sfx/__init__.py +++ b/src/geomtools/sfx/__init__.py @@ -6,7 +6,7 @@ from .draw import (plot_cell_parameters, plot_center_shift, from .lattice import (cell_volume, get_min_bragg_dist, get_q_from_xyz, ph_en_to_lambda, read_crystfel_cell, spacing) from .misc import (avg_pixel_displacement, badpixels_mask, ellipse, - gauss2d_fit, get_peak_position, pixels_to_image, - rmsd_per_group) + gauss2d_fit, get_detector_shape, get_peak_position, + pixels_to_image, rmsd_per_group) from .refine import refine_geometry from .xwizio import parse_xwiz_summary diff --git a/src/geomtools/sfx/misc.py b/src/geomtools/sfx/misc.py index 60f7a891754c5d8c104ea5a91610dde66be51df9..e3ef0a6054f388d929cec60d9df0c4f1a1cb179d 100644 --- a/src/geomtools/sfx/misc.py +++ b/src/geomtools/sfx/misc.py @@ -118,6 +118,19 @@ def badpixels_mask(pe, panels, snr=6, min_peak_count=4): return px +def get_detector_shape(panels): + """Returns the shape of detector image array.""" + ixmax = ( + panels[['modno', 'orig_max_ss', 'orig_max_fs']].max() + .rename({'orig_max_fs': 'fs', 'orig_max_ss': 'ss'}) + ) + ixmin = ( + panels[['modno', 'orig_min_ss', 'orig_min_fs']].min() + .rename({'orig_min_fs': 'fs', 'orig_min_ss': 'ss'}) + ) + return tuple((ixmax - ixmin + 1).tolist()) + + def pixels_to_image(shape, px, attr='msk'): """Transforms dataset of pixels to the image array.""" img = np.zeros(shape, px[attr].dtype)