# -*- coding: utf-8 -*-
# NetCDF ファイルから画像を切り出す Ruby スクリプト
# main = で NetCDF データを指定

require "numru/ggraph"
include NumRu
include GGraph

filename = "BS1998_PTemp.nc"
var = "PTemp"
=begin
DCL.swpset('iwidth',700)      # window width                                    
DCL.swpset('iheight',700)     # window height                                   
###DCL.swpset('ldump',true)      # dump image files                             
DCL.swpset('lwait',false)     # do not wait mouse click to show the next page   
###DCL.swpset('lalt',true)       # background plot                              
DCL.sgscmn(10)                # change colomap (see below)                      
###DCL.sgscmn(5)                 # change colomap (see below)   
=end
DCL.swlset( 'ldump', true )
DCL.gropn(2)

main = GPhys::IO.open("#{filename}", "#{var}")
time = GPhys::IO.open("#{filename}", 't').val
p main

GGraph.set_linear_contour_options( 'min'=>0, 'max'=>6.0, 'interval'=>1)
GGraph.set_linear_tone_options( 'min'=>0, 'max'=>6.0, 'interval'=>1)
p main.mean(0, 1)

p main
#=begin
for i in 0...time.length do
p main.cut('t'=>time[i].to_f).mean(0, 2)
  GGraph.tone(main.cut('t'=>time[i].to_f) - main.cut('t'=>time[i].to_f).mean(0,2))
  GGraph.contour(main.cut('t'=>time[i].to_f) -  main.cut('t'=>time[i].to_f).mean(0,2))
  GGraph.color_bar( 'tickintv'=>4 )
end
#=end
DCL.grcls
