def perform_noise_test(plotname, fignum): fignum = fignum + 1 info = str(fignum).zfill(2) + '___' + plotname plotname = info + '.png' # sample noise nmrObj.noise(samp_freq, samples) # process the data if en_remote_computing: # copy remote files to local directory cp_rmt_file(nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt") meas_folder = parse_simple_info(data_folder, 'current_folder.txt') if en_remote_computing: # copy remote folder to local directory cp_rmt_folder(nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0]) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder) # delete the file in the server # nstd, nmean = compute_stats( min_freq, max_freq, data_folder, meas_folder[0], plotname, en_fig ) # real scan nstd, nmean = compute_in_bw_noise(conf.meas_bw_kHz, conf.Df_MHz, min_freq, max_freq, data_folder, meas_folder[0], plotname, en_fig) f.write("std: %08.3f\tmean: %08.3f \t-> %s\n" % (nstd, nmean, info)) shutil.move(data_folder + '/' + meas_folder[0], swfolder + '/' + info) # move the data folder shutil.move(swfolder + '/' + info + '/' + plotname, swfolder + '/' + plotname) # move the data folder return fignum
def analyze(nmrObj, tuning_freq, sta_freq, sto_freq, spac_freq, samp_freq, fftpts, fftcmd, fftvalsub, continuous, en_fig): timeObj = time_meas(False) fig_num = 1 while True: Vbias, Vvarac = find_Vbias_Vvarac_from_table(nmrObj.client_path, tuning_freq, nmrObj.S21_table) nmrObj.setPreampTuning(Vbias, Vvarac) Cpar, Cser = find_Cpar_Cser_from_table(nmrObj.client_path, tuning_freq, nmrObj.S11_table) # nmrObj.setMatchingNetwork( Cpar, Cser ) timeObj.setTimeSta() # nmrObj.pamp_char_async ( sta_freq, sto_freq, spac_freq, samp_freq ) nmrObj.pamp_char_sync(sta_freq, sto_freq, spac_freq, fftpts, fftcmd, fftvalsub) timeObj.setTimeSto() timeObj.reportTimeRel("pamp_char_sync") timeObj.setTimeSta() if nmrObj.en_remote_computing: # copy remote files to local directory cp_rmt_file(nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt") meas_folder = parse_simple_info(nmrObj.data_folder, 'current_folder.txt') if nmrObj.en_remote_computing: # copy remote folder to local directory cp_rmt_folder(nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0]) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder) # delete the file in the server # maxS21, maxS21_freq, _ = compute_gain_async( nmrObj, data_folder, meas_folder[0], en_fig, fig_num ) # maxS21, maxS21_freq, _ = compute_gain_sync( nmrObj, nmrObj.data_folder, meas_folder[0], en_fig, fig_num ) maxS21, maxS21_freq, _ = compute_gain_fft_sync(nmrObj, nmrObj.data_folder, meas_folder[0], en_fig, fig_num) # print( 'maxS21={0:0.2f} maxS21_freq={1:0.2f}'.format( maxS21, maxS21_freq ) ) print( 'maxS21=%0.2f maxS21_freq=%0.2f Vbias=%0.2fV Vvarac=%0.2fV Cpar=%d Cser=%d' % (maxS21, maxS21_freq, Vbias, Vvarac, Cpar, Cser)) timeObj.setTimeSto() timeObj.reportTimeRel("processing time") if (not continuous): break
def runExpt(vbias, vvarac): # useRef: use the pregenerated S11mV_ref as a reference to compute reflection. If this option is 0, then the compute_wobble will instead generated S11 in mV format instead of dB format # global variable global exptnum global maxS21Table exptnum = exptnum + 1 maxS21dB, maxS21Freq, S21mV = nmr_pamp_char.analyze( nmrObj, vbias, vvarac, freqSta, freqSto, freqSpa, freqSamp, fftpts, fftcmd, fftvalsub, continuous, en_fig) # update the table maxS21Table = updateTable(maxS21Table, 20 * np.log10(abs(S21mV)), vbias, vvarac) # move the measurement folder to the main folder meas_folder = parse_simple_info(nmrObj.data_folder, 'current_folder.txt') swfolder_ind = swfolder + '/' + str('vbias_%0.3f__vvarac_%0.3f' % (vbias, vvarac)) if en_fig: if (mode == 0 or mode == 1): shutil.move(nmrObj.data_folder + '/' + meas_folder[0] + '/gainFFT.png', swfolder + '/' + str('plt%3d__vbias_%0.3f__vvarac_%0.3f.png' % (exptnum, vbias, vvarac))) # move the figure elif (mode == 2): shutil.move(nmrObj.data_folder + '/' + meas_folder[0] + '/gain.png', swfolder + '/' + str('plt%3d__vbias_%0.3f__vvarac_%0.3f.png' % (exptnum, vbias, vvarac))) # move the figure if keepRawData: # write gain values to a file RawDataFile = open( swfolder + '/S21___vbias_%0.3f__vvarac_%0.3f.txt' % (vbias, vvarac), 'w') RawDataFile.write('freq(MHz)\t max-voltage(mV)\n') RawDataFile.close() with open( swfolder + '/S21___vbias_%0.3f__vvarac_%0.3f.txt' % (vbias, vvarac), 'a') as f: for (a, b) in zip(freqSw, abs(S21mV)): f.write('{:-8.3f},{:-8.3f}\n'.format(a, b)) shutil.rmtree(nmrObj.data_folder + '/' + meas_folder[0]) # remove the data folder else: shutil.rmtree(nmrObj.data_folder + '/' + meas_folder[0]) # remove the data folder return S21mV, maxS21Freq
def analyze( nmrObj, extSet, cparVal, cserVal, freqSta, freqSto, freqSpa, freqSamp , fftpts, fftcmd, ftvalsub, S11mV_ref, useRef , en_fig ): # useRef: use the pregenerated S11mV_ref as a reference to compute # reflection. If this option is 0, then the compute_wobble will instead # generated S11 in mV format instead of dB format fig_num = 1 # change matching network values (twice because sometimes it doesnt' work # once due to transient if ( not extSet ): # if extSet is used, matching network should be programmed from external source (e.g. C executable), otherwise set the value from here nmrObj.setMatchingNetwork( cparVal, cserVal ) # nmrObj.setMatchingNetwork( cparVal, cserVal ) timeObj = time_meas( False ) timeObj.setTimeSta() # do measurement if (wobble_mode == 0 or wobble_mode == 1): nmrObj.wobble_sync( freqSta, freqSto, freqSpa , fftpts, fftcmd, ftvalsub ) elif (wobble_mode == 2): nmrObj.wobble_async( freqSta, freqSto, freqSpa, freqSamp ) timeObj.setTimeSto() timeObj.reportTimeRel( "wobble_sync" ) # disable all to save power # nmrObj.deassertAll() timeObj.setTimeSta() # compute the generated data if nmrObj.en_remote_computing: # copy remote files to local directory cp_rmt_file( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt" ) meas_folder = parse_simple_info( nmrObj.data_folder, 'current_folder.txt' ) if nmrObj.en_remote_computing: # copy remote folder to local directory cp_rmt_folder( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0] ) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder ) # delete the file in the server timeObj.setTimeSto() timeObj.reportTimeRel( "transfer_data" ) timeObj.setTimeSta() if (wobble_mode == 0): S11, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = compute_wobble_fft_sync( nmrObj, nmrObj.data_folder, meas_folder[0], -10, S11mV_ref, useRef, en_fig, fig_num ) elif (wobble_mode == 1): S11, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq, freq0, Z11_imag0 = compute_wobble_sync( nmrObj, nmrObj.data_folder, meas_folder[0], -10, S11mV_ref, useRef, en_fig, fig_num ) elif (wobble_mode == 2): S11, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = compute_wobble_async( nmrObj, nmrObj.data_folder, meas_folder[0], -10, S11mV_ref, useRef, en_fig, fig_num ) print( '\t\tfmin={:0.3f} fmax={:0.3f} bw={:0.3f} minS11={:0.2f} minS11_freq={:0.3f} cparVal={:d} cserVal={:d}'.format( S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq, cparVal, cserVal ) ) timeObj.setTimeSto() timeObj.reportTimeRel( "data processing" ) return S11, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq
def runExpt(cparVal, cserVal, S11mV_ref, useRef): # useRef: use the pregenerated S11mV_ref as a reference to compute # reflection. If this option is 0, then the compute_wobble will instead # generated S11 in mV format instead of dB format if meas_time: start_time = time.time() # enable power and signal path nmrObj.assertControlSignal(nmrObj.RX1_2L_msk | nmrObj.RX_SEL2_msk | nmrObj.RX_FL_msk) nmrObj.assertControlSignal(nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk) # change matching network values (twice because sometimes it doesnt' work # once due to transient nmrObj.setMatchingNetwork(cparVal, cserVal) nmrObj.setMatchingNetwork(cparVal, cserVal) # do measurement nmrObj.wobble(sta_freq, sto_freq, spac_freq, samp_freq) # disable all to save power nmrObj.deassertAll() if meas_time: elapsed_time = time.time() - start_time start_time = time.time() # reset the start time print("### time elapsed for running wobble exec: %.3f" % (elapsed_time)) # compute the generated data meas_folder = parse_simple_info(data_parent_folder, 'current_folder.txt') S11dB, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = compute_wobble( nmrObj, data_parent_folder, meas_folder[0], -10, S11mV_ref, useRef, en_fig, fig_num) print( '\t\tfmin={:0.3f} fmax={:0.3f} bw={:0.3f} minS11={:0.2f} minS11_freq={:0.3f} cparVal={:d} cserVal={:d}' .format(S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq, cparVal, cserVal)) if meas_time: elapsed_time = time.time() - start_time print("### time elapsed for compute_wobble: %.3f" % (elapsed_time)) return S11dB, minS11_freq
def runExpt(cparVal, cserVal, S11mV_ref, useRef): # useRef: use the pregenerated S11mV_ref as a reference to compute reflection. If this option is 0, then the compute_wobble will instead generated S11 in mV format instead of dB format # global variable global exptnum global minReflxTable exptnum = exptnum + 1 S11, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = nmr_wobble.analyze( nmrObj, extSet, cparVal, cserVal, freqSta, freqSto, freqSpa, freqSamp, fftpts, fftcmd, fftvalsub, S11mV_ref, useRef, en_fig) # update the table minReflxTable = updateTable(minReflxTable, 20 * np.log10(abs(S11)), cparVal, cserVal) # move the measurement folder to the main folder meas_folder = parse_simple_info(nmrObj.data_folder, 'current_folder.txt') swfolder_ind = swfolder + '/' + str('Cp_[{:d}]__Cs_[{:d}]'.format( cparVal, cserVal)) if en_fig: shutil.move(nmrObj.data_folder + '/' + meas_folder[0] + '/wobble.png', swfolder + '/' + str('plt{:03d}_Cp_[{:d}]__Cs_[{:d}].png'.format( exptnum, cparVal, cserVal))) # move the figure if keepRawData: # write gain values to a file RawDataFile = open( swfolder + '/S11_Cp_[{:d}]__Cs_[{:d}].txt'.format(cparVal, cserVal), 'w') RawDataFile.write('freq(MHz)\t min-voltage(mV)\n') RawDataFile.close() with open( swfolder + '/S11_Cp_[{:d}]__Cs_[{:d}].txt'.format(cparVal, cserVal), 'a') as f: for (a, b) in zip(freqSw, abs(S11)): f.write('{:-8.3f},{:-8.3f}\n'.format(a, b)) shutil.rmtree(nmrObj.data_folder + '/' + meas_folder[0]) # remove the data folder else: shutil.rmtree(nmrObj.data_folder + '/' + meas_folder[0]) # remove the data folder return S11, minS11_freq
def wobb_meas(data_parent_folder, cparIdx, cserIdx, s11_obj, en_fig): startfreq = 3 stopfreq = 5.5 spacfreq = 0.02 sampfreq = 25 wobb_samples = int(sampfreq / spacfreq) command = ("./thesis_nmr_de1soc_hdl2.0_wobble" + " " + str(cparIdx) + " " + str(cserIdx) + " " + str(startfreq) + " " + str(stopfreq) + " " + str(spacfreq) + " " + str(sampfreq) + " " + str(wobb_samples)) os.system(command + ' > /dev/null') meas_folder = parse_simple_info(data_parent_folder, 'current_folder.txt') S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = compute_wobble( data_parent_folder, meas_folder[0], s11_obj, en_fig) #print('fmin={0:0.3f} fmax={1:0.3f} bw={2:0.3f}'.format(S11_fmin, S11_fmax, S11_bw)) return S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq
def perform_noise_test(plotname, fignum): fignum = fignum + 1 info = str(fignum).zfill(2) + '___' + plotname plotname = info + '.png' # sample noise nmrObj.noise(samp_freq, samples) # process the data meas_folder = parse_simple_info(data_folder, 'current_folder.txt') nstd, nmean = compute_stats(min_freq, max_freq, data_folder, meas_folder[0], plotname, en_fig) # real scan f.write("std: %08.3f\tmean: %08.3f \t-> %s\n" % (nstd, nmean, info)) shutil.move(data_folder + '/' + meas_folder[0], swfolder + '/' + info) # move the data folder shutil.move(swfolder + '/' + info + '/' + plotname, swfolder + '/' + plotname) # move the data folder return fignum
def analyze( nmrObj , Vbias, Vvarac, freqSta, freqSto , freqSpa, freqSamp, fftpts, fftcmd, fftvalsub, continuous, en_fig ): fig_num = 1 while True: # set the preamp tuning nmrObj.setPreampTuning( Vbias, Vvarac ) if (mode == 0 or mode == 1): nmrObj.pamp_char_sync ( freqSta, freqSto, freqSpa, fftpts, fftcmd, fftvalsub ) elif (mode == 2): nmrObj.pamp_char_async ( freqSta, freqSto, freqSpa, freqSamp ) if nmrObj.en_remote_computing: # copy remote files to local directory cp_rmt_file( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt" ) meas_folder = parse_simple_info( nmrObj.data_folder, 'current_folder.txt' ) # meas_folder[0] = "nmr_wobb_2018_06_25_12_44_48" if nmrObj.en_remote_computing: # copy remote folder to local directory cp_rmt_folder( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0] ) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder ) # delete the file in the server if (mode == 0): maxS21, maxS21_freq, S21mV = compute_gain_fft_sync( nmrObj, nmrObj.data_folder, meas_folder[0], en_fig, fig_num ) elif (mode == 1): # UNTESTED maxS21, maxS21_freq, _ = compute_gain_sync( nmrObj, data_folder, meas_folder[0], en_fig, fig_num ) elif (mode == 2): maxS21, maxS21_freq, S21mV = compute_gain_async( nmrObj, nmrObj.data_folder, meas_folder[0], en_fig, fig_num ) print( "maxS21_fft=%0.2fdBmV maxS21_freq=%0.2fMHz Vbias=%0.2fV Vvarac=%0.2fV" % ( maxS21, maxS21_freq, Vbias, Vvarac ) ) if ( not continuous ): break; return maxS21, maxS21_freq, S21mV
def analyze( nmrObj, samp_freq, samples, min_freq, max_freq, tuning_freq, meas_bw_kHz, continuous, en_fig ): # load parameters from table Cpar, Cser = find_Cpar_Cser_from_table ( nmrObj.client_path , tuning_freq, nmrObj.S11_table ) Vbias, Vvarac = find_Vbias_Vvarac_from_table ( nmrObj.client_path , tuning_freq, nmrObj.S21_table ) nmrObj.setPreampTuning( Vbias, Vvarac ) # try -2.7, -1.8 if fail # nmrObj.setMatchingNetwork( Cpar, Cser ) # 4.25 MHz AFE nmrObj.setMatchingNetwork( 2190, 484 ) # 4.25 MHz AFE # load parameters from config file # nmrObj.setPreampTuning( conf.vbias, conf.vvarac ) # try -2.7, -1.8 if fail # nmrObj.setMatchingNetwork( conf.cpar, conf.cser ) # 4.25 MHz AFE nmrObj.assertControlSignal( nmrObj.RX_FL_msk | nmrObj.RX_FH_msk | nmrObj.RX_SEL1_msk | nmrObj.RX2_L_msk | nmrObj.RX2_H_msk | nmrObj.RX1_1L_msk | nmrObj.RX1_1H_msk | nmrObj.PAMP_IN_SEL2_msk ) # nmrObj.deassertControlSignal( nmrObj.RX_FH_msk | nmrObj.RX2_L_msk | nmrObj.RX_FH_msk ) nmrObj.deassertControlSignal( nmrObj.RX_FL_msk ) # nmrObj.deassertControlSignal( nmrObj.RX1_1H_msk | nmrObj.RX2_H_msk | nmrObj.RX_FH_msk ) # nmrObj.assertControlSignal( nmrObj.RX1_2L_msk | nmrObj.RX_SEL2_msk | nmrObj.RX_FL_msk ) # for finding FFT wobble function ADC subtraction value while True: nmrObj.noise( samp_freq, samples ) if nmrObj.en_remote_computing: # copy remote files to local directory cp_rmt_file( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt" ) # process the data meas_folder = parse_simple_info( nmrObj.data_folder, 'current_folder.txt' ) if nmrObj.en_remote_computing: # copy remote folder to local directory cp_rmt_folder( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0] ) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder ) # delete the file in the server # compute_stats( min_freq, max_freq, data_folder, meas_folder[0], 'noise_plot.png', en_fig ) compute_in_bw_noise( meas_bw_kHz, tuning_freq, min_freq, max_freq, nmrObj.data_folder, meas_folder[0], 'noise_plot.png', en_fig ) if ( not continuous ): break
def nmr_t2_auto ( cpmg_freq, pulse1_us, pulse2_us, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, dconv_lpf_ord, dconv_lpf_cutoff_Hz, client_data_folder ): # configurations en_fig = 1 # enable figure direct_read = 0 # perform direct read from SDRAM. use with caution above! process_data = 1 # process data within the SoC en_remote_dbg = False en_remote_computing = True pulse1_dtcl = 0.5 # useless with current code pulse2_dtcl = 0.5 # useless with current code pulse180_t1_int = 0 delay180_t1_int = 0 tx_sd_msk = 1 # 1 to shutdown tx opamp during reception, or 0 to keep it powered up during reception en_dconv = 0 # enable downconversion in the fpga dconv_fact = 4 # downconversion factor. minimum of 4. echo_skip = 1 # echo skip factor. set to 1 for the ADC to capture all echoes # instantiate nmr object nmrObj = tunable_nmr_system_2018( client_data_folder, en_remote_dbg, en_remote_computing ) # system setup nmrObj.initNmrSystem() # necessary to set the GPIO initial setting. Also fix the nmrObj.assertControlSignal( nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk ) # nmrObj.deassertControlSignal( # nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk) Vbias, Vvarac = find_Vbias_Vvarac_from_table ( nmrObj.client_path , cpmg_freq, nmrObj.S21_table ) nmrObj.setPreampTuning( Vbias, Vvarac ) Cpar, Cser = find_Cpar_Cser_from_table ( nmrObj.client_path , cpmg_freq, nmrObj.S11_table ) nmrObj.setMatchingNetwork( Cpar, Cser ) nmrObj.setMatchingNetwork( Cpar, Cser ) # setting for WMP nmrObj.assertControlSignal( nmrObj.RX1_1L_msk | nmrObj.RX1_1H_msk | nmrObj.RX2_L_msk | nmrObj.RX2_H_msk | nmrObj.RX_SEL1_msk | nmrObj.RX_FL_msk | nmrObj.RX_FH_msk | nmrObj.PAMP_IN_SEL2_msk ) nmrObj.deassertControlSignal( nmrObj.RX1_1H_msk | nmrObj.RX_FH_msk ) # setting for UF # nmrObj.deassertControlSignal( nmrObj.RX_FL_msk ) # setting for WMP if ( direct_read ): datain = nmrObj.cpmgSequenceDirectRead( cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_int, delay180_t1_int, tx_sd_msk ) else: nmrObj.cpmgSequence( cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_int, delay180_t1_int, tx_sd_msk, en_dconv, dconv_fact, echo_skip ) datain = [] # set datain to 0 because the data will be read from file instead nmrObj.deassertControlSignal( nmrObj.RX1_1H_msk | nmrObj.RX1_1L_msk | nmrObj.RX2_L_msk | nmrObj.RX2_H_msk | nmrObj.RX_SEL1_msk | nmrObj.RX_FL_msk | nmrObj.RX_FH_msk | nmrObj.PAMP_IN_SEL2_msk ) nmrObj.setMatchingNetwork( 0, 0 ) nmrObj.setPreampTuning( 0, 0 ) nmrObj.deassertControlSignal( nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk ) if ( process_data ): # compute the generated data if en_remote_computing: # copy remote files to local directory cp_rmt_file( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt" ) meas_folder = parse_simple_info( nmrObj.data_folder, 'current_folder.txt' ) if en_remote_computing: # copy remote folder to local directory cp_rmt_folder( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0] ) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder ) # delete the file in the server ( a, a_integ, a0, snr, T2, noise, res, theta, data_filt, echo_avg, Df, t_echospace ) = compute_iterate( nmrObj, nmrObj.data_folder, meas_folder[0], 0, 0, 0, direct_read, datain, en_fig , dconv_lpf_ord, dconv_lpf_cutoff_Hz ) nmrObj.deassertAll() nmrObj.exit()
def cpmgT1( self, cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_us, logsw, delay180_sta, delay180_sto, delay180_ste, ref_number_of_iteration, ref_twait_mult, data_folder, en_scan_fig, en_fig ): # create t1 measurement folder t1_meas_folder = datetime.now().strftime( '%Y_%m_%d_%H_%M_%S' ) + '_t1_meas' os.mkdir( t1_meas_folder ) t1_meas_hist = 't1_meas_hist.txt' # the history file name for t1 measurement self.fig_num = 1 self.fcpmg_to_fsys_mult = 16 # system_frequency/cpmg_frequency,set by fpga self.t1_opt_mult = 1.6 # compute period for the system clock (which is multiplication of the cpmg # freq) t_sys = ( 1 / cpmg_freq ) / self.fcpmg_to_fsys_mult # compute pulse180_t1 in integer values and round it to # fcpmg_to_fsys_mult multiplication pulse180_t1_int = np.round( ( pulse180_t1_us / t_sys ) / self.fcpmg_to_fsys_mult ) * self.fcpmg_to_fsys_mult # process delay if logsw: delay180_t1_sw = np.logspace( np.log10( delay180_sta ), np.log10( delay180_sto ), delay180_ste ) else: delay180_t1_sw = np.linspace( delay180_sta, delay180_sto, delay180_ste ) # make delay to be multiplication of fcpmg_to_fsys_mult delay180_t1_sw_int = np.round( ( delay180_t1_sw / t_sys ) / self.fcpmg_to_fsys_mult ) * self.fcpmg_to_fsys_mult # compute the reference and do cpmg ref_twait = ref_twait_mult * delay180_t1_sw_int[delay180_ste - 1] ref_twait_int = np.round( ( ref_twait ) / self.fcpmg_to_fsys_mult ) * self.fcpmg_to_fsys_mult self.cpmgSequence( cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, ref_number_of_iteration, ph_cycl_en, pulse180_t1_int, ref_twait_int ) # process the data meas_folder = parse_simple_info( data_folder, 'current_folder.txt' ) ( a_ref, _, a0_ref, snr_ref, T2_ref, noise_ref, res_ref, theta_ref, data_filt_ref, echo_avg_ref, Df, _ ) = compute_iterate( data_folder, meas_folder[0], 0, 0, 0, en_scan_fig ) # move the folder to t1 measurement folder and write history shutil.move( meas_folder[0], t1_meas_folder ) write_text_append( t1_meas_folder, t1_meas_hist, meas_folder[0] ) # make the loop a0_table = np.zeros( delay180_ste ) # normal format a0_table_decay = np.zeros( delay180_ste ) # decay format asum_table = np.zeros( delay180_ste ) # normal format asum_table_decay = np.zeros( delay180_ste ) # decay format for i in range( 0, delay180_ste ): delay180_t1_int = delay180_t1_sw_int[i] # do cpmg scan self.cpmgSequence( cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_int, delay180_t1_int ) # process the data (note that a0 and T2 is based on single # exponential fit) meas_folder = parse_simple_info( data_folder, 'current_folder.txt' ) ( a, _, a0, snr, T2, noise, res, theta, data_filt, echo_avg, Df, _ ) = compute_iterate( data_folder, meas_folder[0], 1, theta_ref, echo_avg_ref, en_scan_fig ) # move the folder to t1 measurement folder and write history shutil.move( meas_folder[0], t1_meas_folder ) write_text_append( t1_meas_folder, t1_meas_hist, meas_folder[0] ) # interscan data store a0_table[i] = a0 a0_table_decay[i] = a0_ref - a0 asum_table[i] = np.mean( np.real( a ) ) asum_table_decay[i] = np.mean( np.real( a_ref ) ) - np.mean( np.real( a ) ) if en_fig: print( 'Loading Figure' ) plt.ion() fig = plt.figure( self.fig_num ) fig.clf() ax = fig.add_subplot( 3, 1, 1 ) if logsw: line1, = ax.semilogx( delay180_t1_sw[0:i + 1] / 1000, asum_table[0:i + 1], 'r-' ) else: line1, = ax.plot( delay180_t1_sw[0:i + 1] / 1000, asum_table[0:i + 1], 'r-' ) # ax.set_xlim(-50, 0) # ax.set_ylim(-50, 0) ax.set_ylabel( 'Initial amplitude [a.u.]' ) ax.set_title( "T1 inversion recovery" ) ax.grid() ax = fig.add_subplot( 3, 1, 2 ) if logsw: line1, = ax.semilogx( delay180_t1_sw[0:i + 1] / 1000, asum_table_decay[0:i + 1], 'r-' ) else: line1, = ax.plot( delay180_t1_sw[0:i + 1] / 1000, asum_table_decay[0:i + 1], 'r-' ) # ax.set_xlim(-50, 0) # ax.set_ylim(-50, 0) # ax.set_xlabel('Wait time [ms]') ax.set_ylabel( 'Initial amplitude [a.u.]' ) ax.grid() ax = fig.add_subplot( 3, 1, 3 ) ax.set_ylabel( 'Amplitude [a.u.]' ) ax.set_xlabel( 'Wait time [ms]' ) ax.grid() fig.canvas.draw() fig.canvas.flush_events() print( 'Figure Loaded' ) # save t1 data to csv file to be processed f = open( t1_meas_folder + '/' + 't1heel_in.csv', "w+" ) for i in range( 0, delay180_ste ): f.write( "%f," % ( delay180_t1_sw[i] / 1000 ) ) # in milisecond f.write( "%f\n" % ( a0_table_decay[i] ) ) f.close() # process t1 data self.doLaplaceInversion( t1_meas_folder + '/' + 't1heel_in.csv', t1_meas_folder ) tvect, data = parse_csv_float2col( t1_meas_folder, 't1heel_out.csv' ) i_peaks = signal.find_peaks_cwt( data, np.arange( 1, 10 ) ) t1_opt = tvect[max( i_peaks )] ''' a_peaks = np.zeros(len(i_peaks)) for i in range(0, len(i_peaks)): a_peaks[i] = data[i_peaks[i]] # find tvect in which the largest peak is found t1_opt = tvect[i_peaks[np.where(max(a_peaks))[0][0]]] # in second ''' if en_fig: ax = fig.add_subplot( 3, 1, 3 ) if logsw: line1, = ax.semilogx( np.multiply( tvect, 1000 ), data, 'r-' ) else: line1, = ax.plot( np.multiply( tvect, 1000 ), data, 'r-' ) ax.set_ylabel( 'Amplitude [a.u.]' ) ax.set_xlabel( 'Wait time [ms]' ) ax.grid() fig.canvas.draw() # copy the measurement history script shutil.copy( 'measurement_history_matlab_script.txt', t1_meas_folder ) return delay180_t1_sw, a0_table, a0_ref, asum_table, t1_opt, t1_meas_folder
samples = 100000 # number of points min_freq = 3.8 # in MHz max_freq = 4.7 # in MHz # tuning_freq = 1.6 # hardware tuning frequency selector, using lookup table meas_bw_kHz = 200 # downconversion filter bw continuous = False # continuous running at one frequency configuration client_data_folder = "C:\\Users\\dave\\Documents\\NMR_DATA" en_fig = True # create name for new folder now = datetime.now() datename = now.strftime("%Y_%m_%d_%H_%M_%S") swfolder = client_data_folder + '\\' + datename + '_noise_scan' mkdir(swfolder) nmrObj = nmr_noise.init(swfolder) freqList = np.arange(4.0, 4.5, 0.01) for tuning_freq in freqList: nmr_noise.analyze(nmrObj, samp_freq, samples, min_freq, max_freq, tuning_freq, meas_bw_kHz, continuous, en_fig) meas_folder = parse_simple_info(swfolder, 'current_folder.txt') move(swfolder + '/' + meas_folder[0], swfolder + '/noise_at_freq_%2.3f' % tuning_freq) # move the folder copy(swfolder + ('/noise_at_freq_%2.3f' % tuning_freq) + '/noise_plot.png', swfolder + '/' + ('/noise_at_freq_%2.3f.png' % tuning_freq)) # copy the figure into the main folder nmr_noise.exit(nmrObj)
Vbias = -2.0 Vvarac = 2.8 # (vbias vvarac) nmrObj.setPreampTuning(Vbias, Vvarac) #-2.5, 2.8) # try -2.7, -1.8 if fail nmrObj.setMatchingNetwork(0, 0) nmrObj.setMatchingNetwork(0, 0) while True: nmrObj.assertControlSignal(nmrObj.RX1_1L_msk | nmrObj.RX2_L_msk | nmrObj.RX2_H_msk | nmrObj.RX_SEL1_msk | nmrObj.RX_FL_msk) nmrObj.assertControlSignal(nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk) time.sleep(0.1) nmrObj.pamp_char(sta_freq, sto_freq, spac_freq, samp_freq) nmrObj.deassertAll() meas_folder = parse_simple_info(data_parent_folder, 'current_folder.txt') # meas_folder[0] = "nmr_wobb_2018_06_25_12_44_48" maxS21, maxS21_freq, _ = compute_gain(nmrObj, data_parent_folder, meas_folder[0], en_fig, fig_num) print('maxS21={0:0.2f} maxS21_freq={1:0.2f}'.format(maxS21, maxS21_freq))
def nmr_t2_multifreq_auto ( cpmg_freq_list, pulse1_us, pulse2_us, echo_spacing_us, scan_spacing_us, multiscan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, dconv_lpf_ord, dconv_lpf_cutoff_Hz, client_data_folder ): # configurations en_fig = 0 # enable figure direct_read = 0 # perform direct read from SDRAM. use with caution above! process_data = 1 # process data within the SoC en_remote_dbg = False en_remote_computing = True pulse1_dtcl = 0.5 # useless with current code pulse2_dtcl = 0.5 # useless with current code pulse180_t1_int = 0 delay180_t1_int = 0 tx_sd_msk = 1 # 1 to shutdown tx opamp during reception, or 0 to keep it powered up during reception en_dconv = 0 # enable downconversion in the fpga dconv_fact = 4 # downconversion factor. minimum of 4. echo_skip = 1 # echo skip factor. set to 1 for the ADC to capture all echoes # additional configurations timeObj = time_meas( True ) # error checker if ( not ( len( cpmg_freq_list ) % 2 ) ): print( "ERROR: please use odd n number for total different frequencies used inside cpmg_freq_list to ensure phase cycling works correctly." ) quit() # instantiate nmr object nmrObj = tunable_nmr_system_2018( client_data_folder, en_remote_dbg, en_remote_computing ) # system setup nmrObj.initNmrSystem() # necessary to set the GPIO initial setting. Also fix the nmrObj.assertControlSignal( nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk ) # nmrObj.deassertControlSignal( # nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk) Vbias, Vvarac = find_Vbias_Vvarac_from_table ( nmrObj.client_path , cpmg_freq_list[0], nmrObj.S21_table ) nmrObj.setPreampTuning( Vbias, Vvarac ) Cpar, Cser = find_Cpar_Cser_from_table ( nmrObj.client_path , cpmg_freq_list[0], nmrObj.S11_table ) nmrObj.setMatchingNetwork( Cpar, Cser ) nmrObj.setMatchingNetwork( Cpar, Cser ) vbias_list = np.zeros( len( cpmg_freq_list ), dtype = float ) vvarac_list = np.zeros( len( cpmg_freq_list ), dtype = float ) c_series_list = np.zeros( len( cpmg_freq_list ), dtype = int ) c_shunt_list = np.zeros( len( cpmg_freq_list ), dtype = int ) for i in range ( 0, len( cpmg_freq_list ) ): Vbias, Vvarac = find_Vbias_Vvarac_from_table ( nmrObj.client_path , cpmg_freq_list[i], nmrObj.S21_table ) Cpar, Cser = find_Cpar_Cser_from_table ( nmrObj.client_path , cpmg_freq_list[i], nmrObj.S11_table ) vbias_list[i] = Vbias vvarac_list[i] = Vvarac c_series_list[i] = Cser c_shunt_list[i] = Cpar # setting for WMP nmrObj.assertControlSignal( nmrObj.RX1_1L_msk | nmrObj.RX1_1H_msk | nmrObj.RX2_L_msk | nmrObj.RX2_H_msk | nmrObj.RX_SEL1_msk | nmrObj.RX_FL_msk | nmrObj.RX_FH_msk | nmrObj.PAMP_IN_SEL2_msk ) nmrObj.deassertControlSignal( nmrObj.RX1_1H_msk | nmrObj.RX_FH_msk ) # setting for UF # nmrObj.deassertControlSignal( nmrObj.RX_FL_msk ) # setting for WMP timeObj.setTimeSta() # nmrObj.cpmgSequence( cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_int, delay180_t1_int, tx_sd_msk, en_dconv, dconv_fact, echo_skip ) # nmrObj.cpmgSequence( cpmg_freq, pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_int, delay180_t1_int, tx_sd_msk, en_dconv, dconv_fact, echo_skip ) nmrObj.cpmgSequenceMultifreq( pulse1_us, pulse2_us, pulse1_dtcl, pulse2_dtcl, echo_spacing_us, scan_spacing_us, multiscan_spacing_us, samples_per_echo, echoes_per_scan, init_adc_delay_compensation, number_of_iteration, ph_cycl_en, pulse180_t1_int, delay180_t1_int, tx_sd_msk, en_dconv, dconv_fact, echo_skip, cpmg_freq_list, c_series_list, c_shunt_list, vbias_list, vvarac_list ) datain = [] # set datain to 0 because the data will be read from file instead timeObj.setTimeSto() timeObj.reportTimeRel( "cpmgSequenceMultifreq" ) nmrObj.deassertControlSignal( nmrObj.RX1_1H_msk | nmrObj.RX1_1L_msk | nmrObj.RX2_L_msk | nmrObj.RX2_H_msk | nmrObj.RX_SEL1_msk | nmrObj.RX_FL_msk | nmrObj.RX_FH_msk | nmrObj.PAMP_IN_SEL2_msk ) nmrObj.setMatchingNetwork( 0, 0 ) nmrObj.setPreampTuning( 0, 0 ) nmrObj.deassertControlSignal( nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk ) if ( process_data ): # compute the generated data if en_remote_computing: # copy remote files to local directory cp_rmt_file( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt" ) meas_folder = parse_simple_info( nmrObj.data_folder, 'current_folder.txt' ) for i in range ( 0, len( cpmg_freq_list ) ): meas_folder[0] = meas_folder[0][:len( meas_folder[0] ) - 3] + "%03d" % i # change the meas_folder name to different folder names generated by the C programming. 25 is the character count before the last 3 digit number. if en_remote_computing: # copy remote folder to local directory cp_rmt_folder( nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0] ) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder ) # delete the file in the server ( a, a_integ, a0, snr, T2, noise, res, theta, data_filt, echo_avg, Df, t_echospace ) = compute_iterate( nmrObj, nmrObj.data_folder, meas_folder[0], 0, 0, 0, direct_read, datain, en_fig , dconv_lpf_ord, dconv_lpf_cutoff_Hz )
def runExpt(cparVal, cserVal, minReflxTable): if meas_time: start_time = time.time() nmrObj.assertControlSignal(nmrObj.RX_IN_SEL_2_msk | nmrObj.PAMP_IN_SEL_RX_msk) nmrObj.assertControlSignal(nmrObj.AMP_HP_LT1210_EN_msk | nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk) # change matching network values (twice because sometimes it doesnt' work once due to transient nmrObj.setMatchingNetwork(cparVal, cserVal) nmrObj.setMatchingNetwork(cparVal, cserVal) # do measurement nmrObj.wobble(freqSta, freqSto, freqSpa, freqSamp) # disable all to save power nmrObj.deassertControlSignal(nmrObj.AMP_HP_LT1210_EN_msk | nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk) nmrObj.deassertControlSignal(nmrObj.RX_IN_SEL_2_msk | nmrObj.PAMP_IN_SEL_RX_msk) if meas_time: elapsed_time = time.time() - start_time start_time = time.time() # reset the start time print("### time elapsed for running wobble exec: %.3f" % (elapsed_time)) # compute the generated data meas_folder = parse_simple_info(data_parent_folder, 'current_folder.txt') S11mV, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = compute_wobble( nmrObj, data_parent_folder, meas_folder[0], S11_min, en_fig, fig_num) print( '\t\tfmin={:0.3f} fmax={:0.3f} bw={:0.3f} minS11={:0.2f} minS11_freq={:0.3f} cparVal={:d} cserVal={:d}' .format(S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq, cparVal, cserVal)) if meas_time: elapsed_time = time.time() - start_time print("### time elapsed for compute_wobble: %.3f" % (elapsed_time)) # update the table minReflxTable = updateTable(minReflxTable, S11mV, cparVal, cserVal) # move the measurement folder to the main folder swfolder_ind = swfolder + '/' + str('Cp_[{:d}]__Cs_[{:d}]'.format( cparVal, cserVal)) if en_fig: shutil.move(data_parent_folder + '/' + meas_folder[0] + '/wobble.png', swfolder + '/' + str('plot_Cp_[{:d}]__Cs_[{:d}].png'.format( cparVal, cserVal))) # move the figure if keepRawData: # write gain values to a file RawDataFile = open( swfolder + '/S11_Cp_[{:d}]__Cs_[{:d}].txt'.format(cparVal, cserVal), 'w') RawDataFile.write('freq(MHz)\t min-voltage(mV)\n') RawDataFile.close() with open( swfolder + '/S11_Cp_[{:d}]__Cs_[{:d}].txt'.format(cparVal, cserVal), 'a') as f: for (a, b) in zip(freqSw, S11mV): f.write('{:-8.3f},{:-8.3f}\n'.format(a, b)) shutil.rmtree(data_parent_folder + '/' + meas_folder[0]) # move the data folder else: shutil.rmtree(data_parent_folder + '/' + meas_folder[0]) return S11mV, minS11_freq, minReflxTable
nmrObj.setMatchingNetwork(0, 0) nmrObj.setPreampTuning(0, 0) nmrObj.deassertControlSignal(nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk) if (process_data): # compute the generated data if en_remote_computing: # copy remote files to local directory cp_rmt_file(nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, "current_folder.txt") meas_folder = parse_simple_info(nmrObj.data_folder, 'current_folder.txt') if en_remote_computing: # copy remote folder to local directory cp_rmt_folder(nmrObj.scp, nmrObj.server_data_folder, nmrObj.client_data_folder, meas_folder[0]) exec_rmt_ssh_cmd_in_datadir( nmrObj.ssh, "rm -rf " + meas_folder[0], nmrObj.server_data_folder) # delete the file in the server (a, a_integ, a0, snr, T2, noise, res, theta, data_filt, echo_avg, Df, t_echospace) = compute_iterate(nmrObj, nmrObj.data_folder, meas_folder[0], 0, 0, 0, direct_read, datain, en_fig, dconv_lpf_ord, dconv_lpf_cutoff_kHz) if (meas_time): elapsed_time = time.time() - start_time print("data processing time: %.3f" % (elapsed_time))
def runExpt( cparVal, cserVal, S11mV_ref, useRef ): # useRef: use the pregenerated S11mV_ref as a reference to compute reflection. If this option is 0, then the compute_wobble will instead generated S11 in mV format instead of dB format # global variable global exptnum global minReflxTable global minReflxTable_tmp exptnum = exptnum + 1 if meas_time: start_time = time.time() # enable power and signal path nmrObj.assertControlSignal( nmrObj.RX1_2L_msk | nmrObj.RX_SEL2_msk | nmrObj.RX_FL_msk ) nmrObj.assertControlSignal( nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk | nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk ) # change matching network values (twice because sometimes it doesnt' work once due to transient nmrObj.setMatchingNetwork( cparVal, cserVal ) nmrObj.setMatchingNetwork( cparVal, cserVal ) # do measurement nmrObj.wobble( freqSta, freqSto, freqSpa, freqSamp ) # disable all to save power nmrObj.deassertAll() if meas_time : elapsed_time = time.time() - start_time start_time = time.time() # reset the start time print( "### time elapsed for running wobble exec: %.3f" % ( elapsed_time ) ) # compute the generated data meas_folder = parse_simple_info( data_parent_folder, 'current_folder.txt' ) S11dB, S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq = compute_wobble( nmrObj, data_parent_folder, meas_folder[0], S11_min, S11mV_ref, useRef, en_fig, fig_num ) print( '\t\tfmin={:0.3f} fmax={:0.3f} bw={:0.3f} minS11={:0.2f} minS11_freq={:0.3f} cparVal={:d} cserVal={:d}'.format( S11_fmin, S11_fmax, S11_bw, minS11, minS11_freq, cparVal, cserVal ) ) if meas_time : elapsed_time = time.time() - start_time print( "### time elapsed for compute_wobble: %.3f" % ( elapsed_time ) ) # update the table minReflxTable = updateTable( minReflxTable, S11dB, cparVal, cserVal ) minReflxTable_tmp = updateTable( minReflxTable_tmp, S11dB, cparVal, cserVal ) # move the measurement folder to the main folder swfolder_ind = swfolder + '/' + str( 'Cp_[{:d}]__Cs_[{:d}]'.format( cparVal, cserVal ) ) if en_fig: shutil.move( data_parent_folder + '/' + meas_folder[0] + '/wobble.png', swfolder + '/' + str( 'plt{:03d}_Cp_[{:d}]__Cs_[{:d}].png'.format( exptnum, cparVal, cserVal ) ) ) # move the figure if keepRawData: # write gain values to a file RawDataFile = open( swfolder + '/S11_Cp_[{:d}]__Cs_[{:d}].txt'.format( cparVal, cserVal ), 'w' ) RawDataFile.write( 'freq(MHz)\t min-voltage(mV)\n' ) RawDataFile.close() with open( swfolder + '/S11_Cp_[{:d}]__Cs_[{:d}].txt'.format( cparVal, cserVal ), 'a' ) as f: for ( a, b ) in zip ( freqSw, S11dB ): f.write( '{:-8.3f},{:-8.3f}\n' .format( a, b ) ) shutil.rmtree ( data_parent_folder + '/' + meas_folder[0] ) # remove the data folder else: shutil.rmtree( data_parent_folder + '/' + meas_folder[0] ) # remove the data folder return S11dB, minS11_freq