[2016年 10月 26日 水曜日 18:24:56 JST]
[~/2016.PolarLow/Sonde.Profile.02.AM]
[am@aofd165]
$ proc.sonde.pl1101.run.sh
$ grads.bin.pl1101.run.sh
$ plot.profile.run.sh
$ srcdump.sh proc.sonde.pl1101.run.sh proc.sonde.pl1101.sh grads.bin.pl1101.run.sh grads.bin.pl1101.sh plot.profile.run.sh plot.profile.gs >tmp.txt
aofd165.bio.mie-u.ac.jp
/work1/am/2016.PolarLow/Sonde.Profile.02.AM
Wed Oct 26 18:33:44 JST 2016
======================
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 \
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 \
"
nh=39 # Number of header lines in input file
mkdir -vp ${outdir}
for in in $inlist; do
out=${outdir}/$(basename $in .prn).txt
$exe ${indir}/$in $out $nh
done
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=100 # [hPa]
dz=5 # [hPa]
nh=39 # Number of header lines
if [ $# -ne 3 ]; then
echo Error in $0 : Wrong number of arugments
echo Usage: $0 input output header_lines
exit 1
fi
in=$1
out=$2
nh=$3
# awk : 必要なデータの抜き出し
#
# sort: 並べ替え
# filter1d: 平滑化
# Using height as a vertical coordinate
awk -v nh=$nh 'BEGIN{FS=" "}{if (NR>nh) print $9,$2,$3,$4,$5,$6,$7,$8, $10,\
$11,$12,$13,$14,$15,$16,$17,$18,$19,$20}' $in|\
sort -n | \
filter1d -Fb${dz} -T${z0}/1000/${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
----------------------
End of proc.sonde.pl1101.sh
----------------------
======================
grads.bin.pl1101.run.sh
======================
#!/bin/sh
exe=$(basename $0 .run.sh).sh
indir=output
outdir=$indir
inlist="\
011800.txt \
011806.txt \
011812.txt \
011818.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 \
"
for in in $inlist; do
yy=11
out=${yy}$(basename $in .txt).grd
$exe ${indir}/$in ${outdir}/$out
done
exit 0
----------------------
End of grads.bin.pl1101.run.sh
----------------------
======================
grads.bin.pl1101.sh
======================
#!/bin/sh
in=$1
if [ ! -f $in ]; then
echo Error in $0 : No such file, $in
exit 1
fi
out=$2
outdir="$(pwd)/output"
title="MR11 sonde data"
FC=ifort
f90=$(basename $0 .sh).f90
exe=$(basename $0 .sh)
nml=$(basename $0 .sh).namelist.txt
cat <<EOF>$f90
character(len=1000)::in,out
real,parameter::undef=-999.9
integer,parameter::nmax=183
integer,parameter::outvar=19
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
namelist /para/in,out
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,*)P(i), time(i) ,T(i) ,Pscl(i) ,RH(i) ,v(i) ,u(i) &
,Height(i),TD(i) ,MR(i) ,DD(i) ,FF(i) &
,AZ(i) ,Range(i) ,Lon(i) ,Lat(i) ,SpuKey(i) &
,UsrKey(i),RadarH(i)
print *,p(i),t(i),rh(i)
end do !i
open(3,file=out, &
access="direct",form="unformatted",recl=4*outvar*nmax)
write(3,rec=1) &
(p(j),j=1,nmax), &
(Pscl(j),j=1,nmax), &
(T(j),j=1,nmax), &
(RH(j),j=1,nmax), &
(v(j),j=1,nmax), &
(u(j),j=1,nmax), &
(Height(j),j=1,nmax),&
(P(j),j=1,nmax), &
(TD(j),j=1,nmax), &
(MR(j),j=1,nmax), &
(DD(j),j=1,nmax), &
(FF(j),j=1,nmax), &
(AZ(j),j=1,nmax), &
(Range(j),j=1,nmax), &
(Lon(j),j=1,nmax), &
(Lat(j),j=1,nmax), &
(SpuKey(j),j=1,nmax),&
(UsrKey(j),j=1,nmax),&
(RadarH(j),j=1,nmax)
close(3)
print '(A,A)',"Input: ",trim(in)
print '(A,A)',"Output: ",trim(out)
end
EOF
cat <<EOF>$nml
¶
in="$in",
out="$out",
&end
EOF
$FC $f90 -o $exe
$exe
cat <<EOF>sonde.ctl
dset ${outdir}/%y2%m2%d2%h2.grd
options template
undef -999.9
title ${title}
xdef 1 linear 0.0 2.5
ydef 1 linear 60.0 2.5
zdef 183 linear 100 5
tdef 30 linear 00z18Jan2011 6hr
vars 18
p 183 99 Pressure (hPa)
Pscl 183 99 ln
t 183 99 Air Temerature (K)
rh 183 99 Relative Humidity (%)
v 183 99 y-wind component (m s-1)
u 183 99 x-wind component (m s-1)
Height 183 99 height (m)
TD 183 99 K
MR 183 99 g/kg
DD 183 99 dgr
FF 183 99 m/s
AZ 183 99 dgr
Range 183 99 m
Lon 183 99 dgr
Lat 183 99 dgr
SpuKey 183 99 bitfield
UsrKey 183 99 bitfield
RadarH 183 99 m
endvars
EOF
exit 0
----------------------
End of grads.bin.pl1101.sh
----------------------
======================
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 \
"
for datetime in $datelist; do
grads -bcp "$exe -dtime $datetime -q"
done
exit 0
----------------------
End of plot.profile.run.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
say 'Syntax error : arg= 'arg
return
endwhile
endwhile
'!mkdir -vp 'outdir
'open sonde.ctl'
'cc'
'set grads off'
'set timelab off'
'set parea 1.5 8 1 10.3'
'set time 'datetime
'set z 1 181'
'set xlopts 1 7 0.3'
'set ylopts 1 7 0.3'
'set vrange -70 10'
'set yflip on'
'set zlog on'
'set ccolor 1'
'set digsiz 0.01'
'set cthick 20'
'd t-273.15'
'set strsiz 0.3 0.3'
#'set string 1 c 10 0'
#'draw string 5.5 9.5 Obs.'
#'set string 2 c 10 0'
#'draw string 5.37 9 CTL'
'set string 1 c 10 90'
'draw string 0.2 6 [hPa]'
'set strsiz 0.25 0.25'
'set string 1 c 10 0'
'draw string 4.5 0.22 Temperature [degC]'
'draw title '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
if (quitopt="yes")then
quit
endif
----------------------
End of plot.profile.gs
----------------------