add -G option
This commit is contained in:
		@@ -4,6 +4,7 @@
 | 
				
			|||||||
#GMT显示平面数据脚本,输入文件为网格文件,没有包含网格化语句因为网格化过程中的情况多样化,建议在其他脚本中个别添加再调用此脚本
 | 
					#GMT显示平面数据脚本,输入文件为网格文件,没有包含网格化语句因为网格化过程中的情况多样化,建议在其他脚本中个别添加再调用此脚本
 | 
				
			||||||
# 初始化参数
 | 
					# 初始化参数
 | 
				
			||||||
data='null'
 | 
					data='null'
 | 
				
			||||||
 | 
					gridData='null'
 | 
				
			||||||
unit='m'
 | 
					unit='m'
 | 
				
			||||||
color='rainbow'
 | 
					color='rainbow'
 | 
				
			||||||
range='null'
 | 
					range='null'
 | 
				
			||||||
@@ -12,7 +13,7 @@ overwrite=0
 | 
				
			|||||||
labels=("x (m)" "y (m)")
 | 
					labels=("x (m)" "y (m)")
 | 
				
			||||||
plotgrad=0
 | 
					plotgrad=0
 | 
				
			||||||
# 从命令行获取参数
 | 
					# 从命令行获取参数
 | 
				
			||||||
while getopts "hi:r:u:c:a:g" arg
 | 
					while getopts "hi:r:u:c:a:G:g" arg
 | 
				
			||||||
do
 | 
					do
 | 
				
			||||||
	case $arg in
 | 
						case $arg in
 | 
				
			||||||
		h)
 | 
							h)
 | 
				
			||||||
@@ -25,6 +26,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" "-c" "color cpt. The default is rainbow."
 | 
				
			||||||
			printf "%s\t%s\n" "-a" "axis labels. The deafults are x (m) and y (m)."
 | 
								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" "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;;
 | 
								exit 0;;
 | 
				
			||||||
		i)
 | 
							i)
 | 
				
			||||||
			data=$OPTARG;;
 | 
								data=$OPTARG;;
 | 
				
			||||||
@@ -39,6 +41,8 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
 | 
				
			|||||||
			labels=(${OPTARG//,/ });;
 | 
								labels=(${OPTARG//,/ });;
 | 
				
			||||||
		g)
 | 
							g)
 | 
				
			||||||
			plotgrad=1;;
 | 
								plotgrad=1;;
 | 
				
			||||||
 | 
							G)
 | 
				
			||||||
 | 
								gridData=$OPTARG;;
 | 
				
			||||||
		?)
 | 
							?)
 | 
				
			||||||
			printf "error: unknow argument\nuse -h option to see help information\n"
 | 
								printf "error: unknow argument\nuse -h option to see help information\n"
 | 
				
			||||||
			exit 1;;
 | 
								exit 1;;
 | 
				
			||||||
@@ -70,10 +74,14 @@ else
 | 
				
			|||||||
	MAP_FRAME_AXES=WeSnZ \
 | 
						MAP_FRAME_AXES=WeSnZ \
 | 
				
			||||||
	MAP_LABEL_OFFSET=4p
 | 
						MAP_LABEL_OFFSET=4p
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gmt grd2cpt ${data} -C${color} -Z -D > $cptfile
 | 
						gmt grd2cpt ${data} -C${color} -R${range} -Z -D > $cptfile
 | 
				
			||||||
	if [[ $plotgrad == 1 ]]; then
 | 
						if [[ $plotgrad == 1 ]]; then
 | 
				
			||||||
		gradfile=usergradient.nc
 | 
							gradfile=${data%.*}Grad.nc
 | 
				
			||||||
		gmt grdgradient ${data} -G${gradfile} -Nt -A0/45
 | 
							if [[ $gridData == 'null' ]]; then
 | 
				
			||||||
 | 
								gmt grdgradient ${data} -G${gradfile} -Nt -A0/45
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								gmt grdgradient ${gridData} -G${gradfile} -Nt -A0/45
 | 
				
			||||||
 | 
							fi
 | 
				
			||||||
		gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JX3i -K -P > $psfile
 | 
							gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JX3i -K -P > $psfile
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		gmt grdimage ${data} -R${range} -C${cptfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JX3i -K -P > $psfile
 | 
							gmt grdimage ${data} -R${range} -C${cptfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JX3i -K -P > $psfile
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user