;+ ; Contains the make_n3g_files procedure ; ; :Author: ; Baptiste Cecconi ; ; :History: ; 2008/01/28: Created ; ; 2008/01/28: Last Edit ;- ; ;+ ; fabrication et sauvegarde des fichiers N3g (étalonnées en flux absolus) ; a partir des fichiers N2 et d'un fichier de background ; du (jour,heure) (aaaajjjd,hd) a (aaaajjjf,hf) ; donnees "analyse" seulement ; ; :Params: ; aaaajjjd: in, required, type=string ; date de debut ; hd: in, required, type=int ; heure de debut ; aaaajjjf: in, required, type=string ; date de fin ; hf: in, required, type=int ; heure de fin ; bg_file: in, required, type=string ; background file ; ; :Keywords: ; fichier: in, optional, type=sometype ; A keyword named fichier ;- pro MAKE_N3G_FILES, aaaajjjd, hd, aaaajjjf, hf, bg_file, fichier=fichier, $ verbose=verbose, nodb=nodb ; 0=Z, 1=+X, 2=-X, 3=D ; -------------------------------------------------------------------- ; loading bg file ; -------------------------------------------------------------------- READ_DATA_BINARY,bg_file,bg,level='bg' xf=bg.xf & nf=n_elements(xf) fon5=bg.fon5 ; (4,nf) ; -------------------------------------------------------------------- ; loading receiver bg files ; -------------------------------------------------------------------- restore,getenv('ROOT_RPWS')+'/pro/receiver_backgroundj.idl' ; fr,xrd,xrm rec_bg=fon5 for i=0,2 do rec_bg(i,*)=10.^(interpol(xrm,fr,xf)/10.) rec_bg(3,*)=10.^(interpol(xrd,fr,xf)/10.) fon=(fon5-rec_bg)>1.e-18 ; -------------------------------------------------------------------- ; loading gal background ; -------------------------------------------------------------------- restore,getenv('ROOT_RPWS')+'/pro/gal_mod.idl' ; fgalmod,sgalmod sgmod=interpol(sgalmod,fgalmod,xf)>0. ; -------------------------------------------------------------------- ; Zo L^2 (Ca/Ca+Cb)^2 ; -------------------------------------------------------------------- K=[1070.,1070.,1070.,3520.] ; -------------------------------------------------------------------- print,'% Loading List of Files for the selected period ...' ; -------------------------------------------------------------------- if not(keyword_set(fichier)) then begin ptrDataFileList = make_file_list(aaaajjjd, hd, aaaajjjf, hf, level='n2') if (ptr_valid(ptrDataFileList) eq 0) then begin nDataFile=0 print,"# Warning ! No N2 data file selected..." endif else begin dataFileList=*ptrDataFileList nDataFile = n_elements(dataFileList) n3gfiles = strarr(nDataFile) ptr_free, ptrDataFileList endelse endif else begin dataFileList=[fichier] nDataFile=1 n3gfiles = strarr(nDataFile) endelse for iDataFile = 0,nDataFile-1 do begin fichier = dataFileList(iDataFile) str_tmp = strsplit(fichier,'n2/P',/extract,/regex) print & print,'% fichier : ',fichier READ_DATA_BINARY,fichier,data_n2,level='n2' nn = n_elements(data_n2) fileOut= str_tmp(0)+'n3g/F'+str_tmp(1) fi=intarr(nn) for i=0L,nn-1 do fi(i)=where(xf eq data_n2(i).f) >0 data_n3g = replicate({data_n3g},nn) w=where(data_n2.f le 1000) if w(0) ne -1 then data_n3g(w).fluxZ=((data_n2(w).autoZ-rec_bg(0,fi(w)))>0)/K(0) for j=1,3 do begin w=where(data_n2.f le 1000 and (data_n2.ant mod 10) eq j) if w(0) ne -1 then data_n3g(w).fluxX=((data_n2(w).autox-rec_bg(j,fi(w)))>0)/K(j) endfor w=where(data_n2.f gt 1000 and data_n2.f lt 2000) if w(0) ne -1 then data_n3g(w).fluxZ=( ((data_n2(w).autoZ-rec_bg(0,fi(w)))>0)/K(0) + sgmod(fi(w))*((data_n2(w).autoZ-rec_bg(0,fi(w)))>0)/fon(0,fi(w)) )/2. for j=1,3 do begin w=where(data_n2.f gt 1000 and data_n2.f lt 2000 and (data_n2.ant mod 10) eq j) if w(0) ne -1 then data_n3g(w).fluxX=( ((data_n2(w).autox-rec_bg(j,fi(w)))>0)/K(j) + sgmod(fi(w))*((data_n2(w).autoX-rec_bg(j,fi(w)))>0)/fon(j,fi(w)) )/2. endfor w=where(data_n2.f ge 2000) if w(0) ne -1 then data_n3g(w).fluxZ=sgmod(fi(w))*((data_n2(w).autoZ-rec_bg(0,fi(w)))>0)/fon(0,fi(w)) for j=1,3 do begin w=where(data_n2.f ge 2000 and (data_n2.ant mod 10) eq j) if w(0) ne -1 then data_n3g(w).fluxX=sgmod(fi(w))*((data_n2(w).autoX-rec_bg(j,fi(w)))>0)/fon(j,fi(w)) endfor data_n3g.ydh=data_n2.ydh data_n3g.num=data_n2.num print,'writing ',fileOut,' ...' WRITE_DATA_BINARY, fileOut, data_n3g n3gfiles[iDataFile] = fileOut endfor ; Update the Kronos Database with the new files if ~keyword_set(nodb) and nDataFile ne 0 then begin upsert_args = getenv('ROOT_RPWS') + '/pro/kronosdb/upsert.sh' if keyword_set(verbose) then upsert_args = [upsert_args, '-v'] upsert_args = [upsert_args, '-f', n3gfiles] spawn, /NOSHELL, upsert_args end return end