This is an automated email from the git hooks/post-receive script. uwabami-guest pushed a commit to branch master in repository ruby-netcdf.
commit 0baa890c715fcd049b598c1e16cd2a70c2023aff Author: Youhei SASAKI <uwab...@gfd-dennou.org> Date: Wed Sep 2 21:18:42 2015 +0900 Refresh patch: fix location of netcdf_miss.rb Signed-off-by: Youhei SASAKI <uwab...@gfd-dennou.org> --- debian/patches/0001-Change-FHS-For-RubyGems | 453 +++++++++++++--------------- 1 file changed, 209 insertions(+), 244 deletions(-) diff --git a/debian/patches/0001-Change-FHS-For-RubyGems b/debian/patches/0001-Change-FHS-For-RubyGems index 6b7da38..873e83d 100644 --- a/debian/patches/0001-Change-FHS-For-RubyGems +++ b/debian/patches/0001-Change-FHS-For-RubyGems @@ -28,9 +28,6 @@ Signed-off-by: Youhei SASAKI <uwab...@gfd-dennou.org> delete mode 100644 lib/version.rb delete mode 100644 netcdfraw.c -diff --git a/ext/numru/extconf.rb b/ext/numru/extconf.rb -new file mode 100644 -index 0000000..1ad8b17 --- /dev/null +++ b/ext/numru/extconf.rb @@ -0,0 +1,173 @@ @@ -207,9 +204,6 @@ index 0000000..1ad8b17 + end +} +newmkfl.close -diff --git a/ext/numru/netcdfraw.c b/ext/numru/netcdfraw.c -new file mode 100644 -index 0000000..200e8f3 --- /dev/null +++ b/ext/numru/netcdfraw.c @@ -0,0 +1,4721 @@ @@ -4934,9 +4928,6 @@ index 0000000..200e8f3 + rb_define_method(cNetCDFVar,"get_var1_sfloat",NetCDF_get_var1_float,1); + rb_define_method(cNetCDFVar,"get_var1_float",NetCDF_get_var1_double,1); +} -diff --git a/extconf.rb b/extconf.rb -deleted file mode 100644 -index 1ad8b17..0000000 --- a/extconf.rb +++ /dev/null @@ -1,173 +0,0 @@ @@ -5113,8 +5104,6 @@ index 1ad8b17..0000000 - end -} -newmkfl.close -diff --git a/lib/netcdf.rb b/lib/netcdf.rb -index 2c6a922..dee5bd7 100644 --- a/lib/netcdf.rb +++ b/lib/netcdf.rb @@ -1,808 +1 @@ @@ -5927,9 +5916,6 @@ index 2c6a922..dee5bd7 100644 - end -end +require 'numru/netcdf' -diff --git a/lib/netcdf_miss.rb b/lib/netcdf_miss.rb -deleted file mode 100644 -index 4b168f0..0000000 --- a/lib/netcdf_miss.rb +++ /dev/null @@ -1,203 +0,0 @@ @@ -6136,9 +6122,6 @@ index 4b168f0..0000000 - file.close - print "** ncdump tmp.nc **\n", `ncdump tmp.nc` -end -diff --git a/lib/numru/netcdf.rb b/lib/numru/netcdf.rb -new file mode 100644 -index 0000000..2c6a922 --- /dev/null +++ b/lib/numru/netcdf.rb @@ -0,0 +1,808 @@ @@ -6950,218 +6933,6 @@ index 0000000..2c6a922 + + end +end -diff --git a/lib/numru/netcdf/netcdf_miss.rb b/lib/numru/netcdf/netcdf_miss.rb -new file mode 100644 -index 0000000..4b168f0 ---- /dev/null -+++ b/lib/numru/netcdf/netcdf_miss.rb -@@ -0,0 +1,203 @@ -+require "numru/netcdf" -+require "narray_miss" -+ -+module NumRu -+ -+ class NetCDFVar -+ -+ def get_with_miss(*args) -+ __interpret_missing_params if !defined?(@missval) -+ data = simple_get(*args) -+ if @vmin || @vmax -+ if @vmin -+ mask = (data >= @vmin) -+ mask = mask.and(data <= @vmax) if @vmax -+ else -+ mask = (data <= @vmax) -+ end -+ data = NArrayMiss.to_nam(data, mask) -+ elsif @missval # only missing_value is present. -+ mask = (data.ne(@missval)) -+ data = NArrayMiss.to_nam(data, mask) -+ end -+ data -+ end -+ -+ def get_with_miss_and_scaling(*args) -+ __interpret_missing_params if !defined?(@missval) -+ data = simple_get(*args) -+ if @vmin || @vmax -+ if @vmin -+ mask = (data >= @vmin) -+ mask = mask.and(data <= @vmax) if @vmax -+ else -+ mask = (data <= @vmax) -+ end -+ data = NArrayMiss.to_nam(data, mask) -+ elsif @missval # only missing_value is present. -+ mask = (data.ne(@missval)) -+ data = NArrayMiss.to_nam(data, mask) -+ end -+ data = unpack( data ) -+ data -+ end -+ -+ def put_with_miss(data, *args) -+ if data.is_a?( NArrayMiss ) -+ __interpret_missing_params if !defined?(@missval) -+ if @missval -+ simple_put(data.to_na(@missval), *args) -+ else -+ simple_put(data.to_na, *args) -+ end -+ else -+ simple_put(data, *args) -+ end -+ end -+ -+ def put_with_miss_and_scaling(data, *args) -+ if data.is_a?( NArrayMiss ) -+ __interpret_missing_params if !defined?(@missval) -+ if @missval -+ data = pack( data ) -+ data = data.to_na(@missval) -+ else -+ data = pack( data ) -+ data = data.to_na -+ end -+ simple_put(data, *args) -+ else -+ scaled_put(data, *args) -+ end -+ end -+ -+ ######### private ########## -+ -+ def __interpret_missing_params -+ # Interprets the specification of missing data, -+ # either by valid_range, (valid_min and/or valid_max), or missing_value. -+ # (unlike the NetCDF User's guide (NUG), missing_value is interpreted, -+ # but valid_* has a higher precedence.) -+ # Always sets @missval whether missing_value is defined or not, -+ # since it will be used as a fill value for data missing. -+ # -+ @vmin = att('valid_min') -+ @vmin = @vmin.get if @vmin # kept in a NArray(size==1) to consv type -+ @vmax = att('valid_max') -+ @vmax = @vmax.get if @vmax # kept in a NArray(size==1) to consv type -+ vrange = att('valid_range') -+ vrange = vrange.get if vrange -+ if vrange -+ vrange.sort! -+ @vmin = vrange[0..0] # kept in... (same) -+ @vmax = vrange[-1..-1] # kept in... (same) -+ end -+ @missval = att('missing_value') || att('_FillValue') -+ @missval = @missval.get if @missval # kept in... (same) -+ -+ sf = att('scale_factor') -+ ao = att('add_offset') -+ if ( sf || ao ) -+ ## Both NUG & CF conventions requires to specify the valid -+ ## range with respect to the external (i.e. packed) values. -+ ## However, some conventions require specification -+ ## with respect to unpacked values. The following -+ ## is to support such cases as well: -+ thres_tp = [ self.typecode, NArray::LINT ].max -+ @missval = pack(@missval) if @missval && @missval.typecode > thres_tp -+ @vmin = pack(@vmin) if @vmin && @vmin.typecode > thres_tp -+ @vmax = pack(@vmax) if @vmax && @vmax.typecode > thres_tp -+ end -+ -+ if @missval -+ if @vmin && @vmax -+ if @vmin[0] <= @missval[0] && @missval[0] <= @vmax[0] -+ warn "WARNING: missing_value #{@missval[0]} is in the valid range #{@vmin[0]}..#{@vmax[0]} --> will be ignored (#{__FILE__}:#{__LINE__})" -+ end -+ else -+ if @vmin && @missval[0] >= @vmin[0] -+ warn "WARNING: missing_value #{@missval[0]} >= valid min #{@vmin[0]} --> will be ignored (#{__FILE__}:#{__LINE__})" -+ elsif @vmax && @missval[0] <= @vmax[0] -+ warn "WARNING: missing_value #{@missval[0]} <= valid min #{@vmin[0]} --> will be ignored (#{__FILE__}:#{__LINE__})" -+ end -+ end -+ else -+ realtc = NArray::SFLOAT -+ if @vmin -+ if @vmin[0] >= 0 -+ @missval = ( @vmin.typecode>=realtc ? 0.99*@vmin : @vmin-1 ) -+ else -+ @missval = ( @vmin.typecode>=realtc ? 1.01*@vmin : @vmin-1 ) -+ end -+ elsif @vmax -+ if @vmax[0] >= 0 -+ @missval = ( @vmax.typecode>=realtc ? 1.01*@vmax : @vmax+1 ) -+ else -+ @missval = ( @vmax.typecode>=realtc ? 0.99*@vmax : @vmax+1 ) -+ end -+ end -+ end -+ -+ end -+ -+ private :__interpret_missing_params -+ -+ end -+ -+end -+ -+if $0 == __FILE__ -+ include NumRu -+ -+ filename = "tmp.nc" -+ print "creating ",filename,"...\n" -+ file=NetCDF.create(filename) -+ nx = 10 -+ dimx = file.def_dim("x",nx) -+ xf = file.def_var("xf","sfloat",[dimx]) -+ xfn = file.def_var("xfn","sfloat",[dimx]) -+ xf.put_att("valid_range",[-1e12,1e12]) -+ f = 10 ** (2*NArray.sfloat(nx).indgen!) -+ xr = file.def_var("xr","sint",[dimx]) -+ xr.put_att("valid_max",[0.5]) -+ xr.put_att("scale_factor",1e-4) -+ xr.put_att("add_offset",0.5) -+ xr2 = file.def_var("xr2","sint",[dimx]) -+ xr2.put_att("valid_max",NArray.sint(1).fill!(1000)) -+ xr2.put_att("scale_factor",1e-4) -+ xr2.put_att("add_offset",0.5) -+ r = NArray.sfloat(nx).indgen!/nx -+ file.enddef -+ xf.put(f) -+ xfn.put(f) -+ xr.scaled_put(r) -+ file.close -+ -+ file = NetCDF.open(filename,'r+') -+ xf = file.var('xf') -+ xfn = file.var('xfn') -+ p "f0" -+ xf.get.each{|v| print "#{v} "} ; print "\n" -+ p( 'f1', nam = xf.get_with_miss ) -+ def xf.get(*args); get_with_miss(*args); end -+ p( 'f12', xf[2..-3].to_na ) -+ p( 'fn10', xfn.get_with_miss ) -+ p( 'fn11', xfn.get_with_miss_and_scaling ) -+ nam.invalidation([0,1]) -+ p 'f2', nam -+ xf.put_with_miss(nam) -+ p( 'f3', xf.get_with_miss ) -+ xr = file.var('xr') -+ p "r0" -+ xr.simple_get.each{|v| print "#{v} "} ; print "\n" -+ p( 'r1', xr.get_with_miss_and_scaling ) -+ def xr.get(*args); get_with_miss_and_scaling(*args); end -+ def xr.put(*args); put_with_miss_and_scaling(*args); end -+ #xr[0..3] = xr[0..3]*10 -+ p( 'r2', xr.get_with_miss_and_scaling ) -+ p 'r',r -+ xr2.put_with_miss_and_scaling(r) -+ p 'xr2',xr2.get_with_miss_and_scaling -+ file.close -+ print "** ncdump tmp.nc **\n", `ncdump tmp.nc` -+end -diff --git a/lib/numru/netcdf/version.rb b/lib/numru/netcdf/version.rb -new file mode 100644 -index 0000000..7043c9e --- /dev/null +++ b/lib/numru/netcdf/version.rb @@ -0,0 +1,5 @@ @@ -7170,9 +6941,6 @@ index 0000000..7043c9e + VERSION = "0.7.1.1" + end +end -diff --git a/lib/version.rb b/lib/version.rb -deleted file mode 100644 -index 7043c9e..0000000 --- a/lib/version.rb +++ /dev/null @@ -1,5 +0,0 @@ @@ -7181,11 +6949,9 @@ index 7043c9e..0000000 - VERSION = "0.7.1.1" - end -end -diff --git a/metadata.yml b/metadata.yml -index fb30c35..25a1eda 100644 --- a/metadata.yml +++ b/metadata.yml -@@ -49,7 +49,7 @@ email: +@@ -49,7 +49,7 @@ - er...@gfd-dennou.org executables: [] extensions: @@ -7194,7 +6960,7 @@ index fb30c35..25a1eda 100644 extra_rdoc_files: [] files: - .gitignore -@@ -76,11 +76,12 @@ files: +@@ -76,11 +76,12 @@ - doc/Ref_man_jp.html - doc/Ref_man_jp.rd - doc/to_html @@ -7211,9 +6977,6 @@ index fb30c35..25a1eda 100644 - ruby-netcdf.gemspec - test/aref_aset.rb - test/char_var.rb -diff --git a/netcdfraw.c b/netcdfraw.c -deleted file mode 100644 -index 200e8f3..0000000 --- a/netcdfraw.c +++ /dev/null @@ -1,4721 +0,0 @@ @@ -11938,19 +11701,15 @@ index 200e8f3..0000000 - rb_define_method(cNetCDFVar,"get_var1_sfloat",NetCDF_get_var1_float,1); - rb_define_method(cNetCDFVar,"get_var1_float",NetCDF_get_var1_double,1); -} -diff --git a/ruby-netcdf.gemspec b/ruby-netcdf.gemspec -index a6025bc..3886c35 100644 --- a/ruby-netcdf.gemspec +++ b/ruby-netcdf.gemspec -@@ -30,5 +30,5 @@ Gem::Specification.new do |spec| +@@ -30,5 +30,5 @@ spec.add_runtime_dependency(%q<narray>, [">= 0"]) spec.add_runtime_dependency(%q<narray_miss>, [">= 0"]) - spec.extensions << "extconf.rb" + spec.extensions << "ext/numru/extconf.rb" end -diff --git a/test/test.rb b/test/test.rb -index 7ec59c6..b125a69 100644 --- a/test/test.rb +++ b/test/test.rb @@ -1,9 +1,4 @@ @@ -11964,3 +11723,209 @@ index 7ec59c6..b125a69 100644 include NumRu +--- /dev/null ++++ b/lib/numru/netcdf_miss.rb +@@ -0,0 +1,203 @@ ++require "numru/netcdf" ++require "narray_miss" ++ ++module NumRu ++ ++ class NetCDFVar ++ ++ def get_with_miss(*args) ++ __interpret_missing_params if !defined?(@missval) ++ data = simple_get(*args) ++ if @vmin || @vmax ++ if @vmin ++ mask = (data >= @vmin) ++ mask = mask.and(data <= @vmax) if @vmax ++ else ++ mask = (data <= @vmax) ++ end ++ data = NArrayMiss.to_nam(data, mask) ++ elsif @missval # only missing_value is present. ++ mask = (data.ne(@missval)) ++ data = NArrayMiss.to_nam(data, mask) ++ end ++ data ++ end ++ ++ def get_with_miss_and_scaling(*args) ++ __interpret_missing_params if !defined?(@missval) ++ data = simple_get(*args) ++ if @vmin || @vmax ++ if @vmin ++ mask = (data >= @vmin) ++ mask = mask.and(data <= @vmax) if @vmax ++ else ++ mask = (data <= @vmax) ++ end ++ data = NArrayMiss.to_nam(data, mask) ++ elsif @missval # only missing_value is present. ++ mask = (data.ne(@missval)) ++ data = NArrayMiss.to_nam(data, mask) ++ end ++ data = unpack( data ) ++ data ++ end ++ ++ def put_with_miss(data, *args) ++ if data.is_a?( NArrayMiss ) ++ __interpret_missing_params if !defined?(@missval) ++ if @missval ++ simple_put(data.to_na(@missval), *args) ++ else ++ simple_put(data.to_na, *args) ++ end ++ else ++ simple_put(data, *args) ++ end ++ end ++ ++ def put_with_miss_and_scaling(data, *args) ++ if data.is_a?( NArrayMiss ) ++ __interpret_missing_params if !defined?(@missval) ++ if @missval ++ data = pack( data ) ++ data = data.to_na(@missval) ++ else ++ data = pack( data ) ++ data = data.to_na ++ end ++ simple_put(data, *args) ++ else ++ scaled_put(data, *args) ++ end ++ end ++ ++ ######### private ########## ++ ++ def __interpret_missing_params ++ # Interprets the specification of missing data, ++ # either by valid_range, (valid_min and/or valid_max), or missing_value. ++ # (unlike the NetCDF User's guide (NUG), missing_value is interpreted, ++ # but valid_* has a higher precedence.) ++ # Always sets @missval whether missing_value is defined or not, ++ # since it will be used as a fill value for data missing. ++ # ++ @vmin = att('valid_min') ++ @vmin = @vmin.get if @vmin # kept in a NArray(size==1) to consv type ++ @vmax = att('valid_max') ++ @vmax = @vmax.get if @vmax # kept in a NArray(size==1) to consv type ++ vrange = att('valid_range') ++ vrange = vrange.get if vrange ++ if vrange ++ vrange.sort! ++ @vmin = vrange[0..0] # kept in... (same) ++ @vmax = vrange[-1..-1] # kept in... (same) ++ end ++ @missval = att('missing_value') || att('_FillValue') ++ @missval = @missval.get if @missval # kept in... (same) ++ ++ sf = att('scale_factor') ++ ao = att('add_offset') ++ if ( sf || ao ) ++ ## Both NUG & CF conventions requires to specify the valid ++ ## range with respect to the external (i.e. packed) values. ++ ## However, some conventions require specification ++ ## with respect to unpacked values. The following ++ ## is to support such cases as well: ++ thres_tp = [ self.typecode, NArray::LINT ].max ++ @missval = pack(@missval) if @missval && @missval.typecode > thres_tp ++ @vmin = pack(@vmin) if @vmin && @vmin.typecode > thres_tp ++ @vmax = pack(@vmax) if @vmax && @vmax.typecode > thres_tp ++ end ++ ++ if @missval ++ if @vmin && @vmax ++ if @vmin[0] <= @missval[0] && @missval[0] <= @vmax[0] ++ warn "WARNING: missing_value #{@missval[0]} is in the valid range #{@vmin[0]}..#{@vmax[0]} --> will be ignored (#{__FILE__}:#{__LINE__})" ++ end ++ else ++ if @vmin && @missval[0] >= @vmin[0] ++ warn "WARNING: missing_value #{@missval[0]} >= valid min #{@vmin[0]} --> will be ignored (#{__FILE__}:#{__LINE__})" ++ elsif @vmax && @missval[0] <= @vmax[0] ++ warn "WARNING: missing_value #{@missval[0]} <= valid min #{@vmin[0]} --> will be ignored (#{__FILE__}:#{__LINE__})" ++ end ++ end ++ else ++ realtc = NArray::SFLOAT ++ if @vmin ++ if @vmin[0] >= 0 ++ @missval = ( @vmin.typecode>=realtc ? 0.99*@vmin : @vmin-1 ) ++ else ++ @missval = ( @vmin.typecode>=realtc ? 1.01*@vmin : @vmin-1 ) ++ end ++ elsif @vmax ++ if @vmax[0] >= 0 ++ @missval = ( @vmax.typecode>=realtc ? 1.01*@vmax : @vmax+1 ) ++ else ++ @missval = ( @vmax.typecode>=realtc ? 0.99*@vmax : @vmax+1 ) ++ end ++ end ++ end ++ ++ end ++ ++ private :__interpret_missing_params ++ ++ end ++ ++end ++ ++if $0 == __FILE__ ++ include NumRu ++ ++ filename = "tmp.nc" ++ print "creating ",filename,"...\n" ++ file=NetCDF.create(filename) ++ nx = 10 ++ dimx = file.def_dim("x",nx) ++ xf = file.def_var("xf","sfloat",[dimx]) ++ xfn = file.def_var("xfn","sfloat",[dimx]) ++ xf.put_att("valid_range",[-1e12,1e12]) ++ f = 10 ** (2*NArray.sfloat(nx).indgen!) ++ xr = file.def_var("xr","sint",[dimx]) ++ xr.put_att("valid_max",[0.5]) ++ xr.put_att("scale_factor",1e-4) ++ xr.put_att("add_offset",0.5) ++ xr2 = file.def_var("xr2","sint",[dimx]) ++ xr2.put_att("valid_max",NArray.sint(1).fill!(1000)) ++ xr2.put_att("scale_factor",1e-4) ++ xr2.put_att("add_offset",0.5) ++ r = NArray.sfloat(nx).indgen!/nx ++ file.enddef ++ xf.put(f) ++ xfn.put(f) ++ xr.scaled_put(r) ++ file.close ++ ++ file = NetCDF.open(filename,'r+') ++ xf = file.var('xf') ++ xfn = file.var('xfn') ++ p "f0" ++ xf.get.each{|v| print "#{v} "} ; print "\n" ++ p( 'f1', nam = xf.get_with_miss ) ++ def xf.get(*args); get_with_miss(*args); end ++ p( 'f12', xf[2..-3].to_na ) ++ p( 'fn10', xfn.get_with_miss ) ++ p( 'fn11', xfn.get_with_miss_and_scaling ) ++ nam.invalidation([0,1]) ++ p 'f2', nam ++ xf.put_with_miss(nam) ++ p( 'f3', xf.get_with_miss ) ++ xr = file.var('xr') ++ p "r0" ++ xr.simple_get.each{|v| print "#{v} "} ; print "\n" ++ p( 'r1', xr.get_with_miss_and_scaling ) ++ def xr.get(*args); get_with_miss_and_scaling(*args); end ++ def xr.put(*args); put_with_miss_and_scaling(*args); end ++ #xr[0..3] = xr[0..3]*10 ++ p( 'r2', xr.get_with_miss_and_scaling ) ++ p 'r',r ++ xr2.put_with_miss_and_scaling(r) ++ p 'xr2',xr2.get_with_miss_and_scaling ++ file.close ++ print "** ncdump tmp.nc **\n", `ncdump tmp.nc` ++end -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/ruby-netcdf.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel