PRO load_data_loc_3a,yyyydddb,hhb,yyyyddde,hhe, $
n1,n2,n3b,index,loc,loc_error, $
verbose=verbose, source=source, mfl_model=mfl_model
if ~keyword_set(mfl_model) then mfl_model='SPV'
if ~keyword_set(source) then source='sq'
ptrDataFileList = make_file_list(yyyydddb, hhb, yyyyddde, hhe, level='n1')
if (ptr_valid(ptrDataFileList) eq 0) then begin
n_n1DataFile=0
if keyword_set(verbose) then message,/info,"# Warning ! No N1 data file selected..."
endif else begin
n1DataFileList=*ptrDataFileList
n_n1DataFile = n_elements(n1DataFileList)
ptr_free,ptrDataFileList
endelse
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 message,/info,"# 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='d')
if (ptr_valid(ptrDataFileList) eq 0) then begin
n_n3DataFile=0
if keyword_set(verbose) then message,/info,"# Warning ! No N3b data file selected..."
endif else begin
n3DataFileList=*ptrDataFileList
n_n3DataFile = n_elements(n3DataFileList)
ptr_free,ptrDataFileList
endelse
if n_n1DataFile*n_n2DataFile*n_n3DataFile eq 0 then return
indexDataFileList = strarr(n_n2DataFile)
locDataFileList = strarr(n_n2DataFile)
loc_errDataFileList = strarr(n_n2DataFile)
for ifile=0L,n_n2DataFile-1L do begin
str1 = strmid(n2DataFileList(ifile),0,strpos(n2DataFileList(ifile),'n2/P'))
str2 = strmid(n2DataFileList(ifile),strpos(n2DataFileList(ifile),'n2/P')+4)
indexDataFileList(ifile) = str1+'index/INDEX_3A_'+str2
locDataFileList(ifile) = str1+'loc/loc_3A_'+mfl_model+'_'+str2
loc_errDataFileList(ifile) = str1+'loc/loc_err_3A_'+mfl_model+'_n08_'+str2
endfor
nn = 0l
for i=0l,n_n3DataFile-1l do begin
ndata=1l
read_data_binary,n3DataFileList(i),ndata,/ndata,level='n3b'
nn = nn+ndata*2l
endfor
if nn ne 0l then begin
print,'Creating data structures ('+string(nn)+' elements)'
n1 = replicate({data_n1},nn)
n2 = replicate({data_n2},nn)
n3b = replicate({data_n3b_flat},nn)
index = replicate({data_index},nn)
loc = replicate({data_loc},nn)
loc_error = replicate({data_loc},nn*8.) & loc_error = reform(loc_error,8,nn)
ii0 = 0l
for i=0l,n_n3DataFile-1l do begin
while strmid(n3DataFileList(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 N1 file: '+n1DataFileList(i)
read_data_binary,n1DataFileList(i),n1t,level='n1'
print,'Reading N2 file: '+n2DataFileList(i)
read_data_binary,n2DataFileList(i),n2t,level='n2'
print,'Reading N3b file: '+n3DataFileList(i)
read_data_binary,n3DataFileList(i),n3t,valid,level='n3b'
print,'Reading INDEX file: '+indexDataFileList(i)
read_data_binary,indexDataFileList(i),indt,level='index'
print,'Reading LOC file: '+locDataFileList(i)
read_data_binary,locDataFileList(i),loct,level='loc'
if n_elements(loct) gt 1 then begin
print,'Reading LOC_ERROR file: '+loc_errDataFileList(i)
read_data_binary,loc_errDataFileList(i),loc_errort,level='loc'
endif else loc_errort=replicate({data_loc},8)
print,'merging...'
if valid then begin
nnt=n_elements(n3t.num)
n3bt=replicate({data_n3b_flat},nnt)
numt=[n3t.num(0),n3t.num(1)]
ydht=[n3t.ydh,n3t.ydh]
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)]
n3bt.num=numt(sort(numt))
n3bt.ydh=ydht(sort(numt))
n3bt.s=st(sort(numt))
n3bt.q=qt(sort(numt))
n3bt.u=ut(sort(numt))
n3bt.v=vt(sort(numt))
n3bt.th=tht(sort(numt))
n3bt.ph=pht(sort(numt))
n3bt.zr=zrt(sort(numt))
n3bt.sn(0)=sn1t(sort(numt))
n3bt.sn(1)=sn2t(sort(numt))
ii1 = ii0 + nnt
n1(ii0:ii1-1) = n1t(n3bt.num)
n2(ii0:ii1-1) = n2t(n3bt.num)
n3b(ii0:ii1-1) = n3bt
index(ii0:ii1-1) = indt
loc(ii0:ii1-1) = loct
if n_elements(loct) gt 1 then loc_error(*,ii0:ii1-1) = reform(loc_errort,8,nnt)
ii0 = ii1
endif
endfor
endif else begin
print,'No data for the selected period'
n1 = {data_n1}
n2 = {data_n2}
n3b = {data_n3b_flat}
index = {data_index}
loc = {data_loc}
loc_error = reform(replicate({data_loc},8),8,1)
endelse
return
end