pro make_missingn2files, pfiles
day1=long(strmid(pfiles[0], strlen(pfiles[0])-10, 7))
h1=long(strmid(pfiles[0], strlen(pfiles[0])-2, 2))
nb=n_elements(pfiles)
day2=long(strmid(pfiles[nb-1], strlen(pfiles[nb-1])-10, 7))
h2=long(strmid(pfiles[nb-1], strlen(pfiles[nb-1])-2, 2))
make_n2_files, day1, h1, day2, h2
end
PRO dp_valid, ev
common DP_DATA
common DP_TIME, dp_time_from_txt, dp_time_to_txt, dp_time_list
common DP_LOG, dp_log_txt
common COM2
common COM
widget_control, dp_abort_but, /sensitive
t1=systime(/seconds)
datapath=getenv('NAS_RPWS')
datalevel=''
if (kdata=widget_info(dp_k_but, /button_set)) then begin
datalevel=datalevel+' K'
endif
if (n1data=widget_info(dp_n1_but, /button_set)) then begin
datalevel=datalevel+' N1'
endif
if (n2data=widget_info(dp_n2_but, /button_set)) then begin
datalevel=datalevel+' N2'
endif
n3data=intarr(8)
if (n3data[1]=widget_info(dp_n3a_but, /button_set)) then begin
datalevel=datalevel+' N3a'
endif
if (n3data[2]=widget_info(dp_n3b_but, /button_set)) then begin
datalevel=datalevel+' N3b'
endif
if (n3data[3]=widget_info(dp_n3c_but, /button_set)) then begin
datalevel=datalevel+' N3c'
endif
if (n3data[4]=widget_info(dp_n3d_but, /button_set)) then begin
datalevel=datalevel+' N3d'
endif
if (n3data[5]=widget_info(dp_n3e_but, /button_set)) then begin
datalevel=datalevel+' N3e'
endif
if (n3data[6]=widget_info(dp_n3f_but, /button_set)) then begin
datalevel=datalevel+' N3f'
endif
if (n3data[7]=widget_info(dp_n3g_but, /button_set)) then begin
datalevel=datalevel+' N3g'
endif
if (n3data[0]=widget_info(dp_n3_but, /button_set)) then begin
datalevel=datalevel+' N3'
endif
if (ephemdata=widget_info(dp_ephem_but, /button_set)) then begin
datalevel=datalevel+' ephem'
endif
if (bgdata=widget_info(dp_background_but, /button_set)) then begin
datalevel=datalevel+' bg'
endif
indn3=where(1 eq n3data, countn3)
widget_control, dp_time_from_txt, get_value=time1
widget_control, dp_time_to_txt, get_value=time2
time1=time1[0]
time2=time2[0]
hour1=0
hour2=24
if ((time1 eq '') or (time2 eq '')) then begin
index=widget_info(dp_time_list, /list_select)
if (index eq -1) then begin
widget_control, dp_log_txt, set_value=texts[0], $
/append
return
endif
dir=(*(*dp_list->getnameslist()))[index]
Firstdir= ['Turn_on', 'Venus1', 'Ico_m14', 'Venus2', 'Earth']
ind=where(dir eq Firstdir)
if (ind eq -1) then begin
year1=long(strmid(dir, 0, 4))
year2=year1
ddday1=long(strmid(dir, 5, 3))
ddday2=long(strmid(dir, 9, 3))
aj1=year1*1000l+ddday1
aj2=year2*1000l+ddday2
endif else begin
case ind[0] of
0: begin
year1=1997
year2=1997
ddday1=298
ddday2=299
end
1: begin
year1=1998
year2=1998
ddday1=116
ddday2=116
end
2: begin
year1=1998
year2=1999
ddday1=364
ddday2=5
end
3: begin
year1=1999
year2=1999
ddday1=175
ddday2=175
end
4: begin
year1=1999
year2=1999
ddday1=227
ddday2=257
end
endcase
aj1=year1*1000l+ddday1
aj2=year2*1000l+ddday2
endelse
endif else begin
if (strmid(time1, 5, 1) eq '/') then begin
if (strmid(time1, 4, 1) ne '/') then begin
widget_control, dp_log_txt, set_value=texts[0], /append
return
endif
i=0
month1=0
day1=0
year1=valid_year(strmid(time1, 0, 4))
if (year1 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[0], $
/append
return
endif
ddday1=long(strtrim(strmid(time1, 6, 3), 2))
if (ddday1 gt 366 or ddday1 lt 1) then begin
widget_control, dp_log_txt, set_value=texts[0], $
/append
return
endif
if (strmid(time1, 9, 1) eq '.') then begin
hour=strmid(time1, 10, 2)
if strmid(hour, 0, 1) eq '0' then begin
hour1=long(strmid(hour, 1, 1))
endif else begin
hour1=long(hour)
endelse
endif
endif else begin
if (strmid(time1, 4, 1) ne '/') then begin
widget_control, dp_log_txt, set_value=texts[0], /append
return
endif
i=1
ddday1=0
year1=valid_year(strmid(time1, 0, 4))
if (year1 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[0], $
/append
return
endif
month1=valid_month(strmid(time1, 5, 2))
if (month1 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[0], $
/append
return
endif
day1=valid_day(strmid(time1, 8, 2), month1, year1)
if (day1 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[0], $
/append
return
endif
ddday1=ddmm_to_ddd(year1, month1, day1)
if (strmid(time1, 10, 1) eq '.') then begin
hour=strmid(time1, 11, 2)
if strmid(hour, 0, 1) eq '0' then begin
hour1=long(strmid(hour, 1, 1))
endif else begin
hour1=long(hour)
endelse
endif
endelse
if (strmid(time2, 5, 1) eq '/') then begin
if (strmid(time2, 4, 1) ne '/') then begin
widget_control, dp_log_txt, set_value=texts[1], /append
return
endif
i=0
month2=0
day2=0
year2=valid_year(strmid(time2, 0, 4))
if (year2 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[1], $
/append
return
endif
ddday2=long(strtrim(strmid(time2, 6, 3), 2))
if (ddday2 gt 366 or ddday2 lt 1) then begin
widget_control, dp_log_txt, set_value=texts[1], /append
return
endif
if (strmid(time2, 9, 1) eq '.') then begin
hour=strmid(time2, 10, 2)
if strmid(hour, 0, 1) eq '0' then begin
hour2=long(strmid(hour, 1, 1))
endif else begin
hour2=long(hour)
endelse
endif
endif else begin
if ((strmid(time2, 4, 1) ne '/') or (strmid(time2, 7, 1) ne '/')) then begin
widget_control, dp_log_txt, set_value=texts[1], /append
return
endif
i=1
ddday2=0
year2=valid_year(strmid(time2, 0, 4))
if (year2 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[1], /append
return
endif
month2=valid_month(strmid(time2, 5, 2))
if (month2 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[1], /append
return
endif
day2=valid_day(strmid(time2, 8, 2), month2, year2)
if (day2 eq 0) then begin
widget_control, dp_log_txt, set_value=texts[1], /append
return
endif
ddday2=ddmm_to_ddd(year2, month2, day2)
if (strmid(time2, 10, 1) eq '.') then begin
hour=strmid(time2, 11, 2)
if strmid(hour, 0, 1) eq '0' then begin
hour2=long(strmid(hour, 1, 1))
endif else begin
hour1=long(hour)
endelse
endif
endelse
aj1=year1*1000L+ddday1
aj2=year2*1000L+ddday2
if (aj1 gt aj2) then begin
widget_control, dp_log_txt, set_value=texts[2], /append
return
endif
endelse
period=make_dir_tab(year1, ddday1, year2, ddday2)
if (ptr_valid(period) eq 1) then begin
make_directory, *period, datapath
if (kdata) then begin
if (not widget_info(dp_abort_but,/button_set)) then begin
widget_control, dp_log_txt, set_value=texts[3]+'k data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
a=getkfiles(aj1, hour1,aj2, hour2)
endif
endif
if ( n1data ) then begin
if not widget_info(dp_abort_but, /button_set) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n1 data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
make_n1_files, aj1, hour1, aj2, hour2
endif
endif
if ( n2data and not widget_info(dp_abort_but, /button_set)) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n2 data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
make_n2_files, aj1, hour1, aj2, hour2
openw, 1, getenv('ROOT_RPWS')+'/pro/file_script'
printf, 1, "u rpwsCnes KrOnOs04"
printf, 1, "prompt"
printf, 1, "bin"
for aj=aj1, aj2 do begin
fileName=strtrim(string(aj), 2)
year=aj/1000l
ddday=aj-year*1000l
dir=make_dir_tab(year, ddday, year, ddday)
printf, 1, "lcd "+datapath+*dir[0]+'/n2/'
printf, 1, "mput "+'P'+strtrim(string(aj), 2)+'*'
endfor
printf, 1, "bye"
close, 1
endif
if (widget_info(dp_pdf_but, /button_set) and not widget_info(dp_abort_but, /button_set)) then begin
widget_control, dp_log_txt, set_value=texts[4]+' PDF and LIS data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
indnbblocks=widget_info(dp_nblocks_lst, /droplist_select)
nbblocks=[1, 2, 4]
summary, aj1, aj2, nblocks=nbblocks[indnbblocks], print_ps=widget_info(dp_pdfprint_but, /button_set)
openw, 1, getenv('ROOT_RPWS')+'/pro/file_script'
printf, 1, "u rpwsCnes KrOnOs04"
printf, 1, "prompt"
for aj=aj1, aj2 do begin
fileName=strtrim(string(aj), 2)
year=aj/1000l
ddday=aj-year*1000l
dir=make_dir_tab(year, ddday, year, ddday)
printf, 1, "lcd "+datapath+*dir[0]+'/lis/'
printf, 1, "bin"
printf, 1, "lcd "+datapath+*dir[0]+'/pdf/'
printf, 1, "mput "+strtrim(string(aj), 2)+'.pdf'
endfor
printf, 1, "bye"
close, 1
file_delete, getenv('ROOT_RPWS')+'/pro/file_script'
endif
if (widget_info(dp_ephem_but, /button_set) and not widget_info(dp_abort_but, /button_set)) then begin
indsource=widget_info(dp_ephemsource_lst , /droplist_select)
read_data_src_list, src_list
sources=src_list.df_name
i=0
widget_control, dp_log_txt, set_value=texts[3]+'Ephem data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2)+' for '+sources[indsource], /append
if aj1 gt 2000000 then begin
for aj=aj1, aj2 do begin
if (long(strmid(strtrim(string(aj), 2), 4, 3)) gt long(strmid((*period)[i], strlen((*period)[i])-3, 3))) then begin
i=i+1
endif
make_ephem_file, aaaajjj=aj, period=(*period)[i], source=sources[indsource], $
quiet = widget_info(dp_ephemoption_quiet, /button_set), $
reload = widget_info(dp_ephemoption_reload, /button_set)
endfor
endif else begin
for aj=aj1, aj2 do begin
if (not widget_info(dp_abort_but, /button_set)) then begin
widget_control, dp_abort_but, sensitive=0
make_ephem_file, aaaajjj=aj, period=(*period)[0], source=sources[indsource]
widget_control, dp_abort_but, /sensitive
endif
endfor
endelse
endif
if (widget_info(dp_background_but, /button_set) and not widget_info(dp_abort_but, /button_set)) then begin
bg=1
case 1 of
widget_info(dp_background_auto, /button_set): begin
auto=1
end
widget_info(dp_background_manual, /button_set): begin
auto=0
end
else: begin
widget_control, dp_log_txt, set_value='Please select a mode: automatic or manual', /append
bg=0
return
end
endcase
if bg eq 1 then begin
widget_control, dp_log_txt, set_value=texts[4]+'background data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
pfiles=are_all(aj1, aj2, level1='k', level2='n2')
if ptr_valid(pfiles) then begin
length=n_elements(*pfiles)
widget_control, dp_log_txt, set_value=(*pfiles)[length-1]
make_missingn2files,(*pfiles)[0: length-2]
endif else begin
bg=0
case pfiles of
0: bg=1
1: widget_control, dp_log_txt, set_value='There is no file for this period', /append
2: widget_control, dp_log_txt, set_value='There is no n2 file for this period', /append
3: widget_control, dp_log_txt, set_value='Aborting. Missing k files !!!', /append
else:
endcase
endelse
if bg eq 1 then begin
make_bg_files, aj1, 0L, aj2, 24L, quarter=auto, /verbose
endif
endif
endif
if not widget_info(dp_abort_but, /button_set) then begin
if (countn3 ne 0) then begin
if (n3data[1]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3a data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
if ptr_valid(paths[0]) eq 0 then return
message,'N3a analysis not yet implemented, Aborting...',/info
endif
if (n3data[2]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3b data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
if ptr_valid(paths[0]) eq 0 then return
make_n3b_files, aj1, hour1, aj2, hour2, /verbose, bg_file=*(paths[2]), $
ephem_file=*(paths[0]), antenna_file=*(paths[1]), output_path=*(paths[4]), src_df_name=*(paths[5])
endif
if (n3data[3]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3c data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
if ptr_valid(paths[0]) eq 0 then return
make_n3c_files, aj1, hour1, aj2, hour2, /verbose, bg_file=*(paths[2]), $
ephem_file=*(paths[0]), antenna_file=*(paths[1]), output_path=*(paths[4]), src_df_name=*(paths[5])
endif
if (n3data[4]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3d data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
if ptr_valid(paths[0]) eq 0 then return
make_n3d_files, aj1, hour1, aj2, hour2, /verbose, bg_file=*(paths[2]), $
ephem_file=*(paths[0]), antenna_file=*(paths[1]), output_path=*(paths[4]), src_df_name=*(paths[5])
endif
if (n3data[5]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3e data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
if ptr_valid(paths[0]) eq 0 then return
make_n3e_files, aj1, hour1, aj2, hour2, /verbose, bg_file=*(paths[2]), $
ephem_file=*(paths[0]), antenna_file=*(paths[1]), output_path=*(paths[4]), src_df_name=*(paths[5])
endif
if (n3data[6]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3f data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
message,'N3f analysis not yet implemented, Aborting...',/info
endif
if (n3data[7]) then begin
print, 'gg'
widget_control, dp_log_txt, set_value=texts[4]+'n3g data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='g')
print, 'fini options'
if ptr_valid(paths[4]) eq 0 then return
make_n3g_files, aj1, hour1, aj2, hour2, *(paths[2])
print, 'gg fini'
endif
if (n3data[0]) then begin
widget_control, dp_log_txt, set_value=texts[4]+'n3 data from '+strtrim(string(aj1), 2)+' to '+ $
strtrim(string(aj2), 2), /append
paths=get_n3_options(aj1, aj2, period, level='a')
if ptr_valid(paths[0]) eq 0 then return
message,'N3 merging not yet implemented, Aborting...',/info
endif
for i=0, 4 do begin
ptr_free, paths[i]
endfor
endif
endif
if (widget_info(dp_abort_but, /button_set)) then begin
widget_control, dp_log_txt, set_value='Abort', /append
endif else begin
widget_control, dp_log_txt, set_value='DONE', /append
message, string(systime(/seconds)-t1)+' seconds ellapsed',/info
endelse
ptr_free, period
endif
widget_control, dp_abort_but, sensitive=1
widget_control, dp_abort_but, set_button=0
end