add -l option
This commit is contained in:
parent
3fe4e4a41a
commit
ab406d33ce
@ -16,15 +16,18 @@ nocpt=0
|
||||
inverseCPT=0
|
||||
coastline=0
|
||||
axistick=("a" "a") #横纵坐标轴间隔 a表示自动
|
||||
bartick="a"
|
||||
bartick="a" #色标轴标轴间隔 a表示自动
|
||||
# 不同图幅的绘图参数
|
||||
pageChoice='small' # 默认尺寸为small
|
||||
smallPage="1.5i,0.125i/-0.3i,1.2i/0.06i" # 图大小,色标位置,色标尺寸
|
||||
# 从命令行获取参数
|
||||
while getopts "hi:r:u:c:a:t:v:gnpb" arg
|
||||
while getopts "hi:r:u:c:a:t:v:l: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>] [-t<x-tick>,<y-tick>] [-v<c-tick>] [-b] [-g] [-n] [-p]\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>] [-l<size>] [-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 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."
|
||||
@ -32,6 +35,7 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
|
||||
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" "-l" "image layout and size. three available options are small(1.5 inch wide), middle and large."
|
||||
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" "disable the use of grd2cpt."
|
||||
@ -52,6 +56,8 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
|
||||
axistick=(${OPTARG//,/ });;
|
||||
v)
|
||||
bartick=$OPTARG;;
|
||||
l)
|
||||
pageChoice=$OPTARG;;
|
||||
b)
|
||||
coastline=1;;
|
||||
g)
|
||||
@ -105,7 +111,7 @@ else
|
||||
MAP_FRAME_AXES=WESnZ \
|
||||
COLOR_NAN=white \
|
||||
MAP_LABEL_OFFSET=2.5p
|
||||
|
||||
# 设置色标文件
|
||||
if [[ $nocpt == 1 ]]; then
|
||||
cptfile=${color}
|
||||
else
|
||||
@ -115,13 +121,19 @@ else
|
||||
gmt grd2cpt ${data} -R${range} -C${color} -Z -D -M > $cptfile
|
||||
fi
|
||||
fi
|
||||
# 设置绘图尺寸 如果识别参数失败 则还是按small处理
|
||||
if [[ $pageChoice == 'small' ]]; then
|
||||
pagePara=(${smallPage//,/ })
|
||||
else
|
||||
pagePara=(${smallPage//,/ })
|
||||
fi
|
||||
|
||||
if [[ $plotgrad == 1 ]]; then
|
||||
gradfile=usergradient.nc
|
||||
gmt grdgradient ${data} -G${gradfile} -Nt -A0/45
|
||||
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]}/1.5i -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]}/${pagePara[0]} -K -P > $psfile
|
||||
else
|
||||
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]}/1.5i -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]}/${pagePara[0]} -K -P > $psfile
|
||||
fi
|
||||
|
||||
if [[ $coastline == 1 ]]; then
|
||||
@ -129,7 +141,7 @@ else
|
||||
fi
|
||||
|
||||
#-C${cptfile}+Uk 使用km(色标单位除1000)
|
||||
gmt psscale -Dx0.125i/-0.3i+w1.2i/0.06i+h -C${cptfile} -Bx${bartick} -By+l${unit} -O >> $psfile
|
||||
gmt psscale -Dx${pagePara[1]}+w${pagePara[2]}+h -C${cptfile} -Bx${bartick} -By+l${unit} -O >> $psfile
|
||||
gmt psconvert $psfile -A -TEG -E300
|
||||
# 删除临时文件 使用linux终端rm命令
|
||||
rm $psfile gmt.history gmt.conf
|
||||
|
Loading…
Reference in New Issue
Block a user