lib/numru/ganalysis/eof.rb in gphys-1.5.3 vs lib/numru/ganalysis/eof.rb in gphys-1.5.4

- old
+ new

@@ -91,14 +91,18 @@ raise "shape of weight is invalid" end w /= w.mean w.reshape!(n) else - if !(opts[:disable_weight]||opts["disable_weight"]) && /^lon/ =~ new_grid.coord(0).name && /^lat/ =~ new_grid.coord(1).name + nc0 = new_grid.coord(0) + nc1 = new_grid.coord(1) + if !(opts[:disable_weight]||opts["disable_weight"]) && + ( /^lon/ =~ nc0.name || /^degree.*_east/ =~ nc0.units.to_s ) && + ( /^lat/ =~ nc1.name || /^degree.*_north/ =~ nc1.units.to_s ) rad = NumRu::Units.new("radian") - nlon = new_grid.coord(0).length - lat = new_grid.coord(1).convert_units(rad).val + nlon = nc0.length + lat = nc1.convert_units(rad).val w = NArray.new(lat.typecode,nlon).fill!(1) * NMath::cos(lat).reshape(1,lat.length) w /= w.mean w.reshape!(n) else w = nil @@ -110,11 +114,12 @@ ind = Array.new(ind_rank,0) n.times{|n1| index[dims1] = ind val = gphys[*index].val val.reshape!(n_lost) - val -= val.mean + vm = val.mean + val -= vm unless vm.nil? ary[true,n1] = val break if n1==n-1 ind[0] += 1 ind_rank.times{|i| if ind[i] == shape1[i] @@ -123,11 +128,10 @@ else break end } } - ary.mul!(w.reshape(1,n)) if w - + ary = ary.mul!(w.reshape(1,n)) if w nmodes = opts[:nmodes] || opts["nmodes"] || n case @@EOF_engin when "ssl2" print "start calc covariance matrix\n" if $DEBUG