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

TraitError from s.get_virtual_bse_intensity(roi) for EBSD signal read from Bruker h5ebsd #347

Closed
hakonanes opened this issue Apr 23, 2021 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@hakonanes
Copy link
Member

Issue reported by @Fred-Ad in #329:

It's the same with vbse = s.get_virtual_bse_intensity(roi) that gives me this - long - error :

---------------------------------------------------------------------------
TraitError                                Traceback (most recent call last)
<ipython-input-6-a39e5bb3612f> in <module>
----> 1 vbse = s.get_virtual_bse_intensity(roi)
      2 vbse

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\kikuchipy\signals\ebsd.py in get_virtual_bse_intensity(self, roi, out_signal_axes)
   1494         """
   1495         vbse = roi(self, axes=self.axes_manager.signal_axes)
-> 1496         vbse_sum = self._get_sum_signal(vbse, out_signal_axes)
   1497         vbse_sum.metadata.General.title = "Virtual backscatter electron image"
   1498         vbse_sum.set_signal_type("VirtualBSEImage")

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\kikuchipy\signals\ebsd.py in _get_sum_signal(signal, out_signal_axes)
   1443     @staticmethod
   1444     def _get_sum_signal(signal, out_signal_axes: Optional[List] = None):
-> 1445         out = signal.sum(signal.axes_manager.signal_axes)
   1446         if out_signal_axes is None:
   1447             out_signal_axes = list(

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\signal.py in sum(self, axis, out, rechunk)
   3648         if axis is None:
   3649             axis = self.axes_manager.navigation_axes
-> 3650         return self._apply_function_on_data_and_remove_axis(
   3651             np.sum, axis, out=out, rechunk=rechunk)
   3652     sum.__doc__ %= (MANY_AXIS_PARAMETER, OUT_ARG, RECHUNK_ARG)

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\signal.py in _apply_function_on_data_and_remove_axis(self, function, axes, out, **kwargs)
   3594             ar_axes = ar_axes[0]
   3595 
-> 3596         s = out or self._deepcopy_with_new_data(None)
   3597 
   3598         if np.ma.is_masked(self.data):

D:\Python\WPy64-3880\python-3.8.8.amd64\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

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\signal.py in deepcopy(self)
   4847         :py:meth:`~hyperspy.signal.BaseSignal.copy`
   4848         """
-> 4849         return copy.deepcopy(self)
   4850 
   4851     def change_dtype(self, dtype, rechunk=True):

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\copy.py in deepcopy(x, memo, _nil)
    151             copier = getattr(x, "__deepcopy__", None)
    152             if copier is not None:
--> 153                 y = copier(memo)
    154             else:
    155                 reductor = dispatch_table.get(cls)

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\signal.py in __deepcopy__(self, memo)
   4813 
   4814     def __deepcopy__(self, memo):
-> 4815         dc = type(self)(**self._to_dictionary())
   4816         if isinstance(dc.data, np.ndarray):
   4817             dc.data = dc.data.copy()

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\kikuchipy\signals\ebsd.py in __init__(self, *args, **kwargs)
     99         optional input parameters.
    100         """
--> 101         Signal2D.__init__(self, *args, **kwargs)
    102 
    103         self._detector = kwargs.pop(

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\_signals\signal2d.py in __init__(self, *args, **kw)
    318 
    319     def __init__(self, *args, **kw):
--> 320         super().__init__(*args, **kw)
    321         if self.axes_manager.signal_dimension != 2:
    322             self.axes_manager.set_signal_dimension(2)

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\signal.py in __init__(self, data, **kwds)
   2172             self.learning_results = LearningResults()
   2173             kwds['data'] = data
-> 2174             self._load_dictionary(kwds)
   2175             self._plot = None
   2176             self.inav = SpecialSlicersSignal(self, True)

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\signal.py in _load_dictionary(self, file_data_dict)
   2438         if 'axes' not in file_data_dict:
   2439             file_data_dict['axes'] = self._get_undefined_axes_list()
-> 2440         self.axes_manager = AxesManager(
   2441             file_data_dict['axes'])
   2442         if 'metadata' not in file_data_dict:

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\axes.py in __init__(self, axes_list)
    782             obj : The AxesManager that the event belongs to.
    783             """, arguments=['obj'])
--> 784         self.create_axes(axes_list)
    785         # set_signal_dimension is called only if there is no current
    786         # view. It defaults to spectrum

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\axes.py in create_axes(self, axes_list)
    969             axes_list.sort(key=lambda x: x['index_in_array'])
    970         for axis_dict in axes_list:
--> 971             self._append_axis(**axis_dict)
    972 
    973     def _update_max_index(self):

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\axes.py in _append_axis(self, *args, **kwargs)
   1032 
   1033     def _append_axis(self, *args, **kwargs):
-> 1034         axis = DataAxis(*args, **kwargs)
   1035         axis.axes_manager = self
   1036         self._axes.append(axis)

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\hyperspy\axes.py in __init__(self, size, index_in_array, name, scale, offset, units, navigate)
    262         self.high_index = self.size - 1
    263         self.low_index = 0
--> 264         self.index = 0
    265         self.update_axis()
    266         self.navigate = navigate

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\traits\trait_types.py in _validate(self, object, name, value)
   1819                 pass
   1820 
-> 1821         self.error(object, name, value)
   1822 
   1823     def _typed_value(self, value, low, high):

D:\Python\WPy64-3880\python-3.8.8.amd64\lib\site-packages\traits\base_trait_handler.py in error(self, object, name, value)
     72             The proposed new value for the attribute.
     73         """
---> 74         raise TraitError(
     75             object, name, self.full_info(object, name, value), value
     76         )

TraitError: The 'index' trait of a DataAxis instance must be 0 <= a number <= -1, but a value of 0 <class 'int'> was specified.

Originally posted by @Fred-Ad in #329 (comment)

@hakonanes hakonanes added the bug Something isn't working label Apr 23, 2021
@hakonanes hakonanes added this to the v0.4.0 milestone Apr 23, 2021
@hakonanes
Copy link
Member Author

Pretty sure this problem is related to #346.

@hakonanes
Copy link
Member Author

The reason for this error was that the RGB ROIs passed to VirtualBSEGenerator.get_rgb_image() (and other methods) weren't scaled to physical coordinates (detector pixel size in microns). Will push a bug fix for this now.

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

1 participant