Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using fabio to read detector H5 files other than Eiger (e.g. Lambda, etc) #565

Closed
lorcat opened this issue Apr 25, 2024 · 14 comments · Fixed by #566
Closed

Using fabio to read detector H5 files other than Eiger (e.g. Lambda, etc) #565

lorcat opened this issue Apr 25, 2024 · 14 comments · Fixed by #566

Comments

@lorcat
Copy link

lorcat commented Apr 25, 2024

Hi!
I have tried recently to use fabio for an HDF5/NEXUS from an X-spectrum Lambda multi-module system.

Python 3.12.3
fabio 2024.4.0 py312ha90f08f_0 conda-forge

fabio.openimage.openimage("l1_test02_00002_master.nxs")
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\glazyrin.conda\envs\latest_fabio\Lib\site-packages\fabio\openimage.py", line 210, in openimage
obj = obj.read(obj.filename, frame)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\glazyrin.conda\envs\latest_fabio\Lib\site-packages\fabio\eigerimage.py", line 156, in read
raise NotGoodReader("HDF5 file does not contain an Eiger-like structure.")
fabio.fabioutils.NotGoodReader: HDF5 file does not contain an Eiger-like structure.

I am interested in using fabio in own code and as a part of DIOPTAS, including HDF5 VDS capability. Do you think it will be possible to add this detector structure to fabio?

The appended files are as follows:
l1_test02_00002_m0[1-3].nxs - correspond to individual modules
l1_test02_00002_master.nxs - The master file with VDS (Virtual Datasets)

lambda_detector.zip

@kif
Copy link
Member

kif commented Apr 25, 2024

This should be possible if there are some headers which allow to distinguish those files from the one generated by lima or dectris.

@lorcat
Copy link
Author

lorcat commented Apr 25, 2024

The structure of these NEXUS files is fairly simple and one can also check it via silx or else viewer.

Here are the pictures illustrating it for the individual module and the master file.
individual_module_info
master_file

Hopefully there will be more multimodule lambdas around, I know about 9M with 12 modules under commissioning now. Having the capability with fabio would be great!

@kif
Copy link
Member

kif commented Apr 25, 2024

There is the /entry/instrument/detector/description, but it will be fragile at best ...

@lorcat
Copy link
Author

lorcat commented Apr 25, 2024

yes, it has the "Lambda" string. The master file and the modules files are different by absence of the ../module[0-9]+ branch

@kif
Copy link
Member

kif commented May 2, 2024

@lorcat : Can you have a look the associated PR to check if it meets your needs ?

@lorcat
Copy link
Author

lorcat commented May 2, 2024

Hi! PR=pull request. Sure, what should I do?

@kif
Copy link
Member

kif commented May 2, 2024

Can you retrieve the PR and install it locally to validate the reading on your files

wget https://github.com/kif/fabio/archive/refs/heads/565_lambda.zip
unzip 565_lambda.zip
cd fabio-565_lambda
pip install .

and then check it is working for your files...

@lorcat
Copy link
Author

lorcat commented May 2, 2024

Hi!

I have tried the master file and the individual module. So far works, thank you!

import fabio
fh = fabio.openimage.openimage("l1_test02_00002_master.nxs")
fh.data
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=int16)
fh.data.shape
(1813, 1555)

fh = fabio.openimage.openimage("l1_test02_00002_m01.nxs")
fh.data.shape
(516, 1554)
fh.data
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=int16)

@kif
Copy link
Member

kif commented May 2, 2024

Well, those data are part of the non regression test ... I would expect them to work.
Maybe you can test on some other data with actual beam and sample to validate.

@lorcat
Copy link
Author

lorcat commented May 2, 2024

Right, we will have a 2M lambda in 1 week. I will let you know then.
Many thanks!

@lorcat
Copy link
Author

lorcat commented May 2, 2024

One thing to mention is that the master file and modules contain 5 frames.

The following code reports only one:

import fabio
fh = fabio.openimage.openimage("l1_test02_00002_master.nxs")
fh.data
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=int16)
fh.data.shape
(1813, 1555)

@kif
Copy link
Member

kif commented May 2, 2024 via email

@lorcat
Copy link
Author

lorcat commented May 8, 2024

Hi! I have tested the library and it seem to work ok for now.
FABIO version: 15/03/2024

with fabio.openimage.openimage(filename) as data:
    for frame in (100,200,300):
        print(data.getframe(frame).shape, np.sum(data.getframe(frame).data))

frame_01

@kif kif closed this as completed in #566 May 13, 2024
@kif
Copy link
Member

kif commented May 13, 2024

Thanks for the feed-back. The code has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants