PRO MAKE_INDEX_FILES_3A, yyyydddb,hhb,yyyyddde,hhe, $
verbose=verbose, $
source=source, $
antenna_file=antenna_file, $
output_path=output_path
if not keyword_set(source) then $
stop,'% Warning : no source specified'
if not keyword_set(antenna_file) then $
stop,'% Warning : no antenna file(s) specified'
case antenna_file of
'calJGR2004' : str_ant = 'j'
'calDec04' : str_ant = 'd'
'rheometry' : str_ant = 'r'
else : print,'antenna set possibly uncorrect'
endcase
ptrDataFileList = make_file_list(yyyydddb, hhb, yyyyddde, hhe, level='n2')
if (ptr_valid(ptrDataFileList) eq 0) then begin
n_n2DataFile=0
if keyword_set(verbose) then print,"# Warning ! No N2 data file selected..."
endif else begin
n2DataFileList=*ptrDataFileList
n_n2DataFile = n_elements(n2DataFileList)
ptr_free,ptrDataFileList
endelse
ptrDataFileList = make_file_list(yyyydddb, hhb, yyyyddde, hhe, level='n3b', $
source=source, antset=str_ant)
if (ptr_valid(ptrDataFileList) eq 0) then begin
n_n3DataFile=0
if keyword_set(verbose) then print,"# Warning ! No N3b data file selected..."
endif else begin
n3bDataFileList=*ptrDataFileList
n_n3bDataFile = n_elements(n3bDataFileList)
ptr_free,ptrDataFileList
endelse
for i=0l,n_n3bDataFile-1l do begin
while strmid(n3bDataFileList(i),9,/rev) ne strmid(n2DataFileList(i),9,/rev) do begin
if i eq 0 then n2DataFileList=n2DataFileList(1:*) else $
n2DataFileList=[n2DataFileList(0:i-1),n2DataFileList(i+1:*)]
n_n2DataFile = n_n2DataFile-1
endwhile
print,'-------------------------------------------------------------------'
print,'Reading N2 file: '+n2DataFileList(i)
read_data_binary,n2DataFileList(i),n2t,level='n2'
print,'Reading n3b file: '+n3bDataFileList(i)
read_data_binary,n3bDataFileList(i),n3t,level='n3b',valid
print,'merging...'
numt=[n3t.num(0),n3t.num(1)]
st=[n3t.s(0),n3t.s(1)]
qt=[n3t.q(0),n3t.q(1)]
ut=[n3t.u(0),n3t.u(1)]
vt=[n3t.v(0),n3t.v(1)]
tht=[n3t.th,n3t.th]
pht=[n3t.ph,n3t.ph]
zrt=[n3t.zr,n3t.zr]
sn1t=[n3t.sn(0),n3t.sn(2)]
sn2t=[n3t.sn(1),n3t.sn(3)]
n3b=replicate({data_n3b_flat},n_elements(numt))
n3b.num=numt(sort(numt))
n3b.s=st(sort(numt))
n3b.q=qt(sort(numt))
n3b.u=ut(sort(numt))
n3b.v=vt(sort(numt))
n3b.th=tht(sort(numt))
n3b.ph=pht(sort(numt))
n3b.zr=zrt(sort(numt))
n3b.sn(0)=sn1t(sort(numt))
n3b.sn(1)=sn2t(sort(numt))
n2 = n2t(numt(sort(numt)))
period_path = strmid(n3bDataFileList(i),0,strlen(n3bDataFileList(i))-21)
str_aj=strmid(n3bDataFileList(i),9,/rev)
dataFileOut = 'index/INDEX_3A_'+str_aj
if keyword_set(output_path) then dataFileOut = output_path+dataFileOut $
else dataFileOut = period_path+dataFileOut
altmin = 0.
altmax = 10.
snmin = 10
print,'Creating index file: '+dataFileOut
SELECT_DATA_N3B,n2,n3b,source,snmin,altmin,altmax, $
index,rr,tl,zz,ydf,zdf,azi
data_index = replicate({data_index},n_elements(n3b))
data_index.ydh = n3b.ydh
data_index.num = n3b.num
data_index.ind = index
data_index.tl = tl
data_index.rr = rr
data_index.zz = zz
data_index.ydf = ydf
data_index.zdf = zdf
print,"% Writing output 3-antenna index into : ",dataFileOut
if valid eq 1 then write_data_binary,dataFileOut,data_index else $
write_data_binary,dataFileOut,data_index,/null
endfor
spawn, [getenv('ROOT_RPWS') + '/pro/kronosdb/upsert.sh', '-l', 'index', string(format='(I7)', yyyydddb), string(format='(I7)', yyyyddde)], /NOSHELL
return
end