add -p option

This commit is contained in:
张壹 2018-03-25 13:21:55 -07:00
parent f27e997778
commit 755ba86754

View File

@ -13,8 +13,9 @@ labels=("longitude (degree)" "latitude (degree)")
plot_para=(0 0 0 0)
plotgrad=0
nocpt=0
inverseCPT=0
# 从命令行获取参数
while getopts "hi:r:u:c:a:gv:n" arg
while getopts "hi:r:u:c:a:gv:np" arg
do
case $arg in
h)
@ -28,6 +29,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" "-g" "use grdgradient. The default is false."
printf "%s\t%s\n" "-n" "disabele 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)
data=$OPTARG;;
@ -44,6 +46,8 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
plotgrad=1;;
n)
nocpt=1;;
p)
inverseCPT=1;;
?)
printf "error: unknow argument\nuse -h option to see help information\n"
exit 1;;
@ -93,7 +97,11 @@ else
if [[ $nocpt == 1 ]]; then
cptfile=${color}
else
gmt grd2cpt ${data} -R${range} -C${color} -Z -D -M > $cptfile
if [[ $inverseCPT == 1 ]]; then
gmt grd2cpt ${data} -R${range} -C${color} -Z -D -M -I > $cptfile
else
gmt grd2cpt ${data} -R${range} -C${color} -Z -D -M > $cptfile
fi
fi
if [[ $plotgrad == 1 ]]; then