#!/usr/bin/env ruby
=begin
= mkfig-PRATE_EQ.rb -- 単位面積／単位時間あたりの赤道域降雨量の時系列図
=end


##########  設定部分 ここまで #############

require "getopts"        # for option_parse
require "numru/netcdf_miss"
require "ggraph-dcchart"
include NumRu
require "libdraw-n"
include Draw
require "libgphys-n"

module NumRu
  class NetCDFVar
#    alias get get_with_miss_and_scaling
#    def self.put(*args); put_with_miss_and_scaling(*args) end
  end
end


# set User Path for dcldatabase
DCL.glcset('DUPATH','/home/daktu32/.dcldir/')     


sfile = ARGV[0]
lfile = ARGV[1]

#gphys_s = GPhys::NetCDF_IO.open(sfile, "cfnsf")[true, true, 0..848].mean("lon").mean("time").cut("lat"=>-80..80)
gphys_s = GPhys::NetCDF_IO.open(sfile, "cfnsf").mean("lon").mean("time").cut("lat"=>-60..60)
#gphys_l = GPhys::NetCDF_IO.open(lfile, "cfnlf")[true, true, 0..848].mean("lon").mean("time").cut("lat"=>-80..80)
gphys_l = GPhys::NetCDF_IO.open(lfile, "cfnlf").mean("lon").mean("time").cut("lat"=>-60..60)
gphys = gphys_s + gphys_l

gphys_s.data.set_att("line_name", "Cloud Forcing Net Shortwave Flux")
gphys_l.data.set_att("line_name", "Cloud Forcing Net Longtwave Flux")
gphys.data.set_att("line_name", "Cloud Forcing Net Total Flux")


################################################################
#                        描画ルーチン
################################################################

#$OPT_f = true

##
# 事前準備

DCL.uscset('cyspos', 'B' )              # y 軸の単位の位置を下方へ 
rsizel2 = DCL.uzrget('rsizel2')         # 現在のラベルサイズを取得
DCL.uzrset('rsizel2', rsizel2*0.42 )    # ラベルサイズをデフォルトの 0.5 倍に

##
# お絵描きメイン

Draw::mkwin([0.25, 0.75, 0.2, 0.65])                         # ウィンドウオープン

#Draw::plot_line_main([gphys, gphys_s, gphys_l], "min"=>0, "max"=>)
Draw::plot_line_main([gphys, gphys_s, gphys_l], "min"=>-80, "max"=>80)

Draw::clwin                             # ウィンドウクローズ

