diff --git a/Stoner/HDF5.py b/Stoner/HDF5.py index 34105c82d..96f46c550 100644 --- a/Stoner/HDF5.py +++ b/Stoner/HDF5.py @@ -15,7 +15,7 @@ import numpy as _np_ from .Core import StonerLoadError, metadataObject, DataFile from . import Data, DataFolder -from .Image.core import ImageFile +from .Image.core import ImageFile, ImageArray import os.path as path import os @@ -639,12 +639,20 @@ def __init__(self, *args, **kargs): if len(args) > 0 and isinstance(args[0], string_types): d = SLS_STXMFile(args[0]) args = args[1:] + super(STXMImage, self).__init__(*args, **kargs) + self.image = d.data + self.metadata.update(d.metadata) + self.filename = d.filename + elif len(args) > 0 and isinstance(args[0], ImageFile): + src = args[0] + args = args[1:] + super(STXMImage, self).__init__(src.image, *args, **kargs) + elif len(args) > 0 and isinstance(args[0], ImageArray): + src = args[0] + args = args[1:] + super(STXMImage, self).__init__(src, *args, **kargs) else: - d = Data() - super(STXMImage, self).__init__(*args[1:], **kargs) - self.image = d.data - self.metadata.update(d.metadata) - self.filename = d.filename + super(STXMImage, self).__init__(*args, **kargs) if isinstance(regrid, tuple): self.gridimage(*regrid) elif isinstance(regrid, dict): @@ -665,3 +673,8 @@ def __floordiv__(self, other): return ret else: raise TypeError("Can only do XMCD calculation with another STXMFile") + + def _load(self, filename, *args, **kargs): + """Pass through to SLS_STXMFile._load.""" + self.__init__(*args, **kargs) + return self diff --git a/Stoner/__init__.py b/Stoner/__init__.py index 6ec9dee78..837203df4 100644 --- a/Stoner/__init__.py +++ b/Stoner/__init__.py @@ -33,7 +33,7 @@ from os import path as _path_ -__version_info__ = ("0", "9", "6") +__version_info__ = ("0", "9", "7") __version__ = ".".join(__version_info__) __home__ = _path_.realpath(_path_.dirname(__file__)) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index ddf3d0af1..06dbdb760 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -4,10 +4,10 @@ package: name: '{{ name|lower }}' - version: '0.9.6' + version: '0.9.7' source: - git_tag: v0.9.6 + git_tag: v0.9.7 git_url: https://github.com/stonerlab/Stoner-PythonCode.git build: number: 0 diff --git a/scripts/VSManalysis_v2.py b/scripts/VSManalysis_v2.py index b4e0b87f2..3466f937d 100644 --- a/scripts/VSManalysis_v2.py +++ b/scripts/VSManalysis_v2.py @@ -230,9 +230,7 @@ def editData(Data, operations): ) break except ValueError: - timeout += ( - 1 - ) # if get 5 files unreadable in a row then finish the program + timeout += 1 # if get 5 files unreadable in a row then finish the program print("Could not read file ", path) if timeout <= 5: break