silx-kit / fabio

I/O library for images produced by 2D X-ray detector
Other
57 stars 52 forks source link

Is this warning jutified ? #569

Closed kif closed 5 months ago

kif commented 5 months ago

Hi @vasole,

What is your opinion about this warning ?

In [1]: import fabio

In [2]: fabio.open("LR_flatfield_Segde_KPSS_pos1_2515eV_ai0.8deg_5s_wa30.0deg_camserverenergy2450threshold1600eV_id308719_000000_WAXS.tif")
WARNING:fabio.TiffIO:Data at tag id '65000' is smaller than expected
Out[2]: <fabio.tifimage.TifImage at 0x7f841d366590>

data.zip

This comes down to this place: https://github.com/silx-kit/fabio/blob/main/src/fabio/TiffIO.py#L277 where there are only 4 bytes in a struct supposed to hold a double (8 bytes).

vasole commented 5 months ago

Well, the warning has all the reason of being there.

What we can do is to reduce from WARNING to INFO for user TAGs (whose TAG ID is above 65000).

gfreychet commented 5 months ago

@vasole Thank you for the answer. I asked @kif if he know why the warning was there. We have two detectors at the Soft Matter Beamline (NSLS-II) and both Dectris detector give this warning. Do you mind to tell me what the TAG ID above 65000 means?

vasole commented 5 months ago

Do you mind to tell me what the TAG ID above 65000 means?

It means that those are TAGs the writer of the file can use for anything. The information contained in them is not needed to read the image data. For instance, DECTRIS can use those TAGs to add DECTRIS specific information relative to the detector, the acquisition parameters ...

gfreychet commented 5 months ago

@vasole Thank you for the answer. If the info contained in the TAG is not critical to read the image data, I would appreciate if you can pass the WARNING to INFO.

kif commented 5 months ago

Well, if your images are actually malformed and you do not care, why don't you silence-out this specific logger ?

In [1]: import fabio

In [2]: fabio.open("LR_flatfield_Segde_KPSS_pos1_2515eV_ai0.8deg_5s_wa30.0deg_camserverenergy2450threshold1600eV_id308719_0000
   ...: 00_WAXS.tif")
WARNING:fabio.TiffIO:Data at tag id '65000' is smaller than expected
Out[2]: <fabio.tifimage.TifImage at 0x7fdfe809d4d0>

In [3]: import logging;fabio.TiffIO.logger.setLevel(logging.ERROR)

In [4]: fabio.open("LR_flatfield_Segde_KPSS_pos1_2515eV_ai0.8deg_5s_wa30.0deg_camserverenergy2450threshold1600eV_id308719_0000
   ...: 00_WAXS.tif")
Out[4]: <fabio.tifimage.TifImage at 0x7fdf576b0390>

It is the input 3 which does the job.

gfreychet commented 5 months ago

@kif Thank you for the proposition. This works fine for now. I will investigate the TAG of my data to see if I pick what is triggering the warning and will use the silencing of the warning for now.

kif commented 5 months ago

OK, I'll close the issue for now. Feel free to re-open it if you find something relevant.