gphys 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13c32ab65077429fc0f5c4799d6986e2cb672dfa
4
- data.tar.gz: b6cd30441caba1b246ae90b6ae9b8f090364cbce
3
+ metadata.gz: 1341ed41033b2f8c5e07671a4c0e541e0135ef73
4
+ data.tar.gz: 69b01da241605e1337df420e4d48ff8cce4ba561
5
5
  SHA512:
6
- metadata.gz: cc75b8a323b972ace9a8b0beb53fbedf8165409d9613f655bfaf08090c751fa8c4b594f09d51c53b8592a4c9b3be85e32447792cb78bf3ab7f94772aea3d78b2
7
- data.tar.gz: c25b9805785e96f88ecf47e37855169cc4efecc29520d3df74da9385d57c811bd5de44c8f684fdcdc9cf5657972e69338c6699e906a90099f040d517ba5b9725
6
+ metadata.gz: 694f55d83e1ec6a41d25af18f6cbc415b9462e7391a041e4b78f12d2681116ca6dbb74ee61c22aa4756bdc968af55e4e16da81c21685115e8ea30394e2d6ab30
7
+ data.tar.gz: 8cebe5a572e40ab3e1c1b9c98b759e21570a3397abe911206e2c61c7e083d7c623e09060167187979b1302a089df6c26190ab6a1425867dd72e1b2f4034e3da6
data/ChangeLog CHANGED
@@ -1,3 +1,48 @@
1
+ 2018-03-04 Takeshi Horinouchi
2
+ To release version 1.5.4 (git tag v1.5.4)
3
+
4
+ M lib/numru/gphys/version.rb
5
+
6
+ 2018-03-04 Takeshi Horinouchi
7
+ a minor enhancement (on recognition of longitude and latitude)
8
+
9
+ M lib/numru/ganalysis/eof.rb
10
+
11
+ 2018-03-02 Takeshi Horinouchi
12
+ a revision to go around a bug of NArray
13
+
14
+ M lib/numru/ganalysis/eof.rb
15
+
16
+ 2018-02-20 Takeshi Horinouchi
17
+ minor improvement
18
+
19
+ M lib/numru/gphys/varray.rb
20
+
21
+ 2018-02-01 Takeshi Horinouchi
22
+ changed to use GPhys#rank_len_ne_1
23
+
24
+ M bin/gpview
25
+
26
+ 2018-02-01 Takeshi Horinouchi
27
+ added a new method GPhys#rank_len_ne_1
28
+
29
+ M lib/numru/gphys/gphys.rb
30
+
31
+ 2018-02-01 Takeshi Horinouchi
32
+ slightly changed an error message
33
+
34
+ M lib/numru/gphys/assoccoords.rb
35
+
36
+ 2018-02-01 Takeshi Horinouchi
37
+ Enhanced argument check.
38
+
39
+ M lib/numru/gphys/assoccoords.rb
40
+
41
+ 2018-01-26 Takeshi Horinouchi
42
+ fixed the bug in the previous commit
43
+
44
+ M lib/numru/ggraph.rb
45
+
1
46
  2018-01-26 Takeshi Horinouchi
2
47
  updated the years
3
48
 
data/bin/gpview CHANGED
@@ -942,7 +942,7 @@ while ARGV[0] do
942
942
 
943
943
  # judge draw kind
944
944
  unless kind_of_fig
945
- gp_rank = g.rank
945
+ gp_rank = g.rank_len_ne_1
946
946
  if ($OPT_mark)
947
947
  kind_of_fig = "mark"
948
948
  elsif ($OPT_line || gp_rank == 1)
