;$Id: pstress_etc_L.pro,v 1.4 2022/01/29 20:01:51 brandenb Exp $
if !d.name eq 'PS' then begin
  device,xsize=18,ysize=18,yoffset=3
  !p.charthick=1.6 & !p.thick=1.6 & !x.thick=1.6 & !y.thick=1.6
  col0=0
endif else begin
  col0=255
end
;
;  this is to be run in: 2048_1e1_1e4_4e8_1em4a
;
!p.charsize=1.7
!x.margin=[10.5,1.8]
!y.margin=[3.2,0.3]
siz=.9
;
@parameters
default,lread,1
if lread then begin
  ;power,'_mag','_Str',k=k,spec1=spec1,spec2=stre1,i=n,tt=t,/noplot,/lks
  power,'_Str','_Str',k=k,spec1=stre1,spec2=stre1,i=n,tt=tstr,/noplot,/lks
  power,'_mag','_mag',k=k,spec1=spec1,spec2=spec1,i=n,tt=tmag,/noplot,/lks
  power,'_GWs','_GWh',k=k,spec1=grav1,spec2=grah1,i=n,tt=t,/noplot,/lks
  pc_read_ts,obj=ts
  lread=0
endif
;
;  select times from t array
;
ntt=n_elements(tt)
it_ts=intarr(ntt)
it_str=intarr(ntt)
it_mag=intarr(ntt)
it_gws=intarr(ntt)
for itt=0,ntt-1 do begin
  it_str[itt]=findex(tt[itt],tstr)
  it_mag[itt]=findex(tt[itt],tmag)
  it_gws[itt]=findex(tt[itt],t)
  it_ts[itt]=findex(tt[itt],ts.t)
