#!/usr/bin/ruby # coding: utf-8 # 使用するライブラリの読み込み require "numru/ggraph" include NumRu # NDFファイル"uwnd.mon.mean.nc"から変数"uwnd"を取り出しGPhysオブジェクトgpに格納 gp = GPhys::IO.open( "uwnd.mon.mean.nc", "uwnd" ) # 描画した図をpngファイルとして保存 DCL.swpset( "ifl", 1 ) DCL.gropn(2) # 描画の各種設定 DCL.uzfact(0.7) # フォントサイズを設定 DCL.sgpset( 'lclip', true ) # 軸範囲を超えた領域を描画しない DCL.glpset( 'lmiss', true ) # 欠損値処理 DCL.udpset( 'lmsg', false ) # 等値線間隔を表示しない # 描画画面を準備 # 横軸を線形軸, 縦軸を対数軸で描画(itr) GGraph.set_fig( 'itr'=>2 ) # 繰り返しの宣言 for i in 1..12 # 2019年各月月初の日付の文字列を生成 time_label = "2019-" + i.to_s + "-01 00:00:0.0" # 繰り返し回数, 日付を画面に表示 print i, " : ", time_label, "\n" # トーンで描画 # GPhysオブジェクトgp内の変数"uwind"から切り出したデータを緯度ごとに平均し描画(第一引数) # 新しく図を描画(第二引数) # タイトルを設定(title) # 図の右上の情報を非表示(annotate) # トーンの最小値を-60に設定(min) # トーンの最大値を80に設定(max) # トーンの間隔をを10に設定(interval) GGraph.tone( gp.cut('time'=>DateTime.parse(time_label)).mean('lon'), true, 'title'=>"Monthly Mean Zonal Wind", 'annotate'=>false, 'min'=>-60, 'max'=>80, 'interval'=>10 ) # 年月を右上に表示 DCL.uzpset( 'pad1', -3.2 ) ; DCL.uxsttl( 't', "2019-" + i.to_s, 1 ) ; DCL.uzpset( 'pad1', 0.7 ) # カラーバーを描画 GGraph.color_bar # トーンで描画 # GPhysオブジェクトgp内の変数"uwind"から切り出したデータを緯度ごとに平均し描画(第一引数) # 重ねて図を描画(第二引数) # 等値線の間隔を5に設定(interval) GGraph.contour( gp.cut('time'=>DateTime.parse(time_label)).mean('lon'), false, 'min'=>-50, 'max'=>60, 'interval'=>5 ) end DCL.grcls