@@ -0,0 +1,973 @@
1
+ #!/usr/bin/env ruby
2
+ ##################################################
3
+ =begin
4
+ = NAME
5
+
6
+ gpview - quick viewer for the values of a variable specified by a gtool4-type URL.
7
+
8
+
9
+ (1) for 1-dimensional variable, make line plot.
10
+ (2) for 2-dimensional variable, make contour/tone plot.
11
+ (3) for 3/more-dimensional variable, make contour/tone plot,
12
+ select first 2D. possible to make animation.
13
+
14
+ = USAGE
15
+
16
+ The first command form is
17
+
18
+ % gpview [options] gturl1 gturl2 gturl3 ...
19
+
20
+ where the format of the gturl is
21
+
22
+ path[@|/]varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]
23
+
24
+ The second commnad form is
25
+
26
+ % gpview --var url [options] gtfile1 gtfile2 ...
27
+
28
+ where the format of the url is
29
+
30
+ varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]
31
+
32
+ = OPTIONS
33
+
34
+ if you want to know more description, please read
35
+
36
+ http://ruby.gfd-dennou.org/products/gphys/doc/gpview.html
37
+
38
+ == GLOBAL OPTIONS
39
+
40
+ :--help:
41
+ print this message.
42
+
43
+ :--var url:
44
+ set the variable name and slicing parameters.
45
+
46
+ :--wsn [1-4]:
47
+ set work staion number. each number represent output device:
48
+ * for dcl-6,
49
+ 1 : X window
50
+ 2.: PDF file (named dcl.pdf).
51
+ * for dcl-5-?,
52
+ 1 : X window,
53
+ 2 : PS file. (named dcl.ps)
54
+ 3 : Tektronix terminal
55
+ 4 : GTK Windows
56
+
57
+ :--clrmap [1-]:
58
+ set colormap to draw tone/contour.
59
+
60
+ :--itr [1-4,5-7,10-15,20-23,30-33]:
61
+ set axis scale. default is 1.
62
+ 1 : linear scale for x/y axis
63
+ 2 : linear scale for x , log scale for y axis
64
+ 3 : log scale for x , linear scale for y axis
65
+ 4 : log scale for x/y axis
66
+
67
+ :--similar [simfac,vxoff,vyoff]:
68
+ (for 5<=itr<=7) set similarity parameters which are fed in DCL.grssim.
69
+
70
+ :--map_axis [uxc,uyc,rot]:
71
+ (for 10<=itr<=33) set mapping parameters which are fed in DCL.umpcnt.
72
+
73
+ :--map_radius <radius>:
74
+ (for itr>=20) set clipping radius (degree) around the tangential point.
75
+ Deafault=90.
76
+
77
+ :--xcoord [xcoord]
78
+ name of x-coordinate (use for associate coordinates)
79
+
80
+ :--ycoord [ycoord]
81
+ name of y-coordinate (use for associate coordinates)
82
+
83
+ :--title:
84
+ set title of figure
85
+
86
+ :--aspect <aspect>:
87
+ set aspect ratio of Viewport. default is 2.0.
88
+
89
+ :--noannotate:
90
+ not draw annotations.
91
+
92
+ :--animate/anim <dim>:
93
+ plot animation along <dim>. <dim> must be name of dimension.
94
+
95
+ :--alternate, --Ga:
96
+ enable to backing store.
97
+
98
+ :--nowait, --Gw:
99
+ not wait for any actions if animate
100
+
101
+ :--delay <number>:
102
+ wait <number> seconds for each new page drawing of animation
103
+
104
+ :--reverse, --Gr:
105
+ plot animation reversible if animate
106
+
107
+ :--smooth, --Gaw:
108
+ equal to --anlternate && --nowait
109
+
110
+ :--exch:
111
+ exchange(transpose) x/y axis.
112
+
113
+ :--mean <dim>:
114
+ mean along axis <dim>.
115
+
116
+ :--stddev <dim>:
117
+ standard deviation along axis <dim>.
118
+
119
+ :--eddy <dim>:
120
+ deviation from mean along axis <dim>.
121
+
122
+ :--diff:
123
+ calculate the difference of two variables.
124
+ you must provide two gturls whose size and dimension are same.
125
+
126
+ :--m, --map <map_type>:
127
+ plot map. itr number must be set. this option is neglect if itr
128
+ number is 1-4. abailable map type is coast_world, border_world,
129
+ plate_world, state_usa, coast_japan, pref_japan
130
+
131
+ :--operation <math_func>:
132
+ operation of the specified math function on the data.
133
+ <math_func> should be a math function with one argument
134
+ such as log10, sqrt, sin, etc.
135
+
136
+ :--time_ax [nil|false|h|ymd]:
137
+ specify type of calendar-type time axis:
138
+ nil (=> auto slection)
139
+ false (=> do not use the time axis even if
140
+ the units of the axis is a time one with since field)
141
+ "h" (=> like nil, but always use the hour-resolving datetime_ax method
142
+ in dclext_datetime_ax.rb)
143
+ "ymd" (=> like "h" but for y-m-d type using DCL.uc[xy]acl)
144
+
145
+ :-xx:yyyy=value:
146
+ specify Dennou Club Library internal variable.
147
+ 'xx' is a package name prefix of DCL (eg. sg=>sgpack).
148
+ 'yy' is a variable name of DCL.
149
+ 'value' is a value of the DCL variable.
150
+
151
+ == LINE/MARK OPTIONS
152
+
153
+ :--line:
154
+ make line plot forced. (about first 1D)
155
+
156
+ :--mark:
157
+ make mark plot forced. (about first 1D)
158
+
159
+ :--index:
160
+ set DCL line index, which set the color/thickness of the line
161
+ primitive. please see DCL documents.
162
+
163
+ :--type:
164
+ set line type.
165
+
166
+ :--range [min:max]
167
+ set min/max value for line plot. min or max must be set.
168
+
169
+ :--overplot
170
+ set number of lines on each figure.
171
+
172
+ :--overplot_color, --Opc
173
+ multiple lines are distinguished with color rather than line type.
174
+
175
+ == CONTOUR/TONE OPTIONS
176
+
177
+ :--shade:
178
+ make contour and tone plot.
179
+
180
+ :--noshade:
181
+ make contour plot, without tone.
182
+
183
+ :--nocont:
184
+ make tone plot, without contour.
185
+
186
+ :--range [min:max]:
187
+ set min/max value for contour/tone plot. min or max must be set.
188
+
189
+ :--crange:
190
+ set min/max value for contour plot. this is more dominant than --range
191
+
192
+ :--srange:
193
+ set min/max value for tone plot. this is more dominant than --interval/int
194
+
195
+ :--interval,--int [num]:
196
+ set interval value for contour/tone plot. set the number of lines if
197
+ you set negative value.
198
+
199
+ :--cint:
200
+ set interval value for contour plot. this is more dominant
201
+ than --interval/int
202
+
203
+ :--sint:
204
+ set interval value for tone plot. this is more dominant than --interval/int.
205
+
206
+ :--levels:
207
+ set values of contour/tone levels.
208
+
209
+ :--clevels:
210
+ set values of contour levels.
211
+
212
+ :--slevels:
213
+ set tone of contour levels.
214
+
215
+ :--patterns:
216
+ set each patterns for tone plot.
217
+
218
+ :--tone [a|e|f|b|c]:
219
+ set tone subroutine:
220
+ a (=> tone routine is selected automatically depending on the datasize)
221
+ e (=> DCL.uetone is used)
222
+ f (=> DCL.uetonf is used)
223
+ b (=> DCL.uetonb is used)
224
+ c (=> DCL.uetonc is used)
225
+
226
+ :--nocolorbar:
227
+ do not draw color bar
228
+
229
+ :--nozero:
230
+ do not draw zero contour
231
+
232
+ :--udsfmt [strings]:
233
+ change contour label format. see UDCNTR/DCL manual for the format.
234
+
235
+ = EXAMPLES
236
+
237
+ For a single GPhys variable,
238
+
239
+ % gpview data.nc@temp
240
+ % gpview data.nc@temp,lon=130:150,lat=0:90:2
241
+ % gpview --nocont data.nc@temp,lon=130:150,lat=0
242
+ % gpview --noshade data.nc@temp,lon=130:150,lat=0
243
+ % gpview --mean lon data.nc@temp,lon=130:150,lat=0
244
+ % gpview --exch data.nc@temp,lon=130:150,lat=0
245
+ % gpview --animate lon data.nc@temp,lon=130:150
246
+ % gpview --animate lon --alternate data.nc@temp
247
+ % gpview --smooth lon data.nc@temp,lon=130:150
248
+ % gpview --levels 0,10,20,30 --pattern 30999,40999,50999,60999,70999 data.nc@temp
249
+ % gpview --overplot=3 --anim t data.nc@temp,lon=0
250
+ % gpview --overplot=3 --Opc --anim t data.nc@temp,lon=0
251
+ % gpview --mark data.nc@temp,lon=0,lat=0
252
+ % gpview --operation log10 data.nc@temp,lon=0
253
+ % gpview --time_ax false data.nc@temp,lon=0,lat=0
254
+
255
+ Example to set DCL internal variable,
256
+ % gpview -ud:lmsg=false --itr 5 --exch data.nc@temp,lon=0
257
+
258
+ For multiple GPhys variables,
259
+ % gpview data1.nc@temp data2.nc@temp
260
+ % gpview data1.nc@temp,lon=130:150 data2.nc@temp,lon=150:170
261
+ % gpview --overplot=3 --anim t data.nc@temp,lon=0 data.nc@temp,lon=10
262
+ % gpview --var temp,lon=130:150 data?.nc
263
+ % gpview --anim t --var temp,lon=130:150 data*.nc
264
+
265
+ =end
266
+ #
267
+ # = HISTORY
268
+ #
269
+ # 2004/12/14 D Tsukahara && T Horinouti(parse_gturl)
270
+ # 2005/01/08 D Tsukahara (add option --exch and able to invalid value)
271
+ # 2005/01/09 D Tsukahara (add option --animate, smooth, alternate, index )
272
+ # 2005/01/10 D Tsukahara (transpose axis with attr "positive:down" ,
273
+ # abailable loopsense_flag. )
274
+ # 2005/01/10 D Tsukahara (implement GGraph::color_bar, and margin_info,
275
+ # which file name, date, and toolname. )
276
+ # 2005/01/11 D Tsukahara ( 1. write document about OPTIONS.
277
+ # 2. add many options. more info please see document. )
278
+ # 2005/01/23 S Takehiro (add option --similar, map_axis)
279
+ # 2005/02/09 D Tsukahara && M Nakano (add option --reverse, --Gr, --map)
280
+ # 2005/02/10 D Tsukahara (change option parser (getopts => getoptlong))
281
+ # 2005/02/24 D Tsukahara (apply --range for line plot)
282
+ # 2005/06/15 S Takehiro (add option --levels, --clevels, --slevels, --patterns)
283
+ # 2005/06/17 S Takehiro (missing_value attribute setting removed)
284
+ # 2005/06/22 S Takehiro (debug, clipping control added to GGraph::annotate)
285
+ # 2005/06/23 S Takehiro (debug, option --title implemented)
286
+ # 2005/07/15 S Takehiro (option --noannotate implemented)
287
+ # 2005/08/07 S Takehiro (option --overplot implemented)
288
+ # 2005/08/09 S Takehiro && T Horinouchi (add option --help and help function.
289
+ # URL information corrected. )
290
+ # 2005/08/23 S Takehiro (multiple Gphys variables plotting
291
+ # and option --var implemented)
292
+ # 2005/08/23 S Takehiro (common methods to gp* command moved to gpcommon.rb)
293
+ # 2005/10/30 S Takehiro (option --animate recoverd)
294
+ # 2005/10/31 S Takehiro (option --smooth bug fixed)
295
+ # 2006/03/07 M Nakano (option --int bug fixed)
296
+ # 2007/10/03 S Takehiro (option --nocolorbar implemented)
297
+ # 2008/04/03 S Takehiro (option --nozero implemented)
298
+ # 2008/12/14 S Takehiro (option --mark implemented)
299
+ # 2010/03/10 Y SASAKI (change help block into RD format)
300
+ # 2011/01/14 T Tanigawa && S Takehiro (option --operation implemented)
301
+ # 2011/11/04 S Takehiro (option --time_ax implemented)
302
+ # 2011/11/20 S Takehiro (option --eddy implemented)
303
+ # 2012/02/19 S Takehiro (description for gturl format updated)
304
+ # 2013/01/29 T Tanigawa && S Takehiro (calculation of aspect ratio
305
+ # of viewport improved)
306
+ # 2013/01/29 S Nishizawa && S Takehiro (sequential operation implemented)
307
+ # 2014/02/21 Y Naito && S Takehiro (implement DCL internal variable setting,
308
+ # add option --udsfmt)
309
+ # 2014/02/21 S Noda && S Takehiro (add option --stddev)
310
+ # 2014/02/23 S Takehiro (option --tonf is changed to --tone)
311
+ # 2014/03/05 S Takehiro (add option --map_radius)
312
+ # 2014/03/10 Y Kawai && S Takehiro (setting labels for contours)
313
+ # 2014/04/06 S Takehiro (option --map_radius bug fix)
314
+ # 2014/06/27 S Nishizawa && S Takehiro (add options --xcoord, --ycoord)
315
+ # 2014/11/28 H Kashimura && S Takehiro (add option --diff, --tone bug fix)
316
+ # 2014/11/28 Y O Takahashi && S Takehiro (add option --overplot_color, --Opc)
317
+ # 2015/03/10 S Takehiro (History removes from the output of --help option)
318
+ # 2015/09/05 Y O Takahashi && S Takehiro (add option --delay)
319
+ # 2015/09/06 Y O Takahashi && S Takehiro (defalt wsn number changed)
320
+ # 2017/06/07 S Takehiro (int option bug fix)
321
+ #
322
+ #################################################
323
+ require "getoptlong" # for option_parse
324
+ require "numru/ggraph" # ggraph library
325
+ require "numru/gphys/gpcommon"
326
+
327
+ include NumRu
328
+
329
+ #####################################################
330
+ ## Default param.
331
+
332
+ VIEWPORT = [0.15,0.85,0.2,0.55]
333
+ URLfmt = "path[@|/]varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]"
334
+
335
+ #####################################################
336
+ def GGraph::annotate(str_ary)
337
+ lclip = DCL.sgpget('lclip')
338
+ DCL.sgpset('lclip',nil)
339
+ lnum = 0
340
+ str_ary.each{ |str|lnum += 1 }
341
+ charsize = 0.7 * DCL.uzpget('rsizec1')
342
+ dvx = 0.01
343
+ dvy = charsize*1.5
344
+ raise TypeError,"Array expected" if ! str_ary.is_a?(Array)
345
+ vxmin,vxmax,vymin,vymax = DCL.sgqvpt
346
+ vx = 0.70
347
+ vy = 0.045 + (lnum-1)*dvy
348
+ str_ary.each{|str|
349
+ DCL::sgtxzv(vx,vy,str,charsize,0,-1,1)
350
+ vy -= dvy
351
+ }
352
+ DCL.sgpset('lclip',lclip)
353
+ nil
354
+ end
355
+
356
+ def each_along_dims(gphys, loopdim)
357
+
358
+ raise ArgumentError,"1st argument must be an GPhys." if !gphys.is_a?(GPhys)
359
+ if loopdim.is_a?(String)
360
+ dimname = loopdim
361
+ elsif
362
+ if loopdim < 0
363
+ dimname = gphys.coord(gphys.rank + loopdim).name
364
+ else
365
+ dimname = gphys.coord(loopdim).name
366
+ end
367
+ else
368
+ raise ArgumentError,"loopdims must consist of Integer and/or String"
369
+ end
370
+
371
+ loopdim_na = gphys.coord(dimname).val # get coord ary
372
+ loopdim_na = loopdim_na[-1..0] if $OPT_reverse || $OPT_Gr # reverse
373
+ loopdim_na.each { |x|
374
+ yield( gphys.cut(dimname=>x) )
375
+ }
376
+ end
377
+
378
+
379
+ def draw_setup
380
+
381
+ # set missing value
382
+ DCLExt.gl_set_params('lmiss'=>true)
383
+
384
+ # fontsize
385
+ DCL.sgpset('lcntl', false)
386
+ # DCL.uzfact(0.7)
387
+ DCL.sgpset('lfull', true) # use full area in the window
388
+ DCL.sgpset('lfprop',true) # use proportional font
389
+ DCL.uscset('cyspos', 'B' ) # move unit y axis
390
+
391
+ # viewport size
392
+ GGraph.set_fig('viewport'=>$VIEWPORT)
393
+ GGraph.set_fig( 'itr'=>($OPT_itr == nil) ? 1 : $OPT_itr.to_i )
394
+ GGraph.set_fig("xrev"=>"units:mb,units:hPa,units:millibar,positive:down",
395
+ "yrev"=>"units:mb,units:hPa,units:millibar,positive:down")
396
+
397
+ # set options
398
+ min_range, max_range = __split_range($OPT_range)
399
+ min_crange, max_crange = __split_range($OPT_crange)
400
+ min_srange, max_srange = __split_range($OPT_srange)
401
+ if ( $OPT_cint || $OPT_interval || $OPT_int )
402
+ cont_interval = ( $OPT_cint || $OPT_interval || $OPT_int ).to_f
403
+ else
404
+ cont_interval = nil
405
+ end
406
+ if ( $OPT_sint || $OPT_interval || $OPT_int )
407
+ tone_interval = ( $OPT_sint || $OPT_interval || $OPT_int ).to_f
408
+ else
409
+ tone_interval = nil
410
+ end
411
+ GGraph.set_linear_contour_options(
412
+ 'int' => cont_interval,
413
+ 'min' => ( min_crange || min_range ),
414
+ 'max' => ( max_crange || max_range )
415
+ )
416
+ GGraph.set_linear_tone_options(
417
+ 'int' => tone_interval,
418
+ 'min' => ( min_srange || min_range ),
419
+ 'max' => ( max_srange || max_range )
420
+ )
421
+
422
+ if ( $OPT_clevels || $OPT_levels )
423
+ $OPT_label=($OPT_clevels || $OPT_levels).split(',')
424
+ $OPT_clevels=($OPT_clevels || $OPT_levels).split(',').map!{|v| v.to_f }
425
+ end
426
+
427
+ if ( $OPT_slevels || $OPT_levels )
428
+ $OPT_slevels=($OPT_slevels||$OPT_levels).split(',').map!{|v| v.to_f }
429
+ end
430
+
431
+ if ( $OPT_patterns )
432
+ $OPT_patterns=$OPT_patterns.split(',').map!{|v| v.to_f }
433
+ end
434
+
435
+ # similar projection
436
+ if ($OPT_similar)
437
+ if /([\d\-.]*),([\d\-.]*),([\d\-.]*)/ =~ $OPT_similar
438
+ similar=[$1.to_f,$2.to_f,$3.to_f]
439
+ elsif /([\d\-.]*),([\d\-.]*)/ =~ $OPT_similar
440
+ similar=[$1.to_f,$2.to_f,0]
441
+ elsif /([\d\-.]*)/ =~ $OPT_similar
442
+ similar=[$1.to_f,0,0]
443
+ end
444
+ GGraph.set_fig('similar'=>similar)
445
+ end
446
+
447
+ # similar projection
448
+ if ($OPT_map_axis)
449
+ if /([\d\-.]*),([\d\-.]*),([\d\-.]*)/ =~ $OPT_map_axis
450
+ map_axis=[$1.to_f,$2.to_f,$3.to_f]
451
+ elsif /([\d\-.]*),([\d\-.]*)/ =~ $OPT_map_axis
452
+ map_axis=[$1.to_f,$2.to_f,0]
453
+ elsif /([\d\-.]*)/ =~ $OPT_similar
454
+ map_axis=[$1.to_f,0,0]
455
+ end
456
+ GGraph.set_fig('map_axis'=>map_axis)
457
+ end
458
+
459
+ # clipping parameter
460
+ if ( $OPT_map_radius )
461
+ map_radius=$OPT_map_radius.to_f
462
+ else
463
+ map_radius=90.0
464
+ end
465
+ GGraph.set_fig('map_radius'=>map_radius)
466
+
467
+ # map
468
+ if ( $OPT_m || $OPT_map)
469
+ map_type = "coast_world" if $OPT_m
470
+ map_type = $OPT_map if $OPT_map
471
+ GGraph::set_map(map_type=>true)
472
+ end
473
+
474
+ # time axis
475
+ if ($OPT_time_ax)
476
+ $OPT_time_ax = false if $OPT_time_ax == "false"
477
+ GGraph.set_axes('time_ax'=>$OPT_time_ax)
478
+ end
479
+
480
+ end
481
+
482
+ def draw(gp, draw_flag)
483
+
484
+ # draw hontai
485
+ case draw_flag
486
+ when "line"
487
+ if ( $Overplot == 1 )
488
+ GGraph.line(gp,
489
+ true,
490
+ "title"=>$OPT_title,
491
+ "index"=>($OPT_index||1),
492
+ "type" =>($OPT_type ||1),
493
+ "exchange"=>$OPT_exch,
494
+ "annotate"=>$annotate,
495
+ "min" => __split_range($OPT_range)[0],
496
+ "max" => __split_range($OPT_range)[1]
497
+ )
498
+ elsif ( $OPT_overplot_color || $OPT_Opc )
499
+ GGraph.line(gp,
500
+ false,
501
+ "title"=>$OPT_title,
502
+ "index"=>($OPT_index.to_i+$Overplot*10),
503
+ "type" =>($OPT_type ||1),
504
+ "exchange"=>$OPT_exch,
505
+ "annotate"=>$annotate,
506
+ "min" => __split_range($OPT_range)[0],
507
+ "max" => __split_range($OPT_range)[1]
508
+ )
509
+ else
510
+ GGraph.line(gp,
511
+ false,
512
+ "title"=>$OPT_title,
513
+ "index"=>($OPT_index||1),
514
+ "type" =>($OPT_type ||$Overplot),
515
+ "exchange"=>$OPT_exch,
516
+ "annotate"=>$annotate,
517
+ "min" => __split_range($OPT_range)[0],
518
+ "max" => __split_range($OPT_range)[1]
519
+ )
520
+ end
521
+ if ( $Overplot < $Overplot_max )
522
+ $Overplot += 1
523
+ else
524
+ $Overplot = 1
525
+ end
526
+
527
+ when "mark"
528
+ if ( $Overplot == 1 )
529
+ GGraph.mark(gp,
530
+ true,
531
+ "title"=>$OPT_title,
532
+ "index"=>($OPT_index||1),
533
+ "type" =>($OPT_type ||1),
534
+ "exchange"=>$OPT_exch,
535
+ "annotate"=>$annotate,
536
+ "min" => __split_range($OPT_range)[0],
537
+ "max" => __split_range($OPT_range)[1]
538
+ )
539
+ else
540
+ GGraph.mark(gp,
541
+ false,
542
+ "title"=>$OPT_title,
543
+ "index"=>($OPT_index||1),
544
+ "type" =>($OPT_type ||$Overplot),
545
+ "exchange"=>$OPT_exch,
546
+ "annotate"=>$annotate,
547
+ "min" => __split_range($OPT_range)[0],
548
+ "max" => __split_range($OPT_range)[1]
549
+ )
550
+ end
551
+ if ( $Overplot < $Overplot_max )
552
+ $Overplot += 1
553
+ else
554
+ $Overplot = 1
555
+ end
556
+
557
+ when "full"
558
+ GGraph.tone(gp,
559
+ true,
560
+ "title"=>$OPT_title,
561
+ "annotate"=>$annotate,
562
+ "transpose"=>$OPT_exch,
563
+ "levels"=>$OPT_slevels,
564
+ "patterns"=>$OPT_patterns,
565
+ "auto"=>$auto,
566
+ "tonf"=>$tonf,
567
+ "tonb"=>$tonb,
568
+ "tonc"=>$tonc,
569
+ "xcoord"=>$OPT_xcoord,
570
+ "ycoord"=>$OPT_ycoord
571
+ )
572
+ GGraph.contour(gp,
573
+ false,
574
+ "transpose"=>$OPT_exch,
575
+ "levels"=>$OPT_clevels,
576
+ "nozero"=>$OPT_nozero,
577
+ "label"=>$OPT_label,
578
+ "xcoord"=>$OPT_xcoord,
579
+ "ycoord"=>$OPT_ycoord
580
+ )
581
+ when "nocont"
582
+ GGraph.tone(gp,
583
+ true,
584
+ "title"=>$OPT_title,
585
+ "annotate"=>$annotate,
586
+ "transpose"=>$OPT_exch,
587
+ "levels"=>$OPT_slevels,
588
+ "patterns"=>$OPT_patterns,
589
+ "auto"=>$auto,
590
+ "tonf"=>$tonf,
591
+ "tonb"=>$tonb,
592
+ "tonc"=>$tonc,
593
+ "xcoord"=>$OPT_xcoord,
594
+ "ycoord"=>$OPT_ycoord
595
+ )
596
+ when "noshade"
597
+ mj = DCL.udpget('indxmj')
598
+ mn = DCL.udpget('indxmn')
599
+ GGraph.contour(gp,
600
+ true,
601
+ "title" =>$OPT_title,
602
+ "annotate"=>$annotate,
603
+ "transpose"=>$OPT_exch,
604
+ "levels"=>$OPT_clevels,
605
+ "nozero"=>$OPT_nozero,
606
+ "label"=>$OPT_label,
607
+ "xcoord"=>$OPT_xcoord,
608
+ "ycoord"=>$OPT_ycoord
609
+ )
610
+ end
611
+
612
+ # color bar
613
+ if ( ( draw_flag == "full") || ( draw_flag == "nocont") ) && $colorbar
614
+ GGraph::color_bar(
615
+ "left" => true,
616
+ "landscape" => true
617
+ )
618
+ end
619
+
620
+ end
621
+
622
+
623
+ def set_vpsize( default_vp, aspect=2.0 )
624
+
625
+ raise "#{aspect} must be a positive Numeric" if (aspect.to_f <= 0.0)
626
+ aspect = aspect.to_f
627
+
628
+ # default viewport
629
+ x0 = default_vp[0]; x1 = default_vp[1]
630
+ y0 = default_vp[2]; y1 = default_vp[3]
631
+ # viewport size
632
+ hlength = x1 - x0
633
+ vlength = y1 - y0
634
+ # center grid of viewport
635
+ cen_of_vp = [ x0 + hlength/2.0, y0 + vlength/2.0 ]
636
+
637
+ if aspect <= hlength / vlength
638
+ hlength = vlength * aspect
639
+ x0 = cen_of_vp[0] - hlength/2.0
640
+ x1 = cen_of_vp[0] + hlength/2.0
641
+ else
642
+ vlength = hlength / aspect
643
+ y0 = cen_of_vp[1] - vlength/2.0
644
+ y1 = cen_of_vp[1] + vlength/2.0
645
+ end
646
+
647
+ return [ x0, x1, y0, y1 ]
648
+
649
+ end
650
+
651
+ def __split_range(range)
652
+
653
+ if /(.*):(.*)/ =~ range
654
+ if $1 == ""
655
+ min = nil
656
+ else
657
+ min = $1.to_f
658
+ end
659
+ if $2 == ""
660
+ max = nil
661
+ else
662
+ max = $2.to_f
663
+ end
664
+ elsif range == nil
665
+ min = max = nil
666
+ else
667
+ raise "invalid range: variable subset specification error. split range with ':'\n\n"
668
+ end
669
+
670
+ return min, max
671
+ end
672
+
673
+ def check_dclopts
674
+
675
+ indices = []
676
+ ARGV.each_index{|i|
677
+ if /^-(.)(.):(.*)=(.*)/ =~ ARGV[i]
678
+ indices << i
679
+ end
680
+ }
681
+
682
+ dclopts = []
683
+ indices.reverse_each{|i|
684
+ dclopts << ARGV[i]
685
+ ARGV.slice!(i)
686
+ }
687
+
688
+ dclopts.each{|opt|
689
+ pkg = opt[1..2]
690
+ name = opt[4..-1].split('=')[0]
691
+ value = opt[4..-1].split('=')[1]
692
+ dcl_set_params(pkg,name,value)
693
+ }
694
+
695
+ end
696
+
697
+ def dcl_set_params(pkg,name,value)
698
+
699
+ set = 'stx'
700
+ case name
701
+ when /^c/i
702
+ eval( "DCL.#{pkg}c#{set}(name,value.to_s)" )
703
+ when /^l/i
704
+ if /(.*)(T|t)(.*)/ =~ value
705
+ eval( "DCL.#{pkg}l#{set}(name,true)" )
706
+ else
707
+ if /(.*)(F|f)(.*)/ =~ value
708
+ eval( "DCL.#{pkg}l#{set}(name,false)" )
709
+ else
710
+ raise "value of logical parameter must include 't' or 'f'"
711
+ end
712
+ end
713
+ when /^[i-n]/i
714
+ eval( "DCL.#{pkg}i#{set}(name,value.to_i)" )
715
+ else
716
+ eval( "DCL.#{pkg}r#{set}(name,value.to_f)" )
717
+ end
718
+
719
+ end
720
+
721
+ #####################################################
722
+ ###++++++ Main Routine ++++++###
723
+
724
+ ## options for DCL
725
+ check_dclopts
726
+
727
+ ## parse options
728
+ parser = GetoptLong.new
729
+ parser.set_options(
730
+ ### global option ###
731
+ ['--var', GetoptLong::REQUIRED_ARGUMENT],
732
+ ['--wsn', GetoptLong::REQUIRED_ARGUMENT],
733
+ ['--clrmap', GetoptLong::REQUIRED_ARGUMENT],
734
+ ['--itr', GetoptLong::REQUIRED_ARGUMENT],
735
+ ['--similar', GetoptLong::REQUIRED_ARGUMENT],
736
+ ['--map_axis', GetoptLong::REQUIRED_ARGUMENT],
737
+ ['--map_radius', GetoptLong::REQUIRED_ARGUMENT],
738
+ ['--xcoord', GetoptLong::REQUIRED_ARGUMENT],
739
+ ['--ycoord', GetoptLong::REQUIRED_ARGUMENT],
740
+ ['--title', GetoptLong::REQUIRED_ARGUMENT],
741
+ ['--aspect', GetoptLong::REQUIRED_ARGUMENT],
742
+ ['--anim', GetoptLong::REQUIRED_ARGUMENT],
743
+ ['--animate', GetoptLong::REQUIRED_ARGUMENT],
744
+ ['--noannotate', GetoptLong::NO_ARGUMENT],
745
+ ['--alternate', GetoptLong::NO_ARGUMENT],
746
+ ['--Ga', GetoptLong::NO_ARGUMENT],
747
+ ['--nowait', GetoptLong::NO_ARGUMENT],
748
+ ['--Gw', GetoptLong::NO_ARGUMENT],
749
+ ['--smooth', GetoptLong::NO_ARGUMENT],
750
+ ['--Gaw', GetoptLong::NO_ARGUMENT],
751
+ ['--delay', GetoptLong::REQUIRED_ARGUMENT],
752
+ ['--exch', GetoptLong::NO_ARGUMENT],
753
+ ['--reverse', GetoptLong::NO_ARGUMENT],
754
+ ['--Gr', GetoptLong::NO_ARGUMENT],
755
+ ['--mean', GetoptLong::REQUIRED_ARGUMENT],
756
+ ['--stddev', GetoptLong::REQUIRED_ARGUMENT
757
+ ],
758
+ ['--eddy', GetoptLong::REQUIRED_ARGUMENT],
759
+ ['--diff', GetoptLong::NO_ARGUMENT],
760
+ ['--map', GetoptLong::REQUIRED_ARGUMENT],
761
+ ['--m', GetoptLong::NO_ARGUMENT],
762
+ ['--operation', GetoptLong::REQUIRED_ARGUMENT],
763
+ ['--time_ax', GetoptLong::REQUIRED_ARGUMENT],
764
+ ### line/mark option ###
765
+ ['--line', GetoptLong::NO_ARGUMENT],
766
+ ['--mark', GetoptLong::NO_ARGUMENT],
767
+ ['--index', GetoptLong::REQUIRED_ARGUMENT],
768
+ ['--type', GetoptLong::REQUIRED_ARGUMENT],
769
+ ['--overplot', GetoptLong::REQUIRED_ARGUMENT],
770
+ ['--overplot_color', GetoptLong::NO_ARGUMENT],
771
+ ['--Opc', GetoptLong::NO_ARGUMENT],
772
+ ### tone or cont option ###
773
+ ['--nocont', GetoptLong::NO_ARGUMENT],
774
+ ['--noshade', GetoptLong::NO_ARGUMENT],
775
+ ['--range', GetoptLong::REQUIRED_ARGUMENT],
776
+ ['--crange', GetoptLong::REQUIRED_ARGUMENT],
777
+ ['--srange', GetoptLong::REQUIRED_ARGUMENT],
778
+ ['--interval', GetoptLong::REQUIRED_ARGUMENT],
779
+ ['--int', GetoptLong::REQUIRED_ARGUMENT],
780
+ ['--cint', GetoptLong::REQUIRED_ARGUMENT],
781
+ ['--sint', GetoptLong::REQUIRED_ARGUMENT],
782
+ ['--levels', GetoptLong::REQUIRED_ARGUMENT],
783
+ ['--clevels', GetoptLong::REQUIRED_ARGUMENT],
784
+ ['--slevels', GetoptLong::REQUIRED_ARGUMENT],
785
+ ['--patterns', GetoptLong::REQUIRED_ARGUMENT],
786
+ ['--tone', GetoptLong::REQUIRED_ARGUMENT],
787
+ ['--udsfmt', GetoptLong::REQUIRED_ARGUMENT],
788
+ ['--nocolorbar', GetoptLong::NO_ARGUMENT],
789
+ ['--nozero', GetoptLong::NO_ARGUMENT],
790
+ ['--help', GetoptLong::NO_ARGUMENT]
791
+ # ['--version', GetoptLong::NO_ARGUMENT] # to be defined
792
+ )
793
+ begin
794
+ parser.each_option do |name, arg|
795
+ eval "$OPT_#{name.sub(/^--/, '').gsub(/-/, '_')} = '#{arg}'" # strage option value to $OPT_val
796
+ end
797
+ rescue
798
+ help
799
+ raise
800
+ end
801
+
802
+ ## Print out help message
803
+ if ($OPT_help)
804
+ help
805
+ exit(1)
806
+ end
807
+
808
+ ## set some figure option
809
+ DCL::swlset('lwait', false) if ($OPT_nowait || $OPT_Gw || $OPT_smooth || $OPT_Gaw)
810
+ # set wait or nowait
811
+ DCL::swlset('lalt', true) if ($OPT_alternate || $OPT_Ga || $OPT_smooth || $OPT_Gaw)
812
+ # set backing store option
813
+ if ($OPT_noannotate)
814
+ $annotate = false
815
+ else
816
+ $annotate = true
817
+ end
818
+
819
+ $Overplot_max = ( $OPT_overplot.to_i || 1 )
820
+ $Overplot = 1
821
+
822
+ if ($OPT_nocolorbar)
823
+ $colorbar = false
824
+ else
825
+ $colorbar = true
826
+ end
827
+
828
+ if ($OPT_tone)
829
+ case $OPT_tone
830
+ when "a"
831
+ $auto, $tonf, $tonb, $tonc = true,false,false,false
832
+ when "e"
833
+ $auto, $tonf, $tonb, $tonc = false,false,false,false
834
+ when "f"
835
+ $auto, $tonf, $tonb, $tonc = false,true,false,false
836
+ when "b"
837
+ $auto, $tonf, $tonb, $tonc = false,false,true,false
838
+ when "c"
839
+ $auto, $tonf, $tonb, $tonc = false,false,false,true
840
+ else
841
+ raise "The value of option --tone should be 'a','e','f','b' or 'c'."
842
+ end
843
+ else
844
+ $auto, $tonf, $tonb, $tonc = true,false,false,false
845
+ end
846
+
847
+ ## decide VIEWPORT
848
+ $VIEWPORT = set_vpsize( VIEWPORT, ($OPT_aspect||2.0) )
849
+
850
+ ## tune the size of axis parameters.
851
+ DCL.uzfact(0.7)
852
+
853
+ ## set the format of contour labels.
854
+ udsfmt = ($OPT_udsfmt||DCL.udqfmt())
855
+ DCL.udsfmt(udsfmt)
856
+
857
+ ## draw figure
858
+ loopdim = ( $OPT_animate || $OPT_anim )
859
+ loopdim = loopdim.to_i if loopdim.to_i.to_s == loopdim
860
+
861
+ ### set colormap
862
+ DCL.sgscmn($OPT_clrmap||1)
863
+ ## open work station
864
+ if NumRu::DCL::DCLVERSION.to_f >= 6
865
+ DCL.gropn($OPT_wsn||1)
866
+ else
867
+ DCL.gropn($OPT_wsn||4)
868
+ end
869
+
870
+ ## open netcdf variables
871
+
872
+ while ARGV[0] do
873
+ gturl = ARGV[0]
874
+ gturl = gturl+'@'+$OPT_var if $OPT_var
875
+
876
+ gp = GPhys::IO.open_gturl(gturl)
877
+ print " Reading #{gturl}\n"
878
+ ARGV.shift
879
+
880
+ ## for case of calculating difference of two gphys object
881
+ if ($OPT_diff)
882
+ raise "--diff option must be used with even numbers (2, 4, 6,...) of gturls" if ARGV[0] == nil
883
+ prev_gturl = gturl
884
+ gturl = ARGV[0]
885
+ gturl = gturl+'@'+$OPT_var if $OPT_var
886
+ print " Reading #{gturl}\n"
887
+ gp = gp - GPhys::IO.open_gturl(gturl)
888
+ print " Taking difference: #{prev_gturl} - #{gturl}\n"
889
+ gturl = prev_gturl+" - "+gturl
890
+ ARGV.shift
891
+ end
892
+
893
+ ## mean along any axis
894
+ if ($OPT_mean)
895
+ dims_mean = ($OPT_mean).split(/\s*,\s*/)
896
+ dims_mean = dims_mean.map{|dim| dim.to_i.to_s == dim ? dim.to_i : dim}
897
+ end
898
+
899
+ ## standard deviation along any axis
900
+ if ($OPT_stddev)
901
+ dims_stddev = ($OPT_stddev).split(/\s*,\s*/)
902
+ dims_stddev = dims_stddev.map{|dim| dim.to_i.to_s == dim ? dim.to_i : dim}
903
+ end
904
+
905
+ ## deviation from mean along any axis
906
+ if ($OPT_eddy)
907
+ dims_eddy = ($OPT_eddy).split(/\s*,\s*/)
908
+ dims_eddy = dims_eddy.map{|dim| dim.to_i.to_s == dim ? dim.to_i : dim}
909
+ end
910
+
911
+ GGraph.margin_info($0, gturl) if $annotate # draw margin infomation
912
+ draw_setup # determine figure kind
913
+
914
+
915
+ kind_of_fig = nil
916
+ proc = Proc.new do |g|
917
+ ## mean along any axis
918
+ if ($OPT_mean)
919
+ dims_mean.each{|dim|
920
+ g = g.mean(dim)
921
+ }
922
+ end
923
+
924
+ ## standard deviation along any axis
925
+ if ($OPT_stddev)
926
+ dims_stddev.each{|dim|
927
+ g = g.stddev(dim)
928
+ }
929
+ end
930
+
931
+ ## deviation from mean along any axis
932
+ if ($OPT_eddy)
933
+ dims_eddy.each{|dim|
934
+ g = g.eddy(dim)
935
+ }
936
+ end
937
+
938
+ ## operation of a mathematical function
939
+ if ($OPT_operation)
940
+ eval "g = g.#{$OPT_operation}"
941
+ end
942
+
943
+ # judge draw kind
944
+ unless kind_of_fig
945
+ gp_rank = g.rank
946
+ if ($OPT_mark)
947
+ kind_of_fig = "mark"
948
+ elsif ($OPT_line || gp_rank == 1)
949
+ kind_of_fig = "line"
950
+ elsif (!$OPT_line && gp_rank >= 2) && !$OPT_noshade && $OPT_nocont
951
+ kind_of_fig = "nocont"
952
+ elsif (!$OPT_line && gp_rank >= 2) && $OPT_noshade && !$OPT_nocont
953
+ kind_of_fig = "noshade"
954
+ elsif (!$OPT_line && gp_rank >= 2) && !$OPT_noshade && !$OPT_nocont
955
+ kind_of_fig = "full"
956
+ end
957
+ end
958
+
959
+ draw(g, kind_of_fig)
960
+ end
961
+
962
+ if loopdim # animation
963
+ each_along_dims(gp, loopdim){|gp_subset|
964
+ proc.call(gp_subset)
965
+ sleep($OPT_delay.to_f) if ($OPT_delay && !DCL::swlget('lwait'))
966
+ }
967
+ else
968
+ proc.call(gp)
969
+ end
970
+
971
+ end
972
+
973
+ DCL.grcls
@@ -93,10 +93,14 @@ module NumRu
93
93
  w /= w.mean
