Skip to content
Snippets Groups Projects
Commit 85ade029 authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Move get_detector_shape and pixels_to_image into detector.geom

parent 2415be38
No related branches found
No related tags found
1 merge request!1Add reading and writing mask in crystfel file
# flake8: noqa E401
from .detector import (assemble_data, get_pixel_positions,
plot_data_on_detector, plot_detector_layout,
read_crystfel_geom, write_crystfel_geom)
from .sfx import (avg_pixel_displacement, badpixels_mask, cell_volume, ellipse,
extract_cell, extract_geometry, gauss2d_fit,
get_min_bragg_dist, get_peak_position, get_q_from_xyz,
parse_crystfel_streamfile, parse_xwiz_summary,
ph_en_to_lambda, pixels_to_image, plot_cell_parameters,
plot_center_shift, plot_geoptimiser_errormap, plot_peakogram,
plot_powder, read_crystfel_cell, read_crystfel_streamfile,
refine_geometry, rmsd_per_group, spacing)
from .detector import ( # noqa E401
assemble_data, get_pixel_positions, pixels_to_image, plot_data_on_detector,
plot_detector_layout, read_crystfel_geom, write_crystfel_geom)
from .sfx import ( # noqa E401
avg_pixel_displacement, badpixels_mask, cell_volume, ellipse, extract_cell,
extract_geometry, gauss2d_fit, get_min_bragg_dist, get_peak_position,
get_q_from_xyz, parse_crystfel_streamfile, parse_xwiz_summary,
ph_en_to_lambda, plot_cell_parameters, plot_center_shift,
plot_geoptimiser_errormap, plot_peakogram, plot_powder, read_crystfel_cell,
read_crystfel_streamfile, refine_geometry, rmsd_per_group, spacing)
# flake8: noqa E401
from .crystfel_frm import read_crystfel_geom, write_crystfel_geom
from .geom import get_pixel_positions, assemble_data
from .draw import plot_detector_layout, plot_data_on_detector
from .crystfel_frm import read_crystfel_geom, write_crystfel_geom # noqa E401
from .draw import plot_data_on_detector, plot_detector_layout # noqa E401
from .geom import ( # noqa E401
assemble_data, get_detector_shape, get_pixel_positions, pixels_to_image)
......@@ -55,3 +55,23 @@ def assemble_data(data, pos):
img[y - ymin, x - xmin] = data
return img, (-xmin, -ymin)
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)
img[px.modno, px.ss, px.fs] = px[attr]
return img
# flake8: noqa E401
from .crystfelio import (extract_cell, extract_geometry,
parse_crystfel_streamfile, read_crystfel_streamfile)
from .draw import (plot_cell_parameters, plot_center_shift,
plot_geoptimiser_errormap, plot_peakogram, plot_powder)
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_detector_shape, get_peak_position,
pixels_to_image, rmsd_per_group)
from .refine import refine_geometry
from .xwizio import parse_xwiz_summary
from .crystfelio import ( # noqa E401
extract_cell, extract_geometry, parse_crystfel_streamfile,
read_crystfel_streamfile)
from .draw import ( # noqa E401
plot_cell_parameters, plot_center_shift, plot_geoptimiser_errormap,
plot_peakogram, plot_powder)
from .lattice import ( # noqa E401
cell_volume, get_min_bragg_dist, get_q_from_xyz, ph_en_to_lambda,
read_crystfel_cell, spacing)
from .misc import ( # noqa E401
avg_pixel_displacement, badpixels_mask, ellipse, gauss2d_fit,
get_peak_position, rmsd_per_group)
from .refine import refine_geometry # noqa E401
from .xwizio import parse_xwiz_summary # noqa E401
......@@ -116,23 +116,3 @@ def badpixels_mask(pe, panels, snr=6, min_peak_count=4):
px = px.join(rp, on="ri")
px['msk'] = (px.num_peaks > px.num_peaks_hi)
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)
img[px.modno, px.ss, px.fs] = px[attr]
return img
......@@ -4,9 +4,11 @@ import tempfile
import h5py
from ..detector import read_crystfel_geom, write_crystfel_geom
from ..detector import (
get_detector_shape, pixels_to_image, read_crystfel_geom,
write_crystfel_geom)
from .crystfelio import extract_geometry, read_crystfel_streamfile
from .misc import badpixels_mask, get_detector_shape, pixels_to_image
from .misc import badpixels_mask
from .refine import refine_geometry
......
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