- 积分
- 42918
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-8-28
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
function southchinasea(backgcolor,lcolor,dx,bottom_right,lat1,lon1,lat2,lon2)
*say args
* backgcolor ;*背景颜色(缺省图黑色=0)
* lcolor ;*线条颜色(缺省图灰色=15)
* dx ;*南海区域图的水平范围(缺省dx=0,图的1/8水平长度)
* bottom_right ;*取值-1到+1;(缺省=1,右下角;-1,左下角;0,中间)
* 南海区域经纬度范围
* lat1 =0N
* lon1 =104E
* lat2 =25N
* lon2 =123E
*say 'bottom_right= 'bottom_right' dx= 'dx' backgcolor= 'backgcolor' lcolor= 'lcolor
*say 'lat1= 'lat1' lat2= 'lat2' lon1= 'lon1' lon2= 'lon2
if( subwrd(backgcolor,1) = 'china_sea' | subwrd(backgcolor,1) = 'china_sea.gs' )
args = backgcolor
arg1 = subwrd(args,1)
endif
if( valnum(backgcolor) = 0 ); backgcolor = 0 ; endif
if( valnum(bottom_right) = 0); bottom_right = 1 ; endif
if( valnum(lcolor) = 0 ); lcolor = 15 ; endif
if( valnum(dx) = 0 ); dx = 00 ; endif
if( valnum(lat1) = 0 ); lat1 = 00 ; endif
if( valnum(lat2) = 0 ); lat2 = 25 ; endif
if( valnum(lon1) = 0 ); lon1 = 104 ; endif
if( valnum(lon2) = 0 ); lon2 = 123 ; endif
*say 'bottom_right= 'bottom_right' dx= 'dx' backgcolor= 'backgcolor' lcolor= 'lcolor
*say 'lat1= 'lat1' lat2= 'lat2' lon1= 'lon1' lon2= 'lon2
'set imprun default.gs'
'q gxinfo' ;*确定图形的范围投影方式
*say result
xmin = subwrd(result,14)
xmax = subwrd(result,16)
ymin = subwrd(result,20)
ymax = subwrd(result,22)
mprj = subwrd(result,31)
*say xmin' 'ymin' 'xmax' 'ymax' mprj= 'mprj
'q dims' ;*确定经纬度范围
lonmin = subwrd(result,11)
lonmax = subwrd(result,13)
latmin = subwrd(result,24)
latmax = subwrd(result,26)
*say 'latmin= 'latmin' latmax= 'latmax' lonmin= 'lonmin' lonmax= 'lonmax
if( mprj = 4 | latmax <=0 ) ; return ; endif
*if( lat1 < latmin ); lat1 = latmin; endif ;*会造成南海区域不太完整
*if( lat2 > latmax ); lat2 = latmax; endif
x2 = (lonmax+lonmin)*0.5
'q w2xy 'x2 ' 'latmin
y0 = subwrd(result,6)
*say 'y0===== 'y0
'q w2xy 'lonmax ' 'latmin
xmax = subwrd(result,3) ; y1 = subwrd(result,6)
if( y1 < y0 ) ; y0 = y1 ; endif
*say 'xmax/y0===='xmax' 'y0
'q w2xy 'lonmin ' 'latmin
xmin = subwrd(result,3) ; y1 = subwrd(result,6)
if( y1 < y0 ) ; y0 = y1 ; endif
*say 'xmin/y0===='xmin' 'y0
if 1 ;*南海图形x轴与y轴的比率(rat)
if( mprj != 2 ); 'set mproj latlon'; endif
'set mpdraw off'
'set lat 'lat1' 'lat2
'set lon 'lon1' 'lon2
'draw map'
'q gxinfo'
x1 = subwrd(result,14)
x2 = subwrd(result,16)
y1 = subwrd(result,20)
y2 = subwrd(result,22)
rat = (y2-y1)/(x2-x1)
*say x1' 'y1' 'x2' 'y2
endif
if( dx < 0.25 ); dx = (xmax - xmin)/9 ; endif
dy = rat*dx
*say 'dx= 'dx' dy= 'dy' inches'
if( dx < 0.25 | dy < 0.25 )
say 'too small area for south China sea return ..........'
say 'x0/y0/dx/dy===='x0' 'y0' 'dx' 'dy
return
endif
x0 = xmin + (xmax-xmin-dx)*(bottom_right+1)/2
*y0 = ymin
*say 'x0/y0===='x0' 'y0' 'bottom_right
'set parea 'x0' 'x0+dx' 'y0' 'y0+dy
if( arg1 = 'china_sea' | arg1 = 'china_sea.gs' )
* 'china_sea' ;*画海陆地图背景。;
args
w6 = subwrd(args,6)
if( w6 ='' )
'set mpdraw on'
'set mpt * 'lcolor ;*地图颜色
'set mpdset cnhimap'
'draw map' ;*以newcn地图数据画南海区域国界
endif
else
'set line 'backgcolor
'draw recf 'x0' 'y0' 'x0+dx' 'y0+dy
'set mpdraw on'
'set mpdset lowres'
'set mpt * 'lcolor ;*地图颜色
'draw map'
'set mpdset cnhimap'
'draw map' ;*以newcn地图数据画南海区域国界
endif
'set line 15 1 6' ;*边框颜色(黑色)及线形与粗细
'draw rec 'x0' 'y0' 'x0+dx' 'y0+dy
*---------------restore to before --------------------
if( mprj = 1 ); 'set mproj scaled' ; endif
if( mprj = 2 ); 'set mproj latlon' ; endif
if( mprj = 3 ); 'set mproj nps' ; endif
if( mprj = 4 ); 'set mproj sps' ; endif
if( mprj = 5 ); 'set mproj robinson' ; endif
if( mprj = 6 ); 'set mproj mollweide' ; endif
if( mprj = 7 ); 'set mproj orthogr' ; endif
if( mprj = 13); 'set mproj lambert' ; endif
'set mpdset lowres'
'set parea off'
'set lat 'latmin' 'latmax
'set lon 'lonmin' 'lonmax
'set line 1 1 1'
;
直接在grads中使用southchinasea的效果如下图
南海脚本
这个脚本利用了function,类似于fortran中的子程序,实际使用过程中应该是把这一段放到你的脚本中,可以控制相应的底图颜色、线条颜色、南海区域图的水平范围、小图的位置等,但是这样比较麻烦。直接调用southchinasea也能出图就像我给的例子,但是缺点是不能控制上面说的那几项。所以请大神把它改造一下吧!改成目前主流的直接调用并能控制这几个要素的方式吧!
|
|