#
# NCEP データの月平均・東西平均分布をまとめて描画する ctl スクリプト
#
# * 2012/01/24 eps ファイルの作成を追記
# * 2011/12/06 drawzm_clim_mon_ctl を基に作成
#

require "numru/ggraph"
include NumRu

=begin
module NumRu
  class NetCDFVar
    alias :get :simple_get
  end
end
=end

dir = '..'

iyrs = 1988
iyre = 2007

figdir = 'figs_zm_clim_mon_NCEP'
Dir::mkdir( figdir )
Dir::mkdir( figdir+'/eps' )

for imon in 1..12

    p 'Month: ' + imon.to_s

    case imon
    when 1
      title = 'JAN.'
    when 2
      title = 'FEB.'
    when 3
      title = 'MAR.'
    when 4
      title = 'APR.'
    when 5
      title = 'MAY'
    when 6
      title = 'JUN.'
    when 7
      title = 'JUL.'
    when 8
      title = 'AUG'
    when 9
      title = 'SEP.'
    when 10
      title = 'OCT.'
    when 11
      title = 'NOV.'
    when 12
      title = 'DEC.'
    end

    system('ruby drawzm_clim_NCEP.rb ' + dir + ' ' + iyrs.to_s + ' ' + iyre.to_s + ' ' + imon.to_s + ' ' + title )
#    system('ruby test.rb ' + dir + ' ' + iyrs.to_s + ' ' + iyre.to_s + ' ' + imon.to_s + ' ' + title )

# gif ファイルの作成

    com = sprintf( "convert -rotate 90 dcl.ps dcl_mon%0#{2}d.gif" , imon )
    system(com)

# eps ファイルの作成

    com = sprintf( "convert -rotate 90 dcl.ps dcl_mon%0#{2}d.eps" , imon )
    system(com)

    if imon == 12 then

       com = sprintf( "gifsicle *gif --loopcount=20 >"+"clim_zm_mon_NCEP.gif" )
       system(com)

       com = sprintf( "mv *.gif "+figdir )
       system(com)

       com = sprintf( "mv *.eps "+figdir+"/eps/" )
       system(com)

    end
end

