;+ ; Contains the make_index_files_3A procedure ; ; :Author: ; Laurent Lamy ; ; :History: ; 2011/01/20: Created ; ; 2011/01/20: Last Edit ;- ; ;+ ; make_index_files_3A is a procedure that <behavior desc here> ; ; :Uses: ; select_data_n3b ; ; :Params: ; yyyydddb: in, required, type=sometype ; A parameter named yyyydddb ; hhb: in, required, type=sometype ; A parameter named hhb ; yyyyddde: in, required, type=sometype ; A parameter named yyyyddde ; hhe: in, required, type=sometype ; A parameter named hhe ; ; :Keywords: ; verbose: in, optional, type=sometype ; A keyword named verbose ; source: in, optional, type=sometype ; A keyword named source ; antenna_file: in, optional, type=sometype ; A keyword named antenna_file ; output_path: in, optional, type=sometype ; A keyword named output_path ;- PRO MAKE_INDEX_FILES_3A, yyyydddb,hhb,yyyyddde,hhe, $ verbose=verbose, $ source=source, $ antenna_file=antenna_file, $ output_path=output_path ; -------------------------------------------------------------------- ; Testing for keywords: ; -------------------------------------------------------------------- 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 ; -------------------------------------------------------------------- ; Loading list of files: ; -------------------------------------------------------------------- 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))) ; -------------------------------------------------------------------- ; Output data filename: ; -------------------------------------------------------------------- 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 ; -------------------------------------------------------------------- ; Data selection and creation of index arrays: ; -------------------------------------------------------------------- ; Data selection criteria: ;------------------------- altmin = 0. ; Min distance above equator altmax = 10. ; Max distance above equator snmin = 10 ; Min S/N in decibel print,'Creating index file: '+dataFileOut SELECT_DATA_N3B,n2,n3b,source,snmin,altmin,altmax, $ index,rr,tl,zz,ydf,zdf,azi ;w=where(n2.ant eq 11b) ;ww=where(abs(azi(w)) gt !pi/2.) ;n3t(ww).u=-n3t(ww).u ;n3t(ww).v=-n3t(ww).v ;n3t(ww).th=!pi-n3t(ww).th ;n3t(ww).ph=!pi+n3t(ww).ph ;write_data_binary,'../N3b_dsq2008291.10',n3t ; -------------------------------------------------------------------- ; Creation of index structure: ; -------------------------------------------------------------------- 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 ; -------------------------------------------------------------------- ; Writing index: ; -------------------------------------------------------------------- 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 ; Update the Kronos Database with the new files spawn, [getenv('ROOT_RPWS') + '/pro/kronosdb/upsert.sh', '-l', 'index', string(format='(I7)', yyyydddb), string(format='(I7)', yyyyddde)], /NOSHELL return end