94
94
  w.reshape!(n)
95
95
  else
96
- if !(opts[:disable_weight]||opts["disable_weight"]) && /^lon/ =~ new_grid.coord(0).name && /^lat/ =~ new_grid.coord(1).name
96
+ nc0 = new_grid.coord(0)
97
+ nc1 = new_grid.coord(1)
98
+ if !(opts[:disable_weight]||opts["disable_weight"]) &&
99
+ ( /^lon/ =~ nc0.name || /^degree.*_east/ =~ nc0.units.to_s ) &&
100
+ ( /^lat/ =~ nc1.name || /^degree.*_north/ =~ nc1.units.to_s )
97
101
  rad = NumRu::Units.new("radian")
98
- nlon = new_grid.coord(0).length
99
- lat = new_grid.coord(1).convert_units(rad).val
102
+ nlon = nc0.length
103
+ lat = nc1.convert_units(rad).val
100
104
  w = NArray.new(lat.typecode,nlon).fill!(1) * NMath::cos(lat).reshape(1,lat.length)
101
105
  w /= w.mean
102
106
  w.reshape!(n)
@@ -112,7 +116,8 @@ module NumRu
112
116
  index[dims1] = ind
113
117
  val = gphys[*index].val
114
118
  val.reshape!(n_lost)
