Exemplo n.º 1
0
    def fcn(self, data_in):
        """
        If return list, [0] goes to original, [1] goes to affected
        """

        baseline = _sg(data_in, window_length=self.parameters['window_length'],
                       polyorder=self.parameters['polyorder'], axis=-1)
        data_out = data_in - baseline

        return [baseline, data_out]
Exemplo n.º 2
0
    def fcn(self, data_in):
        """
        If return list, [0] goes to original, [1] goes to affected
        """

        baseline = _sg(data_in,
                       window_length=self.parameters['window_length'],
                       polyorder=self.parameters['polyorder'],
                       axis=-1)
        data_out = data_in - baseline

        return [baseline, data_out]
Exemplo n.º 3
0
    def _calc(self, data, ret_obj):
        try:
            if self.rng is None:
                correction_factor = _sg(data.real, window_length=self.win_size,
                                        polyorder=self.order, axis=-1)
            else:
                correction_factor = _sg(data[..., self.rng].real,
                                        window_length=self.win_size,
                                        polyorder=self.order, axis=-1)

            correction_factor[correction_factor == 0] = 1
            correction_factor **= -1

            if self.rng is None:
                ret_obj *= correction_factor
            else:
                ret_obj[..., self.rng] *= correction_factor
        except:
            return False
        else:
            return True
Exemplo n.º 4
0
    def errorCorrectHSData(self, hsdatacls):
        temp_spectra = hsdatacls._get_rand_spectra_real(10,
                                                        pt_sz=3,
                                                        quads=True)

        plugin = widgetSG()

        result = DialogPlotEffect.dialogPlotEffect(
            temp_spectra,
            x=hsdatacls.freqvec,
            plugin=plugin,
            xlabel='Wavenumber (cm$^{-1}$)',
            ylabel='Real {$\chi_R$} (au)',
            show_difference=True)
        if result is not None:
            win_size = result.win_size
            order = result.order

            detrend_ct = 0
            detrend_tot = hsdatacls.mlen * hsdatacls.nlen

            # Most efficient system
            if len(hsdatacls.pixrange) != 0:
                data_out = hsdatacls.spectrafull[:, :, hsdatacls.pixrange[0]:
                                                 hsdatacls.pixrange[1] + 1]
            else:
                data_out = hsdatacls.spectrafull

            start = _ti.default_timer()

            correction = (1 / _sg(data_out.real,
                                  window_length=win_size,
                                  polyorder=order,
                                  axis=-1))

            data_out = data_out * correction

            stop = _ti.default_timer()
            #                print('2: {}'.format(stop2-start2))
            #                print('3: {}'.format(stop3-start3))
            #                print('4: {}'.format(stop4-start4))
            #                print('5: {}'.format(stop5-start5))
            #
            print('Scaled {} spectra ({:.5f} sec/spect)'.format(
                detrend_tot,
                (stop - start) / (hsdatacls.mlen * hsdatacls.nlen)))

            hsdatacls.spectra = data_out
            return [
                'Scaling', 'Type', 'SG', 'win_size', win_size, 'order', order
            ]
        else:
            return None
Exemplo n.º 5
0
    def _calc(self, data, ret_obj):
        try:
            if self.rng is None:
                correction_factor = _sg(data.real, window_length=self.win_size,
                                        polyorder=self.order, axis=-1)
            else:
                correction_factor = _sg(data[..., self.rng].real,
                                        window_length=self.win_size,
                                        polyorder=self.order, axis=-1)

            correction_factor[correction_factor == 0] = 1
            correction_factor **= -1

            if self.rng is None:
                ret_obj *= correction_factor
            else:
                ret_obj[..., self.rng] *= correction_factor
        except:
            return False
        else:
            return True
Exemplo n.º 6
0
    def errorCorrectHSData(self, hsdatacls):
        temp_spectra = hsdatacls._get_rand_spectra_real(10, pt_sz=3, quads=True)
        
        plugin = widgetSG()
        
        result = DialogPlotEffect.dialogPlotEffect(temp_spectra, x=hsdatacls.freqvec,
                                                   plugin=plugin, xlabel='Wavenumber (cm$^{-1}$)',
                                                   ylabel='Real {$\chi_R$} (au)', show_difference=True)
        if result is not None:
            win_size = result.win_size
            order = result.order
            
                        
            detrend_ct = 0
            detrend_tot = hsdatacls.mlen * hsdatacls.nlen
            
            # Most efficient system
            if len(hsdatacls.pixrange) != 0:
                data_out = hsdatacls.spectrafull[:,:, hsdatacls.pixrange[0]:hsdatacls.pixrange[1]+1]
            else:
                data_out = hsdatacls.spectrafull
                
            start = _ti.default_timer()
            
            correction = (1/_sg(data_out.real, window_length=win_size, polyorder=order, axis=-1))
          
            data_out = data_out*correction
                
            stop = _ti.default_timer()
#                print('2: {}'.format(stop2-start2))
#                print('3: {}'.format(stop3-start3))
#                print('4: {}'.format(stop4-start4))
#                print('5: {}'.format(stop5-start5))
#                
            print('Scaled {} spectra ({:.5f} sec/spect)'.format(detrend_tot, (stop-start)/(hsdatacls.mlen*hsdatacls.nlen)))
            
            hsdatacls.spectra = data_out
            return ['Scaling','Type', 'SG', 'win_size', win_size, 'order', order]
        else:
            return None
Exemplo n.º 7
0
    def fcn(self, data_in):

        baseline = _sg(data_in, window_length=self.win_size, polyorder=self.order, axis=-1)
        data_out = data_in - baseline

        return data_out