fixed a bug of -a option

This commit is contained in:
张壹 2018-11-15 14:51:51 -08:00
parent 1b97379188
commit 33f4662eff

View File

@ -28,7 +28,7 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
printf "%s\t%s\n" "-c" "color cpt. The default is rainbow."
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" "-a" "axis labels. The deafults are x (m) and y (m)."
printf "%s\t%s\n" "-a" "axis labels separated by semicolons. The deafults are x (m) and y (m)."
printf "%s\t%s\n" "-g" "use grdgradient. The default is false."
printf "%s\t%s\n" "-G" "provide a different input grid data for the use of grdgradient. This should be used with the '-g' option at the same time"
exit 0;;
@ -46,7 +46,10 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
overwrite=1
overwriteRange=$OPTARG;;
a)
labels=(${OPTARG//,/ });;
OLD_IFS="${IFS}"
IFS=";"
labels=(${OPTARG})
IFS="${OLD_IFS}";;
g)
plotgrad=1;;
G)
@ -71,16 +74,21 @@ else
else
range=$(gmt_get_gridregion ${data})
fi
#根据横纵坐标的范围计算图片的长和高 我们默认图片宽度为1.5i
range_coor=(${range//// })
pic_height=`echo "scale=4; 2.0 * (${range_coor[3]}-${range_coor[2]})/(${range_coor[1]}-${range_coor[0]})"|bc`
# 设置绘图参数
gmt gmtset \
FONT_ANNOT_PRIMARY=7p,Times-Roman,black \
MAP_FRAME_PEN=thin,black \
FONT_ANNOT_PRIMARY=7.5p,Times-Roman,black \
MAP_FRAME_PEN=thinnest,black \
MAP_GRID_PEN_PRIMARY=thinnest,black \
MAP_TICK_PEN_PRIMARY=thinnest,black \
MAP_TICK_LENGTH_PRIMARY=1p/0.5p \
MAP_TITLE_OFFSET=7p \
MAP_TITLE_OFFSET=7.5p \
MAP_GRID_CROSS_SIZE_PRIMARY=2p \
FONT_LABEL=7p,Times-Roman,black \
FONT_LABEL=7.5p,Times-Roman,black \
MAP_FRAME_AXES=WeSnZ \
MAP_LABEL_OFFSET=2p \
MAP_LABEL_OFFSET=2.5p \
MAP_ANNOT_OFFSET_PRIMARY=2.5p
gmt grd2cpt ${data} -C${color} -R${range} -Z -D > $cptfile
@ -91,17 +99,17 @@ else
else
gmt grdgradient ${gridData} -G${gradfile} -Nt -A0/45
fi
gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bx${axistick[0]}g+l"${labels[0]}" -By${axistick[1]}g+l"${labels[1]}" -JX1.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]}" -JX2.0i/${pic_height}i -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]}" -JX1.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]}" -JX2.0i/${pic_height}i -K -P > $psfile
fi
#-C${cptfile}+Uk 使用km色标单位除1000
#如果unit等于km则在cptfile后面添加+Uk
if [[ ${unit} == 'km+Uk' ]]; then
gmt psscale -Dx1.6i/0.1i+w1.2i/0.07i -C${cptfile}+Uk -Bx${bartick} -By+l${unit} -O >> $psfile
gmt psscale -Dx0.24i/-0.32i+w1.5i/0.05i+h -C${cptfile}+Uk -Bx${bartick} -By+l${unit} -O >> $psfile
else
gmt psscale -Dx1.6i/0.1i+w1.2i/0.07i -C${cptfile} -Bx${bartick} -By+l${unit} -O >> $psfile
gmt psscale -Dx0.24i/-0.32i+w1.5i/0.05i+h -C${cptfile} -Bx${bartick} -By+l${unit} -O >> $psfile
fi
gmt psconvert $psfile -A -TEG -E300
# 删除临时文件 使用linux终端rm命令