115
- val -= val.mean
119
+ vm = val.mean
120
+ val -= vm unless vm.nil?
116
121
  ary[true,n1] = val
117
122
  break if n1==n-1
118
123
  ind[0] += 1
@@ -125,8 +130,7 @@ module NumRu
125
130
  end
126
131
  }
127
132
  }
128
- ary.mul!(w.reshape(1,n)) if w
129
-
133
+ ary = ary.mul!(w.reshape(1,n)) if w
130
134
 
131
135
  nmodes = opts[:nmodes] || opts["nmodes"] || n
132
136
  case @@EOF_engin
@@ -3307,7 +3307,7 @@ module NumRu
3307
3307
  xr = NArray.sfloat(2) # --> x ends of the regression line
3308
3308
  yr = NArray.sfloat(2) # --> y ends of the regression line
3309
3309
  if y_given_x
3310
- a,b,r2 = linear_regression(xs,ys)
3310
+ a,b,r = linear_regression(xs,ys)
3311
3311
  if opts["limit"]
3312
3312
  xr[0] = x.min
3313
3313
  xr[1] = x.max
@@ -3318,7 +3318,7 @@ module NumRu
3318
3318
  yrs = a + b*xrs
3319
3319
  yr = !ylog ? yrs : NMath::exp(yrs)
