Ejemplo n.º 1
0
    tester = hdf_is_valid_dsets(pth, filename,'fake_dset')
    assert tester == False

    tester = hdf_is_valid_dsets(pth, filename,['fake_dset1','fake_dset2'])
    assert tester == False

    tester = hdf_is_valid_dsets(pth, filename,dset)
    assert tester == True

    dset_list = hdf_dset_list_rep('/Spectra/Dark_3_5ms_',_np.arange(2))
    tester = hdf_is_valid_dsets(pth, filename,dset_list)
    assert tester == True

    print('--------------\n\n')

    spect_dark = _Spectra()
    tester = hdf_is_valid_dsets(pth, filename,['/Spectra/Dark_3_5ms_2'])
    hdf_import_data(pth, filename,'/Spectra/Dark_3_5ms_2',spect_dark)
    #hdf_process_attr(rosetta, spect_dark)

    print('Shape of dark spectra: {}'.format(spect_dark.shape))
    print('Shape of dark spectra.mean(): {}'.format(spect_dark.mean().shape))

    print('')
    img = _Hsi()
    hdf_import_data(pth, filename,'/BCARSImage/mP2_3_5ms_Pos_2_0/mP2_3_5ms_Pos_2_0_small',img)
    print('Shape of img: {}'.format(img.shape))
    print('Shape of img.mean(): {}'.format(img.mean().shape))

Ejemplo n.º 2
0
    tester = _lazy5.inspect.valid_dsets(pth=pth,
                                        file='fake.h5',
                                        dset_list=['fake_dset1', 'fake_dset2'])
    assert not tester

    print('Path: {}'.format(pth))
    tester = _lazy5.inspect.valid_dsets(pth=pth,
                                        file=filename,
                                        dset_list=dset,
                                        verbose=True)
    assert tester

    print('--------------\n\n')

    spect_dark = _Spectra()
    tester = _lazy5.inspect.valid_dsets(pth=pth,
                                        file=filename,
                                        dset_list=['/Spectra/Dark_3_5ms_2'])
    hdf_import_data(pth, filename, '/Spectra/Dark_3_5ms_2', spect_dark)
    #hdf_process_attr(rosetta, spect_dark)

    print('Shape of dark spectra: {}'.format(spect_dark.shape))
    print('Shape of dark spectra.mean(): {}'.format(spect_dark.mean().shape))
    print('Dtype of dark spectra: {}'.format(spect_dark._data.dtype))
    print('')
    img = _Hsi()
    hdf_import_data(pth, filename,
                    '/BCARSImage/mP2_3_5ms_Pos_2_0/mP2_3_5ms_Pos_2_0_small',
                    img)
    print('Shape of img: {}'.format(img.shape))
Ejemplo n.º 3
0
                        attr['RasterScanParams.FixedAxis'] = 'Y'
                    elif ax3 == 2:
                        attr['RasterScanParams.FixedAxis'] = 'Z'

                    # Figure out fixed positions later

                except:
                    pass
                else:
                    output_cls_instance.data = data
                    output_cls_instance.meta = attr
                    return True

        except:
            print('Something failed in import')


if __name__ == '__main__':
    #from crikit.data.spectra import Spectra as _Spectra

    sp = _Spectra()
    pth = '../../../Young_150617/'
    filename_header = 'SH-03.h'
    filename_data = 'base061715_152213_60ms.txt'

    csv_nist_import_data(pth,
                         filename_header,
                         filename_data,
                         output_cls_instance=sp)

    print(sp.__dict__)
Ejemplo n.º 4
0
    def _transform(self, cars, nrb):
        if issubclass(cars.dtype.type, _np.complex):
            success = self._calc(cars, nrb, ret_obj=cars)
            return success
        else:
            return False


if __name__ == '__main__':  # pragma: no cover

    from crikit.data.spectrum import Spectrum as _Spectrum
    from crikit.data.spectra import Spectra as _Spectra
    from crikit.data.hsi import Hsi as _Hsi

    hsi = _Hsi()
    nrb = _Spectra()

    WN = _np.linspace(-1386, 3826, 400)
    X = .055 + 1 / (1000 - WN - 1j * 20) + 1 / (3000 - WN - 1j * 20)
    XNR = 0 * X + 0.055
    E = 1 * _np.exp(-(WN - 2000)**2 / (2 * 3000**2))

    # Simulated spectrum
    CARS = _np.abs(E + X)**2
    NRB = _np.abs(E + XNR)**2
    nrb.data = NRB

    # Copies of spectrum
    temp = _np.dot(_np.ones((30, 30, 1)), CARS[None, :])

    # Create an HSData class instance
Ejemplo n.º 5
0
                    if ax3 == 0:
                        attr['RasterScanParams.FixedAxis'] = 'X'
                    elif ax3 == 1:
                        attr['RasterScanParams.FixedAxis'] = 'Y'
                    elif ax3 == 2:
                        attr['RasterScanParams.FixedAxis'] = 'Z'
                        
                    # Figure out fixed positions later
                    
                except:
                    pass
                else:
                    output_cls_instance.data = data
                    output_cls_instance.meta = attr
                    return True

        except:
            print('Something failed in import')

