add -p option
This commit is contained in:
		
							
								
								
									
										41
									
								
								gmtsph-JA.sh
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								gmtsph-JA.sh
									
									
									
									
									
								
							@@ -13,25 +13,26 @@ overwrite=0
 | 
			
		||||
labels=("longitude (degree)" "latitude (degree)")
 | 
			
		||||
plotgrad=0
 | 
			
		||||
plotsun=0
 | 
			
		||||
clon="0/0/115"
 | 
			
		||||
clon2="180/0/115"
 | 
			
		||||
clon=("0/0/115" "180/0/115")
 | 
			
		||||
polyfile='null'
 | 
			
		||||
# 从命令行获取参数
 | 
			
		||||
while getopts "hi:r:u:c:a:G:l:gs" arg
 | 
			
		||||
while getopts "hi:r:u:c:a:G:l:p: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] [-s] [-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>] [-p<polygon-file>]\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" "-l" "central longitude and latitude values of the plot, the default value is 0/0/115,180/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"
 | 
			
		||||
			printf "%s\t%s\n" "-p" "plot polygons via a file."
 | 
			
		||||
			exit 0;;
 | 
			
		||||
		i)
 | 
			
		||||
			data=$OPTARG;;
 | 
			
		||||
@@ -45,13 +46,15 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z
 | 
			
		||||
			overwrite=1
 | 
			
		||||
			overwriteRange=$OPTARG;;
 | 
			
		||||
		l)
 | 
			
		||||
			clon=$OPTARG;;
 | 
			
		||||
			clon=(${OPTARG//,/ });;
 | 
			
		||||
		a)
 | 
			
		||||
			labels=(${OPTARG//,/ });;
 | 
			
		||||
		g)
 | 
			
		||||
			plotgrad=1;;
 | 
			
		||||
		G)
 | 
			
		||||
			gridData=$OPTARG;;
 | 
			
		||||
		p)
 | 
			
		||||
			polyfile=$OPTARG;;
 | 
			
		||||
		?)
 | 
			
		||||
			printf "error: unknow argument\nuse -h option to see help information\n"
 | 
			
		||||
			exit 1;;
 | 
			
		||||
@@ -93,24 +96,26 @@ else
 | 
			
		||||
		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
 | 
			
		||||
		gradPlotCommand=-I${gradfile}
 | 
			
		||||
	else
 | 
			
		||||
		gmt grdimage ${data} -R${range} -C${cptfile} -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon}/1.5i -K -P > $psfile
 | 
			
		||||
		gradPlotCommand=""
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	gmt grdimage ${data} -R${range} -C${cptfile} $gradPlotCommand -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon[0]}/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
 | 
			
		||||
		gmt pssolar -R${range} -JA${clon[0]}/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 [[ $polyfile != 'null' ]]; then
 | 
			
		||||
		gmt psxy $polyfile -JA${clon[0]}/1.5i -R${range} -L -K -O >> $psfile
 | 
			
		||||
	fi
 | 
			
		||||
	gmt grdimage ${data} -R${range} -C${cptfile} $gradPlotCommand -Bxa30g30+l"${labels[0]}" -Bpya30g30+l"${labels[1]}" -JA${clon[1]}/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
 | 
			
		||||
		gmt pssolar -R${range} -JA${clon[1]}/1.5i -Td+d2016-02-09T16:00:00 -Gblack@75 -K -O >> $psfile
 | 
			
		||||
	fi
 | 
			
		||||
	if [[ $polyfile != 'null' ]]; then
 | 
			
		||||
		gmt psxy $polyfile -JA${clon[1]}/1.5i -R${range} -L -K -O >> $psfile
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	#-C${cptfile}+Uk 使用km(色标单位除1000
 | 
			
		||||
	#如果unit等于km则在cptfile后面添加+Uk
 | 
			
		||||
	if [[ ${unit} == 'km+Uk' ]]; then
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user