FUNCTION get_n3_options, aj1, aj2, period, level=level
common DP_DATA
common DP_LOG
datapath=getenv('NAS_RPWS')
rootpath=getenv('ROOT_RPWS')
err=0
paths=ptrarr(6)
p=make_file_list(aj1, 0, aj2, 24, level='n2')
if (ptr_valid(p) eq 0) then begin
widget_control, dp_log_txt, set_value="There's no n2 file for this period", /append
for i=0, 4 do begin
paths[i]=ptr_new()
endfor
return, paths
end else begin
n2files=*p
endelse
nbdir=n_elements(n2files)
iephem=0
read_data_src_list, src_list
indsource=widget_info(dp_source_lst , /droplist_select)
vsource=(src_list.veph)[indsource]
src_df=(src_list.df_name)[indsource]
paths[5]=ptr_new(src_df)
ephemfiles=strarr(aj2-aj1+1)
idir=0
if level ne 'g' then begin
while idir le nbdir-1 do begin
if (file_test(strmid(n2files[idir], 0, strlen(n2files[idir])-14)+'ephem/'+strmid(n2files[idir],9, 7, /reverse_offset)+'.'+vsource ) eq 0) then begin
idir0=idir
day=strmid(n2files[idir],9, 7, /reverse_offset)
widget_control, dp_log_txt, set_value='The ephem file '+strmid(n2files[idir], 0, strlen(n2files[idir])-14)+'ephem/'+day+'.'+vsource+" doesn't exist.", /append
err=1
endday=0
while endday eq 0 do begin
if idir le nbdir-2 then begin
idir=idir+1
idir0=idir
if strcmp(day,strmid(n2files[idir],9, 7, /reverse_offset)) ne 1 then begin
endday=1
endif
endif else begin
endday=1
endelse
idir=idir+1
endwhile
endif else begin
idir0=idir
endday=0
day=strmid(n2files[idir],9, 7, /reverse_offset)
ephemfiles[iephem]=strmid(n2files[idir], 0, strlen(n2files[idir])-14)+'ephem/'+day+'.'+vsource
iephem=iephem+1
while endday eq 0 do begin
if idir le nbdir-2 then begin
idir=idir+1
idir0=idir
if strcmp(day,strmid(n2files[idir],9, 7, /reverse_offset)) ne 1 then begin
endday=1
endif
endif else begin
endday=1
endelse
idir=idir+1
endwhile
endelse
endwhile
endif
if (iephem gt 0) then begin
paths[0]=ptr_new(ephemfiles[0:iephem -1])
endif else paths[0]=ptr_new()
if level ne 'g' then begin
indant=widget_info(dp_antset_lst, /droplist_select)
ant=read_ant_list(rootpath+'/pro/ant_list.txt')
antfile=ant(indant).ant_file
if antfile eq 'calDec04' then begin
if (file_test(rootpath+'ant/'+antfile+'_ABC.ant') eq 0) then begin
widget_control, dp_log_txt, set_value='The file '+antfile+"_ABC.ant doesn't exist", /append
err=1
endif
if (file_test(rootpath+'ant/'+antfile+'_H12.ant') eq 0) then begin
widget_control, dp_log_txt, set_value='The file '+antfile+"_H12.ant doesn't exist", /append
err=1
endif
endif else begin
if (file_test(rootpath+'ant/'+antfile+'.ant') eq 0) then begin
widget_control, dp_log_txt, set_value='The file '+antfile+" doesn't exist", /append
err=1
endif
endelse
paths[1]=ptr_new(antfile)
endif else paths[1]=ptr_new()
nbdir=n_elements(*period)
case 1 of
widget_info(dp_n3_bg_auto_but, /button_set): begin
for idir=0, nbdir-1 do begin
bg_file = datapath+(*period)[idir]+'/bg/bg_'+(*period)[idir]
if (file_test(bg_file) eq 0) then begin
widget_control, dp_log_txt, set_value='The bg file '+bg_file+" doesn't exist.", /append
err=1
endif
endfor
if level eq 'g' then paths[2]=ptr_new(datapath+(*period)[0]+'/bg/bg_'+(*period)[0]) else paths[2]=ptr_new('auto')
end
widget_info(dp_n3_bg_manual_but, /button_set): begin
widget_control, dp_n3_bg_filename_txt, get_value=bgfile
if (file_test(bgfile) eq 0) then begin
widget_control, dp_log_txt, set_value='The bg file '+bgfile+"doesn't exist.", /append
err=1
endif
paths[2]=ptr_new(bgfile)
end
endcase
case 1 of
widget_info(dp_n3_d_standard, /button_set): begin
paths[4]=ptr_new(0)
end
widget_info(dp_n3_d_newloc, /button_set): begin
widget_control, dp_n3_newloc_txt, get_value=dataloc
if (strmid(dataloc, 0, 1, /reverse_offset) ne '/') then begin
dataloc=dataloc+'/'
endif
tmp=file_test(dataloc, directory=dirstate)
if dirstate ne 1 then begin
widget_control, dp_log_txt, set_value='The bg file'+dataloc+"does not exist", /append
err=1
endif
n3letters=['', 'a', 'b', 'c', 'd', 'e', 'f', 'g']
for i=0, 7 do begin
tmp=file_test(dataloc+'n3'+n3letters[i], directory=dirstate)
if dirstate ne 1 then begin
file_mkdir, dataloc+'n3'+n3letters[i], /noexpand_path
endif
endfor
paths[4]=ptr_new(dataloc)
end
endcase
if err eq 1 then begin
widget_control, dp_log_txt, set_value='Please, make the needed files and directories', /append
for i=0, 4 do begin
ptr_free, paths[i]
endfor
endif
help, paths
print, paths
return, paths
end