;$Id: pspecm_scl4.pro,v 1.2 2018/05/09 21:23:03 brandenb 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=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'
circ_sym,0.7,1
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='!8h!6!drms!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
fac2=1.263d-18/(freq*k/kM)
xr=[2e-7,.2]
yr=[2e-27,5e-16]
plot_oo,freq*k/kM,fac2*sqrt(fac*k*grav1m/grav1m0),xr=xr,yr=yr,ytickf=ytickf
;stop
;oplot,freq*k/kM,fac*k*grav2m/grav1m0,col=122,ps=8
;oplot,freq*k/kM,-fac*k*grav2m/grav1m0,col=55,ps=8
;
xyouts,3e-7,3e-17,label
;
;@postproc
;
;  fits
;
;xx=[3e-6,3e-3] & oplot,xx,sqrt(1e-10/(xx/.001))*1.263d-18/xx
;xx=[3.2e-3,8e-2] & oplot,xx,sqrt(3e-10*(xx/.01)^2)*1.263d-18/xx
;xx=[3e-6,3e-3] & oplot,xx,sqrt(1e-12/(xx/.001))*1.263d-18/xx
;xx=[3.2e-3,8e-2] & oplot,xx,sqrt(3e-12*(xx/.01)^2)*1.263d-18/xx
;
fac=1e2
xx=[1e-5,8e-3] & oplot,xx,fac*1e-25/(xx/.01)^2,col=155
xx=[8e-3,2] & oplot,xx,fac*2e-25*(xx/.01),col=155
;
fo="(a,3f6.1)"
print,'kM,kGW=',k0,kM,kGW,fo=fo
print,'$mv idl.ps ~/tex/roper/GW/fig/pspecm_scl4_'+run+'.ps
;
END
