hyperspy.misc.slicing module

class hyperspy.misc.slicing.FancySlicing

Bases: object

class hyperspy.misc.slicing.SpecialSlicers(obj, isNavigation)

Bases: object

Create a slice of the signal. The indexing supports integer, decimal numbers or strings (containing a decimal number and an units).

>>> s = hs.signals.Signal1D(np.arange(10))
>>> s
<Signal1D, title: , dimensions: (|10)>
>>> s.data
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> s.axes_manager[0].scale = 0.5
>>> s.axes_manager[0].axis
array([ 0. ,  0.5,  1. ,  1.5,  2. ,  2.5,  3. ,  3.5,  4. ,  4.5])
>>> s.isig[0.5:4.].data
array([1, 2, 3, 4, 5, 6, 7])
>>> s.isig[0.5:4].data
array([1, 2, 3])
>>> s.isig[0.5:4:2].data
array([1, 3])
>>> s.axes_manager[0].units = 'µm'
>>> s.isig[:'2000 nm'].data
array([0, 1, 2, 3])
hyperspy.misc.slicing.copy_slice_from_whitelist(_from, _to, dims, both_slices, isNav, order=None)

Copies things from one object to another, according to whitelist, slicing where required.

Parameters
  • _from (object) – Original object

  • _to (object) – Target object

  • dims (tuple) – (navigation_dimensions, signal_dimensions) of the original object that is sliced

  • both_slices (tuple) – (original_slices, array_slices) of the operation that is performed

  • isNav (bool) – if the slicing operation is performed on navigation dimensions of the object

  • order (tuple, None) – if given, performs the copying in the order given. If not all attributes given, the rest is random (the order a whitelist.keys() returns them). If given in the object, _slicing_order is looked up.