3320
3320
  else
3321
- a,b,r2 = linear_regression(ys,xs)
3321
+ a,b,r = linear_regression(ys,xs)
3322
3322
  if opts["limit"]
3323
3323
  yr[0] = y.min
3324
3324
  yr[1] = y.max
@@ -3346,8 +3346,8 @@ module NumRu
3346
3346
  annot = ["regr x=a+by:",
3347
3347
  " a=#{DCL.chval('A',a)}", " b=#{DCL.chval('A',b)}"]
3348
3348
  end
3349
- annot.push(sprintf("r=%-.3g",Math.sqrt(r2))) if ac
3350
- annot.push(sprintf("r2=%-.3g",r2)) if ar2
3349
+ annot.push(sprintf("r=%-.3g",r)) if ac
3350
+ annot.push(sprintf("r2=%-.3g",r**2)) if ar2
3351
3351
  annotate(annot, @@nannot)
3352
3352
  elsif as
3353
3353
  if y_given_x
@@ -3355,12 +3355,12 @@ module NumRu
3355
3355
  else
3356
3356
  annot = ["regress x given y:", " x(y) slope: #{DCL.chval('A',b)}"]
3357
3357
  end
3358
- annot.push(sprintf("r=%-.3g",Math.sqrt(r2))) if ac
3359
- annot.push(sprintf("r2=%-.3g",r2)) if ar2
3358
+ annot.push(sprintf("r=%-.3g",r)) if ac
3359
+ annot.push(sprintf("r2=%-.3g",r**2)) if ar2
3360
3360
  annotate(annot, @@nannot)
