예제 #1
0
 def to_image(self):
     from hyperspy.signals.image import Image
     dic = self._get_signal_dict()
     dic['mapped_parameters']['record_by'] = 'image'
     dic['data'] = np.rollaxis(dic['data'], -1, 0)
     dic['axes'] = utils_varia.rollelem(dic['axes'], -1, 0)
     i = 0
     for axis in dic['axes']:
         axis['index_in_array'] = i
         i += 1
     return Image(dic)
예제 #2
0
 def to_image(self):
     from hyperspy.signals.image import Image
     dic = self._get_signal_dict()
     dic['mapped_parameters']['record_by'] = 'image'
     dic['data'] = np.rollaxis(dic['data'], -1, 0)
     dic['axes'] = utils_varia.rollelem(dic['axes'],-1,0)
     i = 0
     for axis in dic['axes']:
         axis['index_in_array'] = i
         i += 1
     return Image(dic)
예제 #3
0
파일: spectrum.py 프로젝트: csb60/hyperspy
 def to_image(self):
     from hyperspy.signals.image import Image
     dic = self._get_signal_dict()
     dic['mapped_parameters']['record_by'] = 'image'
     dic['data'] = np.rollaxis(dic['data'], -1, 0)
     dic['axes'] = utils_varia.rollelem(dic['axes'],-1,0)
     i = 0
     for axis in dic['axes']:
         axis['index_in_array'] = i
         i += 1
     im = Image(dic)
     if hasattr(self, 'learning_results'):
         im.learning_results = copy.deepcopy(self.learning_results)
         im.learning_results._transpose_results()
         im.learning_results.original_shape = self.data.shape
     return im
예제 #4
0
파일: image.py 프로젝트: iygr/hyperspy
 def to_spectrum(self):
     from hyperspy.signals.spectrum import Spectrum
     dic = self._get_signal_dict()
     dim = len(self.data.shape)
     dic['mapped_parameters']['record_by'] = 'spectrum'
     dic['data'] = np.rollaxis(dic['data'], 0, dim)
     dic['axes'] = utils_varia.rollelem(dic['axes'],0, dim)
     i = 0
     for axis in dic['axes']:
         axis['index_in_array'] = i
         i += 1
     sp = Spectrum(dic)
     sp.axes_manager._set_axes_index_in_array_from_position()
     if hasattr(self, 'learning_results'):
         sp.learning_results = copy.deepcopy(self.learning_results)
         sp.learning_results._transpose_results()
         sp.learning_results.original_shape = self.data.shape
     return sp
예제 #5
0
    def to_spectrum(self, signal_axis=0):
        """Image to spectrum

        Parameters
        ----------
        signal_axis : integer
            Selected the signal axis.        
            
        Examples
        --------        
        >>> img = signals.Image({'data' : np.ones((3,4,5,6))})
        >>> img
        <Image, title: , dimensions: (3L, 4L, 5L, 6L)>

        >>> img.to_spectrum()
        <Spectrum, title: , dimensions: (4L, 5L, 6L, 3L)>

        >>> img.to_spectrum(1)
        <Spectrum, title: , dimensions: (3L, 5L, 6L, 4L)>
        
        """
        from hyperspy.signals.spectrum import Spectrum
        dic = self._get_signal_dict()
        dim = len(self.data.shape)
        dic['mapped_parameters']['record_by'] = 'spectrum'        
        dic['data'] = np.rollaxis(dic['data'], signal_axis, dim)
        dic['axes'] = utils_varia.rollelem(dic['axes'], signal_axis, dim)
        i = 0
        for axis in dic['axes']:
            axis['index_in_array'] = i
            i += 1
        sp = Spectrum(dic)
        sp.axes_manager._set_axes_index_in_array_from_position()
        if hasattr(self, 'learning_results'):
            if signal_axis != 0 and self.learning_results.loadings is not None:
                print("The learning results won't be transfered correctly")
            else :
                sp.learning_results = copy.deepcopy(self.learning_results)
                sp.learning_results._transpose_results()
                sp.learning_results.original_shape = self.data.shape
                
        sp.tmp_parameters = self.tmp_parameters.deepcopy()
        return sp
예제 #6
0
    def to_image(self, signal_to_index=0):
        """Spectrum to image

        Parameters
        ----------
        signal_to_index : integer
            Position to move the signal axis.        
            
        Examples
        --------        
        >>> s = signals.Spectrum({'data' : np.ones((3,4,5,6))})
        >>> s
        <Spectrum, title: , dimensions: (3L, 4L, 5L, 6L)>

        >>> s.to_image()
        <Image, title: , dimensions: (6L, 3L, 4L, 5L)>

        >>> s.to_image(1)
        <Image, title: , dimensions: (3L, 6L, 4L, 5L)>
        
        """
        from hyperspy.signals.image import Image
        dic = self._get_signal_dict()
        dic['mapped_parameters']['record_by'] = 'image'
        dic['data'] = np.rollaxis(dic['data'], -1, signal_to_index)
        dic['axes'] = utils_varia.rollelem(dic['axes'],-1,signal_to_index)
        i = 0
        for axis in dic['axes']:
            axis['index_in_array'] = i
            i += 1
        im = Image(dic)
        
        if hasattr(self, 'learning_results'):
            if signal_to_index != 0 and self.learning_results.loadings is not None:
                print("The learning results won't be transfered correctly")
            else :
                im.learning_results = copy.deepcopy(self.learning_results)
                im.learning_results._transpose_results()
                im.learning_results.original_shape = self.data.shape

        im.tmp_parameters = self.tmp_parameters.deepcopy()
        return im