[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dennou-ruby:002687] GGraph (itr=10) 'map_fit'=false & 'map_axes'=true
- To: dennou-ruby@xxxxxxxxxxx
- Subject: [dennou-ruby:002687] GGraph (itr=10) 'map_fit'=false & 'map_axes'=true
- From: KOSHIRO Tsuyoshi <koshiro@xxxxxxxxxxxxxx>
- Date: Wed, 16 Aug 2006 15:25:18 +0900
神代です.
GGraphでの地図投影を少し改良してみました.
(以前作りかけのものを堀之内さんにメールしたことがあるやつです)
itr=10で軸描きは,データのwindowと地図の範囲を一致させた場合('map_fit'
=>trueの場合)しか想定されておらず,map_fit=false, map_axes=true にする
とエラーで終了してしまうのですが,'map_fit'=>false の場合でも地図の範
囲に対して軸描きしたくて,作ってみました.
パッチを添付します.最新のCVS資源との差分です.
具体的には,contour/tone/vector の map_axes=true の場合の処理部分で,
DCL.sgqwnd で取得した window値が不定値かどうかで map_fit の真偽を判定
し,false の場合は DCL.sgqtxyで取得した地図の範囲にしたがって軸を描く
ようにしました.
また,DCLExt::flow_vect も DCL.sgqwnd の window値を参照しているので,
同様の変更をしました.
テストスクリプトも添付します.gphys/sample/map_projection.rb を改変し
たものです.gphys/sample に置いて実行できます.
--- ggraph.rb_orig 2006-08-16 12:19:01.932785000 +0900
+++ ggraph.rb 2006-08-16 14:21:45.541558260 +0900
@@ -1535,7 +1535,12 @@
end
nx, ny = fx.shape # again, because of xintv & yintv
vx0,vx1,vy0,vy1 = DCL.sgqvpt
- ux0,ux1,uy0,uy1 = DCL.sgqwnd
+ wnd = DCL.sgqwnd
+ if wnd.include?(DCL.glrget('rundef'))
+ ux0,ux1,uy0,uy1 = DCL.sgqtxy
+ else
+ ux0,ux1,uy0,uy1 = wnd
+ end
dvx = (vx1-vx0)/nx
dvy = (vy1-vy0)/ny
ax = (vx1-vx0)/(ux1-ux0) # factor to convert from U to V coordinate
@@ -2784,9 +2789,16 @@
ttl = (opts['title'] || gp.data.get_att('long_name'))
if map_trn?
map
- if opts['map_axes']
+ if opts['map_axes'] && itr_is?(10)
vpt = DCL.sgqvpt
- wnd= DCL.sgqwnd
+ wnd = DCL.sgqwnd
+ if wnd.include?(DCL.glrget('rundef'))
+ map_fit = false
+ wnd = DCL.sgqtxy
+ cnt = DCL.umqcnt
+ else
+ map_fit = true
+ end
vrat = ( (vpt[3]-vpt[2]) / (vpt[1]-vpt[0]) ).abs
wrat = ( (wnd[3]-wnd[2]) / (wnd[1]-wnd[0]) ).abs
if wrat < vrat
@@ -2801,10 +2813,25 @@
vpt[1] = vxoff + dvx2
end
trn = DCL.sgqtrn
- fig(xax,yax, {'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
- axes(xax, yax)
+ if map_fit
+ fig(xax,yax, {'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
+ axes(xax, yax)
+ title( ttl )
+ DCL.sgstrn(trn)
+ else
+ xax_map = xax[0..1].copy
+ xax_map[0] = cnt[0] + wnd[0]
+ xax_map[1] = cnt[0] + wnd[1]
+ yax_map = yax[0..1].copy
+ yax_map[0] = wnd[2]
+ yax_map[1] = wnd[3]
+ fig(xax_map,yax_map,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
+ axes(xax_map,yax_map)
+ title( ttl )
+ fig(xax_map,yax_map,{'itr'=>trn, 'new_frame'=>false, 'viewport'=>vpt, 'map_fit'=>false, 'map_axis'=>cnt, 'map_window'=>wnd})
+ end
+ else
title( ttl )
- DCL.sgstrn(trn)
end
elsif itr_is?(5)
polar_coordinate_boundaries(xax,yax)
@@ -2974,9 +3001,16 @@
ttl = (opts['title'] || gp.data.get_att('long_name'))
if map_trn?
map
- if opts['map_axes']
+ if opts['map_axes'] && itr_is?(10)
vpt = DCL.sgqvpt
- wnd= DCL.sgqwnd
+ wnd = DCL.sgqwnd
+ if wnd.include?(DCL.glrget('rundef'))
+ map_fit = false
+ wnd = DCL.sgqtxy
+ cnt = DCL.umqcnt
+ else
+ map_fit = true
+ end
vrat = ( (vpt[3]-vpt[2]) / (vpt[1]-vpt[0]) ).abs
wrat = ( (wnd[3]-wnd[2]) / (wnd[1]-wnd[0]) ).abs
if wrat < vrat
@@ -2991,10 +3025,23 @@
vpt[1] = vxoff + dvx2
end
trn = DCL.sgqtrn
- fig(xax,yax,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
- axes(xax, yax)
- title( ttl )
- DCL.sgstrn(trn)
+ if map_fit
+ fig(xax,yax, {'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
+ axes(xax, yax)
+ title( ttl )
+ DCL.sgstrn(trn)
+ else
+ xax_map = xax[0..1].copy
+ xax_map[0] = cnt[0] + wnd[0]
+ xax_map[1] = cnt[0] + wnd[1]
+ yax_map = yax[0..1].copy
+ yax_map[0] = wnd[2]
+ yax_map[1] = wnd[3]
+ fig(xax_map,yax_map,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
+ axes(xax_map,yax_map)
+ title( ttl )
+ fig(xax_map,yax_map,{'itr'=>trn, 'new_frame'=>false, 'viewport'=>vpt, 'map_fit'=>false, 'map_axis'=>cnt, 'map_window'=>wnd})
+ end
else
title( ttl )
end
@@ -3092,9 +3139,16 @@
end
if map_trn?
map
- if opts['map_axes']
+ if opts['map_axes'] && itr_is?(10)
vpt = DCL.sgqvpt
- wnd= DCL.sgqwnd
+ wnd = DCL.sgqwnd
+ if wnd.include?(DCL.glrget('rundef'))
+ map_fit = false
+ wnd = DCL.sgqtxy
+ cnt = DCL.umqcnt
+ else
+ map_fit = true
+ end
vrat = ( (vpt[3]-vpt[2]) / (vpt[1]-vpt[0]) ).abs
wrat = ( (wnd[3]-wnd[2]) / (wnd[1]-wnd[0]) ).abs
if wrat < vrat
@@ -3109,10 +3163,23 @@
vpt[1] = vxoff + dvx2
end
trn = DCL.sgqtrn
- fig(xax,yax,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
- axes(xax, yax)
- title( ttl )
- DCL.sgstrn(trn)
+ if map_fit
+ fig(xax,yax,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
+ axes(xax, yax)
+ title( ttl )
+ DCL.sgstrn(trn)
+ else
+ xax_map = xax[0..1].copy
+ xax_map[0] = cnt[0] + wnd[0]
+ xax_map[1] = cnt[0] + wnd[1]
+ yax_map = yax[0..1].copy
+ yax_map[0] = wnd[2]
+ yax_map[1] = wnd[3]
+ fig(xax_map,yax_map,{'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
+ axes(xax_map,yax_map)
+ title( ttl )
+ fig(xax_map,yax_map,{'itr'=>trn, 'new_frame'=>false, 'viewport'=>vpt, 'map_fit'=>false, 'map_axis'=>cnt, 'map_window'=>wnd})
+ end
else
title( ttl )
end
require 'numru/ggraph'
include NumRu
wsn = ( ARGV[0] ? ARGV[0].to_i : 1 )
path = '../testdata/T.jan.nc'
var = 'T'
gp = GPhys::IO.open(path,var)
DCL.swpset('ldump',true) if wsn == 4
DCL.gropn(wsn)
DCL.sldiv('t',3,2)
DCL.uzfact(0.8)
DCL.sgpset('lcntl',false)
GGraph.set_map('coast_world'=>true)
gpjpn = gp.cut(110..160,10..70,false)
itr = 10
# contour
GGraph.next_fig('itr'=>itr)
GGraph.contour(gp,true,'title'=>'map_fit=T, map_axes=F (default)')
GGraph.next_fig('itr'=>itr)
GGraph.contour(gp, true,'map_axes'=>true,'title'=>'map_fit=T map_axes=T')
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.contour(gp,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F' )
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.contour(gp,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T')
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[-120,120,-60,60])
GGraph.contour(gp,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F map_axis & map_window' )
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[-120,120,-60,60])
GGraph.contour(gp,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T map_axis & map_window')
# tone
GGraph.next_fig('itr'=>itr)
GGraph.tone(gp,true,'title'=>'map_fit=T, map_axes=F (default)')
GGraph.next_fig('itr'=>itr)
GGraph.tone(gp, true,'map_axes'=>true,'title'=>'map_fit=T map_axes=T')
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.tone(gp,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F' )
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.tone(gp,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T')
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[-120,120,-60,60])
GGraph.tone(gp,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F map_axis & map_window' )
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[-120,120,-60,60])
GGraph.tone(gp,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T map_axis & map_window')
# tone & contour
GGraph.next_fig('itr'=>itr)
GGraph.tone(gpjpn,true,'title'=>'map_fit=T, map_axes=F (default)')
GGraph.contour( gpjpn, false )
GGraph.next_fig('itr'=>itr)
GGraph.tone(gpjpn, true,'map_axes'=>true,'title'=>'map_fit=T map_axes=T')
GGraph.contour( gpjpn, false )
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.tone(gpjpn,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F' )
GGraph.contour( gpjpn, false )
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.tone(gpjpn,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T')
GGraph.contour( gpjpn, false )
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[90,180,0,90])
GGraph.tone(gpjpn,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F map_axis & map_window' )
GGraph.contour( gpjpn, false )
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[90,180,0,90])
GGraph.tone(gpjpn,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T map_axis & map_window')
GGraph.contour( gpjpn, false )
# vector ('flow_vect'=>false)
GGraph.next_fig('itr'=>itr)
GGraph.vector(gpjpn,gpjpn,true,'title'=>'map_fit=T, map_axes=F (default)','flow_vect'=>false,'unit_vect'=>true)
GGraph.next_fig('itr'=>itr)
GGraph.vector(gpjpn,gpjpn, true,'map_axes'=>true,'title'=>'map_fit=T map_axes=T','flow_vect'=>false,'unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F' ,'flow_vect'=>false,'unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T','unit_vect'=>true,'flow_vect'=>false,'unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[90,180,0,90])
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F map_axis & map_window','flow_vect'=>false,'unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[90,180,0,90])
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T map_axis & map_window','flow_vect'=>false,'unit_vect'=>true)
# vector ('flow_vect'=>true)
GGraph.next_fig('itr'=>itr)
GGraph.vector(gpjpn,gpjpn,true,'title'=>'map_fit=T, map_axes=F (default)','unit_vect'=>true)
GGraph.next_fig('itr'=>itr)
GGraph.vector(gpjpn,gpjpn, true,'map_axes'=>true,'title'=>'map_fit=T map_axes=T','unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F','unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false)
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T','unit_vect'=>true,'unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[90,180,0,90])
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>false,'title'=>'map_fit=F map_axes=F map_axis & map_window','unit_vect'=>true)
GGraph.next_fig('itr'=>itr,'map_fit'=>false,'map_axis'=>[0,0,0],'map_window'=>[90,180,0,90])
GGraph.vector(gpjpn,gpjpn,true,'map_axes'=>true,'title'=>'map_fit=F map_axes=T map_axis & map_window','unit_vect'=>true)
DCL.grcls