Help!!!
llzy36
I have a loop procedure (Function loop_test()) to do the function of “perform_auto_analysis()”. When I run loop_test() in the command, there will appear a dialog box asking the pathway (see the attached picture). Then I input the numbers (such as 9 and 9), the procedure will get the results. But when the procedure dose the second loop run, there still appear the dialog box asking the pathway. I need the data from the function of "perform_auto_analysis()" when I use different input values (such as the value in Function loop_test()).Thus, my question is how to use the rename code to fix this or other methods. Thank you very much.
function loop_test()
variable BC_n=27, Scat_n=700, lim_BC=28.1, lim_Scat=801
variable/g BC_MASS_CAL
variable/g Scat_cal
do
Scat_n = 600
BC_MASS_CAL = BC_n
do
Scat_cal = Scat_n
perform_auto_analysis()
Scat_n += 25
while (Scat_n < lim_scat)
BC_n += 0.5
while (BC_n < lim_BC)
end
function perform_auto_analysis()
variable/g HUMID_INSTRUMENT,LOW_GAIN_SCATTER_CHANNEL
variable startx,endx
// do it all:
// assumes user has set up the path already, and .sp2 converted to simple-name ibws
// first get variables:
variable tm,t2, file_process_number = 0
variable fnum
prompt tm, "Starting file x#:"
prompt t2, "Ending file x#:"
doprompt "input file info:",tm,t2
startx = tm
endx = t2
if (tm == 0 && t2 == 0)
// then expect a list of file numbers hard coded here:
make/n=(5) File_Number_List = {2,3,5,6,7}
variable/g NonSequentialFiles = 1
startx = File_number_list[0]
endx = File_Number_list[numpnts(file_number_list)-1]
fnum = File_number_list[0]
else
variable/g NonSequentialFiles = 0
fnum = startx
endif
//now for each file:
variable tmr,tmr2
tmr = startMStimer
make/n=0 file_start_stop_times,USED_MIN_PS_SIGNAL
do
if(HUMID_INSTRUMENT ==1)
IF(LOW_GAIN_SCATTER_CHANNEL) // YES:
load_Hsp2_data_with_LGSCAT(fnum)
else // NO:
load_Hsp2_data(fnum)
endif
else
if(LOW_GAIN_SCATTER_CHANNEL) // yes
load_sp2_data_with_LGSCAT(fnum)
else
load_sp2_data(fnum)
endif
endif
//PRINT "1"
full_initialize_workspace()
//PRINT "2"
generate_results() // THIS IS WHERE MOST OF IT HAPPENS.
//PRINT "POST GEN"
Distill_results()
//PRINT "POST DISTILL"
// record breaks between file
wavestats/q time_dat
make/o/n=2 st = {v_min,v_max}
concatenate/np {st}, file_start_stop_times
make/o/n=1 st
variable/G THIS_FILE_MIN_PS_SIGNAL
st = THIS_FILE_MIN_PS_SIGNAL
concatenate/np {st}, used_min_ps_signal
killwaves st
// clear old data:
if(file_process_number == 0)
make/o/n=1 hist_c2c_delay,hist_scat_width
//histogram/b={0,.5,100} cross_to_center_delay_all,hist_c2c_delay
wavestats/q hist_c2c_delay
wavestats/q hist_scat_width
doupdate
else
doupdate
endif
wavestats/q hist_c2c_delay
wavestats/q hist_scat_width
if(fnum<= endx && startx != endx)
clear_old_dataset()
endif
tmr2 = stopmstimer(tmr)
tmr = startmstimer
print "Time for file #", num2str(fnum)," was", tmr2/1e6, " seconds"
if (NonSequentialFiles == 0)
// Not non-sequential:
fnum+=1
file_process_number+=1
else
if (file_process_number < numpnts(file_number_list)-1)
file_process_number +=1
fnum = File_number_list[file_process_number]
else
fnum = inf
endif
endif
while(fnum<=endx)
fraction_bc_with_front_fit()
duplicate file_start_stop_times file_num;file_num = floor((p)/2)+startx
make/o/n=51 psl_diams,psl_sigs // psl signals for 620 counts off 220s.
PSL_diams[0,9] = {0.0166667,0.0333333,0.05,0.0666667,0.0833333,0.1,0.116667,0.133333,0.15,0.166667}
PSL_diams[10,19] = {0.183333,0.2,0.216667,0.233333,0.25,0.266667,0.283333,0.3,0.316667,0.333333}
PSL_diams[20,29] = {0.35,0.366667,0.383333,0.4,0.416667,0.433333,0.45,0.466667,0.483333,0.5}
psl_diams[30,39] = {0.516667,0.533333,0.55,0.566667,0.583333,0.6,0.616667,0.633333,0.65,0.666667}
PSL_diams[40,50] ={0.683333,0.7,0.716667,0.733333,0.75,0.766667,0.783333,0.8,0.816667,0.833333,0.85}
psl_sigs[0,9] = {0.000111487,0.00714235,0.0814905,0.458905,1.75552,5.25922,13.3105,29.7747,60.6046,114.486}
psl_sigs[10,19] = {203.549,344.115,557.428,870.288,1315.5,1932.02,2764.64,3863.18,5281.16,7074.06}
psl_sigs[20,29] ={9297.55,12006.4,15254.8,19099.2,23604.8,28856.1,34971.9,42122.3,50545.1,60552.9}
psl_sigs[30,39] = {72518.8,86823.9,103753,123347,145261,168730,192719,216228,238614,259756}
psl_sigs[40,50] = {280029,300160,321075,343796,369396,398971,433577,474050,520653,572596,627681}
// now, rename "_all" waves
rename_results()
variable/g binning_time_step
bin_scat_data(binning_time_step)
wave bscatter_amplitudes,bscatter_count,scatbin_times
wave bc_mass
duplicate/o bc_mass bc_ved
bc_ved = (bc_mass*6/pi/2/1000)^(1/3)
variable/G KO =0
variable/g FIX_PS2SCAT_GAIN
if(!FIX_PS2SCAT_GAIN)
wave w_coef
if(HUMID_INSTRUMENT)
variable/g PS_to_Scat_GAIN_wet = round(w_coef[1]*100)/100
else
variable/g PS_to_SCAT_GAIN = round(w_coef[1]*100)/100
endif
endif
variable/g SPLICE_CHECKED
if(SPLICE_CHECKED)
splice_detectors() // knit together all the scaled detector measures of scattering of total bc to give a wider range of bc_scatter
else
dont_splice_detectors() // scale only bc_psfit_amplitudes to bc_scatter
endif
generate_mie_outputs()
variable/g binning_time_step
bin_bc_data2(binning_time_step)
makedistrib("bc_ved",50)
variable/g K0
K0=0
duplicate/o scatter_amplitudes scatter_diams
variable/g scat_cal
wave scatter_amplitudes
scatter_diams = interp(scatter_amplitudes*620/scat_cal,psl_sigs,psl_diams)
makedistrib("scatter_diams",100)
calc_frac_bcpsfit(30,5,8,bc_mass,bc_times,bc_scatter)
duplicate bc_ved bc_optd
wave bc_scatter
bc_optd = interp(bc_scatter, bcs,diams_large_volume)
makedistrib("bc_optd", 50)
duplicate bc_ved bc_ved18
bc_ved18 = (bc_mass*6/pi/1.8/1000)^(1/3)
makedistrib("bc_ved18", 50)
Get_sensitivity_to_non_bc()
if(HUMID_INSTRUMENT ==1)
rename_Hresults()
endif
// splice_leos()
// bc_leo_source()
if(HUMID_INSTRUMENT ==1)
wave bc_hscatter
if(SPLICE_CHECKED)
wave s_source
else
endif
else
wave bc_scatter
if(SPLICE_CHECKED)
wave s_source
else
endif
endif
// for PSLs etc
make_scatter_amplitude_image(60,200)
// for bc:
make_bc_massdist_image(60)
make_bc_scatter_image(120,300,3,6)
// for PSLs etc
// make_scatter_amplitude_image(60,200)
end
variable BC_n=27, Scat_n=700, lim_BC=28.1, lim_Scat=801
variable/g BC_MASS_CAL
variable/g Scat_cal
do
Scat_n = 600
BC_MASS_CAL = BC_n
do
Scat_cal = Scat_n
perform_auto_analysis()
Scat_n += 25
while (Scat_n < lim_scat)
BC_n += 0.5
while (BC_n < lim_BC)
end
function perform_auto_analysis()
variable/g HUMID_INSTRUMENT,LOW_GAIN_SCATTER_CHANNEL
variable startx,endx
// do it all:
// assumes user has set up the path already, and .sp2 converted to simple-name ibws
// first get variables:
variable tm,t2, file_process_number = 0
variable fnum
prompt tm, "Starting file x#:"
prompt t2, "Ending file x#:"
doprompt "input file info:",tm,t2
startx = tm
endx = t2
if (tm == 0 && t2 == 0)
// then expect a list of file numbers hard coded here:
make/n=(5) File_Number_List = {2,3,5,6,7}
variable/g NonSequentialFiles = 1
startx = File_number_list[0]
endx = File_Number_list[numpnts(file_number_list)-1]
fnum = File_number_list[0]
else
variable/g NonSequentialFiles = 0
fnum = startx
endif
//now for each file:
variable tmr,tmr2
tmr = startMStimer
make/n=0 file_start_stop_times,USED_MIN_PS_SIGNAL
do
if(HUMID_INSTRUMENT ==1)
IF(LOW_GAIN_SCATTER_CHANNEL) // YES:
load_Hsp2_data_with_LGSCAT(fnum)
else // NO:
load_Hsp2_data(fnum)
endif
else
if(LOW_GAIN_SCATTER_CHANNEL) // yes
load_sp2_data_with_LGSCAT(fnum)
else
load_sp2_data(fnum)
endif
endif
//PRINT "1"
full_initialize_workspace()
//PRINT "2"
generate_results() // THIS IS WHERE MOST OF IT HAPPENS.
//PRINT "POST GEN"
Distill_results()
//PRINT "POST DISTILL"
// record breaks between file
wavestats/q time_dat
make/o/n=2 st = {v_min,v_max}
concatenate/np {st}, file_start_stop_times
make/o/n=1 st
variable/G THIS_FILE_MIN_PS_SIGNAL
st = THIS_FILE_MIN_PS_SIGNAL
concatenate/np {st}, used_min_ps_signal
killwaves st
// clear old data:
if(file_process_number == 0)
make/o/n=1 hist_c2c_delay,hist_scat_width
//histogram/b={0,.5,100} cross_to_center_delay_all,hist_c2c_delay
wavestats/q hist_c2c_delay
wavestats/q hist_scat_width
doupdate
else
doupdate
endif
wavestats/q hist_c2c_delay
wavestats/q hist_scat_width
if(fnum<= endx && startx != endx)
clear_old_dataset()
endif
tmr2 = stopmstimer(tmr)
tmr = startmstimer
print "Time for file #", num2str(fnum)," was", tmr2/1e6, " seconds"
if (NonSequentialFiles == 0)
// Not non-sequential:
fnum+=1
file_process_number+=1
else
if (file_process_number < numpnts(file_number_list)-1)
file_process_number +=1
fnum = File_number_list[file_process_number]
else
fnum = inf
endif
endif
while(fnum<=endx)
fraction_bc_with_front_fit()
duplicate file_start_stop_times file_num;file_num = floor((p)/2)+startx
make/o/n=51 psl_diams,psl_sigs // psl signals for 620 counts off 220s.
PSL_diams[0,9] = {0.0166667,0.0333333,0.05,0.0666667,0.0833333,0.1,0.116667,0.133333,0.15,0.166667}
PSL_diams[10,19] = {0.183333,0.2,0.216667,0.233333,0.25,0.266667,0.283333,0.3,0.316667,0.333333}
PSL_diams[20,29] = {0.35,0.366667,0.383333,0.4,0.416667,0.433333,0.45,0.466667,0.483333,0.5}
psl_diams[30,39] = {0.516667,0.533333,0.55,0.566667,0.583333,0.6,0.616667,0.633333,0.65,0.666667}
PSL_diams[40,50] ={0.683333,0.7,0.716667,0.733333,0.75,0.766667,0.783333,0.8,0.816667,0.833333,0.85}
psl_sigs[0,9] = {0.000111487,0.00714235,0.0814905,0.458905,1.75552,5.25922,13.3105,29.7747,60.6046,114.486}
psl_sigs[10,19] = {203.549,344.115,557.428,870.288,1315.5,1932.02,2764.64,3863.18,5281.16,7074.06}
psl_sigs[20,29] ={9297.55,12006.4,15254.8,19099.2,23604.8,28856.1,34971.9,42122.3,50545.1,60552.9}
psl_sigs[30,39] = {72518.8,86823.9,103753,123347,145261,168730,192719,216228,238614,259756}
psl_sigs[40,50] = {280029,300160,321075,343796,369396,398971,433577,474050,520653,572596,627681}
// now, rename "_all" waves
rename_results()
variable/g binning_time_step
bin_scat_data(binning_time_step)
wave bscatter_amplitudes,bscatter_count,scatbin_times
wave bc_mass
duplicate/o bc_mass bc_ved
bc_ved = (bc_mass*6/pi/2/1000)^(1/3)
variable/G KO =0
variable/g FIX_PS2SCAT_GAIN
if(!FIX_PS2SCAT_GAIN)
wave w_coef
if(HUMID_INSTRUMENT)
variable/g PS_to_Scat_GAIN_wet = round(w_coef[1]*100)/100
else
variable/g PS_to_SCAT_GAIN = round(w_coef[1]*100)/100
endif
endif
variable/g SPLICE_CHECKED
if(SPLICE_CHECKED)
splice_detectors() // knit together all the scaled detector measures of scattering of total bc to give a wider range of bc_scatter
else
dont_splice_detectors() // scale only bc_psfit_amplitudes to bc_scatter
endif
generate_mie_outputs()
variable/g binning_time_step
bin_bc_data2(binning_time_step)
makedistrib("bc_ved",50)
variable/g K0
K0=0
duplicate/o scatter_amplitudes scatter_diams
variable/g scat_cal
wave scatter_amplitudes
scatter_diams = interp(scatter_amplitudes*620/scat_cal,psl_sigs,psl_diams)
makedistrib("scatter_diams",100)
calc_frac_bcpsfit(30,5,8,bc_mass,bc_times,bc_scatter)
duplicate bc_ved bc_optd
wave bc_scatter
bc_optd = interp(bc_scatter, bcs,diams_large_volume)
makedistrib("bc_optd", 50)
duplicate bc_ved bc_ved18
bc_ved18 = (bc_mass*6/pi/1.8/1000)^(1/3)
makedistrib("bc_ved18", 50)
Get_sensitivity_to_non_bc()
if(HUMID_INSTRUMENT ==1)
rename_Hresults()
endif
// splice_leos()
// bc_leo_source()
if(HUMID_INSTRUMENT ==1)
wave bc_hscatter
if(SPLICE_CHECKED)
wave s_source
else
endif
else
wave bc_scatter
if(SPLICE_CHECKED)
wave s_source
else
endif
endif
// for PSLs etc
make_scatter_amplitude_image(60,200)
// for bc:
make_bc_massdist_image(60)
make_bc_scatter_image(120,300,3,6)
// for PSLs etc
// make_scatter_amplitude_image(60,200)
end
About the problem: The input variables (startx or tm, endx or t2) don't get saved anywhere and only exist for the time the function perform_auto_analysis() actually runs. So the program has to ask for the numbers every time the function executes in your do-loop.
There are at least two solutions. One would be to save the values, e.g., as global variables, and then recall the values from within the function on consecutive runs. This is rather convoluted and I would not recommend this approach unless you want to preserve the functionality of perform_auto_analysis() as is. Another approach would be to move the prompt for variables part out into your main function (which then gets only called once at start) and then use your numbers as input variables, i.e., perform_auto_analysis(tm, t2).
October 20, 2015 at 06:43 pm - Permalink