;+ ; Contains the extrait_hfr procedure ; and associated procedures ; ; :Author: ; Philippe Zarka ; ; :History: ; 2004/12/03: Created ; ; 2004/12/03: Last Edit ;- ; Pro SORT_I_R, nnn,signI,signR buf = [signI, signR] buf = reform(buf, 2, 8, nnn) signI = reform(buf(1,*,*)) signR = reform(buf(0,*,*)) return end ;+ ; extraction des data HFR de la structure HFR (cree par paquets_HFR) ; a l'aide des informations decodees par ETAT_HFR et passees par les ; common KRONOS01 et KRONOS02 ; ; :Uses: ; amj_aj ; ; :Params: ; HFR: in, required, type=sometype ; A parameter named HFR ; HFRdata: in, required, type=sometype ; A parameter named HFRdata ; z: in, required, type=sometype ; A parameter named z ;- Pro EXTRAIT_HFR, HFR, HFRdata, z ; remplissage de la structure de donnees "z" ci-dessous ; (modifiee par rapport a la structure initiale Alx pour plus de compacite) common KRONOS01, selB, repAll, ExB, EzB, nEB common KRONOS02, repB,nFilB,StartB,nStepB,stepB,dfB,autoB,crossB,integB z = {HFR, an: 0B, jour: 0, $ ; date (aa, jjj) time: bytarr(4), $ ; time (h,m,s,c) bande: 0B, $ ; 0=A, 1=B, 2=C, 3=H1, 4=H2 df: 0B, $ ; 11=DF/+X, 12=DF/-X, ; 0-3=NoDF (Ex=Off,+X,-X,D) msec: 0B, $ ; temps d'integration (*10=msec) channel: 0, $ ; position du synthetiseur (kHz) filters: 0B, $ ; 1,2,4,8,16,32 filter: 0B, $ ; numero du filtre 0..31 agc1: 255B, agc2: 255B, $ ; agc auto1: 255B, auto2: 255B, $ ; auto-correlations (X,Z) cross1: -999, cross2: -999} ; cross-correlations (R,I) ; Xamp: 0.0, $ ; cross-amplitude ; Xphase: 0.0} ; cross-phase nP = n_elements(HFR) dataHFR = bytarr(max(HFR.lonP)+1,nP) for i=0,nP-1 do dataHFR(0:HFR(i).lonP,i) = $ HFRdata(HFR(i).data:HFR(i).data+HFR(i).lonP) s = Size (dataHFR) & nP = s(2) ; calcul du nombre d'echantillons n = lonarr(5) & ni = n for i=0,4 do if selB(i) then $ n(i) = repAll*repB(i)*nStepB(i)*(dfB(i)+1)*nFilB(i) for i=1,4 do ni(i) = n(i-1) + ni(i-1) nn = total(n) z = replicate (z, nn, nP) ; help,z ; remplissage des entetes for i=0,4 do if selB(i) then begin w = ni(i) + lindgen(n(i)) z(w,*).bande = i z(w,*).msec = integB(i)/10 channel = StartB(i) + stepB(i)*indgen(nStepB(i)) if i eq 3 then channel = channel*25 if i eq 4 then channel = channel*50+25 channel = replicate(1,nFilB(i)*(dfB(i)+1)) # channel channel = reform(channel, N_elements(channel))# $ replicate (1, repB(i)*repAll) z(w,*).channel = reform(channel, N_elements(channel)) # $ replicate(1, nP) z(w,*).filters = nFilB(i) z(w,*).filter = (lindgen(n(i)) mod nFilB(i)) # replicate (1, nP) ; if dfB(i) then z(w,*).df = (1 + (lindgen(n(i))/nFilB(i)) mod 2) # $ ; replicate (1, nP) z(w,*).df = ( dfB(i)*(11 + (lindgen(n(i))/nFilB(i)) mod 2) + $ (1-dfB(i))*ExB(i) ) # replicate (1, nP) endif pos = 0 ; extraction des AGC ; print,'extraction des AGC ... ', pos for i=0,4 do if selB(i) then begin w = ni(i) + lindgen(n(i)) agc1 = reform(dataHFR(pos:pos+nEB(i)*n(i)/nFilB(i)-1,*), $ dfB(i)+1, repB(i)*nstepB(i), repAll, nEB(i), nP) if (nEB(i) eq 2) and EzB(i) then agc2 = $ replicate(1B,nFilB(i)) # reform (agc1(*,*,*,1,*), nP*n(i)/nFilB(i)) if (nEB(i) eq 1) and EzB(i) then agc2 = $ replicate(1B,nFilB(i)) # reform (agc1(*,*,*,0,*), nP*n(i)/nFilB(i)) if ExB(i) then agc1 = replicate(1B,nFilB(i)) # reform (agc1(*,*,*,0,*), $ nP*n(i)/nFilB(i)) if ExB(i) then z(w,*).agc1 = reform (agc1, n(i), nP) if EzB(i) then z(w,*).agc2 = reform (agc2, n(i), nP) pos = pos + nEB(i)*n(i)/nFilB(i) endif ; extraction des auto-correlations ; print,'extraction des auto-correlations ... ', pos for i=0,4 do if selB(i) and autoB(i) then begin w = ni(i) + lindgen(n(i)) auto = reform (dataHFR(pos:pos+nEB(i)*n(i)-1,*), $ nFilB(i), dfB(i)+1, repB(i)*nstepB(i), repAll, nEB(i), nP) if ExB(i) then z(w,*).auto1 = reform(reform(auto(*,*,*,*,0,*), n(i), nP)) if EzB(i) and ExB(i) then $ z(w,*).auto2 = reform(reform(auto(*,*,*,*,1,*), n(i), nP)) if EzB(i) and not(ExB(i)) then $ z(w,*).auto2 = reform(reform(auto(*,*,*,*,0,*), n(i), nP)) pos = pos + nEB(i)*n(i) endif ; extraction des cross-correlations ; print, 'extraction des cross-correlations ...', pos for i=0,4 do if selB(i) and crossB(i) then begin w = ni(i) + lindgen(n(i)) cross = fix(dataHFR(pos:pos+n(i)-1,*)) z(w,*).cross1 = reform(reform(cross, n(i), nP)) pos = pos + n(i) cross = fix(dataHFR(pos:pos+n(i)-1,*)) z(w,*).cross2 = reform(reform(cross, n(i), nP)) pos = pos + n(i) endif ; extraction des signes ; print, 'extraction des signes ... ' ns = lonarr(5) & nsi=ns for i=0,4 do if selB(i) and crossB(i) then $ ns(i) = (n(i)/8 + (n(i) mod 8 ne 0)) ; nb de bytes de signe/bande for i=1,4 do nsi(i) = ns(i-1) + nsi(i-1) nstot = total(ns) ; nb total de bytes de signe if nstot gt 0 then begin nnn = long(nstot*nP) signI = bytarr(8,nnn) ; tableau reserve aux bits de signe I s = dataHFR(pos:pos+nstot-1,*) ; lecture -> s(nstot,nP) s = reform (s, nnn,/over) ; -> s(nstot*nP) for j=0l,nnn-1 do signI(*,j) = (s(j) and 2^indgen(8)) ne 0 ; decomposition en bits de poids croissant -> signI signR = bytarr(8,nnn) ; idem pour signe R s = dataHFR(pos+nstot:pos+2*nstot-1,*) s = reform (s, nstot*nP,/over) for j=0l,N_elements(s)-1 do signR(*,j) = (s(j) and 2^indgen(8)) ne 0 LB = where(selB) ; indice des bandes non vides LB = LB(n_elements(LB)-1) ; indice de la derniere bande non vide if crossB(LB) eq 0 then Sort_I_R, nnn,signI,signR ; si derniere bande utile sans cross, on retrie les signes I & R signI = reform (signI, 8, nstot, nP) signR = reform (signR, 8, nstot, nP) for i=0,4 do if ns(i) ne 0 then begin w = ni(i) + lindgen(n(i)) sign = signI(*, nsi(i):nsi(i)+ns(i)-1, *) sign = reform(sign, 8*ns(i), nP, /over) sign = -2*fix(sign(0:n(i)-1,*))+1 ; -> sign(n(i), nP) avec 0/1 -> +1/-1 z(w,*).cross2 = z(w,*).cross2 * sign sign = signR(*, nsi(i):nsi(i)+ns(i)-1, *) sign = reform(sign, 8*ns(i), nP, /over) sign = -2*fix(sign(0:n(i)-1,*))+1 ; -> sign(n(i), nP) avec 0/1 -> +1/-1 z(w,*).cross1 = z(w,*).cross1 * sign endif endif ; print, 'fini ', pos+long(2*nstot) ; mise en forme ; z.Xamp = sqrt(z.cross1^2 + z.cross2^2) ; z.Xphase = !radeg*atan(z.cross2,z.cross1) ; date & time ; print, 'date & time' z.an = rebin( reform([HFR.an-1900], 1, nP), nn, nP) amj = [HFR.an]*10000L + [HFR.mois]*100 + [HFR.jour] z.jour = fix( rebin( reform(amj_aj(amj) - [HFR.an]*1000L, 1, nP), nn, nP)) z.time(0) = rebin( reform([HFR.hh], 1, nP), nn, nP) z.time(1) = rebin( reform([HFR.mm], 1, nP), nn, nP) z.time(2) = rebin( reform([HFR.ss], 1, nP), nn, nP) z.time(3) = rebin( reform([HFR.cs], 1, nP), nn, nP) return end