3361
3361
  end
3362
3362
 
3363
- [a,b,r2]
3363
+ [a,b,r]
3364
3364
  end
3365
3365
  end
3366
3366
 
@@ -3372,8 +3372,8 @@ module NumRu
3372
3372
  b = cxy/cxx
3373
3373
  a = my - b*mx
3374
3374
  cyy, ndiv = NMMath.covariance(y,y)
3375
- r2 = cxy/Math.sqrt(cxx*cyy)
3376
- [a,b,r2]
3375
+ r = cxy/Math.sqrt(cxx*cyy)
3376
+ [a,b,r]
3377
3377
  end
3378
3378
 
3379
3379
  def linear_reg_slope_error(x,y,a,b)
@@ -19,19 +19,22 @@ module NumRu
19
19
  if assoc_crds.uniq.length != assoc_crds.length
20
20
  raise ArgumentError, "Names are not uniq: #{assoc_crds.inspect}."
21
21
  end
22
+ @axnames = axnames.dup
22
23
  assoc_crds.each do |gp|
23
24
  raise(ArgumentError,"Non-GPhys included") if !gp.is_a?(GPhys)
24
25
  if axnames.include?(gp.name)
25
26
  raise ArgumentError,
26
27
  "'#{gp.name}' overwraps an axis name #{axnames.inspect}."
