gphys 1.5.4 → 1.5.5

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: 1341ed41033b2f8c5e07671a4c0e541e0135ef73
4
- data.tar.gz: 69b01da241605e1337df420e4d48ff8cce4ba561
3
+ metadata.gz: 7aaecda27419a8adf9f1e781af6a5f20b99cc379
4
+ data.tar.gz: 04e9c2a1bfc1f64f64b3a22dca57f58670cc253a
5
5
  SHA512:
6
- metadata.gz: 694f55d83e1ec6a41d25af18f6cbc415b9462e7391a041e4b78f12d2681116ca6dbb74ee61c22aa4756bdc968af55e4e16da81c21685115e8ea30394e2d6ab30
7
- data.tar.gz: 8cebe5a572e40ab3e1c1b9c98b759e21570a3397abe911206e2c61c7e083d7c623e09060167187979b1302a089df6c26190ab6a1425867dd72e1b2f4034e3da6
6
+ metadata.gz: 22a6d4fd428e831e759cb0fdba47d3a13efa1a4dd274484875fd473588b0a6d4c479dc612d017c0a62686869d662ce5e37deda682b17903e333a5f0abc77a9ce
7
+ data.tar.gz: f4acafc4f36955dbeec365137659ccfd5077f4372a5e379f21acde0670a1a8578216c6fc9a2c5e902749ccb62b4934a8db801642fcd4de34dcd1366d6ba7a919
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ 2018-03-20 Takeshi Horinouchi
2
+ To release version 1.5.5 (git tag v1.5.5)
3
+
4
+ M lib/numru/gphys/version.rb
5
+
6
+ 2018-03-19 Takeshi Horinouchi
7
+ Reverted the previous commit (9d63cd41fa53c on 2018-02-20)
8
+
9
+ M lib/numru/gphys/varray.rb
10
+
1
11
  2018-03-04 Takeshi Horinouchi
2
12
  To release version 1.5.4 (git tag v1.5.4)
3
13
 
@@ -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
556
555
  else
557
556
  gp = myunits.convert2(self, to)
558
557
  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.4"
4
+ VERSION = "1.5.5"
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.4
4
+ version: 1.5.5
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-04 00:00:00.000000000 Z
15
+ date: 2018-03-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: narray
@@ -129,7 +129,6 @@ executables:
129
129
  - gpprint
130
130
  - gpvect
131
131
  - gpview
132
- - gpview~
133
132
  - grads2nc_with_gphys
134
133
  extensions:
135
134
  - ext/numru/gphys/extconf.rb
@@ -153,7 +152,6 @@ files:
153
152
  - bin/gpprint
154
153
  - bin/gpvect
155
154
  - bin/gpview
156
- - bin/gpview~
157
155
  - bin/grads2nc_with_gphys
158
156
  - doc/attribute.html
159
157
  - doc/attributenetcdf.html
@@ -1,973 +0,0 @@
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