if __name__ == '__main__':
    #from crikit.data.spectra import Spectra as _Spectra
    
    sp = _Spectra()
    pth = '../../../Young_150617/'
    filename_header = 'SH-03.h'
    filename_data = 'base061715_152213_60ms.txt'
    
    csv_nist_import_data(pth, filename_header, filename_data,
                    output_cls_instance=sp)
    
    print(sp.__dict__)
Ejemplo n.º 6
0
if __name__ == '__main__':  # pragma: no cover

    from crikit.data.spectrum import Spectrum as _Spectrum
    from crikit.data.spectra import Spectra as _Spectra
    from crikit.data.hsi import Hsi as _Hsi

    

    x = _np.linspace(0, 100, 10)
    y = _np.linspace(0, 100, 10)
    freq = _np.arange(20)
    data = _np.ones((10, 10, 20))

    hs = _Hsi(data=_copy.deepcopy(data), freq=freq, x=x, y=y)
    spa = _Spectra(data=_copy.deepcopy(data), freq=freq)
    sp = _Spectrum(data=_copy.deepcopy(data)[0, 0, :], freq=freq)

    mean_sub = SubtractMeanOverRange([5, 8])

    print('\n---------TRANSFORM TEST----------\n')
    print('\n3D----------')
    print('Initial mean: {}'.format(hs.data.mean()))
    out = mean_sub.transform(hs.data)
    print('Success?: {}'.format(out))
    print('Final mean: {}\n'.format(hs.data.mean()))

    print('2D----------')
    print('Initial mean: {}'.format(spa.data.mean()))
    out = mean_sub.transform(spa.data)
    print('Success?: {}'.format(out))
Ejemplo n.º 7
0
        self.dark = _expand_1d_to_ndim(self.dark, data.ndim)

        ret_obj -= self.dark
        return True


if __name__ == '__main__': # pragma: no cover

    x = _np.linspace(0,100,10)
    y = _np.linspace(0,100,10)
    freq = _np.arange(20)
    data = _np.ones((10,10,20))

    # OVERWRITE TEST
    hs = _Hsi(data=_copy.deepcopy(data), freq=freq, x=x, y=y)
    spa = _Spectra(data=_copy.deepcopy(data)[0,:,:], freq=freq)
    sp = _Spectrum(data=_copy.deepcopy(data)[0,0,:], freq=freq)

    dark=0.5 * _copy.deepcopy(data)
    dark_sub = SubtractDark(dark)

    print('\n---------TRANSFORM TEST----------\n')
    print('\n3D----------')
    print('Initial mean: {}'.format(hs.data.mean()))
    out = dark_sub.transform(hs.data)
    print('Success?: {}'.format(out))
    print('Final mean: {}\n'.format(hs.data.mean()))

    print('2D----------')
    print('Initial mean: {}'.format(spa.data.mean()))
    out = dark_sub.transform(spa.data)
Ejemplo n.º 8
0
    out = sub_baseline_als.transform(sp.data)
    _plt.plot(sp.data, label='Detrended')
    _plt.title('Spectrum')
    _plt.legend(loc='best')
    _plt.show()

    sp.data = _np.exp(-(_np.arange(1000)-500)**2/100**2)
    _plt.plot(sp.data, label='Original')
    sub_baseline_als.redux_factor = 10
    out = sub_baseline_als.transform(sp.data)
    _plt.plot(sp.data, label='Detrended (Redux)')
    _plt.title('Spectrum')
    _plt.legend(loc='best')
    _plt.show()
#
    spa = _Spectra()
    sub_baseline_als = SubtractBaselineALS(smoothness_param=1e2, asym_param=1e-4)
    spa.data = _np.dot(_np.ones((2,1)),_np.exp(-(_np.arange(1000)-500)**2/100**2)[None,:])
    _plt.plot(spa.data.T, label='Original')
    out = sub_baseline_als.transform(spa.data)
    _plt.plot(spa.data.T, label='Detrended')
    _plt.title('Spectra')
    _plt.legend(loc='upper right')
    _plt.show()

    hsi = _Hsi()
    sub_baseline_als.redux_factor = 10
    hsi.data = _np.dot(_np.ones((1,1,1)),_np.exp(-(_np.arange(1000)-500)**2/100**2)[None,:])

    _plt.plot(hsi.data.reshape((-1,1000)).T, label='Original')
    out = sub_baseline_als.calculate(hsi.data)
Ejemplo n.º 9
0
    def _transform(self, cars, nrb):
        if issubclass(cars.dtype.type, _np.complex):
            success = self._calc(cars, nrb, ret_obj=cars)
            return success
        else:
            return False


if __name__ == '__main__': # pragma: no cover

    from crikit.data.spectrum import Spectrum as _Spectrum
    from crikit.data.spectra import Spectra as _Spectra
    from crikit.data.hsi import Hsi as _Hsi

    hsi = _Hsi()
    nrb = _Spectra()

    WN = _np.linspace(-1386,3826,400)
    X = .055 + 1/(1000-WN-1j*20) + 1/(3000-WN-1j*20)
    XNR = 0*X + 0.055
    E = 1*_np.exp(-(WN-2000)**2/(2*3000**2))

    # Simulated spectrum
    CARS = _np.abs(E+X)**2
    NRB = _np.abs(E+XNR)**2
    nrb.data = NRB

    # Copies of spectrum
    temp = _np.dot(_np.ones((30,30,1)),CARS[None,:])

    # Create an HSData class instance