update -s option

This commit is contained in:
张壹 2018-07-10 11:12:40 -07:00
parent d5403dc00c
commit 84f2b77544

View File

@ -12,21 +12,23 @@ overwriteRange='null'
overwrite=0
labels=("longitude (degree)" "latitude (degree)")
plotgrad=0
plotsun=0
clon="0/0/115"
clon2="180/0/115"
# 从命令行获取参数
while getopts "hi:r:u:c:a:G:l:g" arg
while getopts "hi:r:u:c:a:G:l:gs" arg
do
case $arg in
h)
printf "simple global wide 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>] [-l<clon>/<clat>/<horizon>] [-u<unit>] [-c<cpt-file>] [-a<x-label>,<y-label>] [-g] [-G<grad-data>]\n"
printf "usage: ${0##*/} -i<grid-data> [-r<xmin>/<xmax>/<ymin>/<ymax>] [-l<clon>/<clat>/<horizon>] [-u<unit>] [-c<cpt-file>] [-a<x-label>,<y-label>] [-g] [-s] [-G<grad-data>]\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" "-l" "central longitude and latitude values of the plot, the default value is 0/0/115. "
printf "%s\t%s\n" "-u" "data unit. The default is meter. use 'km+Uk' to append '+Uk' option to the psscale command"
printf "%s\t%s\n" "-c" "color cpt. The default is rainbow."
printf "%s\t%s\n" "-s" "plot the day-night terminator. The default is false."
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" "-G" "provide a different input grid data for the use of grdgradient. This should be used with the '-g' option at the same time"
@ -37,6 +39,8 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
unit=$OPTARG;;
c)
color=$OPTARG;;
s)
plotsun=1;;
r)
overwrite=1
overwriteRange=$OPTARG;;
@ -81,7 +85,7 @@ else
MAP_FRAME_AXES=WESnZ \
MAP_LABEL_OFFSET=2.5p
gmt grd2cpt ${data} -C${color} -Z -D > $cptfile
gmt grd2cpt ${data} -R${range} -C${color} -Z -D > $cptfile
if [[ $plotgrad == 1 ]]; then
gradfile=${data%.*}Grad.nc
if [[ $gridData == 'null' ]]; then
@ -90,10 +94,22 @@ else
gmt grdgradient ${gridData} -G${gradfile} -Nt -A0/45
fi
gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon}/1.5i -K -P > $psfile
if [[ $plotsun == 1 ]]; then
gmt pssolar -R${range} -JA${clon}/1.5i -Td+d2016-02-09T16:00:00 -Gblack@75 -K -O >> $psfile
fi
gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon2}/1.5i -X1.7i -K -O >> $psfile
if [[ $plotsun == 1 ]]; then
gmt pssolar -R${range} -JA${clon2}/1.5i -Td+d2016-02-09T16:00:00 -Gblack@75 -K -O >> $psfile
fi
else
gmt grdimage ${data} -R${range} -C${cptfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30s+l"${labels[1]}" -JA${clon}/1.5i -K -P > $psfile
gmt grdimage ${data} -R${range} -C${cptfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30s+l"${labels[1]}" -JA${clon}/1.5i -X1.7i -K -O >> $psfile
gmt grdimage ${data} -R${range} -C${cptfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon}/1.5i -K -P > $psfile
if [[ $plotsun == 1 ]]; then
gmt pssolar -R${range} -JA${clon}/1.5i -Td+d2016-02-09T16:00:00 -Gblack@75 -K -O >> $psfile
fi
gmt grdimage ${data} -R${range} -C${cptfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon2}/1.5i -X1.7i -K -O >> $psfile
if [[ $plotsun == 1 ]]; then
gmt pssolar -R${range} -JA${clon2}/1.5i -Td+d2016-02-09T16:00:00 -Gblack@75 -K -O >> $psfile
fi
fi
#-C${cptfile}+Uk 使用km色标单位除1000
#如果unit等于km则在cptfile后面添加+Uk