[2017年 1月 26日 木曜日 17:40:20 JST]
[~/2016.PolarLow/Sonde.Profile.04.Lapse.rate.smooth]
[am@aofd165]
$ proc.sonde.pl1101.run.sh
$ grads.bin.pl1101.run.sh 100 100 15000
$ plot.profile.run.sh
$ srcdump.sh proc.sonde.pl1101.* grads.bin.pl1101.* plot.profile.*>tmp.txt
------------------------------
List of the following files:
------------------------------
proc.sonde.pl1101.run.sh
proc.sonde.pl1101.sh
grads.bin.pl1101.f90
grads.bin.pl1101.namelist.txt
grads.bin.pl1101.run.sh
grads.bin.pl1101.sh
plot.profile.gs
plot.profile.run.sh
------------------------------
Machine info
------------------------------
aofd165.bio.mie-u.ac.jp
/work1/am/2016.PolarLow/Sonde.Profile.04.Lapse.rate.smooth
Thu Jan 26 17:51:56 JST 2017
======================
proc.sonde.pl1101.run.sh
======================
#!/bin/bash
exe=$(basename $0 .run.sh).sh
if [ ! -f $exe ]; then
echo Error in $0: No such file, $exe
exit 1
fi
indir=/work4/data/Sonde/PL1101
outdir=output
inlist="\
011800.prn \
011806.prn \
011812.prn \
011818.prn \
011900.prn \
011906.prn \
011912.prn \
011918.prn \
012000.prn \
012006.prn \
012012.prn \
012018.prn \
012100.prn \
012106.prn \
012112.prn \
012118.prn \
012200.prn \
012206.prn \
012212.prn \
012218.prn \
012300.prn \
012306.prn \
012312.prn \
012318.prn \
012400.prn \
012406.prn \
012412.prn \
012418.prn \
012500.prn \
012506.prn \
012512.prn \
012518.prn \
012600.prn \
012606.prn \
012612.prn \
"
nh=39 # Number of header lines in input file
z0=100
dz=100
zmax=15000 #
mkdir -vp ${outdir}
for in in $inlist; do
out=${outdir}/$(basename $in .prn).txt
$exe ${indir}/$in $out $nh $z0 $dz $zmax
done
echo
echo "Input: $in"
echo "Output: $out"
echo "nh=$nh"
echo "z0=$z0"
echo "dz=$dz"
echo "zmax=$zmax"
echo
exit 0
----------------------
End of proc.sonde.pl1101.run.sh
----------------------
======================
proc.sonde.pl1101.sh
======================
#!/bin/bash
# Description:
#
# Author: AM
#
# 明星ゾンデデータ整理
#
#
# Host: aofd165.fish.nagasaki-u.ac.jp
# Directory: /work2/kunoki/to_manda_sensei/Tools
#
# Revision history:
# This file is created by /usr/local/mybin/nbscr.sh at 10:00 on 06-05-2014.
# Default values
z0=500 # [m]
dz=500 # [m]
nh=39 # Number of header lines
zmax=15000
if [ $# -ne 6 ]; then
echo Error in $0 : Wrong number of arugments
echo Usage: $0 input output header_lines zmax
exit 1
fi
in=$1
out=$2
nh=$3
z0=$4
dz=$5
zmax=$6
# awk : 必要なデータの抜き出し
#
# sort: 並べ替え
# filter1d: 平滑化
# Interpolation using height as a vertical coordinate
#awk -v nh=$nh 'BEGIN{FS=" "}{if (NR>nh) print $8,$2,$3,$4,$5,$6,$7,$9,$10,\
#$11,$12,$13,$14,$15,$16,$17,$18,$19,$20}' $in|\
#sort -n | \
#sample1d -Fl -I${dz} -T0 > $out
# Using height as a vertical coordinate
awk -v nh=$nh 'BEGIN{FS=" "}{if (NR>nh) print $8,$2,$3,$4,$5,$6,$7,$9,$10,\
$11,$12,$13,$14,$15,$16,$17,$18,$19,$20}' $in|\
sort -n | \
filter1d -Fg${dz} -T${z0}/${zmax}/${dz} -N19/0 > $out
# Using pressure as a vertical coordinate
#awk 'BEGIN{FS=","}{if (NR>7) print $21,$10,$11,$12,$22,$23}' $in|\
#sort -n |\
#filter1d -Fb5 -T100/1020/5 -N6/0 > $out
echo Input: $in
echo Output: $out
echo
# -F
#
# フィルタの種類を設定する。畳込み・非畳込みフィルタの中から 選ぶこと。フィルタコードと時間列と同じ単位のフィルタ全幅 width を付けること。利用できる畳込みフィルタは以下の通り。
#
# (b) ボックスカー: 全ての重みが等しい。
# (c) コサインアーチ: コサインアーチ曲線に従う重み。
# (g) ガウシアン: ガウス関数によって与えられる重み。
# (f) カスタム: width の代わりに独自の重み定数の 1 列のファイルの 名前を与えること。
# 非畳込みフィルタは以下の通り。
# (m) 中央: 中央値を返す。
# (p) 最尤推定 (最頻値推定): 最頻値を返す。 1 つ以上の最頻値が 見 つ かったときはそれらの平均値を返す。最頻値の中から最小あるいは 最大を返して欲しい場合はフィルタ幅に - あるいは + を付けるこ と 。
# (l) 最小: 全ての値の最小値を返す。
# (L) 最小: 全ての正の値の中から最小値を返す。
# (u) 最大: 全ての値の最大値を返す。
# (U) 最大: 全ての負の値の中から最大値を返す。
# 大 文字の B, C, G, M, P, F にすると頑健フィルタが使われる。すな わち、フィルタリングの際に、外れ値(中央値から L1 スケール の2.5 倍離れた値)を中央値に置き換える。
# L|U の場合は最初の符号テストを通過するデータが無いことがある。 その場合、フィルタは 0.0 を返す。
----------------------
End of proc.sonde.pl1101.sh
----------------------
======================
grads.bin.pl1101.f90
======================
character(len=1000)::in,out,outtp
real,parameter::undef=-999.9
integer,parameter::nmax=20000
integer,parameter::outvar=8
character(len=1000)::strm
real,dimension(nmax):: &
! Record name: Unit: Divisor: Offset:
! --------------------------------------------------
time = undef, & ! sec 1 0
Pscl = undef, & ! ln 1 0
T = undef, & ! K 10 0
RH = undef, & ! % 1 0
v = undef, & ! m/s -100 0
u = undef, & ! m/s -100 0
Height= undef, & ! m 1 30000
P = undef, & ! hPa 10 0
TD = undef, & ! K 10 0
MR = undef, & ! g/kg 100 0
DD = undef, & ! dgr 1 0
FF = undef, & ! m/s 10 0
AZ = undef, & ! dgr 1 0
Range = undef, & ! m 0.01 0
Lon = undef, & ! dgr 100 0
Lat = undef, & ! dgr 100 0
SpuKey= undef, & ! bitfield 1 0
UsrKey= undef, & ! bitfield 1 0
RadarH= undef ! m 1 30000
integer,parameter::kmax=150
real,dimension(kmax)::&
z = undef, &
timeout = undef, &
pout = undef, tout = undef, rhout = undef,&
vout = undef, uout = undef, &
lonout = undef, latout = undef, &
vpt = undef, gammad = undef, gammavpt= undef
real::tph !tropopause height
namelist /para/in,out,outtp,z0,dz,zmax
open(1,file="grads.bin.pl1101.namelist.txt")
read(1,nml=para)
open(10,file=in,action="read")
n=0
count_vaild_data: do
read(10,'(A)',iostat=ios)strm
if(ios<0)exit
if(strm(1:1) == "#")then
cycle
else
n=n+1
endif
enddo count_vaild_data
nt=n
rewind(10)
print *,'nt=',nt
do i=1,nt
read(10,*)Height(i), time(i) ,Pscl(i) ,T(i) ,RH(i), v(i), u(i) &
,P(i) , TD(i) ,MR(i) ,DD(i) ,FF(i) &
,AZ(i) , Range(i) ,Lon(i) ,Lat(i),SpuKey(i) &
,UsrKey(i), RadarH(i)
! print *,height(i),p(i),t(i),rh(i)
end do !i
nz=int((zmax-z0)/dz)+1
do k=1,nz
z(k)=z0+dz*(k-1)
do i=1,nt
if(z(k)==Height(i))then
timeout(k)=time(i)
pout(k)=P(i)
tout(k)=T(i)
rhout(k)=rh(i)
vout(k)=v(i)
uout(k)=u(i)
lonout(k)=lon(i)
latout(k)=lat(i)
endif
end do !i
enddo !k
vpt(:)=undef
gammad(:)=undef
do k=2,kmax-1
call virtual_potential_temperature&
&(vpt(k), tout(k), pout(k), rhout(k), undef)
end do !k
call virtual_potential_temperature&
&(vpt(1), tout(1), pout(1), rhout(1), undef)
call virtual_potential_temperature&
&(vpt(kmax), tout(kmax), pout(kmax), rhout(kmax), undef)
call lapse_rate(gammad,kmax,tout,z,undef)
call lapse_rate(gammavpt,kmax,vpt,z,undef)
zbtm=6000.0 !
gm_thold=2.0 !K/km
kbtm=int((zbtm-z0)/dz)
call tropopause(tph,temptp,kmax,kbtm,gm_thold,tout,gammad,z0,dz,z,undef)
open(3,file=out, &
access="direct",form="unformatted",recl=4*outvar*kmax)
write(3,rec=1) &
(z(k),k=1,kmax), (pout(k),k=1,kmax), &
(tout(k),k=1,kmax), (rhout(k),k=1,kmax), &
(vout(k),k=1,kmax), (uout(k),k=1,kmax), &
(vpt(k),k=1,kmax), (gammad(k),k=1,kmax),&
(gammavpt(k),k=1,kmax)
close(3)
!do k=1,kmax
! print *,z(k),pout(k),tout(k),rhout(k),vpt(k)
!end do !i
print '(A,A)',"Input: ",trim(in)
print '(A,A)',"Output: ",trim(out)
print '(A,A)',"Output: ",trim(outtp)
open(22,file=outtp)
write(22,'(A)') '# temp tph'
write(22,'(f10.2,f10.0)') temptp, tph
close(22)
end
subroutine tropopause(tph,temptp,kmax,kbtm,gm_thold,temp,gammad,z0,dz,z,undef)
!
! Nagurny, A. P., 1998: Climatic characteristics of the tropopause over the
! Arctic Basin, Ann. Geophysicae 16, 110-115 (1998)
!
integer,parameter::dzcheck=2000.0 !m
integer,intent(in)::kmax,kbtm
real,intent(in),dimension(kmax)::temp,gammad, z
real,intent(in)::gm_thold,z0,dz,undef
real,intent(inout)::tph,temptp
kcheck=int(dzcheck/dz)
tph=undef
do k=kbtm,kmax-1
gammad_smth=gammad(k-1)*0.25+gammad(k)*0.5+gammad(k+1)*0.25
if(gammad_smth <= gm_thold)then
sum=0.0
do m=k,k+kcheck
sum=sum+gammad(k)
end do !m
gammad_ave=sum/float(kcheck)
print *,k,k+kcheck,gammad_ave
if(gammad_ave<=gm_thold)then
tph=z(k)
temptp=temp(k)
exit
end if
end if
end do !k
end subroutine tropopause
subroutine lapse_rate(gamma,kmax,tout,zout,undef)
implicit none
integer,intent(in)::kmax
real,intent(out)::gamma(kmax) !lapse rate [K/km]
real,intent(in)::tout(kmax),zout(kmax)
real,intent(in)::undef
real,parameter::m2km=1000.0
integer k
do k=2,kmax
if(tout(k)==undef .or. zout(k)==undef .or. tout(k-1)==undef .or. &
& zout(k-1)==undef )then
gamma(k)=undef
else
gamma(k)=-(tout(k)-tout(k-1))/(zout(k)-zout(k-1))*m2km
endif
end do !k
!print *,gamma
end subroutine lapse_rate
subroutine virtual_potential_temperature(vpt, tc, p, rh, rmiss)
!
implicit none
real,intent(out)::vpt
! pt: virtual potential temperature (kelvin)
real,intent(in)::tc,p,rh,rmiss
! tc: temperature (degree C)
! p : pressure (hPa)
! rh: Relative Humidity (%)
real tk ! temp in Kelvin
real,parameter:: kappa=287.0/1004.0
! Rd=287 J K-1 kg-1
! Cp=1004 J K-1 kg-1
real,parameter::p0=1000.0
! p0: pressue (hPa)
real pt !Potential Temp.
real es !saturated water vapor pressure
real e !water vapor pressure
real w !Mixing Ratio
if (tc == rmiss .or. p == rmiss .or. rh == rmiss)then
vpt=rmiss
return
endif
tk=tc+273.15
pt=tk*(p0/p)**kappa
! saturated water vapor pressure by Tetens (1930)'s formulae
! tc=tk-273.15
es=611.0/100.*10**((7.5*tc)/(237.3+tc)) ![hPa]
e=rh/100*es
! water vapor mixing ratio in kg/kg
w=0.622*e/(p-e)
vpt=pt*(1.0 + 0.61*w)
end subroutine virtual_potential_temperature
----------------------
End of grads.bin.pl1101.f90
----------------------
======================
grads.bin.pl1101.namelist.txt
======================
¶
in="output/012612.txt",
out="output/11012612.grd",
outtp="/work1/am/2016.PolarLow/Sonde.Profile.04.Lapse.rate.smooth/output/11012612_TPH.txt",
z0=100,
dz=100,
zmax=15000,
&end
----------------------
End of grads.bin.pl1101.namelist.txt
----------------------
======================
grads.bin.pl1101.run.sh
======================
#!/bin/sh
exe=$(basename $0 .run.sh).sh
if [ $# -ne 3 ]; then
echo Error in $0: Wrong number of arguments
echo Usage : $0 z0 dz zmax
exit 1
fi
z0=$1
dz=$2
zmax=$3
indir=output
outdir=$indir
inlist="\
011800.txt \
011806.txt \
011812.txt \
011818.txt \
011900.txt \
011906.txt \
011912.txt \
011918.txt \
012000.txt \
012006.txt \
012012.txt \
012018.txt \
012100.txt \
012106.txt \
012112.txt \
012118.txt \
012200.txt \
012206.txt \
012212.txt \
012218.txt \
012300.txt \
012306.txt \
012312.txt \
012318.txt \
012400.txt \
012406.txt \
012412.txt \
012418.txt \
012500.txt \
012506.txt \
012512.txt \
012518.txt \
012600.txt \
012606.txt \
012612.txt \
"
for in in $inlist; do
yy=11
out=${yy}$(basename $in .txt).grd
$exe ${indir}/$in ${outdir}/$out $z0 $dz $zmax
done
exit 0
----------------------
End of grads.bin.pl1101.run.sh
----------------------
======================
grads.bin.pl1101.sh
======================
#!/bin/sh
if [ $# -ne 5 ]; then
echo Error in $0 : Wrong number of arguments
echo Usage $0 in out z0 dz zmax
exit 1
fi
in=$1
if [ ! -f $in ]; then
echo Error in $0 : No such file, $in
exit 1
fi
out=$2
z0=$3
dz=$4
zmax=$5
undef=-999.9
outdir="$(pwd)/output"
mkdir -vp $outdir
outtp=${outdir}/$(basename $out .grd)_TPH.txt
title="MR11 sonde data"
f90=ifort
opt="-CB -fpe0 -traceback"
src=$(basename $0 .sh).f90
exe=$(basename $0 .sh)
nml=$(basename $0 .sh).namelist.txt
cat <<EOF>$nml
¶
in="$in",
out="$out",
outtp="$outtp",
z0=${z0},
dz=${dz},
zmax=${zmax},
&end
EOF
kmax=$(echo "scale=0; (${zmax} - ${z0})/${dz}+1" |bc)
z0km=$(echo "scale=3; ${z0}/1000.0" |bc)
dzkm=$(echo "scale=3; ${dz}/1000.0" |bc)
cat <<EOF>sonde.ctl
dset ${outdir}/%y2%m2%d2%h2.grd
options template
undef ${undef}
title ${title}
xdef 1 linear 0.0 2.5
ydef 1 linear 60.0 2.5
zdef ${kmax} linear ${z0km} ${dzkm}
tdef 36 linear 00z18Jan2011 6hr
vars 9
z ${kmax} 99 height (m)
p ${kmax} 99 Pressure (hPa)
t ${kmax} 99 Air Temerature (degC)
rh ${kmax} 99 Relative Humidity (%)
v ${kmax} 99 y-wind component (m s-1)
u ${kmax} 99 x-wind component (m s-1)
vpt ${kmax} 99 virtual potential temperature (K)
gammad ${kmax} 99 lapse rate (K/km)
gammavpt ${kmax} 99 vpt lapse rate (K/km)
endvars
EOF
cat<<EOF>$src
character(len=1000)::in,out,outtp
real,parameter::undef=-999.9
integer,parameter::nmax=20000
integer,parameter::outvar=8
character(len=1000)::strm
real,dimension(nmax):: &
! Record name: Unit: Divisor: Offset:
! --------------------------------------------------
time = undef, & ! sec 1 0
Pscl = undef, & ! ln 1 0
T = undef, & ! K 10 0
RH = undef, & ! % 1 0
v = undef, & ! m/s -100 0
u = undef, & ! m/s -100 0
Height= undef, & ! m 1 30000
P = undef, & ! hPa 10 0
TD = undef, & ! K 10 0
MR = undef, & ! g/kg 100 0
DD = undef, & ! dgr 1 0
FF = undef, & ! m/s 10 0
AZ = undef, & ! dgr 1 0
Range = undef, & ! m 0.01 0
Lon = undef, & ! dgr 100 0
Lat = undef, & ! dgr 100 0
SpuKey= undef, & ! bitfield 1 0
UsrKey= undef, & ! bitfield 1 0
RadarH= undef ! m 1 30000
integer,parameter::kmax=${kmax}
real,dimension(kmax)::&
z = undef, &
timeout = undef, &
pout = undef, tout = undef, rhout = undef,&
vout = undef, uout = undef, &
lonout = undef, latout = undef, &
vpt = undef, gammad = undef, gammavpt= undef
real::tph !tropopause height
namelist /para/in,out,outtp,z0,dz,zmax
open(1,file="${nml}")
read(1,nml=para)
open(10,file=in,action="read")
n=0
count_vaild_data: do
read(10,'(A)',iostat=ios)strm
if(ios<0)exit
if(strm(1:1) == "#")then
cycle
else
n=n+1
endif
enddo count_vaild_data
nt=n
rewind(10)
print *,'nt=',nt
do i=1,nt
read(10,*)Height(i), time(i) ,Pscl(i) ,T(i) ,RH(i), v(i), u(i) &
,P(i) , TD(i) ,MR(i) ,DD(i) ,FF(i) &
,AZ(i) , Range(i) ,Lon(i) ,Lat(i),SpuKey(i) &
,UsrKey(i), RadarH(i)
! print *,height(i),p(i),t(i),rh(i)
end do !i
nz=int((zmax-z0)/dz)+1
do k=1,nz
z(k)=z0+dz*(k-1)
do i=1,nt
if(z(k)==Height(i))then
timeout(k)=time(i)
pout(k)=P(i)
tout(k)=T(i)
rhout(k)=rh(i)
vout(k)=v(i)
uout(k)=u(i)
lonout(k)=lon(i)
latout(k)=lat(i)
endif
end do !i
enddo !k
vpt(:)=undef
gammad(:)=undef
do k=2,kmax-1
call virtual_potential_temperature&
&(vpt(k), tout(k), pout(k), rhout(k), undef)
end do !k
call virtual_potential_temperature&
&(vpt(1), tout(1), pout(1), rhout(1), undef)
call virtual_potential_temperature&
&(vpt(kmax), tout(kmax), pout(kmax), rhout(kmax), undef)
call lapse_rate(gammad,kmax,tout,z,undef)
call lapse_rate(gammavpt,kmax,vpt,z,undef)
zbtm=6000.0 !
gm_thold=2.0 !K/km
kbtm=int((zbtm-z0)/dz)
call tropopause(tph,temptp,kmax,kbtm,gm_thold,tout,gammad,z0,dz,z,undef)
open(3,file=out, &
access="direct",form="unformatted",recl=4*outvar*kmax)
write(3,rec=1) &
(z(k),k=1,kmax), (pout(k),k=1,kmax), &
(tout(k),k=1,kmax), (rhout(k),k=1,kmax), &
(vout(k),k=1,kmax), (uout(k),k=1,kmax), &
(vpt(k),k=1,kmax), (gammad(k),k=1,kmax),&
(gammavpt(k),k=1,kmax)
close(3)
!do k=1,kmax
! print *,z(k),pout(k),tout(k),rhout(k),vpt(k)
!end do !i
print '(A,A)',"Input: ",trim(in)
print '(A,A)',"Output: ",trim(out)
print '(A,A)',"Output: ",trim(outtp)
open(22,file=outtp)
write(22,'(A)') '# temp tph'
write(22,'(f10.2,f10.0)') temptp, tph
close(22)
end
subroutine tropopause(tph,temptp,kmax,kbtm,gm_thold,temp,gammad,z0,dz,z,undef)
!
! Nagurny, A. P., 1998: Climatic characteristics of the tropopause over the
! Arctic Basin, Ann. Geophysicae 16, 110-115 (1998)
!
integer,parameter::dzcheck=2000.0 !m
integer,intent(in)::kmax,kbtm
real,intent(in),dimension(kmax)::temp,gammad, z
real,intent(in)::gm_thold,z0,dz,undef
real,intent(inout)::tph,temptp
kcheck=int(dzcheck/dz)
tph=undef
do k=kbtm,kmax-1
gammad_smth=gammad(k-1)*0.25+gammad(k)*0.5+gammad(k+1)*0.25
if(gammad_smth <= gm_thold)then
sum=0.0
do m=k,k+kcheck
sum=sum+gammad(k)
end do !m
gammad_ave=sum/float(kcheck)
print *,k,k+kcheck,gammad_ave
if(gammad_ave<=gm_thold)then
tph=z(k)
temptp=temp(k)
exit
end if
end if
end do !k
end subroutine tropopause
subroutine lapse_rate(gamma,kmax,tout,zout,undef)
implicit none
integer,intent(in)::kmax
real,intent(out)::gamma(kmax) !lapse rate [K/km]
real,intent(in)::tout(kmax),zout(kmax)
real,intent(in)::undef
real,parameter::m2km=1000.0
integer k
do k=2,kmax
if(tout(k)==undef .or. zout(k)==undef .or. tout(k-1)==undef .or. &
& zout(k-1)==undef )then
gamma(k)=undef
else
gamma(k)=-(tout(k)-tout(k-1))/(zout(k)-zout(k-1))*m2km
endif
end do !k
!print *,gamma
end subroutine lapse_rate
subroutine virtual_potential_temperature(vpt, tc, p, rh, rmiss)
!
implicit none
real,intent(out)::vpt
! pt: virtual potential temperature (kelvin)
real,intent(in)::tc,p,rh,rmiss
! tc: temperature (degree C)
! p : pressure (hPa)
! rh: Relative Humidity (%)
real tk ! temp in Kelvin
real,parameter:: kappa=287.0/1004.0
! Rd=287 J K-1 kg-1
! Cp=1004 J K-1 kg-1
real,parameter::p0=1000.0
! p0: pressue (hPa)
real pt !Potential Temp.
real es !saturated water vapor pressure
real e !water vapor pressure
real w !Mixing Ratio
if (tc == rmiss .or. p == rmiss .or. rh == rmiss)then
vpt=rmiss
return
endif
tk=tc+273.15
pt=tk*(p0/p)**kappa
! saturated water vapor pressure by Tetens (1930)'s formulae
! tc=tk-273.15
es=611.0/100.*10**((7.5*tc)/(237.3+tc)) ![hPa]
e=rh/100*es
! water vapor mixing ratio in kg/kg
w=0.622*e/(p-e)
vpt=pt*(1.0 + 0.61*w)
end subroutine virtual_potential_temperature
EOF
echo Compiling ${src} ...
${f90} ${opt} ${src} -o ${exe}
if [ $? -ne 0 ]; then
echo
echo Compile error!
echo
echo Terminated.
echo
exit 1
fi
echo "Done Compile."
echo
echo ${exe} is running ...
echo
${exe}
if [ $? -ne 0 ]; then
echo
echo ERROR in $exe: Runtime error!
echo
echo Terminated.
echo
exit 1
fi
echo
echo "Done ${exe}"
echo
exit 0
----------------------
End of grads.bin.pl1101.sh
----------------------
======================
plot.profile.gs
======================
function profile( args )
*
* Default values
*
yymmddhh='11011800'
datetime='00Z18JAN2011'
outdir='Fig'
*
* Decode options
*
i = 1
while( 1 )
arg = subwrd( args, i )
i = i + 1;
if( arg = '' ); break; endif
while( 1 )
if( arg = '-dtime');datetime= subwrd(args,i);i=i+1; break;endif
if( arg = '-q' );quitopt=yes ;i=i+1; break; endif
if( arg = '-tph' );tphfle= subwrd(args,i);i=i+1; break;endif
say 'Syntax error : arg= 'arg
return
endwhile
endwhile
'!mkdir -vp 'outdir
res = read(tphfle)
res = read(tphfle)
stat=sublin( res, 1)
line=sublin( res, 2)
temptp=subwrd( line, 1)
tph=subwrd(line, 2)
#say temptp' 'tph
'open sonde.ctl'
'cc'
'set grads off'
xmax = 2
ymax = 2
xwid = 6.0/xmax
ywid = 7.0/ymax
xmargin=0.7
ymargin=2
lev1=0.05
lev2=15
xmap = 1
ymap = 1
xs = 1 + (xwid+ xmargin)*(xmap-1)
xe = xs + xwid
ye = 10.0 - (ywid+ymargin)*(ymap-1)
ys = ye - ywid
'set vpage 0.0 8.5 0.0 11.0'
'set parea 'xs ' 'xe' 'ys' 'ye
'set time 'datetime
'set lev 'lev1' 'lev2
'set xlopts 1 4 0.2'
'set ylopts 1 4 0.2'
'set xlint 20'
'set ylint 2'
'set vrange -80 10'
'set lev 'lev1' 'lev2
'set ccolor 2'
'set cthick 20'
'set cstyle 1'
'set cmark 0'
'set xlab on'
'set ylab off'
'set grid off'
'd t'
tphk=tph/1000
say temptp' 'tph' 'tphk
'markplot 'temptp' 'tphk' -c 3 -m 4 -s 0.15'
'set lev 'lev1' 'lev2
'set vpage 0.0 8.5 0.0 11.0'
'set parea 'xs ' 'xe' 'ys' 'ye
'set vrange 0 100'
'set xlint 20'
'set ylint 3'
'set ccolor 4'
'set cstyle 1'
'set cmark 0'
'set xlpos -0.8 b'
'set xlab on'
'set ylab on'
'set grid off'
'd rh'
'set strsiz 0.15 0.15'
'set string 1 c 4 90'
'draw string 0.5 8.2 [km]'
'set string 1 c 4 0'
'draw string 2.5 6 T [`3.`0C]'
'draw string 2.5 5.1 RH [%]'
'set parea off'
'set vpage off'
xmap=2
ymap=1
xs = 0.8 + (xwid+xmargin)*(xmap-1)
xe = xs + xwid
ye = 10.0 - (ywid+ymargin)*(ymap-1)
ys = ye - ywid
'set vpage 0.0 8.5 0.0 11.0'
'set parea 'xs ' 'xe' 'ys' 'ye
'set time 'datetime
'set lev 'lev1' 'lev2
'set xlopts 1 4 0.2'
'set ylopts 1 4 0.2'
'set xlint 50'
'set vrange 250 450'
'set lev 'lev1' 'lev2
'set ccolor 2'
'set cthick 20'
'set cstyle 1'
'set cmark 0'
'set xlab on'
'set ylab off'
'set grid off'
'd vpt'
'set strsiz 0.15 0.15'
#'set string 1 c 4 90'
#'draw string 0.5 8.2 [km]'
'set string 1 c 4 0'
'draw string 6 6 VPT [K]'
'set parea off'
'set vpage off'
xmap = 1
ymap = 2
xs = 1 + (xwid+ xmargin)*(xmap-1)
xe = xs + xwid
ye = 10.0 - (ywid+ymargin)*(ymap-1)
ys = ye - ywid
'set vpage 0.0 8.5 0.0 11.0'
'set parea 'xs ' 'xe' 'ys' 'ye
'set lev 'lev1' 'lev2
'set vrange -10 10'
'set xlint 5'
'set ylint 3'
'set ccolor 4'
'set cstyle 1'
'set cmark 0'
'set xlab on'
'set ylab on'
'set grid vertical'
'd gammad'
'set strsiz 0.15 0.15'
'set string 1 c 4 90'
'draw string 0.5 8.2 [km]'
'set string 1 c 4 0'
'draw string 2.5 0.5 gamma T [K/km]'
'set parea off'
'set vpage off'
xmap = 2
ymap = 2
xs = 1 + (xwid+ xmargin)*(xmap-1)
xe = xs + xwid
ye = 10.0 - (ywid+ymargin)*(ymap-1)
ys = ye - ywid
'set vpage 0.0 8.5 0.0 11.0'
'set parea 'xs ' 'xe' 'ys' 'ye
'set lev 'lev1' 'lev2
'set vrange -40 0'
'set xlint 10'
'set ylint 3'
'set ccolor 4'
'set cstyle 1'
'set cmark 0'
'set xlab on'
'set ylab on'
'set grid vertical'
'd gammavpt'
'set strsiz 0.15 0.15'
'set string 1 c 4 90'
#'draw string 0.5 8.2 [km]'
'set string 1 c 4 0'
'draw string 6 0.5 gamma VPT [K/km]'
'set parea off'
'set vpage off'
'set strsiz 0.2 0.25'
'set string 1 c 4 0'
'draw string 4 10.5 'datetime
'q dims'
line=sublin(result,5)
time=subwrd(line,6)
yy=substr(time,11,4)
mmm=substr(time,6,3)
if(mmm='JAN');mm='01';endif
if(mmm='FEB');mm='02';endif
if(mmm='MAR');mm='03';endif
if(mmm='APR');mm='04';endif
if(mmm='MAY');mm='05';endif
if(mmm='JUN');mm='06';endif
if(mmm='JUL');mm='07';endif
if(mmm='AUG');mm='08';endif
if(mmm='SEP');mm='09';endif
if(mmm='OCT');mm='10';endif
if(mmm='NOV');mm='11';endif
if(mmm='DEC');mm='12';endif
dd=substr(time,4,2)
hh=substr(time,1,2)
say hh
yymmddhh=yy''mm''dd''hh
out=outdir'/Profile.' yymmddhh '.eps'
'gxprint 'out
say
say 'Output: 'out
say
'q dims' ;*ctlinfo'
say result
if (quitopt="yes")then
quit
endif
----------------------
End of plot.profile.gs
----------------------
======================
plot.profile.run.sh
======================
#!/bin/bash
exe=$(basename $0 .run.sh).gs
datelist="\
00Z18JAN2011 \
06Z18JAN2011 \
12Z18JAN2011 \
18Z18JAN2011 \
00Z19JAN2011 \
06Z19JAN2011 \
12Z19JAN2011 \
18Z19JAN2011 \
00Z20JAN2011 \
06Z20JAN2011 \
12Z20JAN2011 \
18Z20JAN2011 \
00Z21JAN2011 \
06Z21JAN2011 \
12Z21JAN2011 \
18Z21JAN2011 \
00Z22JAN2011 \
06Z22JAN2011 \
12Z22JAN2011 \
18Z22JAN2011 \
00Z23JAN2011 \
06Z23JAN2011 \
12Z23JAN2011 \
18Z23JAN2011 \
00Z24JAN2011 \
06Z24JAN2011 \
12Z24JAN2011 \
18Z24JAN2011 \
00Z25JAN2011 \
06Z25JAN2011 \
12Z25JAN2011 \
18Z25JAN2011 \
00Z26JAN2011 \
06Z26JAN2011 \
12Z26JAN2011 \
"
indir="output"
for datetime in $datelist; do
yy=${datetime:10:2}
mmm=${datetime:5:3}
if [ $mmm = "JAN" ]; then mm=01 ; fi
if [ $mmm = "FEB" ]; then mm=02 ; fi
if [ $mmm = "MAR" ]; then mm=03 ; fi
if [ $mmm = "APR" ]; then mm=04 ; fi
if [ $mmm = "MAY" ]; then mm=05 ; fi
if [ $mmm = "JUN" ]; then mm=06 ; fi
if [ $mmm = "JUL" ]; then mm=07 ; fi
if [ $mmm = "AUG" ]; then mm=08 ; fi
if [ $mmm = "SEP" ]; then mm=09 ; fi
if [ $mmm = "OCT" ]; then mm=10 ; fi
if [ $mmm = "NOV" ]; then mm=11 ; fi
if [ $mmm = "DEC" ]; then mm=12 ; fi
dd=${datetime:3:2}
hh=${datetime:0:2}
tph=${indir}/${yy}${mm}${dd}${hh}_TPH.txt
echo $tph
if [ ! -f $tph ]; then
echo Error in $0: No such file, $tph
exit 1
fi
grads -bcp "$exe -dtime $datetime -tph $tph -q"
done
exit 0
----------------------
End of plot.profile.run.sh
----------------------