pro FILL_SPEC, x, hfabc
nx=n_elements(x)
test=where(x ge 0)
if test(0) ne -1 then begin
if hfabc then xtest=x(test(0):*) else $
xtest=x(test(0):test(n_elements(test)-1))
para=xtest ge 0
ADJUST_LIN2, xtest,para, xnet
if hfabc then x(test(0):*)=xnet else $
x(test(0):test(n_elements(test)-1))=xnet
endif
return
end
pro FILL_TAB, x, hfabc
if n_elements(hfabc) eq 0 then hfabc=0
nx=n_elements(x(*,0))
for i=0,nx-1 do begin
xx=reform(x(i,*))
test=where(xx lt 0)
if test(0) ne -1 then begin
FILL_SPEC,xx, hfabc
x(i,*)=xx
endif
endfor
return
end
pro APPEND_TAB, ex,ez,x1,z1,f1,x2,z2,f2
f=[f1,f2] & nf=n_elements(f)
sf=sort(f) & f=f(sf)
test=[0b,f(1:nf-1) eq f(0:nf-2)]
f=f(where(test eq 0)) & nf=n_elements(f)
nf1=n_elements(f1) & if1=intarr(nf1)
for i=0,nf1-1 do if1(i)=where(f eq f1(i))
nf2=n_elements(f2) & if2=intarr(nf2)
for i=0,nf2-1 do if2(i)=where(f eq f2(i))
if ex then begin
nb1=n_elements(x1(*,0)) & nb2=n_elements(x2(*,0))
x=fltarr(nb1+nb2,nf)-1000
x(0:nb1-1,if1)=x1 & x(nb1:*,if2)=x2
x1=x
endif
if ez then begin
nb1=n_elements(z1(*,0)) & nb2=n_elements(z2(*,0))
z=fltarr(nb1+nb2,nf)-1000
z(0:nb1-1,if1)=z1 & z(nb1:*,if2)=z2
z1=z
endif
f1=f
return
end
pro PLOT_SPDYN, aaaajjj,hd,hf, abc,h1,h2, fmin,fmax, ex,ez, dsec,b, texte, $
x, nblocks=nblocks, log=log
if not(keyword_set(nblocks)) then nblocks = 1
if not(keyword_set(log)) then log=0
exname=['','X'] & ezname=['','Z']
textebande=''
aaaa=long(aaaajjj/1000L)
jjj=long(aaaajjj) mod 1000
ffmin=fmin & ffmax=fmax
if fmax le 16.125 then begin
ffmin=ffmin*1000. & ffmax=ffmax*1000.
endif
hl = fix(hf)+(fix(hf) ne hf) - fix(hd)
if hl lt nblocks then nblocks = hl
if abc then begin
print & print,'******************** ABC ********************' & print
textebande=textebande+'ABC'
PREP_SPDYN,aaaajjj,fix(hd),fix(hd)+fix(hl/nblocks),0,ffmin,ffmax,ex,ez,dsec, $
x,z,t,f
if nblocks gt 1 then for ib = 1,nblocks-1 do begin
hdb = fix(hd) + fix(hl*ib/nblocks)
hfb = fix(hd) + fix(hl*(ib+1)/nblocks)
PREP_SPDYN,aaaajjj,hdb,hfb,0,ffmin,ffmax,ex,ez,dsec,xtmp,ztmp,ttmp,ftmp
t = [t, ttmp]
APPEND_TAB, ex,ez,x,z,f,xtmp,ztmp,ftmp
endfor
ok=where(t ge hd*3600. and t le hf*3600.)
t=t(ok)
if ex then begin
x=x(ok,*) & help,x
test=where(x ge -999)
if test(0) ne -1 then x(test)=x(test)-min(x(test))
test=where(x lt 0)
if test(0) ne -1 then FILL_TAB,x,1
endif
if ez then begin
z=z(ok,*) & help,z
test=where(z ge -999)
if test(0) ne -1 then z(test)=z(test)-min(z(test))
test=where(z lt 0)
if test(0) ne -1 then FILL_TAB,z,1
endif
xabc=x & zabc=z
if log then fabc=f else fabc=10.^f
ffmin=max([ffmin,325.])
endif
if h1 or h2 then begin
if h1 and not h2 then begin
print & print,'******************** HF1 ********************' & print
textebande=textebande+'H1'
PREP_SPDYN,aaaajjj,fix(hd),fix(hd)+fix(hl/nblocks),1,ffmin,ffmax,ex,ez, $
dsec, x,z,t,f
if nblocks gt 1 then for ib = 1,nblocks-1 do begin
hdb = fix(hd) + fix(hl*ib/nblocks)
hfb = fix(hd) + fix(hl*(ib+1)/nblocks)
PREP_SPDYN,aaaajjj,hdb,hfb,1,ffmin,ffmax,ex,ez,dsec,xtmp,ztmp,ttmp,ftmp
x = [x, xtmp]
z = [z, ztmp]
t = [t, ttmp]
endfor
endif
if h2 and not h1 then begin
print & print,'******************** HF2 ********************' & print
textebande=textebande+'H2'
PREP_SPDYN,aaaajjj,fix(hd),fix(hd)+fix(hl/nblocks),2,ffmin,ffmax,ex,ez, $
dsec, x,z,t,f
if nblocks gt 1 then for ib = 1,nblocks-1 do begin
hdb = fix(hd) + fix(hl*ib/nblocks)
hfb = fix(hd) + fix(hl*(ib+1)/nblocks)
PREP_SPDYN,aaaajjj,hdb,hfb,2,ffmin,ffmax,ex,ez,dsec,xtmp,ztmp,ttmp,ftmp
x = [x, xtmp]
z = [z, ztmp]
t = [t, ttmp]
endfor
endif
if h1 and h2 then begin
print & print,'******************** HF1&2 ********************' & print
textebande=textebande+'H1H2'
PREP_SPDYN,aaaajjj,fix(hd),fix(hd)+fix(hl/nblocks),3,ffmin,ffmax,ex,ez, $
dsec, x,z,t,f
if nblocks gt 1 then for ib = 1,nblocks-1 do begin
hdb = fix(hd) + fix(hl*ib/nblocks)
hfb = fix(hd) + fix(hl*(ib+1)/nblocks)
PREP_SPDYN,aaaajjj,hdb,hfb,3,ffmin,ffmax,ex,ez,dsec,xtmp,ztmp,ttmp,ftmp
t = [t, ttmp]
APPEND_TAB, ex,ez,x,z,f,xtmp,ztmp,ftmp
endfor
endif
ok=where(t ge hd*3600. and t le hf*3600.)
t=t(ok)
if ex then begin
x=x(ok,*) & help,x
test=where(x ge -999)
if test(0) ne -1 then x(test)=x(test)-min(x(test))
test=where(x lt 0)
if test(0) ne -1 then FILL_TAB,x
endif
if ez then begin
z=z(ok,*) & help,z
test=where(z ge -999)
if test(0) ne -1 then z(test)=z(test)-min(z(test))
test=where(z lt 0)
if test(0) ne -1 then FILL_TAB,z
endif
xh=x & zh=z
if log then fh=alog10(f*1.) else fh=f*1.
endif
help, fabc,fh, xabc,xh,zh
ff=[0.]
if abc then ff=[ff,fabc]
if h1 or h2 then ff=[ff,fh]
ff=ff[1:*] & nff=n_elements(ff)
nf=fix(600./max([!p.multi(2),1]))
if log then f=alog10(fmin*1.)+findgen(nf)*alog10(fmax*1./fmin)/(nf-1.) else $
f=fmin+findgen(nf)*(fmax-fmin)/(nf-1.)
textefreq='kHz' & if fmax le 16.125 then textefreq='MHz'
if fmax le 16.125 then if log then f=f+3. else f=f*1000.
nt=n_elements(t)
aj=strtrim(aaaajjj,2)
if ex then begin
x=fltarr(nt,nf)
for i=0,nt-1 do begin
xx=[0.]
if abc then xx=[xx,reform(xabc(i,*))]
if h1 or h2 then xx=[xx,reform(xh(i,*))]
xx=xx[1:*]
if nff gt 1 then x(i,*)=interpol(xx,ff,f)
endfor
if nt lt 1000./max([!p.multi(1),1]) then $
x=rebin(x,nt*ceil(1000./max([!p.multi(1),1])/nt),nf)
test=where(x lt 0)
if test(0) ne -1 then x(test)=-1000
xnorm=fltarr(nf)+1.
for i=0,nf-1 do begin
test=where(x(*,i) gt 0)
if test(0) ne -1 then xnorm(i)=total(x(test,i))/n_elements(test)
endfor
xnorm=rebin(reform(xnorm,1,nf),n_elements(x(*,0)),nf)
xn=x/xnorm
test=where(xn lt 0)
if test(0) ne -1 then xn(test)=-1000
if (b mod 2) eq 0 then SPDYNPS,xn,hd,hf,fmin,fmax, $
'Hour of '+strmid(aj,0,4)+' / '+strmid(aj,4,3), $
'Frequency ('+textefreq+')','RPWS ['+textebande+'/Ex] '+texte, $
0,0,0,0.01,0.93,0,'.',log=log
if b ge 1 then SPDYNPS,x,hd,hf,fmin,fmax, $
'Hour of '+strmid(aj,0,4)+' / '+strmid(aj,4,3), $
'Frequency ('+textefreq+')','RPWS ['+textebande+'/Ex] (-B) '+texte, $
0,1,-0.5,0.,0.93,0,' ',log=log
endif
if ez then begin
z=fltarr(nt,nf)
for i=0,nt-1 do begin
zz=[0.]
if abc then zz=[zz,reform(zabc(i,*))]
if h1 or h2 then zz=[zz,reform(zh(i,*))]
zz=zz[1:*]
if nff gt 1 then z(i,*)=interpol(zz,ff,f)
endfor
if nt lt 1000./max([!p.multi(1),1]) then $
z=rebin(z,nt*ceil(1000./max([!p.multi(1),1])/nt),nf)
test=where(z lt 0)
if test(0) ne -1 then z(test)=-1000
znorm=fltarr(nf)+1.
for i=0,nf-1 do begin
test=where(z(*,i) gt 0)
if test(0) ne -1 then znorm(i)=total(z(test,i))/n_elements(test)
endfor
znorm=rebin(reform(znorm,1,nf),n_elements(z(*,0)),nf)
zn=z/znorm
test=where(zn lt 0)
if test(0) ne -1 then zn(test)=-1000
if (b mod 2) eq 0 then SPDYNPS,zn,hd,hf,fmin,fmax, $
'Hour of '+strmid(aj,0,4)+' / '+strmid(aj,4,3), $
'Frequency ('+textefreq+')','RPWS ['+textebande+'/Ez] '+texte, $
0,0,0,0.01,0.93,0,'.',log=log
if b ge 1 then SPDYNPS,z,hd,hf,fmin,fmax, $
'Hour of '+strmid(aj,0,4)+' / '+strmid(aj,4,3), $
'Frequency ('+textefreq+')','RPWS ['+textebande+'/Ez] (-B) '+texte, $
0,1,-0.5,0.,0.93,0,' ',log=log
endif
RETURN
END