European-XFEL / karabo_data

Python tools to read and analyse data from European XFEL
https://karabo-data.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
13 stars 7 forks source link

AGIPD_1MGeometry.from_quad_positions #218

Closed Calpas closed 5 years ago

Calpas commented 5 years ago

Dear experts, I'm using 'AGIPD_1MGeometry.from_quad_positions' with these parameters (1), which produces an ideal geometry from what I understood. How can I parse the real parameters to that function, to have the real geometry description? Could I retrieve them from the geometry file? Regards

(1) geom = AGIPD_1MGeometry.from_quad_positions ( quad_pos = [ (-525, 625), (-550, - 10), ( 520, -160), ( 542.5, 475), ])

takluyver commented 5 years ago

If you've got a CrystFEL format (.geom) geometry file, you can use the AGIPD_1MGeometry.from_crystfel_geom method. Docs: https://karabo-data.readthedocs.io/en/latest/geometry.html#karabo_data.geometry2.AGIPD_1MGeometry.from_crystfel_geom

Calpas commented 5 years ago

Dear Takluyver, when I run (1) with both of these 2 methods on this data (2) I have this error message (3). To access the mask parameter, I provided the short path 'entry_1/data_1/mask'. Do you see what is wrong? Regards

(1) geom.position_modules_fast(mask)

(2) /gpfs/exfel/u/scratch/SPB/201801/p002120/

(3) File "/home/bcalpas/machine_learning/tensorflow_keras/xfel/job_alex_stream/tool/function.py", line 707, in process_data mask, centre_xy = geom.position_modules_fast(mask) File "/home/bcalpas/.local/lib/python3.6/site-packages/karabo_data/geometry2.py", line 231, in position_modules_fast return self._snapped().position_modules(data) File "/home/bcalpas/.local/lib/python3.6/site-packages/karabo_data/geometry2.py", line 649, in position_modules assert data.shape[-3:] == self.geom.expected_data_shape AssertionError

takluyver commented 5 years ago

What does mask.shape show?

Calpas commented 5 years ago

mask shape: (8192, 128)

takluyver commented 5 years ago

OK, position_modules_fast() expects a 3D array (16, 512, 128), with the 16 modules along a separate dimension. Some tools (including OnDA) work with a 2D array where the first two dimensions are combined.

You can rearrange the array like this:

mask = mask.reshape(16, 512, 128)
Calpas commented 5 years ago

Dear Takluyver, it works fine. Thank you. Regards

takluyver commented 5 years ago

Great, thanks.