Detector Geometry¶
- pyfoamalgo.geometry.stack_detector_modules(train_data, device, ppt, *, modules=None, module_numbers=None, memory_cell_last=False)¶
Stack detector modules.
- Parameters
train_data (dict) – Data from a pulse-train.
device (str) – Device or output channel name with a * replacing the module number. For example, SCS_DET_DSSC1M-1/DET/*CH0:xtdf.
ppt (str) – Property name.
modules (int) – Number of modules. Ignored if module_numbers is given. For AGIPD-1M, LPD-1M and DSSC-1M, number of modules must be 16 so it is not recommended to use module_numbers to specify modules. Note that the default module number starts from 0, i.e., the default module numbers for 4 modules are 0, 1, 2 and 3.
module_numbers (list) – A list of module numbers. The numbers do not need to be continuous or be monotonically increasing. One should use it for detectors like JungFrau, ePix100, etc. They have a different naming convention from 1M detectors and the module number starts from 1.
memory_cell_last (bool) – Whether memory cell is the last dimension.
- Returns
A limited array-like wrapper around the modules data. It is sufficient for assembling modules using detector geometry. It can be converted to a real numpy array by calling the asarray method.
1M-detector geometry¶
- class pyfoamalgo.geometry.AGIPD_1MGeometry(*args: Any, **kwargs: Any)¶
Geometry for AGIPD 1M.
- __init__(*args: Any, **kwargs: Any) None¶
- classmethod from_crystfel_geom(filename)¶
Construct a geometry from an CrystFEL format geometry file.
- Parameters
filename (str) – Path of the geometry file.
- output_array_for_position_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of assembled data filled with nan.
- Parameters
extra_shape (tuple) – By default, a 2D array is generated to hold the assembling image of modules from a single pulse. For assembling multiple pulses at once, pass
extra_shape=(pulses,)to return a 3D array.dtype (numpy.dtype) – dtype of the output array.
- position_all_modules(modules, out, *, ignore_tile_edge=False, ignore_asic_edge=False)¶
Assemble data in modules according to where the pixels are.
- Parameters
modules (numpy.ndarray/list) – Data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
out (numpy.ndarray) – Assembled data. Shape = (memory cells, y, x) / (y, x)
ignore_tile_edge – True for ignoring the pixels at the edges of tiles. If ‘out’ is pre-filled with nan, it it equivalent to masking the tile edges.
ignore_asic_edge – True for ignoring the pixels at the edges of asics. If ‘out’ is pre-filled with nan, it it equivalent to masking the asic edges.
- abstract output_array_for_dismantle_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of data in modules filled with nan.
- Parameters
extra_shape (tuple) – By default, a 3D array is generated to hold the dismantled modules from a single assembled image. For dismantling multiple images at once, pass
extra_shape=(pulses,)to return a 4D array.dtype (numpy.dtype) – dtype of the output array.
- dismantle_all_modules(assembled, out)¶
Dismantle assembled data into data in modules.
- Parameters
out (numpy.ndarray) – assembled data. Shape = (memory cells, y, x) / (y, x)
out – data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
- class pyfoamalgo.geometry.LPD_1MGeometry(*args: Any, **kwargs: Any)¶
Geometry for LPD 1M.
- __init__(*args: Any, **kwargs: Any) None¶
- classmethod from_h5_file_and_quad_positions(filepath, positions)¶
Construct a geometry from an XFEL HDF5 format geometry file.
- Parameters
filename (str) – Path of the geometry file.
positions (list) – A list of 4 (x, y) coordinates of the corner of each quadrant.
- output_array_for_position_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of assembled data filled with nan.
- Parameters
extra_shape (tuple) – By default, a 2D array is generated to hold the assembling image of modules from a single pulse. For assembling multiple pulses at once, pass
extra_shape=(pulses,)to return a 3D array.dtype (numpy.dtype) – dtype of the output array.
- position_all_modules(modules, out, *, ignore_tile_edge=False, ignore_asic_edge=False)¶
Assemble data in modules according to where the pixels are.
- Parameters
modules (numpy.ndarray/list) – Data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
out (numpy.ndarray) – Assembled data. Shape = (memory cells, y, x) / (y, x)
ignore_tile_edge – True for ignoring the pixels at the edges of tiles. If ‘out’ is pre-filled with nan, it it equivalent to masking the tile edges.
ignore_asic_edge – True for ignoring the pixels at the edges of asics. If ‘out’ is pre-filled with nan, it it equivalent to masking the asic edges.
- abstract output_array_for_dismantle_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of data in modules filled with nan.
- Parameters
extra_shape (tuple) – By default, a 3D array is generated to hold the dismantled modules from a single assembled image. For dismantling multiple images at once, pass
extra_shape=(pulses,)to return a 4D array.dtype (numpy.dtype) – dtype of the output array.
- dismantle_all_modules(assembled, out)¶
Dismantle assembled data into data in modules.
- Parameters
out (numpy.ndarray) – assembled data. Shape = (memory cells, y, x) / (y, x)
out – data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
- class pyfoamalgo.geometry.DSSC_1MGeometry(*args: Any, **kwargs: Any)¶
Geometry for DSSC 1M.
- __init__(*args: Any, **kwargs: Any) None¶
- classmethod from_h5_file_and_quad_positions(filepath, positions)¶
Construct a geometry from an XFEL HDF5 format geometry file.
- Parameters
filename (str) – Path of the geometry file.
positions (list) – A list of 4 (x, y) coordinates of the corner of each quadrant.
- output_array_for_position_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of assembled data filled with nan.
- Parameters
extra_shape (tuple) – By default, a 2D array is generated to hold the assembling image of modules from a single pulse. For assembling multiple pulses at once, pass
extra_shape=(pulses,)to return a 3D array.dtype (numpy.dtype) – dtype of the output array.
- position_all_modules(modules, out, *, ignore_tile_edge=False, ignore_asic_edge=False)¶
Assemble data in modules according to where the pixels are.
- Parameters
modules (numpy.ndarray/list) – Data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
out (numpy.ndarray) – Assembled data. Shape = (memory cells, y, x) / (y, x)
ignore_tile_edge – True for ignoring the pixels at the edges of tiles. If ‘out’ is pre-filled with nan, it it equivalent to masking the tile edges.
ignore_asic_edge – True for ignoring the pixels at the edges of asics. If ‘out’ is pre-filled with nan, it it equivalent to masking the asic edges.
- abstract output_array_for_dismantle_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of data in modules filled with nan.
- Parameters
extra_shape (tuple) – By default, a 3D array is generated to hold the dismantled modules from a single assembled image. For dismantling multiple images at once, pass
extra_shape=(pulses,)to return a 4D array.dtype (numpy.dtype) – dtype of the output array.
- dismantle_all_modules(assembled, out)¶
Dismantle assembled data into data in modules.
- Parameters
out (numpy.ndarray) – assembled data. Shape = (memory cells, y, x) / (y, x)
out – data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
Generalized geometry¶
- class pyfoamalgo.geometry.JungFrauGeometry(*args: Any, **kwargs: Any)¶
JungFrau geometry.
- __init__(*args: Any, **kwargs: Any) None¶
- classmethod from_crystfel_geom(filename, n_rows, n_columns, *, module_numbers=None)¶
Construct a geometry from an CrystFEL format geometry file.
- Parameters
filename (str) – Path of the geometry file.
n_rows (int) – Number of rows of the grid layout.
n_columns (int) – Number of columns of the grid layout.
module_numbers (list) – A list of module numbers.
- output_array_for_position_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of assembled data filled with nan.
- Parameters
extra_shape (tuple) – By default, a 2D array is generated to hold the assembling image of modules from a single pulse. For assembling multiple pulses at once, pass
extra_shape=(pulses,)to return a 3D array.dtype (numpy.dtype) – dtype of the output array.
- position_all_modules(modules, out, *, ignore_tile_edge=False, ignore_asic_edge=False)¶
Assemble data in modules according to where the pixels are.
- Parameters
modules (numpy.ndarray/list) – Data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
out (numpy.ndarray) – Assembled data. Shape = (memory cells, y, x) / (y, x)
ignore_tile_edge – True for ignoring the pixels at the edges of tiles. If ‘out’ is pre-filled with nan, it it equivalent to masking the tile edges.
ignore_asic_edge – True for ignoring the pixels at the edges of asics. If ‘out’ is pre-filled with nan, it it equivalent to masking the asic edges.
- abstract output_array_for_dismantle_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of data in modules filled with nan.
- Parameters
extra_shape (tuple) – By default, a 3D array is generated to hold the dismantled modules from a single assembled image. For dismantling multiple images at once, pass
extra_shape=(pulses,)to return a 4D array.dtype (numpy.dtype) – dtype of the output array.
- dismantle_all_modules(assembled, out)¶
Dismantle assembled data into data in modules.
- Parameters
out (numpy.ndarray) – assembled data. Shape = (memory cells, y, x) / (y, x)
out – data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
- class pyfoamalgo.geometry.EPix100Geometry(*args: Any, **kwargs: Any)¶
EPix100 geometry.
- __init__(*args: Any, **kwargs: Any) None¶
- output_array_for_position_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of assembled data filled with nan.
- Parameters
extra_shape (tuple) – By default, a 2D array is generated to hold the assembling image of modules from a single pulse. For assembling multiple pulses at once, pass
extra_shape=(pulses,)to return a 3D array.dtype (numpy.dtype) – dtype of the output array.
- position_all_modules(modules, out, *, ignore_tile_edge=False, ignore_asic_edge=False)¶
Assemble data in modules according to where the pixels are.
- Parameters
modules (numpy.ndarray/list) – Data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)
out (numpy.ndarray) – Assembled data. Shape = (memory cells, y, x) / (y, x)
ignore_tile_edge – True for ignoring the pixels at the edges of tiles. If ‘out’ is pre-filled with nan, it it equivalent to masking the tile edges.
ignore_asic_edge – True for ignoring the pixels at the edges of asics. If ‘out’ is pre-filled with nan, it it equivalent to masking the asic edges.
- abstract output_array_for_dismantle_fast(extra_shape=(), dtype=numpy.float32)¶
Make an array with the shape of data in modules filled with nan.
- Parameters
extra_shape (tuple) – By default, a 3D array is generated to hold the dismantled modules from a single assembled image. For dismantling multiple images at once, pass
extra_shape=(pulses,)to return a 4D array.dtype (numpy.dtype) – dtype of the output array.
- dismantle_all_modules(assembled, out)¶
Dismantle assembled data into data in modules.
- Parameters
out (numpy.ndarray) – assembled data. Shape = (memory cells, y, x) / (y, x)
out – data in modules. Shape = (memory cells, modules, y x) / (modules, y, x)