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

support for multi-frame hdf5 files #2221

Closed
marcocamma opened this issue Jun 21, 2024 · 5 comments
Closed

support for multi-frame hdf5 files #2221

marcocamma opened this issue Jun 21, 2024 · 5 comments
Assignees
Labels
bug Serious issue, to be addressed in priority ! easy First contribution welcome

Comments

@marcocamma
Copy link

Dear Jerome and all,

as you are certainly aware of, lima2 can handle more than one images taken with more than one threshold.
At id10, we have already one Eiger2 4M running with Lima2
When I tried to use pyFAI-average, we get the error message reported below (pyFAI 2024.5.0)

It would be great if pyFAI-average (and possibly other CLIs?) can be improved to support Lima2 files.
Thanks,
marco

#####@#####:/data/visitor/hc5730/id10/20240611/RAW_DATA/yzo2/yzo2_0001/scan0122$ pyFAI-average -o sum.npy -m sum eiger4m_v2_frame_0_00000.h5
[ .....]
File "/usr/lib/python3/dist-packages/pyFAI/average.py", line 877, in process
writer.write_reduction(algorithm, image_reduction)
File "/usr/lib/python3/dist-packages/pyFAI/average.py", line 562, in write_reduction
image = self._fabio_class.__class__(data=data, header=header)
File "/usr/lib/python3/dist-packages/fabio/edfimage.py", line 801, in init
raise Exception("Data dimension too big. Only 1d or 2d arrays are supported.")
Exception: Data dimension too big. Only 1d or 2d arrays are supported.
@kif kif added bug Serious issue, to be addressed in priority ! easy First contribution welcome labels Jun 21, 2024
@kif kif self-assigned this Jun 21, 2024
@kif
Copy link
Member

kif commented Jun 21, 2024

Apparently the file-driver used is currently EDF ... can you try to switch format with --format lima or numpy or eiger.

@marcocamma
Copy link
Author

marcocamma commented Jun 21, 2024

Indeed it works with --format numpy.
Do you think that it could be possible to have the format be inferred if the -o filename is provided ?
It would make the tool a bit handier to use (and it is already very handy!)
Thanks anyway for your help !

@kif
Copy link
Member

kif commented Jun 21, 2024

Well, I tried to understand the reason for the bug, and EDF is tailored for 1&2D data. Here the dataset looks of higher dimentionnality. The fact is: this is a bug which deserves a proper fix, and I suspected other fileformat would be more permissive. I need first to have a proper look at the data coming from those new detectors.

About the automatic determination of the fileformat: it is true a .npy extension should be associated to numpy but tiff or hdf5 have several fileformats associated with a single extension so a generic solution is not really achievable.

@kif kif assigned mjdiff and unassigned kif Jun 24, 2024
@mjdiff
Copy link
Contributor

mjdiff commented Jul 12, 2024

I have looked at the problem. Marco tries to process the (N x M x K x P) data where additional M is a dimension related to frames recorded at different detector thresholds. From a general point of view, I could think about a few solutions:

  1. Automatic determination of the file format for the file extension -o filename as proposed by Marco. However, Jerome has the right point that this can be an issue for other extensions as they can serve several file formats.

  2. For 2D formats split output to multiple files for each additional dimension. In the case of Lima2, the data is not 3D but 4D where the additional dimension is related to frames recorded at different thresholds. However, it could be considered unpractical to use a 2D file format for multidimensional frame data.

  3. Before processing data, detect if the input data is 4D, notify the user that the current format is not compatible, propose alternative formats, and terminate.

Personally, I opt for solution number 3 until there is a strong need to use 2D data file formats for this case. Also, we can think about a specific solution that we save stack to edf but what about other 2d formats?

@kif
Copy link
Member

kif commented Jul 12, 2024

It could be frustrating for the user to wait for a minute or two for the compete dataset to be read and then have the program crashing just at the ends.

I would go for a warning, saying that there is an issue with the shape of what came in (option 3) but then try to save anyway. If the reduced dataset is 3d: take the first frame, create a fabioimage instance with it. If this fabioimage has an "append_frame" method, just, stuff all the frames in it and save. If not, save each frame deserves to be saved into an independent file.

mjdiff added a commit to mjdiff/pyFAI_average_id10 that referenced this issue Jul 21, 2024
mjdiff added a commit to mjdiff/pyFAI_average_id10 that referenced this issue Jul 21, 2024
mjdiff added a commit to mjdiff/pyFAI_average_id10 that referenced this issue Jul 21, 2024
mjdiff added a commit to mjdiff/pyFAI_average_id10 that referenced this issue Jul 21, 2024
@kif kif closed this as completed in aecdfe3 Aug 19, 2024
kif added a commit that referenced this issue Aug 19, 2024
This pull request addresses issue #2221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Serious issue, to be addressed in priority ! easy First contribution welcome
Projects
None yet
Development

No branches or pull requests

3 participants