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

Write detector resolution in crystfel geometry file, fix type issue for binary...

Write detector resolution in crystfel geometry file, fix type issue for binary mask bitwise operations
parent 12421d6e
No related branches found
No related tags found
1 merge request!1Add reading and writing mask in crystfel file
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)
assemble_data, get_detector_shape, 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,
......
......@@ -6,7 +6,6 @@ from natsort import natsorted
from .geom import get_detector_shape
HEADER_TEMPLATE = """\
; {detector} geometry file written by geomtools
; You may need to edit this file to add:
......@@ -45,6 +44,7 @@ def write_crystfel_geom(file, panels, beam, rigid_groups, mask=None):
"""Writes geometry in CrystFEL format in file."""
# header
clen = panels.clen[0]
res = panels.res[0]
paths = {}
paths['data'] = (
panels.data[0] if panels.data[0]
......@@ -65,7 +65,7 @@ def write_crystfel_geom(file, panels, beam, rigid_groups, mask=None):
path_str = '\n'.join('{} = {} ;'.format(i, j) for i, j in paths.items())
header = HEADER_TEMPLATE.format(
detector="AGIPD1M", resolution=1/200e-6, frame_dim=0,
detector="AGIPD1M", resolution=res, frame_dim=0,
clen=clen, photon_energy=beam["photon_energy"],
adu_per_ev=1, paths=path_str,
)
......@@ -162,6 +162,7 @@ def read_crystfel_geom(filename, indexes=dict()):
if mask_file:
with h5py.File(mask_file, "r") as f:
mask = f[mask_path][:]
mask = mask.astype(int)
mask = (
(np.bitwise_and(mask, mask_goodbits) != mask_goodbits) |
(np.bitwise_and(mask, mask_badbits) != 0)
......
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