endfor
print,it_str
print,it_mag
print,it_gws
;
xlab1=.15
xlab1b=60.
xlab2a=6e-1
xlab2b=60.
xrt=[4e-1,125.]
xr=[k[1],max(k)]
!p.multi=[0,2,4]
col=[col0,col0,col0,col0,55,122,155]
dot='!s!9!A .!n!6!r'
circ_sym,.9,1
ps=8
;
;---------------------------------------------------------------------------------
!x.title='!6'
!y.title='!8E!6!dM!n(!8k!6)'
yr_mag=[1d-12,1d-3]
plot_oo,xr,yr_mag,/nodata
for itt=0,ntt-1 do oplot,k[1:*],spec1[1:*,it_mag[itt]],col=col[itt]
xyouts,xlab1,1e-4,siz=siz,'!6(a)'
;
yr_mag_ts=[6e-4,5e-2]
!y.title='!13E!6!dM!n'
plot_oo,ts.t-1.,.5*ts.brms^2,xr=xrt,yr=yr_mag_ts
for itt=0,ntt-1 do oplot,[1,1]*ts.t[it_ts[itt]]-1.,[1,1]*.5*ts.brms[it_ts[itt]]^2,col=col[itt],ps=ps
xx=[3.,110.] & oplot,xx,.03/xx^.6,li=3
xyouts,30.,5e-3,siz=siz,'!8t!6!u-0.6!n'
xyouts,xlab2b,3e-2,siz=siz,'!6(b)'
;
;---------------------------------------------------------------------------------
!y.title='!6Sp(!8S!6)'
!y.title='!6Sp(!8T!6!dTT!n)'
yr_str=[1d-11,1d-4]
plot_oo,xr,yr_str,/nodata
for itt=0,ntt-1 do oplot,k[1:*],(tstr[it_str[itt]]/6.)^2*stre1[1:*,it_str[itt]],col=col[itt]
for itt=0,ntt-1 do print,'t=',tstr[it_str[itt]]
xyouts,xlab1,1.2e-5,siz=siz,'!6(c)'
;circ_sym,.9,0
;oplot,[5.5,15.,50.],[5.0e-11,1.4e-10,7e-10],ps=8
;xx=[5.,80.] & oplot,xx,4.5e-12*xx^1.33,li=3
;circ_sym,.9,1
;
yr_str_ts=[1e-6,6e-3]
!y.title='!6<!8T!6!s!u2!n!r!dTT!n>'
tot_stre=total(stre1,1)
plot_oo,tstr-1.,(tstr/6.)^2*tot_stre,xr=xrt,yr=yr_str_ts
for itt=0,ntt-1 do oplot,[1,1]*tstr[it_str[itt]]-1.,[1,1]*(tstr[it_str[itt]]/6.)^2*tot_stre[it_str[itt]],col=col[itt],ps=ps
oplot,ts.t-1.,.4*ts.brms^4,li=1
xx=[5.,110.] & oplot,xx,1.4e-3/xx^1.2,li=3
xyouts,25.,6e-5,siz=siz,'!8t!6!u-1.2!n'
xyouts,.9,2e-3,siz=siz,'!6<!8B!6!u2!n>!u2!n'
xyouts,3.,5e-5,siz=siz,'!6<!8T!6!s!u2!n!r!dTT!n>'
xyouts,xlab2b,1.8e-3,siz=siz,'!6(d)'
;
;---------------------------------------------------------------------------------
!y.title='!6Sp('+dot+'!8h!6)'
;!y.title='!8E!6!dM!n(!8k!6)'
yr_GWs=[1d-14,7d-7]
plot_oo,xr,yr_GWs,/nodata
for itt=0,ntt-1 do oplot,k[1:*],grav1[1:*,it_GWs[itt]],col=col[itt]
oplot,[1,1]*5000.,yr_GWs,li=3
;xyouts,siz=siz,56.,1e-20,'!8k!6!d0!n'
;xyouts,siz=siz,3000.,5e-12,'!8k!7!dl!n!6'
xyouts,xlab1b,3e-8,siz=siz,'!6(e)'
xx=[.14,1.] & oplot,xx,8e-9*xx^.7,li=3
xyouts,.4,1.0e-8,siz=siz,'!9A!8k!6!u0.7!n'
;
yr_GWs_ts=[5.4d-10,5.8d-1]
!y.title='!13E!6!dGW!n'
tot_grav=total(grav1,1)/6.
plot_oi,t-1.,tot_grav,xr=xrt,yr=[4.5e-10,7e-7]
for itt=0,ntt-1 do oplot,[1,1]*t[it_GWs[itt]]-1.,[1,1]*tot_grav[it_GWs[itt]],col=col[itt],ps=ps
xyouts,xlab2a,5.5e-7,siz=siz,'!6(f)'
;
;---------------------------------------------------------------------------------
!x.title='!8k!6'
!y.title='!6Sp(!8h!6)'
yr_GWh=[1d-20,5d-7]
plot_oo,xr,yr_GWh,/nodata
for itt=0,ntt-1 do oplot,k[1:*],grah1[1:*,it_GWs[itt]],col=col[itt]
oplot,[1,1]*5000.,yr_GWh,li=3
;xyouts,siz=siz,56.,1e-24,'!8k!6!d0!n'
;xyouts,siz=siz,3000.,1e-14,'!8k!7!dl!n!6'
xyouts,xlab1b,5e-10,siz=siz,'!6(g)'
xx=[.14,5.] & oplot,xx,2e-8/xx^1.0,li=3
xyouts,5.,1.4e-8,siz=siz,'!9A!8k!6!u-1!n'
;
!x.title='!8t!6-1'
!y.title='!8h!6!s!u2!n!r!drms!n'
plot_oo,ts.t-1.,ts.hrms^2,xr=xrt,yr=[3e-19,5e-4]
for itt=0,ntt-1 do oplot,[1,1]*ts.t[it_ts[itt]]-1.,[1,1]*ts.hrms[it_ts[itt]]^2,col=col[itt],ps=ps
xyouts,xlab2a,2e-5,siz=siz,'!6(h)'
;
print,'$mv idl.ps ~/GitHub/Axel/GWspectra_from_CME/fig/pstress_etc_L.eps'
END
