나의 연구/GraADS2009. 12. 30. 11:00

i=1
ii=1
jj=1
itot=23
*---------------------------
* ii = color
* jj = style
*---------------------------
iitot=7
jjtot=3
*
while (i<=itot)
ii=math_mod(i,iitot)
if(ii=0) ; ii=iitot ;endif
jj=math_nint(i/iitot)+1
say i' 'ii' 'jj
pull dummy
*
'q file 'i
line=sublin(result,2)
ctl=subwrd(line,2)
model=substr(ctl,11,10)
say model

is=(i-1)*12*5+1
ie=i*12*5

*
  x0=8.5
  y0=7.5
  x1 = x0
  x2 = x0+0.5
  x3 = x0+0.8
  y1=y0-i*0.2+0.05
  y2=y0-i*0.2
*
'set ccolor 'ii
'set cstyle 'jj
'set cmark 0'

'set line ' ii ' 'jj
'draw line 'x1' ' y1' ' x2' ' y1
'draw string 'x3 ' 'y2' 'model
*
'set grads off'


'나의 연구 > GraADS' 카테고리의 다른 글

trend 분석  (0) 2010.02.10
script_math_demo.gs [결과]  (0) 2009.12.29
script_math_demo.gs  (5) 2009.12.29
Standard Deviation  (1) 2009.12.29
draw string  (0) 2009.12.29
Posted by mclab
나의 연구/GraADS2009. 12. 29. 13:44
ga-> script_math_demo.gs
 
Formatting numbers:
%-6.1f of 3.1456 = 3.1  
%-6.2f of 3.1456 = 3.15 
%6.2f  of 3.1456 =   3.15
%06.3f of 3.1456 = 03.146
%6.0g  of 3.1456 =      3
%12.3e of 3.1456 =    3.146e+00
 
Trigonometric functions:
cos of 45 = 0.7071
sin of 45 = 0.7071
tan of 45 = 1.0000
acos of 0.7071 = 45.0000
asin of 0.7071 = 45.0000
atan of 1.0000 = 45.0000
atan2 of (1,-1) = 135.0000
cosh of 30 = 1.1402
sinh of 30 = 0.5479
tanh of 30 = 0.4805
acosh of 1.1402 = 65.3308 <-- math_acosh() may have a bug ... this value should be 30
asinh of 0.5479 = 30.0000
atanh of 0.4805 = 30.0000
 
Evaluating strings to see if they are numbers:
0 = not a number
1 = integer
2 = not an integer
valnum of 3.1455 = 2
valnum of 3 = 1
valnum of 3e10 = 2
valnum of 390210 = 1
valnum of a string = 0
 
Real-to-integer conversion:
nint of 3.0 = 3    int of 3.0 = 3
nint of 3.1 = 3    int of 3.1 = 3
nint of 3.2 = 3    int of 3.2 = 3
nint of 3.3 = 3    int of 3.3 = 3
nint of 3.4 = 3    int of 3.4 = 3
nint of 3.5 = 4    int of 3.5 = 3
nint of 3.6 = 4    int of 3.6 = 3
nint of 3.7 = 4    int of 3.7 = 3
nint of 3.8 = 4    int of 3.8 = 3
nint of 3.9 = 4    int of 3.9 = 3
 
Exponents:
2 raised to the power 0.5 = 1.4142135623731
 
Exponential function:
exp(1) = 2.71828182845905
 
Natural logarithm:
log(2.71828) = 0.999999327347282
 
Base 10 logarithm:
log10(2) = 0.301029995663981
10 raised to the power 0.3103 = 2.0000000199681
 
Modulo operator fmod:
6 fmod 2.25 (the remainder when 6 is divided by 2.25) = 1.5
 
Modulo operator mod:
6 mod 2.25 (the integer part of the remainder when 6 is divided by 2.25) = 1
 
String operations:
length of the string "this is a test" = 14
word 2 of the string "this is a test" starts at character 6

'나의 연구 > GraADS' 카테고리의 다른 글

trend 분석  (0) 2010.02.10
draw string (math_mod)  (0) 2009.12.30
script_math_demo.gs  (5) 2009.12.29
Standard Deviation  (1) 2009.12.29
draw string  (0) 2009.12.29
Posted by mclab
나의 연구/GraADS2009. 12. 29. 13:43
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* script_math_demo.gs
*
* Illustrates the use of the scripting language math funcitons
* Written by M. Fiorino
* Modified by J.M. Adams
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

doformat = 1
dotrig = 1
doint = 1
domisc = 1
dovalnum = 1

* FORMATTING NUMBERS
if (doformat)
  print ' '
  print 'Formatting numbers:'
  v = 3.1456
  fmt = '%-6.1f'
  rc = math_format(fmt,v)
  print fmt' of 'v' = 'rc

  fmt = '%-6.2f'
  rc = math_format(fmt,v)
  print fmt' of 'v' = 'rc

  fmt = '%6.2f'
  rc = math_format(fmt,v)
  print fmt'  of 'v' = 'rc

  fmt = '%06.3f'
  rc = math_format(fmt,v)
  print fmt' of 'v' = 'rc

  fmt = '%6.0g'
  rc = math_format(fmt,v)
  print fmt'  of 'v' = 'rc

  fmt = '%12.3e'
  rc = math_format(fmt,v)
  print fmt' of 'v' = 'rc
  print ' '
