Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns load from EDAX .h5 file cannot be plotted directly #487

Closed
IMBalENce opened this issue Dec 11, 2021 · 4 comments
Closed

Patterns load from EDAX .h5 file cannot be plotted directly #487

IMBalENce opened this issue Dec 11, 2021 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@IMBalENce
Copy link
Contributor

Not sure if the title explains the issue accurate enough or not.

The symptom shows up after loading an EDAX .h5 file and plot the data

s = kp.load(datadir + "//" + ebsd, scan_group_names="map20210707165220751")
s

<EBSD, title: TSLmap_0p85nA_8x8 ma..., dimensions: (76, 76|60, 60)>

plt.imshow(s.inav[0, 0].data, cmap="gray")

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_22936/3160823787.py in <module>
----> 1 plt.imshow(s.inav[0, 0].data, cmap="gray")

~\Anaconda3\envs\kp-dev\lib\site-packages\hyperspy\misc\slicing.py in __getitem__(self, slices, out)
    191 
    192     def __getitem__(self, slices, out=None):
--> 193         return self.obj._slicer(slices, self.isNavigation, out=out)
    194 
    195 

~\Anaconda3\envs\kp-dev\lib\site-packages\hyperspy\misc\slicing.py in _slicer(self, slices, isNavigation, out)
    283 
    284         if out is None:
--> 285             _obj = self._deepcopy_with_new_data(new_data,
    286                                                 copy_variance=True)
    287             _to_remove = []

~\Anaconda3\envs\kp-dev\lib\site-packages\hyperspy\signal.py in _deepcopy_with_new_data(self, data, copy_variance, copy_navigator, copy_learning_results)
   2329                 del self.learning_results
   2330             self.models._models = DictionaryTreeBrowser()
-> 2331             ns = self.deepcopy()
   2332             ns.data = data
   2333             return ns

c:\users\zhouxu\01_kikuchipy\kikuchipy master\kikuchipy\signals\ebsd.py in deepcopy(self)
   2003             new._xmap = copy.deepcopy(self.xmap)
   2004         if self.static_background is not None:
-> 2005             new._static_background = self.static_background.copy()
   2006         else:
   2007             new._static_background = copy.deepcopy(self.static_background)

AttributeError: 'int' object has no attribute 'copy'

It seems to have something to do with s.static_background, as I can confirm s.data has been correctly imported. and the value of s.static_background is -1.

I also did a quick comparison by loading a Oxford .ebsp file. The plot function behaves like normal and the value of s.static_background is None in this case.

@IMBalENce
Copy link
Contributor Author

By the way, I found a way to convert EDAX .up1 and .up2 binaries to .h5 in EDAX OIM, not quite straight forward though. Happy to share them if you find useful.

@hakonanes hakonanes added the bug Something isn't working label Dec 11, 2021
@hakonanes hakonanes added this to the v0.6.0 milestone Dec 11, 2021
@hakonanes
Copy link
Member

Thanks for reporting this! The cause is a new property EBSD.static_background which replaces EBSD.metadata.Acquisition_instrument.SEM.Detector.EBSD.static_background (for obvious reasons), and the desire to keep the background when deepcopying, which is done with EBSD.inav[]. This only affects develop, so there's no rush to fix this.

The new property was added in anticipation of completing #466, where I try to remove unnecessary metadata and move stuff over to EBSD.xmap and EBSD.detector. But that is a lot of work, so it's done in stages.

Since EDAX HDF5 files store patterns after static background correction, there isn't a static background pattern in the file. The check for whether it's possible to deepcopy EBSD.static_background should be better than just to check whether it's None. Or, perhaps we should use np.copy(self.static_background) instead. If you want, you can make a PR to fix this (to develop), or I'll do it myself next week.

@IMBalENce
Copy link
Contributor Author

That make sense now, as I've only tested this part on develop very recently.

I'll give it a try to fix it. Otherwise I'll leave it to you.

@hakonanes
Copy link
Member

This will be fixed in #537.

hakonanes added a commit to hakonanes/kikuchipy that referenced this issue Jun 12, 2022
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants