[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dennou-ruby:002682] [gphys] bug: sample/cira86_to_nc.rb
- To: dennou-ruby@xxxxxxxxxxx
- Subject: [dennou-ruby:002682] [gphys] bug: sample/cira86_to_nc.rb
- From: KOSHIRO Tsuyoshi <koshiro@xxxxxxxxxxxxxx>
- Date: Mon, 14 Aug 2006 22:35:33 +0900
堀之内様:
神代です.
今日,CVS版のgphysを取ってきたのですが,以前(MLじゃなくて直接)報告した,
サンプルプログラム cira86_to_nc.rb のバグがまだなおってなかったので,
再送します.
At Tue, 21 Feb 2006 19:37:00 +0900,
KOSHIRO Tsuyoshi wrote:
> gphys のデモプログラムで動かないものがあるのでパッチを送ります.
ところで,ここで修正したように,VArray に
set_att('missing_value',gp_miss_val)
とするとき,gp_miss_val は,実数だと
/usr/local/lib/site_ruby/1.8/numru/gphys/attribute.rb:84:in `[]=': Not allowed as an attribute value: 1.0e+30 (ArgumentError)
from /usr/local/lib/site_ruby/1.8/numru/gphys/varray.rb:507:in `set_att'
from cira86_to_nc.rb:94
とエラーになります.gphys/attribute.rb を見ると,
## val.is_a?(Numeric) || # disabled 2005/03/25 by horinout
となっているので,これは意図した動作なんですよね.
RubyNetCDF で put_att するときは,
tmp.put_att("missing_value",-1000.0,"sfloat")
などとできますが.
diff -uNr gphys-0.5.1_orig/sample/cira86_to_nc.rb gphys-0.5.1/sample/cira86_to_nc.rb
--- gphys-0.5.1_orig/sample/cira86_to_nc.rb 2003-09-26 13:34:03.001000000 +0900
+++ gphys-0.5.1/sample/cira86_to_nc.rb 2006-02-14 02:53:21.117801600 +0900
@@ -38,19 +38,19 @@
for imon in 0...nmon
dummy = file.gets
for iht in 0...nht
- data = file.gets.strip.split(' +').collect{|v| v.to_f}
+ data = file.gets.strip.split(/ +/).collect{|v| v.to_f}
ht[iht] = data.shift
prs[iht] = data.shift
temp[iht,true,imon] = data
end
dummy = file.gets
for iht in 0...nht
- data = file.gets.strip.split(' +').collect{|v| v.to_f}
+ data = file.gets.strip.split(/ +/).collect{|v| v.to_f}
gph[iht,true,imon] = data[2..-1]
end
dummy = file.gets
for iht in 0...nht
- data = file.gets.strip.split(' +').collect{|v| v.to_f}
+ data = file.gets.strip.split(/ +/).collect{|v| v.to_f}
west[iht,true,imon] = data[2..-1]
end
end
@@ -67,6 +67,9 @@
gph[gph.eq(cira_miss_val)] = gp_miss_val
west[west.eq(cira_miss_val)] = gp_miss_val
+gp_miss_val = NArray.to_na(gp_miss_val).to_type('sfloat')
+valid_max = NArray.to_na(valid_max).to_type('sfloat')
+
#<< into GPhys >>
include NumRu