def show_fts(fids, data_dir, data_viewer, prefix='', flip_angle=None, auto_pc=False, weighting=False): for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = load(fid_filepath) fid = cut_fid(fid) fid *= 10**(-ds['gain'] / 20.) fid *= 1 / np.sin(np.radians(flip_angle)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) ft = cut_fft(do_fft(fid)) if auto_pc: pc_angle, ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.) else: pc_angle = ds['pc'] ft['fft'] = phase_correct(ft['fft'], angle=ds['pc']) data_viewer.add_object( ft, '{}{} FT (pc={})'.format(prefix, ds['data'], pc_angle))
def compute(fids, data_dir, pc=False, weighting=False, arg='index'): values = [] arguments = [] res = 0. idx = 0 for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=3.)[1] res = integrate.simps(np.real(ft['fft']), ft.index) else: res = integrate.simps(np.abs(ft['fft']), ft.index) res *= 10 ** (-ds['gain'] / 20.) values.append(res) if arg == 'index': arguments.append(idx) idx += 1 else: arguments.append(ds[arg]) return pd.DataFrame(values, columns=['Pol'], index=arguments)
def compute(fids, data_dir, pc=False, weighting=False, arg='index'): values = [] arguments = [] res = 0. idx = 0 for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=3.)[1] res = integrate.simps(np.real(ft['fft']), ft.index) else: res = integrate.simps(np.abs(ft['fft']), ft.index) res *= 10**(-ds['gain'] / 20.) values.append(res) if arg == 'index': arguments.append(idx) idx += 1 else: arguments.append(ds[arg]) return pd.DataFrame(values, columns=['Pol'], index=arguments)
def show_fts(fids, data_dir, data_viewer, pc=False, prefix='', weighting=False): for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) electronic_gain_factor = 10 ** (-ds['gain'] / 20.) fid *= electronic_gain_factor ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1] data_viewer.add_object(ft, '{}{} FT'.format(prefix, ds['data']))
def show_fts(fids, data_dir, data_viewer, pc=False, prefix='', weighting=False): for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) electronic_gain_factor = 10**(-ds['gain'] / 20.) fid *= electronic_gain_factor ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1] data_viewer.add_object(ft, '{}{} FT'.format(prefix, ds['data']))
def compute_mwdep(fids, data_dir, pc=False, weighting=False): values = [] arguments = [] res = 0. for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=5) ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1] res = integrate.simps(np.real(ft['fft']), ft.index) else: res = integrate.simps(np.abs(ft['fft']), ft.index) res *= 10**(-ds['gain'] / 20.) values.append(res) arguments.append(np.sqrt(ds['P'])) return pd.DataFrame(values, columns=['Pol'], index=arguments)
def compute_pol(data_dir, fids, flip_angle=None, pc=False, weighting=False): values = [] time = [] for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1] ft['fft'] = np.real(ft['fft']) res = integrate.simps(ft['fft'], ft.index) res *= 10**(-ds['gain'] / 20.) res *= 1 / np.sin(np.radians(flip_angle)) values.append(res) time.append(ds['t']) return pd.DataFrame(values, columns=['P'], index=time)
def compute_mwdep(fids, data_dir, pc=False, weighting=False): values = [] arguments = [] res = 0. for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=5) ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1] res = integrate.simps(np.real(ft['fft']), ft.index) else: res = integrate.simps(np.abs(ft['fft']), ft.index) res *= 10 ** (-ds['gain'] / 20.) values.append(res) arguments.append(np.sqrt(ds['P'])) return pd.DataFrame(values, columns=['Pol'], index=arguments)
def show_fts(fids, data_dir, data_viewer, prefix='', flip_angle=None, auto_pc=False, weighting=False): for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = load(fid_filepath) fid = cut_fid(fid) fid *= 10 ** (-ds['gain'] / 20.) fid *= 1 / np.sin(np.radians(flip_angle)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) ft = cut_fft(do_fft(fid)) if auto_pc: pc_angle, ft['fft'] = auto_phase_correct( ft['fft'], ft.index, step=1.) else: pc_angle = ds['pc'] ft['fft'] = phase_correct(ft['fft'], angle=ds['pc']) data_viewer.add_object(ft, '{}{} FT (pc={})' .format(prefix, ds['data'], pc_angle))
def compute_pol(data_dir, fids, flip_angle=None, pc=False, weighting=False): values = [] time = [] for ds in fids: fid_filepath = os.path.join(data_dir, ds['data']) fid = cut_fid(load(fid_filepath)) if weighting: fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) ft = cut_fft(do_fft(fid)) if pc: ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1] ft['fft'] = np.real(ft['fft']) res = integrate.simps(ft['fft'], ft.index) res *= 10 ** (-ds['gain'] / 20.) res *= 1 / np.sin(np.radians(flip_angle)) values.append(res) time.append(ds['t']) return pd.DataFrame(values, columns=['P'], index=time)
def compute_water_fft(water_fid): ft = cut_fft(do_fft(water_fid)) pc_angle, ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.) return ft
if __name__ == '__main__': common.configure_logging() dv = data_viewer() fid_file = 'ise14.dat' fid = load(os.path.join(data2013_dir, fid_file)) fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) dv.add_object(fid, 'FID: ' + os.path.basename(fid_file)) fid_cutted = cut_fid(fid) dv.add_object(fid_cutted, 'FID[50:]: ' + os.path.basename(fid_file)) ft = do_fft(fid_cutted) ft_cut = cut_fft(ft) dv.add_object(ft_cut, "FFT cut: " + os.path.basename(fid_file)) theta, ft_phase_corrected = auto_phase_correct(ft_cut['fft'], ft_cut.index, step=0.5) integr = integrate.simps(np.imag(ft_phase_corrected), ft_cut.index) df_pc = pd.DataFrame(ft_phase_corrected, index=ft_cut.index, columns=['fft']) dv.add_object(df_pc, 'sample, pc={}, I(Im)={}'.format(theta, integr)) water_fid, water_fid_cutted = process_water_fid(WATER_FID, WATER_DATA_DIR) water_ft = compute_water_fft(water_fid_cutted) dv.add_object(water_fid, '{} FID H2O'.format(WATER_FID['data'])) dv.add_object(water_fid_cutted, '{} FID H2O (cut)'.format(WATER_FID['data'])) dv.add_object(water_ft, '{} FT H2O'.format(WATER_FID['data']))
def compute_water_fft(water_fid): ft = cut_fft(do_fft(water_fid)) pc_angle, ft['fft'] = auto_phase_correct( ft['fft'], ft.index, step=1.) return ft
if __name__ == '__main__': common.configure_logging() dv = data_viewer() fid_file = 'ise14.dat' fid = load(os.path.join(data2013_dir, fid_file)) fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING) dv.add_object(fid, 'FID: ' + os.path.basename(fid_file)) fid_cutted = cut_fid(fid) dv.add_object(fid_cutted, 'FID[50:]: ' + os.path.basename(fid_file)) ft = do_fft(fid_cutted) ft_cut = cut_fft(ft) dv.add_object(ft_cut, "FFT cut: " + os.path.basename(fid_file)) theta, ft_phase_corrected = auto_phase_correct( ft_cut['fft'], ft_cut.index, step=0.5) integr = integrate.simps(np.imag(ft_phase_corrected), ft_cut.index) df_pc = pd.DataFrame(ft_phase_corrected, index=ft_cut.index, columns=['fft']) dv.add_object(df_pc, 'sample, pc={}, I(Im)={}' .format(theta, integr)) water_fid, water_fid_cutted = process_water_fid(WATER_FID, WATER_DATA_DIR) water_ft = compute_water_fft(water_fid_cutted) dv.add_object(water_fid, '{} FID H2O' .format(WATER_FID['data'])) dv.add_object(water_fid_cutted, '{} FID H2O (cut)' .format(WATER_FID['data']))