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
Pro EXTRAIT_HFR, HFR, HFRdata, z
common KRONOS01, selB, repAll, ExB, EzB, nEB
common KRONOS02, repB,nFilB,StartB,nStepB,stepB,dfB,autoB,crossB,integB
z = {HFR, an: 0B, jour: 0, $
time: bytarr(4), $
bande: 0B, $
df: 0B, $
msec: 0B, $
channel: 0, $
filters: 0B, $
filter: 0B, $
agc1: 255B, agc2: 255B, $
auto1: 255B, auto2: 255B, $
cross1: -999, cross2: -999}
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)
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)
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)
z(w,*).df = ( dfB(i)*(11 + (lindgen(n(i))/nFilB(i)) mod 2) + $
(1-dfB(i))*ExB(i) ) # replicate (1, nP)
endif
pos = 0
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
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
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
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))
for i=1,4 do nsi(i) = ns(i-1) + nsi(i-1)
nstot = total(ns)
if nstot gt 0 then begin
nnn = long(nstot*nP)
signI = bytarr(8,nnn)
s = dataHFR(pos:pos+nstot-1,*)
s = reform (s, nnn,/over)
for j=0l,nnn-1 do signI(*,j) = (s(j) and 2^indgen(8)) ne 0
signR = bytarr(8,nnn)
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)
LB = LB(n_elements(LB)-1)
if crossB(LB) eq 0 then Sort_I_R, nnn,signI,signR
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
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
z(w,*).cross1 = z(w,*).cross1 * sign
endif
endif
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