Ruby
Rubyのページ
2011/11/20 Update
Ruby Programing
改行つきで表示
puts "Hello World!!!"
改行無しで表示
print "Hello World!!!"
printに改行を付ける
print "Hello World!!!\n"
script 内でシステムコマンドを実行する。
ex) date を実行する
system("date")
for ループ
for inum in [30, 60, 90]
puts " number = #{inum}"
end
irb を使いこなす
Rubyの基本
http://www.lastday.jp/2010/12/29/learning-ruby-with-my-cat
Dennou-Ruby を使う
参考URL: http://ruby.gfd-dennou.org/index-j.htm
インストール関連はこちらを参照.
・NetCDF形式のMSMをつかってお絵かき.
---------
# <draw range setting>
slon = 130
elon = 136
slat = 31
elat = 36
require "numru/ggraph"
include NumRu
# <file open>
rh = GPhys::IO.open('0513.nc', 'rh')
uwind = GPhys::IO.open('0513.nc', 'u')
vwind = GPhys::IO.open('0513.nc', 'v')
# <DCL setting>
DCL.gropn(1)
DCL.sgpset('lcntl', false)
DCL.sgpset('lclip', true)
DCL.uzfact(0.7)
DCL.sgpset('lfull',true)
GGraph.set_fig 'itr'=>10, 'viewport'=>[0.05,0.95,0.1,0.6]
GGraph.set_map 'coast_japan'=>true
# <draw section>
for lev in [950, 850, 700]
for time in [0, 3, 6, 9, 12, 15, 18, 21]
puts "Press = #{lev}"
puts "Time = #{time}"
GGraph.tone( gphys.cut('lon'=>"#{slon}".."#{elon}",'lat'=>#{slat}..#{elat},'p'=>lev,'time'=>time ), true, 'map_axes'=>true, 'levels'=> [0,10,20,30,40,50,60,70,80,90,100] )
GGraph.color_bar('tickintv'=>0,"voff"=>0.05)
GGraph.vector(uwind.cut('lon'=>"#{slon}".."#{elon}",'lat'=>#{slat}..#{elat},'p'=>lev,'time'=>time ),vwind.cut('lon'=>"#{slon}".."#{elon}",'lat'=>#{slat}..#{elat},'p'=>lev,'time'=>time ), true, 'map_axes'=>true, 'xintv'=>1,'yintv'=>1 )
end
end
DCL.grcls
Rdoc を使おう
参考URL: http://ruby.gfd-dennou.org/index-j.htm
インストールは, 以下のように打つだけ(CentOS 5.5の場合).
# yum install rdoc
Link
Ruby netCDF