;**************************************************************************** ;* make_bi_guisdap_3.pro ;* ;* edit dateguisdap ;* ;**************************************************************************** ;* run by zbi ;* edit set_filenames.pro and dateguisdap ;* change cp in this program ;* set itsys=1 at the main routine if Tsys is stored. ;* ;* ;* ;* For change of write_ascii (now mat2das), ;* file contents are changed (newly lat and lon are added. ;* alt is in float (ex. 101.2 km). ;* for cp2 use /ESR00/guisdap_nozawa/mat2das_cp2.m ;* ;* Version 1.0 July 15, 1999 Made ;* 1.1 October 21, 1999 Tsys ;* 1.2 October 25, 1999 Transmitter power ;* 1.3 October 27, 1999 set_cp1l ;* 1.4 November 2, 1999 pathfile ;* 1.5 May 18, 2000 range in float ;* 1.6 July 24, 2000 check_lp ;* 1.7 Nov 16, 2000 extract_no_itr ;**************************************************** ;* ;* make_bi_guisdap_2.pro ;* Version 1.0 October 1, 1997 Made ;* 1.0 October 9, 1997 Last edition ;* 1.1 Nov 26, 1997 A94, A98 ;* 1.2 Dec 18, 1997 set_930420 ;* 1.3 Jan 28, 1998 read_dateguisdap.pro ;* 1.4 May 15, 1998 BUG fixed (icount) ;* 1.5 July 30, 1998 icound bug again ;* 1.6 January 16, 1999 ESR data ;* 1.7 January 16, 1999 ESR long-pulse data ;* 2.0 July 2, 1999 CP-2 ;**************************************************************************** ; set_filenames.pro ; Please specify day, site, etc. ; pro print_proname,proname date='November 2, 1999: V1.4 ' & s='-----' & s2=' ' print,' ' & print,s,s2,proname,s2,date,s2,s & print,' ' end ;read_guisdap.pro ; January 28, 1998 pro read_dateguisdap,head,sdate0,path,cp,pathfile ;addition of cp made on 991028 ; pathfile on 991102 file='dateguisdap' head='moji' sdate0='990114' path='30min' pathfile='string' cp='0000' openr,1,file print,'----- Open ',file readf,1,head readf,1,sdate0 readf,1,path if EOF(1) ne 1 then readf,1,cp if EOF(1) ne 1 then begin readf,1,pathfile k=strlen(pathfile) & b=strmid(pathfile,k-1,1) if b ne '/' then pathfile=pathfile+'/' endif else pathfile='no' ; if no default close,1 Case head of 't':head='tr' 's':head='so' 'k':head='ki' 'l':head='lo' else:stop endcase end ;*************************************************************************** ;* ;* give_cp_ver2.pro ;* ;* return 'cp1h' ;* ;* Version 1.0 Feb 9, 1999 Made ;*************************************************************************** function give_cp_ver2,cp0,sdate0 cp=strmid(cp0,0,3) ver='Z' date=long(sdate0) year=date/10000 if cp eq 'cp1' then begin ver='k' if date lt 861200 then ver='f' if date ge 861200 and date le 881231 then ver='h' if date ge 890000 and date le 911231 then ver='i' if date ge 920000 and date le 921231 then ver='j' if date ge 930000 then ver='k' endif if cp eq 'cp2' then begin ver='e' if date ge 840829 and date lt 850219 then Ver='b' if date ge 850219 and date lt 861111 then Ver='c' if date ge 861111 and date lt 920500 then Ver='d' if date ge 920707 then Ver='e' endif if cp eq 'cp4' then begin ver='b' & if year le 91 then ver='a' endif if ver eq 'Z' then begin print,'please edit give_cp_ver.pro ' print,'currently CP1, CP2, and CP4 are available' stop endif ver=cp+ver return,ver end function set_k common par,head,sdate0,dat1,dat2,cp if strmid(cp,0,3) eq 'cp2' then begin k=500000 if sdate0 eq '990701' then k=1000000 return,k endif i=strpos(dat2,'.gdat') i2=strmid(dat2,0,i) l=strpos(i2,'min') if l ne -1 then lmin=fix(strmid(i2,0,l)) l2=strpos(i2,'sec') k=200000 if head eq 'ki' or head eq 'so' then begin k=200000 return,k endif if l2 ne -1 then k=2000000 if l2 ne -1 then k=2000000 if l ne -1 then begin if lmin lt 5 then k=700000 if lmin lt 2 then k=1000000 if cp eq 'cp1j' and i2 eq '1min' then k=1000000 endif return,k end ;-------------------------------------------------------------- ; Version 1.0 ; number pro read_guisdap_asci_3,iarr,farr,icount common time,timesec common tsys,itsys common par,head,sdate0,dat1,dat2,cp k=set_k() print,'k = ',k read_head ; also write head to outfile ; k=600000 & iarr=intarr(17,k) & farr=fltarr(k) if itsys eq 1 then begin ;k=600000 & iarr=intarr(19,k) & farr=fltarr(3,k) ; addition of Tsys (K) ;k=600000 & iarr=intarr(19,k) & farr=fltarr(3,k) ; addition of Tsys (K) ;k=1600000 & iarr=intarr(19,k) & farr=fltarr(3,k) ; addition of Tsys (K) ;iarr=intarr(19,k) & farr=fltarr(3,k) ; addition of Tsys (K) iarr=intarr(19,k) & farr=fltarr(4,k) ; addition of Tsys (K), range in flt endif else begin ;k=600000 & iarr=intarr(19,k) & farr=fltarr(2,k) ;=600000 & iarr=intarr(19,k) & farr=fltarr(2,k) ;k=1600000 & iarr=intarr(19,k) & farr=fltarr(2,k) iarr=intarr(19,k) & farr=fltarr(2,k) endelse ; addition of Transmitter power (iarr(19,*)) if timesec then begin iarr=intarr(21,k) if itsys ge 1 then iarr=intarr(22,k) endif ; 19:lat0 ; 20:lon0 ; 21:Tx power ; farr(1,*) = altitude ; farr(2,*) = Tsys icount=0 while EOF(1) ne 1 do begin ;read_standard,icount,iarr,farr read_special,icount,iarr,farr if (icount mod 1000) eq 0 then print,format='(7I7)',icount,iarr(0:5,icount) icount=icount+1l endwhile print,format='(7I7)',icount,iarr(0:5,icount-1) print,'icount = ',icount iarr=iarr(*,0:icount-1) ; fixed 980730 farr=farr(*,0:icount-1) end function strmid_c,moji,i1,i2 a=strmid(moji,i1,i2) & n=strlen(a) & k=0 for i=0,n-1 do if strmid(a,i,1) eq 'I' or strmid(a,i,1) eq 'N' then k=1 if k then a='-30000' ; if a eq ' ' then a='0' if a eq ' ' then a='0' if a eq ' ' then a='0' if strmid(a,0,3) eq '.00' then begin a='-32768' print,'Warning! ',moji endif a2=long(a) ;if !error ne 0 then stop if a2 ge 32768 or a2 lt -32768 then begin if fix(strmid(moji,18,2)) eq 0 then begin print,'Warning! ',moji & print,a2 endif a='-32768' endif return,a end pro read_special,icount,iarr,farr common time,timesec common tsys,itsys ;moji='123' & str='(A90)' & readf,1,format=str,moji ;moji='123' & str='(A94)' ;if timesec then str='(A98)' moji='string' if itsys eq 1 then begin str='(A125)' ; Tsys endif else begin str='(A114)' ; timesec is not neccesarry on July 15, 1999 endelse readf,1,format=str,moji Case timesec of 1:der_iarr2,moji,icount,iarr,farr else:der_iarr,moji,icount,iarr,farr endcase end pro der_iarr,moji,icount,iarr,farr iarr(0,icount)=fix(strmid_c(moji,0,4)) ; date iarr(1,icount)=fix(strmid_c(moji,4,5)) ; time1 iarr(2,icount)=fix(strmid_c(moji,9,5)) ; time2 iarr(3,icount)=fix(strmid_c(moji,14,4)) ; alt iarr(4,icount)=fix(strmid_c(moji,18,2)) ; q iarr(5,icount)=fix(strmid_c(moji,20,6)) ; Ne iarr(6,icount)=fix(strmid_c(moji,26,6)) ; Vi iarr(7,icount)=fix(strmid_c(moji,32,6)) ; Ti iarr(8,icount)=fix(strmid_c(moji,38,6)) ; Te iarr(9,icount)=fix(strmid_c(moji,44,6)) ; Neerr iarr(10,icount)=fix(strmid_c(moji,50,6)) ; Vierr iarr(11,icount)=fix(strmid_c(moji,56,6)) ; Tierr iarr(12,icount)=fix(strmid_c(moji,62,6)) ; Teerr iarr(13,icount)=fix(strmid_c(moji,68,5)) ; Az iarr(14,icount)=fix(strmid_c(moji,73,5)) ; El farr(icount)=float(strmid(moji,78,6)) ; O+/Ne iarr(15,icount)=fix(strmid_c(moji,84,6)) ; col.f iarr(16,icount)=fix(strmid_c(moji,90,4)) ; range ;print,iarr(*,icount) ;& ;print,moji end pro der_iarr2,moji,icount,iarr,farr iarr(0,icount)=fix(strmid_c(moji,0,4)) ; date iarr(1,icount)=fix(strmid_c(moji,4,5)) ; time1 iarr(2,icount)=fix(strmid_c(moji,11,5)) ; time2 iarr(3,icount)=fix(strmid_c(moji,18,4)) ; alt farr(1,icount)=float(strmid(moji,18,6)) ; alt iarr(19,icount)=fix(strmid_c(moji,24,5)) ; lat iarr(20,icount)=fix(strmid_c(moji,29,5)) ; lon iarr(4,icount)=fix(strmid_c(moji,34,2)) ; q iarr(5,icount)=fix(strmid_c(moji,36,6)) ; Ne iarr(6,icount)=fix(strmid_c(moji,42,6)) ; Vi iarr(7,icount)=fix(strmid_c(moji,48,6)) ; Ti iarr(8,icount)=fix(strmid_c(moji,54,6)) ; Te iarr(9,icount)=fix(strmid_c(moji,60,6)) ; Neerr iarr(10,icount)=fix(strmid_c(moji,66,6)) ; Vierr iarr(11,icount)=fix(strmid_c(moji,72,6)) ; Tierr iarr(12,icount)=fix(strmid_c(moji,78,6)) ; Teerr iarr(13,icount)=fix(float(strmid(moji,84,6))*10) ; Az at mat2das.pro iarr(14,icount)=fix(float(strmid(moji,90,6))*10) ; El farr(0,icount)=float(strmid(moji,96,6)) ; O+/Ne iarr(15,icount)=fix(strmid_c(moji,102,6)) ; col.f ;iarr(16,icount)=fix(strmid_c(moji,108,6)) ; range farr(3,icount)=float(strmid_c(moji,108,6)) ; range in float iarr(16,icount)=fix(float(strmid_c(moji,108,6))) ; range ; 000518 iarr(17,icount)=fix(strmid_c(moji,9,2)) ; time1 of sec part iarr(18,icount)=fix(strmid_c(moji,16,2)) ; time2 of sec part if strlen(moji) gt 114 then farr(2,icount)=float(strmid(moji,114,6)) ; Tsys if strlen(moji) gt 120 then iarr(21,icount)=fix(strmid_c(moji,120,5)) ; Tx power end pro read_standard,icount,iarr,farr ; no longer valid if timesec=1 str='(I4,2I5,I4,I2,8I6,2I5,F6.2,I6) a=lonarr(15) & b=0.0 & c=0 readf,1,format=str,a,b,c if (icount mod 1000) eq 0 then print,format='(6I6)',a(0:5) iarr(0:14,icount)=a(*) & iarr(15,icount)=c & farr(icount)=b end pro read_head iprint=1 if iprint then print,'-----------------------------------------------' for i=1,8 do begin moji='moji' & readf,1,' ',moji & if iprint then print,i,moji printf,2,'A '+moji endfor if iprint then print,'-----------------------------------------------' end ;--- until here for read_guisdap_asci_3 pro open_files,file,outfile openr,1,file & print,'Open (r) = ',file openw,2,outfile & print,'Open (w) = ',outfile end pro set_sp_ni_vaka,path2,sdate0,path,dat2 path='/EISCAT8/sp-ni-vaka/'+sdate0+'_'+path2+'/' dat2=path2+'.rgdat3' end function set_head2,head case head of 'ki':head2='kiruna' 'tr':head2='tromso' 'so':head2='sodankyla' 'lo':head2='longyearbyen' else:stop endcase return,head2 end pro set_cp1k,sdate0,path2,head2,path,cp,dat2 path='/ak0/'+sdate0+'/'+path2+'/'+head2+'/' path='/ESR04/'+sdate0+'/'+path2+'/'+head2+'/' if sdate0 eq '950620' then path='/EISCAT8/'+sdate0+'/'+path2+'/'+head2+'/' if sdate0 eq '970514' then path='/ESR00/'+sdate0+'tsys/'+path2+'/'+head2+'/' if sdate0 eq '950927' then path='/ESR00/'+sdate0+'/'+path2+'/'+head2+'/' cp='cp1k' & dat2=path2+'.gdat3' end pro set_cp1j,sdate0,path2,head2,path,cp,dat2 path='/EISCAT00/'+sdate0+'-2/'+path2+'/'+head2+'/' path='/EISCAT00/'+sdate0+'/'+path2+'/'+head2+'/' path='/ak0/'+sdate0+'/'+path2+'/'+head2+'/' path='/ESR01/'+sdate0+'/'+path2+'/'+head2+'/' cp='cp1j' & dat2=path2+'.gdat3' end pro set_cp1h,sdate0,path2,head2,path,cp,dat2 path_parent='/EISCAT8/' path_parent='/ak0/' ; path_parent='/u5data1/' ; stesun11 path_parent='/ESR01/' ; stesun10 path_parent='/EISCAT00/' ; stesun6 if (long(sdate0)/10000) eq 87 then path_parent='/EISCAT00/' path=path_parent+sdate0+'/'+path2+'/'+head2+'/' cp='cp1h' & dat2=path2+'.gdat3' end pro set_cp1i,sdate0,path2,head2,path,cp,dat2 path='/EISCAT8/'+sdate0+'/'+path2+'/'+head2+'/' path='/ak0/'+sdate0+'/'+path2+'/'+head2+'/' path='/ESR01/'+sdate0+'/'+path2+'/'+head2+'/' cp='cp1i' & dat2=path2+'.gdat3' end pro set_930420,sdate0,path2,head2,path,cp,dat2 if sdate0 ne '930420' then return path='/EISCAT8/'+sdate0+'/'+path2+'/'+head2+'/' cp='cp1k' & dat2=path2+'.gdat3' end pro set_970714,sdate0,head2,path,cp,dat2 if sdate0 ne '970714' then return path='/EISCAT8/sp-ni-enw/'+head2+'13/' path='/ESR00/sp-ni-enw/tromso9Tsys/' cp='enw' & dat2='enw.gdat3' end pro set_970106,sdate0,head2,path,cp,dat2 if sdate0 ne '970106' then return path='/ESR01/970106/'+head2+'/' cp='cp2e' & dat2='.gdat3' end pro set_990701,sdate0,head2,path,cp,dat2 if sdate0 ne '990701' then return if strmid(head2,0,2) eq 'lo' then return path='/ESR01/990701/'+head2+'/' cp='cp2e' & dat2='.gdat3' return end pro set_990308,sdate0,head2,path,cp,dat2 if sdate0 ne '990308' then return path='/ESR01/990308/'+head2+'/' cp='cp2e' & dat2='.gdat3' end pro set_cp2e,sdate0,head2,path,cp,dat2 if strmid(cp,0,3) ne 'cp2' then return if strmid(cp,0,4) eq 'cp2l' then return path='/ESR03/'+sdate0+'/'+head2+'/' ;cp='cp2e' dat2='.gdat3' end pro set_cp1l,sdate0,path2,head2,path,cp,dat2 if strmid(cp,0,3) ne 'cp1' then return if strmid(head2,0,2) ne 'lo' then return path='/ESR02/'+sdate0+'esr/'+path2+'/' cp='cp1l' & dat2=path2+'.gdat3' end pro set_cp2l,sdate0,head2,path,cp,dat2 if strmid(cp,0,3) ne 'cp2' then return if strmid(head2,0,2) ne 'lo' then return path='/ESR04/'+sdate0+'esr2/' path='/ESR03/'+sdate0+'esr/' ;path='/ESR02/'+sdate0+'esr_3min/' cp='cp2l' & dat2='.gdat3' end pro set_980701,sdate0,head2,path,cp,dat2 if sdate0 ne '980701' then return path='/EISCAT03/sp-ni-tg1/results/'+head2+'/' cp='cp1k' & dat2='.dat' end pro set_980201,sdate0,head2,path,cp,dat2 if sdate0 ne '980201' then return path='/EISCAT02/980201tony/' path='/EISCAT02/980201data/' cp='gup0' & dat2='.dat' end function check_lp,path ; check the data is longpuse data or not ; July 24, 2000 n=strlen(path) a=strmid(path,n-2,2) if strmid(a,1,1) eq '/' then a=strmid(path,n-3,2) print,a if a eq 'LP' then i=1 else i=0 return,i end ;001116 made function extract_no_itr,head,file if head eq 'so' then a='sodankyla' if head eq 'ki' then a='kiruna' i=strpos(file,a) no_itr=strmid(file,i+strlen(a),3) i=strpos(no_itr,'/') if i eq 0 then begin no_itr='100' ; default return,no_itr endif if i ne -1 then no_itr=strmid(no_itr,0,i) else no_itr='00' ; wrong return,no_itr end ;-------------------------------------------------------------------------- ;FILES ; MAIN SUB pro set_filenames,path,head,cp,sdate0,dat1,dat2,file,outfile head='ki' & head='so' & head='tr' sdate0='970714' ; set by file dateguisdap path='./' path='/work11/nozawa_matlab/das/' path='/work11/kikuchi/' path='/EISCAT8/sp-ni-enw/' read_dateguisdap,head,sdate0,path2,cpread,pathfile head2=set_head2(head) path='/ESR01/'+sdate0+'/'+head2+'/' ; set cp ; NEED to be modifield !!!! ;cp='sp_ni_vaka' ;cp='cp4b' ;cp='cp1h' ;cp='cp1i' ;SET HERE ;cp='cp2e' ;cp='enw' ;cp='cp1k' ; CP1K 980701 is also cp1k ;cp='cp2l' ;cp='cp1l' if cpread ne '0000' then cp=cpread ; set at dateguisdap line 4 ; at least specify which number of cp;cp1, or cp2, if cp ne 'cp1l' and cp ne 'enw' then cp=give_cp_ver2(cp,sdate0) ;---- if sdate0 eq '970208' then $ path='/EISCAT8/sp-ni-fpi/'+sdate0+'_'+path2+'/' if sdate0 eq '980701' then $ path='/EISCAT03/sp-ni-tg1/results/'+head2+'/' if sdate0 eq '990112' or sdate0 eq '990114' or $ sdate0 eq '990116' or sdate0 eq '990121' then begin path='/EISCAT02/'+sdate0+'/'+path2+'/' path='/ESR01/'+sdate0+'/'+path2+'/' cp='gup3' ;path2='gup3' endif dat1='.gdas3' if cp eq 'gup3' then dat1='c.gdas3' dat2='.gdat3' dat2='_'+path2+dat2 if cp eq 'cp1k' and (sdate0 ne '970714' and $ sdate0 ne '970208' and sdate0 ne '980701') then $ set_cp1k,sdate0,path2,head2,path,cp,dat2 if cp eq 'cp1h' then set_cp1h,sdate0,path2,head2,path,cp,dat2 if cp eq 'cp1i' then set_cp1i,sdate0,path2,head2,path,cp,dat2 if cp eq 'cp1j' then set_cp1j,sdate0,path2,head2,path,cp,dat2 if cp eq 'gup3' then set_cp1l,sdate0,path2,head2,path,cp,dat2 if cp eq 'cp1l' then set_cp1l,sdate0,path2,head2,path,cp,dat2 set_970714,sdate0,head2,path,cp,dat2 set_970106,sdate0,head2,path,cp,dat2 set_990701,sdate0,head2,path,cp,dat2 set_990308,sdate0,head2,path,cp,dat2 set_980701,sdate0,head2,path,cp,dat2 set_980201,sdate0,head2,path,cp,dat2 set_cp2e,sdate0,head2,path,cp,dat2 set_cp2l,sdate0,head2,path,cp,dat2 if cp eq 'sp_ni_vaka' then set_sp_ni_vaka,path2,sdate0,path,dat2 if sdate0 eq '970106' then path='/ESR00/guisdap_nozawa/' if pathfile ne 'no' then path=pathfile ; from 5th line in dateguisdap icount=1 ON_IOERROR,E1 J1: file=path+head+sdate0+cp+dat1 year=long(sdate0)/10000 & if year eq 92 and cp eq 'cp1k' then cp='cp1j' if sdate0 ne 970714 then begin outfile=head+sdate0+cp+dat2 if strmid(path,1,5) eq 'ESR10' then begin i=strpos(dat2,'.') ;outfile=head+sdate0+cp+strmid(dat2,0,i)+'_99km_100'+strmid(dat2,i,strlen(dat2)-i) outfile=head+sdate0+cp+strmid(dat2,0,i)+'_100km_100'+strmid(dat2,i,strlen(dat2)-i) if head eq 'so' or head eq 'ki' then begin no_itr=extract_no_itr(head,file) if no_itr ne '00' then $ outfile=head+sdate0+cp+strmid(dat2,0,i)+'_100km_'+no_itr+strmid(dat2,i,strlen(dat2)-i) endif endif if strmid(path,1,5) eq 'ESR11' then begin i=strpos(dat2,'.') ;outfile=head+sdate0+cp+strmid(dat2,0,i)+'_99km_100'+strmid(dat2,i,strlen(dat2)-i) outfile=head+sdate0+cp+strmid(dat2,0,i)+'_100km_100'+strmid(dat2,i,strlen(dat2)-i) if head eq 'ki' or head eq 'so' then begin if head eq 'ki' then j=strpos(path,'kiruna/') if head eq 'so' then j=strpos(path,'sodankyla/') if j eq -1 then begin if head eq 'ki' then k=strpos(path,'kiruna') if head eq 'so' then k=strpos(path,'sodankyla') if head eq 'ki' then j2=6 else j2=9 p=strmid(path,k+j2,strlen(path)-k-1-j2) outfile=head+sdate0+cp+strmid(dat2,0,i)+'_100km_'+p+strmid(dat2,i,strlen(dat2)-i) endif endif endif if check_lp(path) then begin i=strpos(dat2,'.') outfile=head+sdate0+cp+strmid(dat2,0,i)+'LP'+strmid(dat2,i,strlen(dat2)-i) endif endif if sdate0 eq 970714 then outfile=head+sdate0+dat2 if cp eq 'gup3' then outfile=head+sdate0+dat2 print,'cp=',cp,' file = ',file openr,1,file & close,1 !error=0 & return E1: icount=icount+1 if icount ge 3 then begin print,'File doesnot exist ',file stop endif print,'File doesnot exist ',file dat1='.rgdas' & file0=file & file=path+head+sdate0+cp+dat1 goto, J1 end ;-------------------------------------------------------------------------- ; ;----- Main ------ ; main, Main common time,timesec common tsys,itsys common par,head,sdate0,dat1,dat2,cp itsys = 0 ; no itsys = 1 ; Tsys, TxPw are stored. timesec=1 ; time1=120012 including seconds proname='make_bi_guisdap.pro' set_filenames,path,head,cp,sdate0,dat1,dat2,file,outfile open_files,file,outfile read_guisdap_asci_3,iarr,farr,icount icount=long(n_elements(iarr(0,*))) size1=long(n_elements(iarr(*,0))) size2=long(n_elements(farr(*,0))) print,icount,size1,size2 writeu,2,icount,size1,size2,iarr,farr close,1 & close,2 print,' Read filename = ',file print,' Outfilename = ',outfile com='chmod 444 '+outfile spawn,com end