;$Id: pspecm_scl3.pro,v 1.8 2019/07/03 19:30:32 roper Exp $
if !d.name eq 'PS' then begin
  ;device,xsize=18,ysize=8,yoffset=3
  device,xsize=18,ysize=12,yoffset=3
  !p.charthick=3 & !p.thick=3 & !x.thick=3 & !y.thick=3
end
;
;  mv idl.ps ~/tex/roper/GW/fig/pspecm_scl2.ps
;
siz=1.6
siz=2.0
@parameters
!p.charsize=2.6
!p.charsize=2.1
;!p.charsize=1.8
!x.margin=[7.6,0.5]
!y.margin=[3.2,0.2]
;
cwd,run
half='!s!u 1!n!r!s-!r!d 2!n'
file='specm.sav'
restore,file
;
;  determine normalization
;
k1=k & k1[0]=1. & k1=1./k1 & k1[0]=0.
EEM=total(spec1m)
kM=EEM/total(k1*spec1m)
kGW=sqrt(total(k^2*grav1m)/total(grav1m))
if cstress_prefactor eq '1' then begin
  EEGW0=EEM^2/(8.*kM^2)
endif else begin
  EEGW0=32.*!pi^2*EEM^2/kM^2
endelse
if lhalf_factor_in_GW then EEGW0=.5*EEGW0
spec1m0=EEM/kM
grav1m0=EEGW0/kM
print,spec1m0,kM
;kM=k
;
;grav1m=s*grav1m
;
!p.title='!6';+run
;!x.title='!8k!6/!8k!6!d0!n'
!x.title='!6'
;!y.title='!8E!6(!8k!6)  and  !8f!6(!8k!6)'
;!y.title='!8E!6(!8k!6)'
!y.title='!6!8h!6!u2!n!7X!6!dGW!n(!8f!6)'
!y.title='!6!8h!6!u2!n!7X!6!dGW!n(!8f!6)  and  !6!8h!6!u2!n!7X!6!dmag!n(!8f!6)'
!x.title='!8f!6  [Hz]'
default,kin,0
default,hdone,1
default,yr_pspecm_scl2,[2d-5,2d1]
ytickf='logticks_exp'
yr=yr_pspecm_scl3
;
L=1.
c=3e10
scalefactor=8d-16
freq=c/L*scalefactor
;
;fac=.26e-2*1e-10
fac=4.9e-12
facGW=1./(32.*!pi)
xr=[2e-7,.2]
xr=[8e-7,8e-3]
circ_sym,0.7,1
plot_oo,freq*k/kM,facGW*fac*k*grav1m/grav1m0,xr=xr,yr=yr,ytickf=ytickf
oplot,freq*k/kM,facGW*fac*k*grav2m/grav1m0,col=122,ps=8
oplot,freq*k/kM,-facGW*fac*k*grav2m/grav1m0,col=55,ps=8
;
circ_sym,0.3,0
oplot,freq*k/kM,fac*k*spec1m/grav1m0
oplot,freq*k/kM,.5*fac*k^2*spec2m/grav1m0,col=122,ps=8
oplot,freq*k/kM,-.5*fac*k^2*spec2m/grav1m0,col=55,ps=8
;
;xyouts,6e-5,1e-13,'!6GW',siz=siz
;xyouts,2e-3,1e-7,'!6mag',siz=siz
;
xyouts,6e-5,1e-12,'!6GW',siz=siz
xyouts,1e-4,1e-8,'!6mag',siz=siz
;
;xyouts,1.0e-4,3e-14,'!6GW',siz=siz
;xyouts,2e-4,1e-3,'!6mag',siz=siz
;
xyouts,3e-7,2e-8,label
;
;@postproc
;
;xx=[3e-7,3e-3] & oplot,xx,1e-10/(xx/.001)
;xx=[3.2e-3,8e-2] & oplot,xx,3e-10*(xx/.01)^2
;xx=[3e-7,3e-3] & oplot,xx,1e-12/(xx/.001)
;xx=[3.2e-3,8e-2] & oplot,xx,3e-12*(xx/.01)^2
;
loadct,6
;xx=[6e-5,1.7e-4] & oplot,xx,1.6e-10/(xx/.001)^1.5,col=122
;xx=[1.2e-4,2.4e-4] & oplot,xx,3e-14/(xx/.001)^2.5,col=122
loadct,5
;
;  fits
;
;xx=[1e-5,1e-4] & oplot,xx,1e-20/xx^(5./3.+1.)
;xx=[1e-6,1e-4] & oplot,xx,1e0*xx^(2.)
;
fo="(a,3f6.1)"
print,'kM,kGW=',k0,kM,kGW,fo=fo
print,'$mv idl.ps ~/tex/roper/GW/fig/pspecm_scl3_'+run+'.ps
print,'$mv idl.ps ~/tex/tina/prop/nasaGW/fig/pspecm_scl3_'+run+'.ps
;
END