27
28
  end
29
+ if (gp.axnames - @axnames).length > 0
30
+ raise ArgumentError, "Provided assoc coord '#{gp.name}' has an axis (axes) #{gp.axnames - @axnames} not in the present object #{@axnames}"
31
+ end
28
32
  end
29
33
 
30
34
  # < some internal variables >
31
35
 
32
36
  @assoc_crds = Hash.new
33
37
  assoc_crds.each{|gp| @assoc_crds[gp.name] = gp}
34
- @axnames = axnames.dup
35
38
  @lost_assoc_crds = nil
36
39
 
37
40
  # < lengths of original axes >
@@ -747,6 +747,9 @@ module NumRu
747
747
  def rank
748
748
  @grid.rank
749
749
  end
750
+ def rank_len_ne_1
751
+ (shape_current - [1]).length
752
+ end
750
753
  def axis(i)
751
754
  @grid.axis(i)
752
755
  end
@@ -552,10 +552,10 @@ These methods returns a NArray (not a VArray).
552
552
  un0 = UNumeric.from_date(date0,to,calendar)
553
553
  offset = un0.to_f
554
554
  gp = self + offset
555
+ gp.units = to
555
556
  else
556
557
  gp = myunits.convert2(self, to)
557
558
  end
558
- gp.units = to
559
559
  gp
560
560
  else
561
561
  self # returns self (no duplication)
@@ -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.3"
4
+ VERSION = "1.5.4"
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.3
4
+ version: 1.5.4
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-01-26 00:00:00.000000000 Z
15
+ date: 2018-03-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: narray
@@ -129,6 +129,7 @@ executables:
129
129
  - gpprint
130
130
  - gpvect
131
131
  - gpview
132
+ - gpview~
132
133
  - grads2nc_with_gphys
133
134
  extensions:
134
135
  - ext/numru/gphys/extconf.rb
@@ -152,6 +153,7 @@ files:
152
153
  - bin/gpprint
153
154
  - bin/gpvect
154
155
  - bin/gpview
156
+ - bin/gpview~
155
157
  - bin/grads2nc_with_gphys
156
158
  - doc/attribute.html
157
159
  - doc/attributenetcdf.html