endif

* TRIG FUNCTIONS
if (dotrig)
  print 'Trigonometric functions:'
  pi  = 3.1415926
  d2r = pi/180
  r2d = 1/d2r
  dang = 45
  ang = dang*d2r
  fmt = '%-6.4f'

  cos  = math_cos(ang)
  cosf = math_format(fmt,cos)
  print 'cos of 'dang' = 'cosf

  sin  = math_sin(ang)
  sinf = math_format(fmt,sin)
  print 'sin of 'dang' = 'sinf

  tan  = math_tan(ang)
  tanf = math_format(fmt,tan)
  print 'tan of 'dang' = 'tanf

  ang = math_acos(cos)
  dang = ang * r2d
  dangf = math_format(fmt,dang)
  print 'acos of 'cosf' = 'dangf

  ang = math_asin(sin)
  dang = ang * r2d
  dangf = math_format(fmt,dang)
  print 'asin of 'sinf' = 'dangf

  ang = math_atan(tan)
  dang = ang * r2d
  dangf = math_format(fmt,dang)
  print 'atan of 'tanf' = 'dangf

  u =  1
  v = -1
  rc = math_atan2(u,v)
  rc2 = rc*r2d
  rc2f = math_format(fmt,rc2)
  print 'atan2 of ('u','v') = 'rc2f

  dang = 30
  ang = dang*d2r

  cosh = math_cosh(ang)
  coshf = math_format(fmt,cosh)
  print 'cosh of 'dang' = 'coshf

  sinh = math_sinh(ang)
  sinhf = math_format(fmt,sinh)
  print 'sinh of 'dang' = 'sinhf

  tanh = math_tanh(ang)
  tanhf = math_format(fmt,tanh)
  print 'tanh of 'dang' = 'tanhf

  demo = dang
  ang = math_acosh(cosh)
  dang = ang * r2d
  dangf = math_format(fmt,dang)
  print 'acosh of 'coshf' = 'dangf' <-- math_acosh() may have a bug ... this value should be 'demo

  ang = math_asinh(sinh)
  dang = ang * r2d
  dangf = math_format(fmt,dang)
  print 'asinh of 'sinhf' = 'dangf

  ang = math_atanh(tanh)
  dang = ang * r2d
  dangf = math_format(fmt,dang)
  print 'atanh of 'tanhf' = 'dangf
  print ' '
endif

* VALNUM
if (dovalnum)
  print 'Evaluating strings to see if they are numbers:'
  print '0 = not a number'
  print '1 = integer'
  print '2 = not an integer'
  num = '3.1455'
  rc = valnum(num)
  print 'valnum of 'num' = 'rc

  num = '3'
  rc = valnum(num)
  print 'valnum of 'num' = 'rc

  num = '3e10'
  rc = valnum(num)
  print 'valnum of 'num' = 'rc

  num = '390210'
  rc = valnum(num)
  print 'valnum of 'num' = 'rc

  num = 'a string'
  rc = valnum(num)
  print 'valnum of 'num' = 'rc
  print ' '
endif

* INTEGER CONVERSION
if (doint) 
  print 'Real-to-integer conversion:'
  v = 3.0
  while(v < 4.0) 
    rc1 = math_nint(v)
    rc2 = math_int(v)
    print 'nint of 'v' = 'rc1'    int of 'v' = 'rc2
    v = v + 0.1
  endwhile
  print ' '
endif

* MISCELLANEOUS FUNCTIONS
if (domisc)
  print 'Exponents:'
  pow = math_pow(2,0.5);
  print '2 raised to the power 0.5 = 'pow
  print ' '

  print 'Exponential function:'
  num = math_exp(1)
  print 'exp(1) = 'num
  print ' '

  print 'Natural logarithm:'
  num = math_log(2.71828)
  print 'log(2.71828) = 'num
  print ' '

  print 'Base 10 logarithm:'
  num = math_log10(2)
  print 'log10(2) = 'num
  pow = math_pow(10,0.30103);
  print '10 raised to the power 0.3103 = 'pow
  print ' '

  print 'Modulo operator fmod:'
  fmod = math_fmod(6,2.25);
  print '6 fmod 2.25 (the remainder when 6 is divided by 2.25) = 'fmod
  print ' '

  print 'Modulo operator mod:'
  fmod = math_mod(6,2.25);
  print '6 mod 2.25 (the integer part of the remainder when 6 is divided by 2.25) = 'fmod
  print ' '

  print 'String operations:'
  s = 'this is a test'
  rc = math_strlen(s)
  print 'length of the string "'s'" = 'rc

  p = 2
  rc = wrdpos(s,p)
  print 'word 'p' of the string "'s'" starts at character 'rc
  print ' '
endif


return

'나의 연구 > GraADS' 카테고리의 다른 글

draw string (math_mod)  (0) 2009.12.30
script_math_demo.gs [결과]  (0) 2009.12.29
Standard Deviation  (1) 2009.12.29
draw string  (0) 2009.12.29
my subplot  (0) 2009.12.29
Posted by mclab