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

05 GaAs Strain measurements #74

Open
CMHell opened this issue Jun 24, 2021 · 1 comment
Open

05 GaAs Strain measurements #74

CMHell opened this issue Jun 24, 2021 · 1 comment

Comments

@CMHell
Copy link

CMHell commented Jun 24, 2021

Hi,

After finally switching to calibrated units ^^ The subpixelrefinementGenerator worked... The center of mass method however does not. Suggestions where I made a mistake?

x_peak = [-0.08,0.27]
y_peak = [-0.45,0.0027]
spg = SubpixelrefinementGenerator(dp, np.asarray([x_peak,y_peak]))
Vs = spg.center_of_mass_method(4)


Output:
0%
0/3000 [00:00<?, ?it/s]
---------------------------------------------------------------------------
UFuncTypeError                            Traceback (most recent call last)
<ipython-input-39-2ca1685e808f> in <module>
      4 y_peak = [-0.45,0.0027]
      5 spg = SubpixelrefinementGenerator(dp, np.asarray([x_peak,y_peak]))
----> 6 Vs = spg.center_of_mass_method(4)

~\.conda\envs\pyxem\lib\site-packages\pyxem\generators\subpixelrefinement_generator.py in center_of_mass_method(self, square_size)
    366             return ((vectors + shifts) - center) * calibration
    367 
--> 368         self.vectors_out = self.dp.map(
    369             _center_of_mass_map,
    370             vectors=self.vector_pixels,

~\.conda\envs\pyxem\lib\site-packages\hyperspy\signal.py in map(self, function, show_progressbar, parallel, max_workers, inplace, ragged, output_signal_size, output_dtype, **kwargs)
   4591                 kwargs["output_dtype"] = output_dtype
   4592             # Iteration over coordinates.
-> 4593             res = self._map_iterate(function, iterating_kwargs=ndkwargs,
   4594                                     show_progressbar=show_progressbar,
   4595                                     parallel=parallel,

~\.conda\envs\pyxem\lib\site-packages\hyperspy\signal.py in _map_iterate(self, function, iterating_kwargs, show_progressbar, parallel, max_workers, ragged, inplace, **kwargs)
   4733 
   4734             with ThreadPoolExecutor(max_workers=max_workers) as executor:
-> 4735                 for ind, res in zip(
   4736                     range(res_data.size), executor.map(func, zip(*iterators))
   4737                 ):

~\.conda\envs\pyxem\lib\concurrent\futures\_base.py in result_iterator()
    606                     # Careful not to keep a reference to the popped future
    607                     if timeout is None:
--> 608                         yield fs.pop().result()
    609                     else:
    610                         yield fs.pop().result(end_time - time.monotonic())

~\.conda\envs\pyxem\lib\concurrent\futures\_base.py in result(self, timeout)
    436                     raise CancelledError()
    437                 elif self._state == FINISHED:
--> 438                     return self.__get_result()
    439 
    440                 self._condition.wait(timeout)

~\.conda\envs\pyxem\lib\concurrent\futures\_base.py in __get_result(self)
    388         if self._exception:
    389             try:
--> 390                 raise self._exception
    391             finally:
    392                 # Break a reference cycle with the exception in self._exception

~\.conda\envs\pyxem\lib\concurrent\futures\thread.py in run(self)
     50 
     51         try:
---> 52             result = self.fn(*self.args, **self.kwargs)
     53         except BaseException as exc:
     54             self.future.set_exception(exc)

~\.conda\envs\pyxem\lib\site-packages\hyperspy\misc\utils.py in func(*args)
   1167     def func(*args):
   1168         dat, these_kwargs = figure_out_kwargs(*args)
-> 1169         return function(dat, **these_kwargs)
   1170 
   1171     return func, iterators

~\.conda\envs\pyxem\lib\site-packages\pyxem\generators\subpixelrefinement_generator.py in _center_of_mass_map(dp, vectors, square_size, center, calibration)
    363             for i, vector in enumerate(vectors):
    364                 expt_disc = _com_experimental_square(dp, vector, square_size)
--> 365                 shifts[i] = [a - square_size / 2 for a in _center_of_mass_hs(expt_disc)]
    366             return ((vectors + shifts) - center) * calibration
    367 

~\.conda\envs\pyxem\lib\site-packages\pyxem\generators\subpixelrefinement_generator.py in _center_of_mass_hs(z)
    325             s = np.sum(z)
    326             if s != 0:
--> 327                 z *= 1 / s
    328             dx = np.sum(z, axis=0)
    329             dy = np.sum(z, axis=1)

UFuncTypeError: Cannot cast ufunc 'multiply' output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'
@pc494
Copy link
Member

pc494 commented Jun 29, 2021

This is a type error, check what type your dp is (probably uint8) using dp.data.type or similar, then try converting it to float64 - this avoid problems relating to the fact that the operation of division isn't nicely defined for integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants