gphys 1.5.5 → 1.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7aaecda27419a8adf9f1e781af6a5f20b99cc379
4
- data.tar.gz: 04e9c2a1bfc1f64f64b3a22dca57f58670cc253a
3
+ metadata.gz: 96baf70ba208aa464245d2d24de0c08a6f3af3d4
4
+ data.tar.gz: 10fd31971847395f74e6bcc34eaaf850a54b2dcf
5
5
  SHA512:
6
- metadata.gz: 22a6d4fd428e831e759cb0fdba47d3a13efa1a4dd274484875fd473588b0a6d4c479dc612d017c0a62686869d662ce5e37deda682b17903e333a5f0abc77a9ce
7
- data.tar.gz: f4acafc4f36955dbeec365137659ccfd5077f4372a5e379f21acde0670a1a8578216c6fc9a2c5e902749ccb62b4934a8db801642fcd4de34dcd1366d6ba7a919
6
+ metadata.gz: 9547009e1b3be0d64a542154c289f535886d7a5323f6055e5d762f57bcf7682be651938153ebacf6497751c746ce62e600abb8f26ed11e147db752cef64fc03b
7
+ data.tar.gz: 48172e1d51e732f92ab7e29b64fcd2ed5f7e73cde1f379261713fbff2adea8f4de2af2e92562917023b8a9d9cf5c5c46dba62ec57a655cb47db7c34bca431ff5
data/ChangeLog CHANGED
@@ -1,3 +1,80 @@
1
+ 2019-03-19 Takeshi Horinouchi
2
+ To release version 1.5.6 (git tag v1.5.6)
3
+
4
+ M lib/numru/gphys/version.rb
5
+
6
+ 2019-03-19 Takeshi Horinouchi
7
+ Update the years (to -2019)
8
+
9
+ M LICENSE.txt
10
+
11
+ 2019-03-19 Takeshi Horinouchi
12
+ to require 'numru/gphys/derivative' from the begining
13
+
14
+ M lib/numru/gphys.rb
15
+
16
+ 2019-02-28 Takeshi Horinouchi
17
+ Fitting::least_square_fit: bug fix of best fit when with_offset==false
18
+
19
+ M lib/numru/ganalysis/fitting.rb
20
+
21
+ 2019-01-13 Takeshi Horinouchi
22
+ GAnalysis::PDE::SOR_2D_2ndorder : added an option "ignore_non_eliptic". Changed optional arguments to keyword arguments.
23
+
24
+ M ext/numru/ganalysis/pde_ext.c
25
+ M lib/numru/ganalysis/pde.rb
26
+
27
+ 2018-12-09 Takeshi Horinouchi
28
+ bug fix
29
+
30
+ M lib/numru/ganalysis/narray_ext.rb
31
+
32
+ 2018-12-09 Takeshi Horinouchi
33
+ Update and bug fix
34
+
35
+ M ext/numru/ganalysis/pde_ext.c
36
+ M lib/numru/ganalysis/pde.rb
37
+
38
+ 2018-12-06 Takeshi Horinouchi
39
+ Created NArray#cum_sum which accepts multi-D NArray unlike NArray#cumsum
40
+
41
+ M ext/numru/ganalysis/ext_init.c
42
+ A ext/numru/ganalysis/narray_ext_dfloat.c
43
+ A lib/numru/ganalysis/narray_ext.rb
44
+
45
+ 2018-12-04 Takeshi Horinouchi
46
+ Added ext/numru/ganalysis/extconf.rb
47
+
48
+ M gphys.gemspec
49
+
50
+ 2018-12-04 Takeshi Horinouchi
51
+ Created GAnalysis::PDE and its method SOR_2D_2ndorder (to solve 2D 2nd order PDE by SOR)
52
+
53
+ A ext/numru/ganalysis/ext_init.c
54
+ A ext/numru/ganalysis/extconf.rb
55
+ A ext/numru/ganalysis/pde_ext.c
56
+ A lib/numru/ganalysis/pde.rb
57
+
58
+ 2018-11-29 Takeshi Horinouchi
59
+ least_square_fit: added an option with_offset
60
+
61
+ M lib/numru/ganalysis/fitting.rb
62
+
63
+ 2018-11-29 Takeshi Horinouchi
64
+ tone: Improved treatment of fullcolor
65
+
66
+ M lib/numru/ggraph.rb
67
+
68
+ 2018-11-29 Takeshi Horinouchi
69
+ Added no_sort option to join_md.
70
+
71
+ M lib/numru/gphys/gphys.rb
72
+
73
+ 2018-04-09 Takeshi Horinouchi
74
+ completed the change in b86d44ca18fca98bb
75
+
76
+ M lib/numru/ganalysis/eof.rb
77
+
1
78
  2018-03-20 Takeshi Horinouchi
