Skip to content

Commit

Permalink
Fix STXMImage load in ImageFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Jul 21, 2020
1 parent 0d9454d commit a57b145
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
25 changes: 19 additions & 6 deletions Stoner/HDF5.py
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand All @@ -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
2 changes: 1 addition & 1 deletion Stoner/__init__.py
Expand Up @@ -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__))
Expand Down
4 changes: 2 additions & 2 deletions recipe/meta.yaml
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/VSManalysis_v2.py
Expand Up @@ -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
Expand Down

0 comments on commit a57b145

Please sign in to comment.