Sampling MSM data at given locations and times along bird's trajectory
Please read "known problems" after you go through this sample.
[elham@aofd31]
$ pwd
/home/elham/time-height.diagram/Data.MSM
$ chmod u+x *.sh
$ ll -lh *.sh
-rwxrw-r-- 1 elham elham 85 2月 24 13:41 2015 all_run_get_msm_nc.sh
-rwxrw-r-- 1 elham elham 570 2月 24 13:32 2015 get_msm_nc.sh
-rwxrw-r-- 1 elham elham 446 2月 24 13:32 2015 run_get_msm_nc.sh
$ cat all_run_get_msm_nc.sh
You may need to modify the lines marked by red if necessary.
#!/bin/bash
export PATH=$PATH:.
run_get_msm_nc.sh MSM-S 20130925 13
run_get_msm_nc.sh MSM-P 20130925 13
#
# Usage: run_get_msm_nc.sh <data> <yyyymmdd> <days>
#
# <data>: data type (MSM-S or MSM-P)
# MSM-S: meteo. data at the surface
# MSM-P: meteo data at pressure levels
# yyyymmdd
#
# <yyyymmdd>: year, month, day in 8 digit number (e.g., 20130925)
#
# <days>: Number of days of data you want to download
#
$ (time ./all_run_get_msm_nc.sh )
...
... Takes time. Be patient.
...
real 4m8.825s
$ tree MSM-P
MSM-P
└── 2013
├── 0925.nc
├── 0926.nc
├── 0927.nc
├── 0928.nc
├── 0929.nc
├── 0930.nc
├── 1001.nc
├── 1002.nc
├── 1003.nc
├── 1004.nc
├── 1005.nc
├── 1006.nc
├── 1007.nc
└── README
$ tree MSM-S
MSM-S
└── 2013
├── 0925.nc
├── 0926.nc
├── 0927.nc
├── 0928.nc
├── 0929.nc
├── 0930.nc
├── 1001.nc
├── 1002.nc
├── 1003.nc
├── 1004.nc
├── 1005.nc
├── 1006.nc
├── 1007.nc
└── README
$ cd ..
$ pwd
/home/elham/time-height.diagram
$ cd Data.Trajectory
$ ls
YAMAGATA2013.csv YAMAGATA2013_115582.csv
YAMAGATA2013_115581.csv YAMAGATA2013_115584.csv
Edit your csv file if needed. You can use divide.csv.sh for this purpose.
Here I show the first 10 lines of the sample data file:
$ head -10 YAMAGATA2013_115581.csv
You may need to modify the lines marked by red if necessary.
# ptt,yr,mo,dy,hr,mi,sc,lat,lon,alt
115581,2013,09,25,07,39,46,34.36,130.784,-9999
115581,2013,09,25,09,38,05,34.942,130.923,-9999
115581,2013,09,27,03,00,00,33.85583,130.8595,280
115581,2013,09,27,05,00,00,33.38433,129.96533,520
115581,2013,09,27,07,00,00,33.0065,129.11983,340
115581,2013,09,27,09,00,00,32.91083,129.002,240
115581,2013,09,27,11,00,00,32.911,129.00217,220
115581,2013,09,27,12,14,51,32.918,129.021,-9999
115581,2013,09,27,12,28,02,32.91,128.995,-9999
NOTE:
Please add a hash mark (#) for indicating the header line(s). The Fortran program described in the next section skips reading the line starting from a hash mark.
Please set alt (altitude data) to -9999 when altitude data is unavailable.
$ cd ..
$ cat pl.traj.xyz.sh
#!/bin/bash
# Description:
#
# Author: am
#
# Host: aofd165.fish.nagasaki-u.ac.jp
# Directory: /work1/am/TRAJECTORY/Runge.Kutta
#
# Revision history:
# This file is created by /usr/local/mybin/ngmt.sh at 16:44 on 01-08-2015.
usage(){
cat <<EOF
Usage: $0 [-h][-d <header>][-i <interval>] <input>
-h : print this help message
input: input data file name
header: number of header lines in input files.
Default values are:
header= $header
interval= $interval
EOF
}
. ./gmtpar.sh
echo "Bash script $0 starts."
#default values
header=1
interval=1
xrange=115/155
yrange=22/50
zrange=0/1000
# Command line option
while getopts d:i:h OPT
do
case $OPT in
"d" ) FLG_D="TRUE" ; header="$OPTARG" ;;
"h" ) FLG_H="TRUE" ; usage ; exit 0
esac
done
shift $(expr $OPTIND - 1)
in=$1
if [ ! -f $in ]; then
echo Error in $0 : No such file, $in
exit 1
fi
figdir="./fig/"
if [ ! -d ${figdir} ];then
mkdir -p $figdir
fi
out=$(basename $in .csv).ps
range=${xrange}/${yrange}
size=4.5
xanot=a10f5
yanot=a10f5
zanot=a500f100
anot=${xanot}/${yanot}WsNe
symbol=a
#symbol=c
#symbol=d
#symbol=s
#symbol=t
color=${orange}
pscoast -R$range -JM$size -Dl -W3 -G200 \
-X3 -Y5 -P -K >$out
awk -F, \
'{if($1!="# ptt") print $9,$8}' $in|\
psxy -R$range -JM$size -S${symbol}0.15 -G${white} \
-O -K >> $out
awk -F, \
'{if($1!="# ptt") print $9,$8}' $in|\
psxy -R$range -JM$size -S${symbol}0.07 -G0${color} -O -K >>$out
awk -F, \
'{if($1!="# ptt") print $9,$8}' $in|\
psxy -R$range -JM$size -S${symbol}0.07 -W1 -O -K >>$out
psbasemap -R$range -JM$size -B$anot -O -K >> $out
psxy <<EOF -R$range -JM$size -W5/${blue} -O -K >>$out
120 22.4
150 22.4
150 47.6
120 47.6
120 22.4
EOF
range=${xrange}/${zrange}
size=4.5/1.5
zanot=a500f100
anot=${xanot}:"Longitude":/${zanot}:"height${sp}[m]":WSne
psbasemap -R$range -JX$size -B$anot -X0 -Y-2 -O -K >> $out
awk -F, \
'{if($1!="# ptt") print $9,$10}' $in|\
psxy -R$range -JX$size -S${symbol}0.07 -G${color} -O -K >> $out
awk -F, \
'{if($1!="# ptt") print $9,$10}' $in|\
psxy -R$range -JX$size -S${symbol}0.07 -W1 -O -K >>$out
echo
echo Input: $in
echo Output: $out
echo
xoffset=2
yoffset=11
comment=
. ./note.sh
echo "Done $0"
$ chmod u+x *.sh
$ ./pl.traj.xyz.sh YAMAGATA2013_115581.csv
Bash script ./pl.traj.xyz.sh starts.
Input: YAMAGATA2013_115581.csv
Output: YAMAGATA2013_115581.ps
pstext: Record 6 is incomplete (skipped)
Done ./pl.traj.xyz.sh
The area enclosed by blue lines indicates the domain of the MSM data.
$ pwd
/home/elham/time-height.diagram
$ cd MSM.Profiles.Trajectory/
$ ls
makefile mod_thermodynamics.f90
mod_input.f90 mod_timer.f90
mod_interpolate.f90 msm_profiles_trajectory
mod_msmp_var.f90 msm_profiles_trajectory.f90
mod_msms_var.f90 msm_profiles_trajectory.namelist.txt
mod_output.f90 msm_profiles_trajectory_run.sh
mod_parameter.f90 output
$ make clean; make
rm -rf ./obj/mod_parameter.o ./obj/mod_msms_var.o ./obj/mod_msmp_var.o ./obj/mod_input.o ./obj/mod_output.o ./obj/mod_interpolate.o ./obj/mod_thermodynamics.o ./obj/mod_timer.o ./obj/msm_profiles_trajectory.o ./obj/*.mod
if [ ! -d ./obj ]; then \
mkdir -p ./obj ; \
fi
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_parameter.o mod_parameter.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_msms_var.o mod_msms_var.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_msmp_var.o mod_msmp_var.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_input.o mod_input.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_output.o mod_output.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_interpolate.o mod_interpolate.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_thermodynamics.o mod_thermodynamics.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/mod_timer.o mod_timer.f90
ifort -c -CB -traceback -fpe0 -module ./obj -c -o obj/msm_profiles_trajectory.o msm_profiles_trajectory.f90
ifort -o msm_profiles_trajectory ./obj/mod_parameter.o ./obj/mod_msms_var.o ./obj/mod_msmp_var.o ./obj/mod_input.o ./obj/mod_output.o ./obj/mod_interpolate.o ./obj/mod_thermodynamics.o ./obj/mod_timer.o ./obj/msm_profiles_trajectory.o -module ./obj -L/usr/local/lib -lnetcdf
$ ll -lh msm_profiles_trajectory
-rwxrwxr-x 1 elham elham 1.8M 2月 24 13:59 2015 msm_profiles_trajectory
$ cat msm_profiles_trajectory_run.sh
You may need to modify the lines marked by red if necessary.
#!/bin/bash
#-----------------------------------------------------------------
# Set up parameters
#
prefix=YAMAGATA2013
traj=115581
in_dir_trajectory=../Data.Trajectory #Location of the trajectory data
in_file_trajectory=${in_dir_trajectory}/${prefix}_${traj}.csv #Name of the trajectory file
# Location of the MSM data
in_dir_msm_p=../Data.MSM/MSM-P #Pressure level
in_dir_msm_s=../Data.MSM/MSM-S #surface
# Origin of the time-height diagram described below
yr0=2013
mo0=09
dy0=25
hr0=06
out_dir_stn=output/${prefix}_${traj}
#-----------------------------------------------------------------
export PATH=$PATH:.
exe=$(basename $0 _run.sh)
if [ ! -f $exe ]; then
echo Error in $0: No such file, $0
exit 1
fi
namelist=${exe}.namelist.txt
if [ ! -f $in_file_trajectory ]; then
echo
echo Error in $0: No such file:
echo $in_file_trajectory
echo
exit 1
fi
if [ ! -d $in_dir_msm_p ]; then
echo
echo Error in $0: No such directory, $in_dir_msm_p
echo
exit 1
fi
if [ ! -d $in_dir_msm_s ]; then
echo
echo Error in $0: No such directory, $in_dir_msm_s
echo
exit 1
fi
mkdir -vp $out_dir_stn
cat <<EOF >$namelist
&input
prefix="${prefix}_${traj}",
in_file_trajectory="${in_file_trajectory}",
in_dir_msm_p="${in_dir_msm_p}",
in_dir_msm_s="${in_dir_msm_s}",
yr0=${yr0}
mo0=${mo0}
dy0=${dy0}
hr0=${hr0}
&end
&output
out_dir_stn="${out_dir_stn}"
&end
EOF
$exe < $namelist
echo
echo Directory of the output files: ${out_dir_stn}
echo
echo
echo Done ${exe}.
echo
$ chmod u+x *.sh
$ ./msm_profiles_trajectory_run.sh
.....
..... Lots of messages
.....
Origin of time for computing elapsed time:
2013 9 25 6
Directory of the output files: output/YAMAGATA2013_115581
Done msm_profiles_trajectory.
$ tree output | head -15
output
└── YAMAGATA2013_115581
├── YAMAGATA2013_115581_20130925_073946.txt
├── YAMAGATA2013_115581_20130925_093805.txt
├── YAMAGATA2013_115581_20130927_030000.txt
├── YAMAGATA2013_115581_20130927_050000.txt
├── YAMAGATA2013_115581_20130927_070000.txt
├── YAMAGATA2013_115581_20130927_090000.txt
├── YAMAGATA2013_115581_20130927_110000.txt
├── YAMAGATA2013_115581_20130927_121451.txt
├── YAMAGATA2013_115581_20130927_122802.txt
├── YAMAGATA2013_115581_20130927_130000.txt
├── YAMAGATA2013_115581_20130927_130931.txt
├── YAMAGATA2013_115581_20130927_150000.txt
├── YAMAGATA2013_115581_20130927_170000.txt
$ cd ..
$ pwd
/home/elham/time-height.diagram
$ cd MSM.Trajectory.Time-Height/
$ pwd
/home/elham/time-height.diagram/MSM.Trajectory.Time-Height
$ ls
gmtpar.sh merge.profiles.sh note.sh pl.traj.time-height.sh pl.traj.time-height.uvw.sh
$ cat merge.alt.sh
You may need to modify the lines marked by red if necessary.
#!/bin/sh
prefix=YAMAGATA2013_115581
indir0=../MSM.Profiles.Trajectory/output
indir=${indir0}/${prefix}
list_input=$(ls ${indir}/${prefix}* )
out=${prefix}.Alt.txt
for input in $list_input; do
n=$(expr $n + 1)
echo $(basename $input)
if [ $n -eq 1 ]; then
awk '{if ($2=="trajectory=") print $0}' $input > $out
fi
eltime=$(awk '{if (NR==4) printf "%12.5f", $2}' $input )
alt=$(awk '{if ($2=="alt") printf "%10.1f", $3}' $input )
yyyy=$(awk '{if (NR==4) printf "%4d", $3}' $input )
mm=$(awk '{if (NR==4) printf "%4d", $4}' $input )
dd=$(awk '{if (NR==4) printf "%4d", $5}' $input )
hh=$(awk '{if (NR==4) printf "%4d", $6}' $input )
mi=$(awk '{if (NR==4) printf "%4d", $7}' $input )
lon=$(awk '{if ($2=="lon=") print $3}' $input )
lat=$(awk '{if ($2=="lat=") print $3}' $input )
printf "%12.5f %4d %2.2d %2.2d %2.2d %2.2d %10.5f %9.5f \
%10.1f\n" \
$eltime $yyyy $mm $dd $hh $mi $lon $lat $alt >> $out
done
echo
echo Done $(basename $0)
echo
echo "Output: $out"
echo
$ ./merge.alt.sh
.....
..... Lots of messages
.....
Done merge.alt.sh
Output: YAMAGATA2013_115581.Alt.txt
$ cat merge.alt.sh
You may need to modify the lines marked by red if necessary.
#!/bin/sh
prefix=YAMAGATA2013_115581
indir0=../MSM.Profiles.Trajectory/output
indir=${indir0}/${prefix}
list_input=$(ls ${indir}/${prefix}* )
out=${prefix}.Time-Height.txt
for input in $list_input; do
n=$(expr $n + 1)
echo $(basename $input)
if [ $n -eq 1 ]; then
awk '{if ($2=="trajectory=") print $0}' $input > $out
awk '{if ($2=="p[hPa]") print "# eltime yyyy mm dd hh mi lon lat ", $0}' $input >> $out
fi
eltime=$(awk '{if (NR==4) printf "%12.5f", $2}' $input )
yyyy=$(awk '{if (NR==4) printf "%4d", $3}' $input )
mm=$(awk '{if (NR==4) printf "%4d", $4}' $input )
dd=$(awk '{if (NR==4) printf "%4d", $5}' $input )
hh=$(awk '{if (NR==4) printf "%4d", $6}' $input )
mi=$(awk '{if (NR==4) printf "%4d", $7}' $input )
lon=$(awk '{if ($2=="lon=") print $3}' $input )
lat=$(awk '{if ($2=="lat=") print $3}' $input )
numLine=1
cat $input | while read line
do
if [ ${line:0:1} != "#" ]; then
printf "%12.5f %4d %2.2d %2.2d %2.2d %2.2d %10.5f %9.5f \
%8.2f %8.1f %6.1f %6.1f %9.3f %6.1f %9.3f %9.3f %9.3f %11.5f %11.5f %11.5f\n" \
$eltime $yyyy $mm $dd $hh $mi $lon $lat $line >> $out
numLine=$((numLine + 1))
fi
done
done
echo
echo Done $(basename $0)
echo
echo "Output: $out"
echo
$ ./merge.profiles.sh
.....
..... Lots of messages
.....
Done merge.profiles.sh
Output: YAMAGATA2013_115581.Time-Height.txt
$ cat pl.traj.time-height.uvw.sh
You may need to modify the lines marked by red if necessary.
$ cat pl.traj.time-height.uvw.sh
#!/bin/bash
# Description:
#
# Author: am
#
# Host: aofd165.fish.nagasaki-u.ac.jp
# Directory: /work2/kunoki/to_manda_sensei/Tools/MSM.Back.Trajectory.Time-Hight
#
# Revision history:
# This file is created by /usr/local/mybin/ngmt.sh at 14:10 on 10-18-2014.
prefix=YAMAGATA2013_115581
in=${prefix}.Time-Height.txt
in2=${prefix}.Alt.txt
range_t=2013-09-25T06:00/2013-10-05T12:00/0/10
xrange=0/246 #Elapsed time in hr
xsize=4.5
if [ ! -f $in ]; then
echo
echo Error in $0: No such file, $in
echo
exit 1
fi
if [ ! -f $in2 ]; then
echo
echo Error in $0: No such file, $in2
echo
exit 1
fi
. ./gmtpar.sh
gmtset ANOT_FONT_SIZE 16
date_format= #"INPUT_DATE_FORMAT yyyy-mm-dd"
clock_format= #"INPUT_CLOCK_FORMAT hh:mm"
gmtset PLOT_DATE_FORMAT "o dd"
plot_clock_format="PLOT_CLOCK_FORMAT hh:mm"
gmtset $date_format $clock_format $plot_clock_format
xanot=a120f24:[hr]:
yanot=a500f100:[m]:
anot0=${xanot}/${yanot}Wsne
yanot=a1000f1000:[m]:
anot1=${xanot}/${yanot}Wsne
out=$(basename $in .txt).uvw.ps
grd=$(basename $in .txt).grd
size=${xsize}/2.25
xanot1=pa1df1d #per 5 days for primary x-axis
xanot2=sa5D #per 5 days for secondary x-axis
psbasemap -R$range_t -JX$size -B${xanot1}/${yanot}S -B${xanot2}/${yanot}S -P -X2 -Y1.4 -K > $out
cpt=$(basename $in .txt).cpt
range=${xrange}/0/1000
range2=${xrange}/-100/6000
#omega (pressure velocity in negative upward)
makecpt -Cno_green -I -T-10/10/2 >$cpt
awk '{if($1!="#" && $17 < 360 && $17 > 0)print $1,$10,$20*10}' $in |\
blockmean -R$range2 -I0.4/200 |\
surface -R$range2 -T.5 -I0.2/50 -G$grd
grdimage $grd -R$range -JX$size -C$cpt -O -K -X0 -Y0.5 >> $out
#grdcontour $grd -R$range -JX$size -W10/${white} -C1 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -C1 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -A1f12 -G2/2 -O -K >> $out
psbasemap -R$range0 -JX -B$anot0 -O -K >> $out
psscale -D5.2/1/1.5/0.1 -E -Ba5f1/:"@~w@~${sp}10@+-3@+hPa${sp}s@+-1@+": -C$cpt -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.18 -G255 -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.07 -W3 -O -K >> $out
awk '{if($1!="#" && $9 < 0) print $1, 20}' $in2 |\
psxy -R$range -JX -Sx0.07 -W3 -O -K -Y-0.1 >> $out
#northward component of wind velocity
makecpt -Cno_green -T-20/20/2 >$cpt
awk '{if($1!="#") print $1,$10,$12}' $in |\
blockmean -R$range2 -I0.4/200 |\
surface -R$range2 -T.5 -I0.2/50 -G$grd
grdimage $grd -R$range -JX$size -C$cpt -O -K -X0 -Y2.6 >> $out
#grdcontour $grd -R$range -JX$size -W10/${white} -C2 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -C2 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -A2f12 -G2/2 -O -K >> $out
psbasemap -R$range0 -JX -B$anot0 -O -K >> $out
psscale -D5.2/1/1.5/0.1 -E -Ba10f2/:"v${sp}m${sp}s@+-1@+": -C$cpt -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.18 -G255 -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.07 -W3 -O -K >> $out
awk '{if($1!="#" && $9 < 0) print $1, 20}' $in2 |\
psxy -R$range -JX -Sx0.07 -W3 -O -K -Y-0.1 >> $out
#eastward component of wind velocity
makecpt -Cno_green -T-20/20/2 >$cpt
awk '{if($1!="#")print $1,$10,$11}' $in |\
blockmean -R$range2 -I0.4/200 |\
surface -R$range2 -T.5 -I0.2/50 -G$grd
grdimage $grd -R$range -JX$size -C$cpt -O -K -X0 -Y2.6 >> $out
#grdcontour $grd -R$range -JX$size -W10/${white} -C2 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -C2 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -A2f12 -G2/2 -O -K >> $out
psbasemap -R$range0 -JX -B$anot0 -O -K >> $out
psscale -D5.2/1/1.5/0.1 -E -Ba10f2/:"u${sp}m${sp}s@+-1@+": -C$cpt -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.18 -G255 -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.07 -W3 -O -K >> $out
awk '{if($1!="#" && $9 < 0) print $1, 20}' $in2 |\
psxy -R$range -JX -Sx0.07 -W3 -O -K -Y-0.1 >> $out
size=${xsize}/2.25
psbasemap -R$range_t -JX$size -B${xanot1}/${yanot}N -B${xanot2}/${yanot}N -O -K -Y0.2 >> $out
xoffset=0
yoffset=3
comment=
. ./note.sh
echo
rm -v $cpt $grd $xyz $grdr
echo
echo "Done $0"
echo
echo Input : $in
echo
echo Output : $out
echo
$ ./pl.traj.time-height.uvw.sh
...
Done ./pl.traj.time-height.uvw.sh
Input : YAMAGATA2013_115581.Time-Height.txt
Output : YAMAGATA2013_115581.Time-Height.uvw.ps
Stars indicate the altitude of a bird at a given time. Crosses mean altitude data are unavailable.
$ cat pl.traj.time-height.sh
#!/bin/bash
# Description:
#
# Author: kunoki
#
# Host: aofd165.fish.nagasaki-u.ac.jp
# Directory: /work2/kunoki/to_manda_sensei/Tools/MSM.Back.Trajectory.Time-Hight
#
# Revision history:
# This file is created by /usr/local/mybin/ngmt.sh at 14:10 on 10-18-2014.
prefix=YAMAGATA2013_115581
in=${prefix}.Time-Height.txt
in2=${prefix}.Alt.txt
range_t=2013-09-25T06:00/2013-10-05T12:00/0/10
xrange=0/246 #Elapsed time in hr
xsize=4.5
if [ ! -f $in ]; then
echo
echo Error in $0: No such file, $in
echo
exit 1
fi
if [ ! -f $in2 ]; then
echo
echo Error in $0: No such file, $in2
echo
exit 1
fi
. ./gmtpar.sh
gmtset ANOT_FONT_SIZE 16
date_format= #"INPUT_DATE_FORMAT yyyy-mm-dd"
clock_format= #"INPUT_CLOCK_FORMAT hh:mm"
gmtset PLOT_DATE_FORMAT "o dd"
plot_clock_format="PLOT_CLOCK_FORMAT hh:mm"
gmtset $date_format $clock_format $plot_clock_format
xanot=a120f24:[hr]:
yanot=a500f100:[m]:
anot0=${xanot}/${yanot}Wsne
yanot=a1000f1000:[m]:
anot1=${xanot}/${yanot}Wsne
out=$(basename $in .txt).ps
grd=$(basename $in .txt).grd
blkfile=$(basename $in .txt).blk
mask=$(basename $in .txt).mask.grd
masked=$(basename $in .txt).masked.grd
size=${xsize}/2.25
xanot1=pa1df1d #per 5 days for primary x-axis
xanot2=sa5D #per 5 days for secondary x-axis
psbasemap -R$range_t -JX$size -B${xanot1}/${yanot}S -B${xanot2}/${yanot}S -P -X2 -Y1.4 -K > $out
cpt=$(basename $in .txt).cpt
range=${xrange}/0/1000
range2=${xrange}/-100/6000
# relative humidity (RH)
makecpt -Cdrywet -T0/100/5 >$cpt
awk '{if($1!="#" && $14 > 0 && $14<=100 )print $1,$10,$14}' $in |\
blockmean -R$range2 -I0.4/200 |\
surface -R$range2 -T1 -I0.2/50 -G$grd
grdimage $grd -R$range -JX$size -C$cpt -O -K -X0 -Y0.5 >> $out
#grdcontour $grd -R$range -JX$size -W10/${white} -C1 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -C1 -O -K >> $out
#grdcontour $grd -R$range -JX$size -W3/${black} -A1f12 -G2/2 -O -K >> $out
psbasemap -R$range0 -JX -B$anot0 -O -K >> $out
psscale -D5.2/1/1.5/0.1 -E -Ba50f10/:"RH${sp}%": -C$cpt -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.18 -G255 -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.07 -W3 -O -K >> $out
awk '{if($1!="#" && $9 < 0) print $1, 20}' $in2 |\
psxy -R$range -JX -Sx0.07 -W3 -O -K -Y-0.1 >> $out
# Temperature
makecpt -Chaxby -T4/34/2 >$cpt
awk '{if($1!="#" && $13 <350.0) print $1,$10,$13 - 273.15}' $in |\
blockmean -R$range2 -I0.4/200 > $blkfile
surface $blkfile -R$range2 -T1 -I0.2/50 -G$grd
grdimage $grd -R$range -JX$size -C$cpt -O -K -X0 -Y2.6 >> $out
psscale -D5.2/1/1.5/0.1 -E -Ba10f2/:"T${sp}${deg}C": -C$cpt -O -K >> $out
psbasemap -R$range0 -JX -B$anot0 -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.18 -G255 -O -K >> $out
awk '{if($1!="#" && $9 >= 0) print $1,$9}' $in2 |\
psxy -R$range -JX -Sa0.07 -W3 -O -K >> $out
awk '{if($1!="#" && $9 < 0) print $1, 20}' $in2 |\
psxy -R$range -JX -Sx0.07 -W3 -O -K -Y-0.1 >> $out
#
size=${xsize}/2.25
psbasemap -R$range_t -JX$size -B${xanot1}/${yanot}N -B${xanot2}/${yanot}N -O -K -Y0.2 >> $out
xoffset=0
yoffset=3
comment=
. ./note.sh
echo
rm -v $grd $xyz $grdr $mask $masked $cpt $blkfile
echo
echo "Done $0"
echo
echo Input : $in
echo
echo Output : $out
echo
$ ./pl.traj.time-height.sh
...
...
...
Done ./pl.traj.time-height.sh
Input : YAMAGATA2013_115581.Time-Height.txt
Output : YAMAGATA2013_115581.Time-Height.ps
The interpolation software bundled in Generic Mapping Tools (http://gmt.soest.hawaii.edu/gmt4/) gives some physically unreasonable values in the data-sparse regions (e.g., u, v, omega, t, and RH around Sep. 25 in the figures shown above). In order to avoid such problem, you should add dummy data to the trajectory file by interpolating birds' locations. Linear interpolation in time is enough for this purpose.
MSM surface data contain outliers (e.g., Temperature exceeded 800 K ). Such outliers are removed when plotting.