2
79
  To release version 1.5.5 (git tag v1.5.5)
3
80
 
@@ -1,7 +1,7 @@
1
1
  GPhys is copyrighted free software by Takeshi Horinouchi and
2
2
  GFD Dennou Club (http://www.gfd-dennou.org/).
3
3
 
4
- Copyright 2003-2018 (C) Takeshi Horinouchi and GFD Dennou Club
4
+ Copyright 2003-2019 (C) Takeshi Horinouchi and GFD Dennou Club
5
5
  (http://www.gfd-dennou.org/) All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without
@@ -0,0 +1,9 @@
1
+ void init_ganalysis_pde_ext();
2
+ void init_narray_ext_dfloat();
3
+
4
+ void
5
+ Init_ganalysis_ext()
6
+ {
7
+ init_ganalysis_pde_ext();
8
+ init_narray_ext_dfloat();
9
+ }
@@ -0,0 +1,43 @@
1
+ require 'mkmf'
2
+ gem_path = nil
3
+
4
+ if Gem.respond_to?(:find_files) and Gem.find_files("narray.h").length > 0
5
+ require "rbconfig"
6
+ so = RbConfig::CONFIG["DLEXT"]
7
+ narray_include = File.expand_path(File.dirname(Gem.find_files("narray.h")[0]))
8
+ narray_lib = File.expand_path(File.dirname(Gem.find_files("narray." + so)[0]))
9
+ else
10
+ gem_home=(`gem environment GEM_HOME`).chomp
11
+ narray_dir = Dir.glob("#{gem_home}/gems/narray-*/ext/narray").sort[-1]
12
+ if narray_dir
13
+ narray_include = narray_lib = narray_dir
14
+ else
15
+ narray_include = narray_lib = [ $sitearchdir, $vendorarchdir]
16
+ end
17
+ end
18
+ dir_config('narray', narray_include, narray_lib)
19
+
20
+ require "narray"
21
+ if NArray.const_defined?(:SUPPORT_BIGMEM) && NArray::SUPPORT_BIGMEM
22
+
23
+ case RbConfig::CONFIG["CC"]
24
+ when "gcc"
25
+ omp_opt = "-fopenmp"
26
+ else
27
+ omp_opt = nil
28
+ end
29
+ omp_opt = arg_config("--openmp", omp_opt)
30
+
31
+ omp_opt = nil if omp_opt.to_s.empty?
32
+
33
+ if omp_opt
34
+ $CFLAGS << " " << omp_opt
35
+ $DLDFLAGS << " " << omp_opt
36
+ warn "OpenMP support: ON"
37
+ else
38
+ warn "OpenMP support: OFF"
39
+ warn "if you want to enable openmp, set --openmp=compile_option"
40
+ end
41
+ end
42
+
43
+ create_makefile('numru/ganalysis_ext')
@@ -0,0 +1,84 @@
1
+ /* narray_ext_dfloat.c : Extention library of NArray (DFLOAT only)
2
+ */
3
+ #include<stdio.h>
4
+ #include<string.h>
5
+ #include "ruby.h"
6
+ #include "narray.h"
7
+ #ifndef NARRAY_BIGMEM
8
+ typedef int na_shape_t;
9
+ #endif
10
+
11
+ typedef double c_num_t;
12
+ #define NATYPE NA_DFLOAT
13
+
14
+ static VALUE
15
+ cum_sum_dfloat(obj, self, dim)
16
+ VALUE obj;
17
+ VALUE self;
18
+ VALUE dim;
19
+ {
20
+ VALUE res;
21
+ int d, dj, rank;
22
+ struct NARRAY *na;
23
+ na_shape_t i, j, k, ni, nj, nk, nij;
24
+ na_shape_t *sh;
25
+ c_num_t *p, *c;
26
+
27
+ /* check & read arguments */
28
+ dj = NUM2INT(dim);
29
+
30
+ if (NA_TYPE(self) != NATYPE) rb_raise(rb_eArgError,"Unexpected type");
31
+ rank = NA_RANK(self);
32
+ if (dj<-rank || dj>=rank) rb_raise(rb_eArgError,
33
+ "dim (%d) out of range (%d to %d)", dj, -rank, rank-1);
34
+ if (dj<0) dj += rank;
35
+
36
+ /* interpret shape as 3D */
37
+ GetNArray(self, na);
38
+ sh = na->shape;
39
+ p = (c_num_t *) NA_PTR(na, 0);
40
+ ni = 1;
41
+ for(d=0; d<dj; d++) ni *= sh[d];
42
+ nj = sh[dj];
43
+ nij = ni*nj;
44
+ nk = 1;
45
+ for(d=dj+1; d<rank; d++) nk *= sh[d];
46
+
47
+ /* initialize the output object */
48
+ res = na_make_object(NATYPE, rank, sh, cNArray);
49
+ GetNArray(res, na);
50
+ c = (c_num_t *) NA_PTR(na, 0);
51
+
52
+ /* operation */
53
+ for(k=0; k<nk; k++){
54
+ for(i=0; i<ni; i++){
55
+ c[i+nij*k] = p[i+nij*k]; /* copy the first element */
56
+ }
57
+ }
58
+ for(k=0; k<nk; k++){
59
+ for(j=1; j<nj; j++){
60
+ for(i=0; i<ni; i++){
61
+ c[i+ni*j+nij*k] = p[i+ni*j+nij*k] + c[i+ni*(j-1)+nij*k];
62
+ }
63
+ }
64
+ }
65
+
66
+ return(res);
67
+ }
68
+
69
+
70
+ // VALUE cNArray;
71
+
72
+ void
73
+ init_narray_ext_dfloat()
74
+ {
75
+ /* 以下はどうもうまく行かない。(NArrayが拡張ライブラリだからか)
76
+ rb_require("narray");
77
+ // cNArray = rb_define_class("NArray", rb_cObject);
78
+ rb_define_method(cNArray, "cum_sum_dfloat", cum_sum_dfloat, 1);
79
+ */
80
+ static VALUE mNumRu, mNArrayExt;
81
+ mNumRu = rb_define_module("NumRu");
82
+ mNArrayExt = rb_define_module_under(mNumRu, "NArrayExt");
83
+ rb_define_module_function(mNArrayExt, "cum_sum_dfloat", cum_sum_dfloat, 2);
84
+ }
@@ -0,0 +1,130 @@
1
+ /* c_pde.c : Extention library for partial differential equation solvers
2
+ * All in NArray
3
+ */
4
+
5
+ #include<stdio.h>
6
+ #include<string.h>
7
+ #include<math.h>
8
+ #include "ruby.h"
9
+ #include "narray.h"
10
+
11
+ /* for compatibility for NArray and NArray with big memory patch */
12
+ #ifndef NARRAY_BIGMEM
13
+ typedef int na_shape_t;
14
+ #endif
15
+
16
+ #define ID(i,j) ((i)+nx*(j))
17
+
18
+ /* Eq: A z_xx + 2 B z_xy + C z_yy + D z_x + E z_y = F
19
+ * ^^^
20
+ *
21
+ * Assumption: dx and dy are constants (uniform).
22
+ * Boundary values are not changed. --> change afterwords if not Dirichlet.
23
+ *
24
+ * Basic discretization: by central differences:
25
+ * A/dx^2 (z[i-1,j]-2z[i,j]+z[i+1,j])
26
+ * + B/(2dxdy) ((z[i+1,j+1]-z[i-1,j+1]-z[i+1,j-1]+z[i-1,j-1])
27
+ * + C/dy^2 (z[i,j-1]-2z[i,j]+z[i,j+1])
28
+ * + D/(2dx) (z[i+1,j]-z[i-1,j]) + E/(2dy) (z[i,j+1]-z[i,j-1]) - F = 0
29
+ *
30
+ * * Z [2D Float(=DFLOAT) NArray] (inout) -- to be overwritten
31
+ * * A, B, ... [2D Float(=DFLOAT) NArray] coeffitients
32
+ * * OME [Float] constant, which should 1<= OME < 2 (Gauss-Seidel if OME=1)
33
+ * * Return value: res = |H dz| (L2 norm),
34
+ * where H = 2(diag(A)/dx^2+diag(C)/dy^2).
35
+ * Convergence can be judged by res/|F| < eps
36
+ */
37
+ static VALUE
38
+ SOR_2D_2ndorder_1step(obj, Z, A, B, C, D, E, F, DX, DY, OME, Ignore_non_eliptic)
39
+ VALUE obj;
40
+ VALUE Z;
41
+ VALUE A, B, C, D, E, F;
42
+ VALUE DX, DY, OME;
43
+ VALUE Ignore_non_eliptic;
44
+ {
45
+ double *z, *ap, *bp, *cp, *dp, *ep, *fp;
46
+ double a, b, c, d, e, f, g, h, sum=0;
47
+ double dx, dy, ome;
48
+ struct NARRAY *na;
49
+ na_shape_t nx, ny, i, j;
50
+ VALUE res;
51
+
52
+ /* check & read arguments */
53
+
54
+ if (NA_TYPE(Z) != NA_DFLOAT) rb_raise(rb_eArgError, "Z nust be DFLOAT");
55
+ if (NA_TYPE(A) != NA_DFLOAT) rb_raise(rb_eArgError, "A nust be DFLOAT");
56
+ if (NA_TYPE(B) != NA_DFLOAT) rb_raise(rb_eArgError, "B nust be DFLOAT");
57
+ if (NA_TYPE(C) != NA_DFLOAT) rb_raise(rb_eArgError, "C nust be DFLOAT");
58
+ if (NA_TYPE(D) != NA_DFLOAT) rb_raise(rb_eArgError, "D nust be DFLOAT");
59
+ if (NA_TYPE(E) != NA_DFLOAT) rb_raise(rb_eArgError, "E nust be DFLOAT");
60
+ if (NA_TYPE(F) != NA_DFLOAT) rb_raise(rb_eArgError, "F nust be DFLOAT");
61
+
62
+ if (NA_RANK(Z) != 2) rb_raise(rb_eArgError, "Z must be 2-dimensional");
63
+ nx = NA_SHAPE0(Z);
64
+ ny = NA_SHAPE1(Z);
65
+ if (NA_SHAPE0(A)!=nx || NA_SHAPE1(A)!=ny) rb_raise(rb_eArgError,
66
+ "A: invalid shape");
67
+ if (NA_SHAPE0(B)!=nx || NA_SHAPE1(B)!=ny) rb_raise(rb_eArgError,
68
+ "B: invalid shape");
69
+ if (NA_SHAPE0(C)!=nx || NA_SHAPE1(C)!=ny) rb_raise(rb_eArgError,
70
+ "C: invalid shape");
71
+ if (NA_SHAPE0(D)!=nx || NA_SHAPE1(D)!=ny) rb_raise(rb_eArgError,
72
+ "D: invalid shape");
73
+ if (NA_SHAPE0(E)!=nx || NA_SHAPE1(E)!=ny) rb_raise(rb_eArgError,
74
+ "E: invalid shape");
75
+ if (NA_SHAPE0(F)!=nx || NA_SHAPE1(F)!=ny) rb_raise(rb_eArgError,
76
+ "F: invalid shape");
77
+
78
+ GetNArray(Z, na); z = (double *)NA_PTR(na, 0);
79
+ GetNArray(A, na); ap = (double *)NA_PTR(na, 0);
80
+ GetNArray(B, na); bp = (double *)NA_PTR(na, 0);
81
+ GetNArray(C, na); cp = (double *)NA_PTR(na, 0);
82
+ GetNArray(D, na); dp = (double *)NA_PTR(na, 0);
83
+ GetNArray(E, na); ep = (double *)NA_PTR(na, 0);
84
+ GetNArray(F, na); fp = (double *)NA_PTR(na, 0);
85
+
86
+ dx = NUM2DBL(DX);
87
+ dy = NUM2DBL(DY);
88
+ if (dx==0.0) rb_raise(rb_eArgError, "dx == 0");
89
+ if (dy==0.0) rb_raise(rb_eArgError, "dy == 0");
90
+ ome = NUM2DBL(OME);
91
+
92
+ /* solve (1 step) */
93
+ for (j=1; j<ny-1; j++){
94
+ for (i=1; i<nx-1; i++){
95
+ a = ap[ID(i,j)] / (dx*dx);
96
+ b = bp[ID(i,j)] / (dx*dy);
97
+ c = cp[ID(i,j)] / (dy*dy);
98
+ if (Ignore_non_eliptic == Qfalse || Ignore_non_eliptic == Qnil ) {
99
+ if((a*c-b*b)<=0.0)
100
+ rb_raise(rb_eStandardError,"non-eliptic@[%d,%d]",i,j);
101
+ }
102
+ d = dp[ID(i,j)] / dx;
103
+ e = ep[ID(i,j)] / dy;
104
+ f = fp[ID(i,j)];
105
+ h = 2*(a+c);
106
+ g = ome * ( a*( z[ID(i-1,j)]+z[ID(i+1,j)] )
107
+ + b/2*( z[ID(i+1,j+1)] - z[ID(i-1,j+1)] - z[ID(i+1,j-1)]
108
+ +z[ID(i-1,j-1)] )
109
+ + c*( z[ID(i,j-1)]+z[ID(i,j+1)] )
110
+ + d/2*( z[ID(i+1,j)]-z[ID(i-1,j)] )
111
+ + e/2*( z[ID(i,j+1)]-z[ID(i,j-1)] )
112
+ - f - h*z[ID(i,j)]);
113
+ sum += g*g;
114
+ z[ID(i,j)] += g/h;
115
+ }
116
+ }
117
+ res = DBL2NUM( sqrt(sum) );
118
+ return(res);
119
+ }
120
+
121
+ void
122
+ init_ganalysis_pde_ext()
123
+ {
124
+ static VALUE mNumRu, mGA, mPDE;
125
+ mNumRu = rb_define_module("NumRu");
126
+ mGA = rb_define_module_under(mNumRu, "GAnalysis");
127
+ mPDE = rb_define_module_under(mGA, "PDE");
128
+ rb_define_module_function(mPDE, "SOR_2D_2ndorder_1step",
129
+ SOR_2D_2ndorder_1step, 11);
130
+ }
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["ext","lib"]
26
26
  spec.test_files = spec.files.grep(%r{^(test|test_old|sample|testdata)/})
27
27
  spec.extensions << "ext/numru/gphys/extconf.rb"
28
+ spec.extensions << "ext/numru/ganalysis/extconf.rb"
28
29
 
29
30
  spec.post_install_message = "Thanks for installing! You can add extra libraries (i.e., ruby-lapack, rb-gsl) to enjoy powerful calculating and handling datasets."
30
31
 
@@ -92,7 +92,7 @@ module NumRu
92
92
  end
93
93
  w /= w.mean
94
94
  w.reshape!(n)
95
- else
95
+ elsif new_grid.rank >= 2
96
96
  nc0 = new_grid.coord(0)
97
97
  nc1 = new_grid.coord(1)
98
98
  if !(opts[:disable_weight]||opts["disable_weight"]) &&
@@ -107,6 +107,8 @@ module NumRu
107
107
  else
108
108
  w = nil
109
109
  end
110
+ else
111
+ w = nil
110
112
  end
111
113
 
112
114
  ary = NArrayMiss.new(gphys.typecode, n_lost, n)
@@ -215,14 +215,16 @@ module NumRu
215
215
  # number of functions (also unsolvable).
216
216
  #
217
217
  def least_square_fit(data, grid_locs, functions, ensemble_dims=nil,
218
- indep_dims=nil)
218
+ indep_dims=nil, with_offset=true)
219
219
 
220
220
  #< argument check >
221
221
 
222
222
  grid_locs.each_with_index{|x,i| self.ensure_1D_NArray(x, i)}
223
223
  functions.each{|f| raise("Found non-Proc arg") if !f.is_a?(Proc)}
224
224
 
225
- functions = functions + [@@unity] # constanf offset
225
+ if with_offset
226
+ functions = functions + [@@unity] # constanf offset
227
+ end
226
228
 
227
229
  ng = grid_locs.length
228
230
  rank = data.rank
@@ -336,9 +338,16 @@ module NumRu
336
338
  c = na
337
339
 
338
340
  # best fit
339
- bf = c[-1] # the constant offset
340
- for i in 0...ms-1
341
- bf += c[i]*fv[i]
341
+ if with_offset
342
+ bf = c[-1] # the constant offset
343
+ for i in 0...ms-1
344
+ bf += c[i]*fv[i]
345
+ end
346
+ else
347
+ bf = 0.0
348
+ for i in 0...ms
349
+ bf += c[i]*fv[i]
350
+ end
342
351
  end
343
352
 
344
353
  else # fitting multiple times
@@ -381,9 +390,16 @@ module NumRu
381
390
  end
382
391
  end
383
392
  cs = c.reshape(ms, *idshp_full)
384
- bf = cs[-1,false]
385
- for i in 0...ms-1
386
- bf += cs[i,false]*fv[i]
393
+ if with_offset
394
+ bf = cs[-1,false]
395
+ for i in 0...ms-1
396
+ bf += cs[i,false]*fv[i]
397
+ end
398
+ else
399
+ bf = cs[-1,false] * 0
400
+ for i in 0...ms
401
+ bf += cs[i,false]*fv[i]
402
+ end
387
403
  end
388
404
 
389
405
  end
@@ -0,0 +1,13 @@
1
+ require "narray"
2
+ require "numru/ganalysis/ganalysis_ext"
3
+
4
+ class NArray
5
+ def cum_sum(dim)
6
+ case self.typecode
7
+ when DFLOAT
8
+ NumRu::NArrayExt.cum_sum_dfloat(self,dim)
9
+ else
10
+ raise "Sorry, this narray type #{self.typecode} is not supported."
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,90 @@
1
+ require "numru/gphys"
2
+ require "numru/ganalysis/ganalysis_ext"
3
+
4
+ module NumRu
5
+ module GAnalysis
6
+ module PDE
7
+ module_function
8
+ #
9
+ # = Solve 2-dim 2nd order PDE by the succesive over-relaxation method
10
+ #
11
+ # ARGUMENTS.
12
+ # * z [in-out, 2D dfloat NArray] : When in, initial values. When out,
13
+ # the result. Boundary values are not changed (Dirichlet problem)
14
+ # (developper's memo: Neuman cond can be supported as an option)
15
+ # * a, b, c, d, e, f [in, 2D dfloat NArray with the same shape as z] :
16
+ # Specifies the PDF as
17
+ # a z_xx + 2*b z_xy + c z_yy + d z_x + e z_y = f
18
+ # ^^^
19
+ # Please note that 2*b is the coefficient of z_xy.
20
+ # x is the first (0th) NArray dimension.
21
+ # * dx, dy [Float] : grid spacings
22
+ # * ome [Float] : the over-relaxation parameter 1<=ome<2.
23
+ # For a large-scale poisson equation, should be ~ 2 (e.g. 1.9).
24
+ # * eps [optional, Float] : conversion threshold (e.g. 1e-5).
25
+ # Compared with |increment|/|F| (| | is the L2 norm).
26
+ # When |f| == 0 (homogenous), compared simply with |increment|.
27
+ # * maxi [optional, Integer]: max iteration times(default, 5*[nx,ny].max).
28
+ # Since SOR (or the Gauss-Seidel method) acts like a stepwise diffusion,
29
+ # it must be greater than the along-x and along-y grid sizes.
30
+ # * ignore_non_eliptic : if true (non-nil,non-false), do not raise
31
+ # error when the coeeficients are not entirely eliptic.
32
+ #
33
+ # RETURN VALUE
34
+ # * |last increment|/|F| of |last increment| (to be compared with eps)
35
+ #
36
+ def SOR_2D_2ndorder(z, a, b, c, d, e, f, dx, dy, ome, eps: nil, maxi: nil,
37
+ ignore_non_eliptic: false)
38
+ lf = Math.sqrt( (f**2).sum ) # L2 norm of f
39
+ lf = 1.0 if lf==0 # when |f|==0 (homogeneous), no-division by |f|.
40
+ res = nil
41
+ if !maxi
42
+ maxi = [ z.shape[0], z.shape[1] ].max * 5 # default max itr times
43
+ end
44
+ convd = false
45
+ for i in 0...maxi
46
+ res = SOR_2D_2ndorder_1step(z, a, b, c, d, e, f, dx, dy, ome,
47
+ ignore_non_eliptic)
48
+ #p res/lf, z
49
+ if (eps && res/lf < eps)
50
+ convd = true
51
+ break
52
+ end
53
+ end
54
+ if (eps && !convd)
55
+ raise("Max iteration times (#{maxi}) reached before convergence" +
56
+ " (#{res/lf} > #{eps}). Change ome (#{ome}) or specify maxi.")
57
+ end
58
+ #p i,res/lf #, z
59
+ res/lf
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ ################################################
66
+ ##### test part ######
67
+ if $0 == __FILE__
68
+ require "numru/ggraph"
69
+ include NumRu
70
+
71
+ #nx = ny = 9
72
+ nx = ny = 91
73
+ z = NArray.float(nx,ny)
74
+ a = c = NArray.float(nx,ny).fill!(1.0)
75
+ b = d = e = NArray.float(nx,ny)
76
+ f = NArray.float(nx,ny)
77
+ f[nx/2,ny/2] = 1.0
78
+ dx = dy = 1.0
79
+ #ome = 1.9
80
+ #GAnalysis::PDE.SOR_2D_2ndorder(z, a, b, c, d, e, f, dx, dy, ome)
81
+ =begin
82
+ (1.0..1.91).step(0.1){|ome|
83
+ puts "ome = #{ome}"
84
+ GAnalysis::PDE.SOR_2D_2ndorder(z, a, b, c, d, e, f, dx, dy, ome)
85
+ }
86
+ =end
87
+ eps = 1e-6
88
+ ome = 1.95
89
+ GAnalysis::PDE.SOR_2D_2ndorder(z, a, b, c, d, e, f, dx, dy, ome, eps: eps)
90
+ end
@@ -2839,11 +2839,7 @@ module NumRu
2839
2839
 
2840
2840
  @@used_fullcolor_tone = false
2841
2841
  val = gp.data.val
2842
- if ( opts['ltone'] &&
2843
- ( opts['tonf'] || opts['auto'] && !opts['tonb'] && !opts['tonc'] &&
2844
- ( val.length >= TONE_TONF_THRES_SIZE || val.shape.min >= TONE_TONF_THRES_LEN ) ) )
2845
- DCL.uetonf(val)
2846
- elsif opts['fullcolor']
2842
+ if opts['fullcolor']
2847
2843
  @@used_fullcolor_tone = true
2848
2844
  sopt = opts.dup.delete_if{|k,v| !DCLExt.shade_1_option_keys.include?(k)}
2849
2845
  DCLExt.ui_shade_1(val, sopt)
@@ -2851,6 +2847,11 @@ module NumRu
2851
2847
  DCL.uetonb(val)
2852
2848
  elsif opts['tonc'] && opts['ltone']
2853
2849
  DCL.uetonc(val)
2850
+ elsif ( opts['ltone'] &&
2851
+ ( opts['tonf'] ||
2852
+ opts['auto'] && ( val.length >= TONE_TONF_THRES_SIZE ||
2853
+ val.shape.min >= TONE_TONF_THRES_LEN ) ) )
2854
+ DCL.uetonf(val)
2854
2855
  else
2855
2856
  DCL.uetone(val)
2856
2857
  end
@@ -12,4 +12,5 @@ require 'numru/gphys_ext' # extension library
12
12
  require 'numru/gphys/interpolate'
13
13
  require 'numru/gphys/gphys_dim_op'
14
14
  require 'numru/gdir'
15
+ require 'numru/gphys/derivative'
15
16
  # require 'numru/gphys/ep_flux' # Made optional. Require it explicitly if needed
@@ -1210,7 +1210,8 @@ module NumRu
1210
1210
  grid = Grid.new(*axes)
1211
1211
  if gp0.assoc_coords
1212
1212
  assoc_coords = gp0.assoccoordnames.collect do |aname|
1213
- GPhys.join( gpnary.collect{|gp| gp.assoc_coord_gphys(aname)}, true )
1213
+ GPhys.join( gpnary.collect{|gp| gp.assoc_coord_gphys(aname)}, true,
1214
+ true )
1214
1215
  end
1215
1216
  grid.set_assoc_coords(assoc_coords)
1216
1217
  end
@@ -1222,7 +1223,7 @@ module NumRu
1222
1223
  GPhys.new(grid, data)
1223
1224
  end
1224
1225
 
1225
- def GPhys.join_md(gpnary)
1226
+ def GPhys.join_md(gpnary, no_sort=false)
1226
1227
  #< Check >
1227
1228
 
1228
1229
  if !gpnary.is_a?(NArray)
@@ -1283,7 +1284,7 @@ module NumRu
1283
1284
  end
1284
1285
 
1285
1286
  #< Sort along dimensions to join >
1286
- gpnary = __sort_gpnary(gpnary)
1287
+ gpnary = __sort_gpnary(gpnary) unless no_sort
1287
1288
 
1288
1289
  #< Join! >
1289
1290
  self.join_md_nocheck(gpnary)
@@ -1294,7 +1295,7 @@ module NumRu
1294
1295
  # ARGUMENT
1295
1296
  # * gpnarray [Array (or 1D NArray) of GPhys]
1296
1297
  #
1297
- def GPhys.join(gpary, ignore_overlap=false)
1298
+ def GPhys.join(gpary, ignore_overlap=false, no_sort=false)
1298
1299
 
1299
1300
  #< initialization with the first GPhys object >
1300
1301
 
@@ -1332,7 +1333,7 @@ module NumRu
1332
1333
  gpnary = gpstore.to_na
1333
1334
 
1334
1335
  #< Sort along dimensions to join >
1335
- gpnary = __sort_gpnary(gpnary)
1336
+ gpnary = __sort_gpnary(gpnary) unless no_sort
1336
1337
 
1337
1338
  #< Join! >
1338
1339
  self.join_md_nocheck(gpnary)
@@ -1,6 +1,6 @@
1
1
  module NumRu
2
2
  class GPhys
3
3
  # Add subsubminor version while under development; remove it and advance version to release
4
- VERSION = "1.5.5"
4
+ VERSION = "1.5.6"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gphys
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi Horinouchi
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-03-20 00:00:00.000000000 Z
15
+ date: 2019-03-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: narray
@@ -132,6 +132,7 @@ executables:
132
132
  - grads2nc_with_gphys
133
133
  extensions:
134
134
  - ext/numru/gphys/extconf.rb
135
+ - ext/numru/ganalysis/extconf.rb
135
136
  extra_rdoc_files: []
136
137
  files:
137
138
  - ".ChangeLog.until201303"
@@ -539,6 +540,10 @@ files:
539
540
  - doc/update_rdoc
540
541
  - doc/varray.html
541
542
  - doc/varraycomposite.html
543
+ - ext/numru/ganalysis/ext_init.c
544
+ - ext/numru/ganalysis/extconf.rb
545
+ - ext/numru/ganalysis/narray_ext_dfloat.c
546
+ - ext/numru/ganalysis/pde_ext.c
542
547
  - ext/numru/gphys/dim_op.c
543
548
  - ext/numru/gphys/ext_coord.c
544
549
  - ext/numru/gphys/ext_init.c
@@ -559,6 +564,8 @@ files:
559
564
  - lib/numru/ganalysis/log_p.rb
560
565
  - lib/numru/ganalysis/met.rb
561
566
  - lib/numru/ganalysis/met_z.rb
567
+ - lib/numru/ganalysis/narray_ext.rb
568
+ - lib/numru/ganalysis/pde.rb
562
569
  - lib/numru/ganalysis/planet.rb
563
570
  - lib/numru/ganalysis/qg.rb
564
571
  - lib/numru/ganalysis/sigma_coord.rb