tmp update

This commit is contained in:
张壹 2023-03-20 21:19:15 +08:00
parent b00d094cfc
commit 60f0ec6fae

View File

@ -9,6 +9,7 @@ data='null'
gridData='null' gridData='null'
unit='m' unit='m'
color='rainbow' color='rainbow'
direct_cpt='user.cpt'
range='null' range='null'
overwriteRange='null' overwriteRange='null'
overwrite=0 overwrite=0
@ -18,7 +19,7 @@ clon=0
polyfile='null' polyfile='null'
bartick="a" #色标轴标轴间隔 a表示自动 bartick="a" #色标轴标轴间隔 a表示自动
# 从命令行获取参数 # 从命令行获取参数
while getopts "hi:r:u:c:a:G:l:p:v:g" arg while getopts "hi:r:u:c:C:a:G:l:p:v:g" arg
do do
case $arg in case $arg in
h) h)
@ -31,6 +32,7 @@ For futher explanations, please look for GMT's manuscripts."
dispOptionShort "-l" "central longitude value of the plot, the default value is 0" dispOptionShort "-l" "central longitude value of the plot, the default value is 0"
dispOptionShort "-u" "data unit. The default is meter. use 'km+Uk' to append '+Uk' option to the psscale command" dispOptionShort "-u" "data unit. The default is meter. use 'km+Uk' to append '+Uk' option to the psscale command"
dispOptionShort "-c" "color cpt. The default is rainbow." dispOptionShort "-c" "color cpt. The default is rainbow."
dispOptionShort "-C" "color cpt. Use the input cpt file directly."
dispOptionShort "-v" "intervals of color bar's labels. the script will set the intervals automatically if -v option is not set." dispOptionShort "-v" "intervals of color bar's labels. the script will set the intervals automatically if -v option is not set."
dispOptionShort "-a" "axis labels. The deafults are x (m) and y (m)." dispOptionShort "-a" "axis labels. The deafults are x (m) and y (m)."
dispOptionShort "-g" "use grdgradient. The default is false." dispOptionShort "-g" "use grdgradient. The default is false."
@ -43,6 +45,8 @@ For futher explanations, please look for GMT's manuscripts."
unit=$OPTARG;; unit=$OPTARG;;
c) c)
color=$OPTARG;; color=$OPTARG;;
C)
direct_cpt=$OPTARG;;
r) r)
overwrite=1 overwrite=1
overwriteRange=$OPTARG;; overwriteRange=$OPTARG;;
@ -69,7 +73,7 @@ if [[ $data == "null" ]]; then
exit 1 exit 1
else else
# 初始化临时文件名 # 初始化临时文件名
cptfile=user.cpt cptfile=${direct_cpt}
psfile=${data%.*}.ps psfile=${data%.*}.ps
jpgfile=${data%.*}.png jpgfile=${data%.*}.png
# 获取网格范围 # 获取网格范围
@ -90,7 +94,10 @@ else
MAP_FRAME_AXES=WESnZ \ MAP_FRAME_AXES=WESnZ \
MAP_LABEL_OFFSET=2.5p MAP_LABEL_OFFSET=2.5p
gmt grd2cpt ${data} -C${color} -Z -D > $cptfile if [[ $cptfile == 'user.cpt' ]]; then
gmt grd2cpt ${data} -C${color} -Z -D > $cptfile
fi
if [[ $plotgrad == 1 ]]; then if [[ $plotgrad == 1 ]]; then
gradfile=${data%.*}Grad.nc gradfile=${data%.*}Grad.nc
if [[ $gridData == 'null' ]]; then if [[ $gridData == 'null' ]]; then
@ -103,7 +110,9 @@ else
gmt grdimage ${data} -R${range} -C${cptfile} -Bxag+l"${labels[0]}" -Bpya40g40+l"${labels[1]}" -JN${clon}/2i -K -P > $psfile gmt grdimage ${data} -R${range} -C${cptfile} -Bxag+l"${labels[0]}" -Bpya40g40+l"${labels[1]}" -JN${clon}/2i -K -P > $psfile
fi fi
if [[ $polyfile != 'null' ]]; then if [[ $polyfile != 'null' ]]; then
gmt psxy $polyfile -JN${clon}/2i -R${range} -L -K -O >> $psfile #-L force closed polygon
#gmt psxy $polyfile -JN${clon}/2i -R${range} -L -K -O >> $psfile
gmt psxy $polyfile -JN${clon}/2i -R${range} -W0.1p -K -O >> $psfile
fi fi
#-C${cptfile}+Uk 使用km色标单位除1000 #-C${cptfile}+Uk 使用km色标单位除1000
#如果unit等于km则在cptfile后面添加+Uk #如果unit等于km则在cptfile后面添加+Uk
@ -114,7 +123,10 @@ else
fi fi
gmt psconvert $psfile -A -TEG -E300 gmt psconvert $psfile -A -TEG -E300
# 删除临时文件 使用linux终端rm命令 # 删除临时文件 使用linux终端rm命令
rm $cptfile $psfile gmt.history gmt.conf if [[ $cptfile == 'user.cpt' ]]; then
rm $cptfile
fi
rm $psfile gmt.history gmt.conf
if [[ $plotgrad == 1 ]]; then if [[ $plotgrad == 1 ]]; then
rm $gradfile rm $gradfile
fi fi