add -t and -v options

This commit is contained in:
张壹 2018-04-03 11:05:44 -07:00
parent 2fca6689da
commit b442ade8b0

View File

@ -15,22 +15,26 @@ plotgrad=0
nocpt=0
inverseCPT=0
coastline=0
axistick=("a" "a") #横纵坐标轴间隔 a表示自动
bartick="a"
# 从命令行获取参数
while getopts "hi:r:u:c:a:gv:npb" arg
while getopts "hi:r:u:c:a:t:v:gnpb" arg
do
case $arg in
h)
printf "simple regional data mapping using GMT script. The template accepts a grid (.nc .grid) file as input and outputs a .png and a .eps file. \
For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (zhangyi.cugwuhan@gmail.com)\n"
printf "usage: ${0##*/} -i<grid-data> [-r<xmin>/<xmax>/<ymin>/<ymax>] [-u<unit>] [-c<cpt-file>] [-a<x-label>,<y-label>] [-b] [-g] [-n]\n"
printf "usage: ${0##*/} -i<grid-data> [-r<xmin>/<xmax>/<ymin>/<ymax>] [-u<unit>] [-c<cpt-file>] [-a<x-label>,<y-label>] [-t<x-tick>,<y-tick>] [-v<c-tick>] [-b] [-g] [-n] [-p]\n"
printf "%s\t%s\n" "-i" "input grid file"
printf "%s\t%s\n" "-r" "data range. The template will ditect the input data range automaticly, the use of this option will overwrite the range."
printf "%s\t%s\n" "-r" "data range. The template will detect the input data range automatically, the use of this option will overwrite the range."
printf "%s\t%s\n" "-u" "data unit. The default is meter."
printf "%s\t%s\n" "-c" "color cpt. The default is rainbow. The script will use grd2cpt to recalculate the color scale file, use -n option to disable the use of grd2cpt."
printf "%s\t%s\n" "-a" "axis labels. The deafults are x (m) and y (m)."
printf "%s\t%s\n" "-t" "intervals of axis's labels. the script will set the intervals automatically if -t option is not set."
printf "%s\t%s\n" "-v" "intervals of color bar's labels. the script will set the intervals automatically if -v option is not set."
printf "%s\t%s\n" "-b" "draw coast line."
printf "%s\t%s\n" "-g" "use grdgradient. The default is false."
printf "%s\t%s\n" "-n" "disabele the use of grd2cpt."
printf "%s\t%s\n" "-n" "disable the use of grd2cpt."
printf "%s\t%s\n" "-p" "inverse the color pattern specified by the -c option, no use if -n option is implemented."
exit 0;;
i)
@ -44,6 +48,10 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
overwriteRange=$OPTARG;;
a)
labels=(${OPTARG//,/ });;
t)
axistick=(${OPTARG//,/ });;
v)
bartick=$OPTARG;;
b)
coastline=1;;
g)
@ -111,9 +119,9 @@ else
if [[ $plotgrad == 1 ]]; then
gradfile=usergradient.nc
gmt grdgradient ${data} -G${gradfile} -Nt -A0/45
gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JL${plot_para[0]}/${plot_para[1]}/${plot_para[2]}/${plot_para[3]}/2i -K -P > $psfile
gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bx${axistick[0]}g+l"${labels[0]}" -By${axistick[1]}g+l"${labels[1]}" -JL${plot_para[0]}/${plot_para[1]}/${plot_para[2]}/${plot_para[3]}/2i -K -P > $psfile
else
gmt grdimage ${data} -R${range} -C${cptfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JL${plot_para[0]}/${plot_para[1]}/${plot_para[2]}/${plot_para[3]}/2i -K -P > $psfile
gmt grdimage ${data} -R${range} -C${cptfile} -Bx${axistick[0]}g+l"${labels[0]}" -By${axistick[1]}g+l"${labels[1]}" -JL${plot_para[0]}/${plot_para[1]}/${plot_para[2]}/${plot_para[3]}/2i -K -P > $psfile
fi
if [[ $coastline == 1 ]]; then
@ -121,7 +129,7 @@ else
fi
#-C${cptfile}+Uk 使用km色标单位除1000
gmt psscale -Dx0.4i/-0.3i+w1.2i/0.06i+h -C${cptfile} -Bxa -By+l${unit} -O >> $psfile
gmt psscale -Dx0.4i/-0.3i+w1.2i/0.06i+h -C${cptfile} -Bx${bartick} -By+l${unit} -O >> $psfile
gmt psconvert $psfile -A -TEG -E300
# 删除临时文件 使用linux终端rm命令
rm $psfile gmt.history gmt.conf