Skip to content

Commit

Permalink
Handle mask with URL for support for HDF5
Browse files Browse the repository at this point in the history
  • Loading branch information
kif committed Dec 19, 2024
1 parent d8f7d8a commit f63caba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions src/pyFAI/diffmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "13/12/2024"
__date__ = "19/12/2024"
__status__ = "development"
__docformat__ = 'restructuredtext'

Expand Down Expand Up @@ -291,18 +291,27 @@ def parse(self, sysargv=None, with_config=False):
config["input_data"] = [(i, None) for i in self.inputfiles]

if options.mask:
mask = urlparse(options.mask).path
urlmask = urlparse(options.mask)
elif ai.get("do_mask", False) or ai.get("mask_file", None):
urlmask = urlparse(ai.get("mask_file", None))
elif config.get("do_mask", False) or config.get("mask_file", None):
mask = urlparse(config.get("mask_file", None)).path
# compatibility with elder config files...
deprecated_warning("Config of mask no more top-level, but in ai config group", "mask_file", deprecated_since="2024.12.0")
urlmask = urlparse(config.get("mask_file", None))
else:
mask = ""
if os.path.isfile(mask):
logger.info("Reading Mask file from: %s", mask)
self.mask = os.path.abspath(mask)
urlmask = urlparse("")
if "::" in urlmask.path:
mask_filename, idx = urlmask.path.split("::", 1)
mask_filename = os.path.abspath(mask_filename)
urlmask = urlparse(f"fabio://{mask_filename}?slice={idx}")

if os.path.isfile(urlmask.path):
logger.info("Reading Mask file from: %s", urlmask.path)
self.mask = urlmask.geturl()
ai["mask_file"] = self.mask
ai["do_mask"] = True
else:
logger.warning("No such mask file %s", mask)
logger.warning("No such mask file %s", urlmask.path)
if options.poni:
if os.path.isfile(options.poni):
logger.info("Reading PONI file from: %s", options.poni)
Expand Down
2 changes: 1 addition & 1 deletion src/pyFAI/io/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
__contact__ = "[email protected]"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "11/12/2024"
__date__ = "19/12/2024"
__status__ = "development"


Expand Down

0 comments on commit f63caba

Please sign in to comment.