GrADS: Some useful prerequisite scripts - vec.gs

Save the below script as "vec.gs" in a text editor:

The script:


function vec (args)


variable=subwrd(args,1)


autopl  = 'on'

scl = 0

strlast=''

hdsz=0.15


* examine options are set or not

n=2

while(n<10000)

idx=subwrd(args,n)

opt=subwrd(args,n+1)

if(idx='');break;endif

if(idx='-P')

 cxleft =subwrd(args,n+1)

 cylow  =subwrd(args,n+2)

 autopl ='off'

 n=n+3

endif

if(idx='-SCL')

 size=subwrd(args,n+1)

 magni=subwrd(args,n+2)

 scl=1

 n=n+3

endif

if(idx='-SL')

 strlast=subwrd(args,n+1)

 n=n+2

endif

if(idx='-HDSZ')

 hdsz=subwrd(args,n+1)

 n=n+2

endif

endwhile


*** set default arrow labeling off

'set arrlab on'

if(autopl='off');'set arrlab off';endif


*** set arrow scale

if(scl=1); 'set arrscl 'size ' 'magni;endif


*** draw the vector

'display 'variable


*** draw the vector arrow label

if(autopl='off')

 if(scl=0)

  say '!! CANNOT PLOT Arrow Label: Set allow scale with -SCL option !!'

 else

  'draw line 'cxleft' 'cylow' 'cxleft+size' 'cylow

  'draw line 'cxleft+size' 'cylow' 'cxleft+(1.0-hdsz)*size' 'cylow-0.5*hdsz*size

  'draw line 'cxleft+size' 'cylow' 'cxleft+(1.0-hdsz)*size' 'cylow+0.5*hdsz*size

  'set string 1 tc 5'

  'draw string 'cxleft+0.5*size' 'cylow-0.05' 'magni%' '%strlast

 endif

endif


*** set arrow label on

'set arrlab on'


Comments

Popular posts from this blog

ഔ ന്റെ കുദരേ അൻക്ക് പിരാന്താണ്!!

GrADS: Some useful prerequisite scripts - basemap.gs

ഇൻഡോർ: ഞാൻ താമസിച്ച ആദ്യ ഉത്തരേന്ത്യൻ സിറ്റിയും ഒരു എൻ.സി.സി. നാഷണൽ ക്യാമ്പും