EDF dataset: numerous fabio error messages
Since fabio >= 0.10.0
, a lot of error like this appear when parsing some EDF datasets:
ERROR:fabio.edfimage:Unable converting index of DIM_V to integer
ERROR:fabio.edfimage:Unable converting index of DIM_H to integer
This occurs when tomoscan does
with fabio.open(image) as fabio_fid:
n_frames = fabio_fid.nframes
The parsing still completes, though.
Not sure it's a regression in fabio or an issue in the dataset itself.
In the case where the root of the problem cannot be fixed, we can still silence these messages:
import logging
from contextlib import ContextDecorator
class PatchLogLevel(ContextDecorator):
def __init__(self, prefix, loglevel):
self.prefix = prefix
self.new_loglevel = loglevel
self.base_loglevels = {
k: v.getEffectiveLevel()
for k, v in logging.root.manager.loggerDict.items()
if k.startswith(prefix) and isinstance(v, logging.Logger)
}
def __enter__(self):
for logger_name in self.base_loglevels.keys():
logging.getLogger(logger_name).setLevel(self.new_loglevel)
def __exit__(self, exc_type, exc, exc_tb):
for logger_name, old_log_level in self.base_loglevels.items():
logging.getLogger(logger_name).setLevel(old_log_level)
# [...]
with PatchLogLevel("fabio", logging.CRITICAL):
fabio_stuff(...)