gentooboontoo-gphys 0.6.1.3 → 1.3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +5631 -464
  3. data/LICENSE.txt +34 -0
  4. data/README +23 -25
  5. data/bin/gdir_client +25 -7
  6. data/bin/gdir_server +19 -13
  7. data/bin/gpaop +41 -28
  8. data/bin/gpcat +19 -11
  9. data/bin/gpcut +20 -11
  10. data/bin/gpedit +37 -1
  11. data/bin/gplist +5 -4
  12. data/bin/gpmath +21 -14
  13. data/bin/gpmaxmin +9 -7
  14. data/bin/gpprint +15 -11
  15. data/bin/gpvect +217 -96
  16. data/bin/gpview +278 -123
  17. data/bin/grads2nc_with_gphys +11 -6
  18. data/doc/attribute.html +1 -1
  19. data/doc/axis.html +85 -66
  20. data/doc/coordmapping.html +22 -22
  21. data/doc/dclext.html +709 -0
  22. data/doc/derivative/gphys-derivative.html +33 -13
  23. data/doc/derivative/numru-derivative.html +60 -31
  24. data/doc/gdir.html +76 -76
  25. data/doc/gdir_server.html +28 -16
  26. data/doc/ggraph.html +493 -706
  27. data/doc/gpcat.html +28 -11
  28. data/doc/gpcut.html +26 -11
  29. data/doc/gphys.html +195 -71
  30. data/doc/gphys_fft.html +162 -21
  31. data/doc/gphys_grads_io.html +9 -9
  32. data/doc/gphys_grib_io.html +7 -7
  33. data/doc/gphys_io.html +118 -31
  34. data/doc/gphys_io_common.html +1 -1
  35. data/doc/gphys_netcdf_io.html +14 -14
  36. data/doc/gplist.html +6 -5
  37. data/doc/gpmath.html +32 -14
  38. data/doc/gpmaxmin.html +9 -7
  39. data/doc/gpprint.html +14 -11
  40. data/doc/gpview.html +254 -146
  41. data/doc/grads2nc_with_gphys.html +6 -8
  42. data/doc/grads_gridded.html +77 -77
  43. data/doc/grib.html +102 -59
  44. data/doc/grid.html +45 -61
  45. data/doc/index.html +51 -41
  46. data/doc/index.rd +47 -36
  47. data/doc/netcdf_convention.html +39 -39
  48. data/doc/unumeric.html +79 -30
  49. data/doc/update +2 -1
  50. data/doc/varray.html +62 -56
  51. data/doc/varraycomposite.html +3 -3
  52. data/ext/ext_coord.c +209 -0
  53. data/ext/ext_init.c +7 -0
  54. data/ext/extconf.rb +41 -0
  55. data/ext/interpo.c +536 -0
  56. data/ext/multibitIO.c +567 -0
  57. data/lib/numru/dcl_mouse.rb +71 -0
  58. data/lib/numru/dclext.rb +2749 -0
  59. data/lib/numru/derivative.rb +124 -31
  60. data/lib/numru/ganalysis.rb +7 -0
  61. data/lib/numru/ganalysis/covariance.rb +154 -0
  62. data/lib/numru/ganalysis/eof.rb +302 -0
  63. data/lib/numru/ganalysis/histogram.rb +337 -0
  64. data/lib/numru/ganalysis/met.rb +872 -0
  65. data/lib/numru/ganalysis/planet.rb +392 -0
  66. data/lib/numru/ggraph.rb +1709 -2498
  67. data/lib/numru/gphys.rb +7 -1
  68. data/lib/numru/gphys/assoccoords.rb +384 -0
  69. data/lib/numru/gphys/attribute.rb +10 -11
  70. data/lib/numru/gphys/axis.rb +97 -25
  71. data/lib/numru/gphys/coordmapping.rb +2 -2
  72. data/lib/numru/gphys/derivative.rb +117 -46
  73. data/lib/numru/gphys/gphys.rb +595 -31
  74. data/lib/numru/gphys/gphys_fft.rb +365 -13
  75. data/lib/numru/gphys/gphys_grads_io.rb +6 -5
  76. data/lib/numru/gphys/gphys_grib_io.rb +6 -6
  77. data/lib/numru/gphys/gphys_gtool3_io.rb +162 -0
  78. data/lib/numru/gphys/gphys_hdfeos5_io.rb +672 -0
  79. data/lib/numru/gphys/gphys_io.rb +260 -20
  80. data/lib/numru/gphys/gphys_io_common.rb +1 -1
  81. data/lib/numru/gphys/gphys_netcdf_io.rb +111 -40
  82. data/lib/numru/gphys/gphys_nusdas_io.rb +64 -7
  83. data/lib/numru/gphys/grads_gridded.rb +158 -57
  84. data/lib/numru/gphys/grib.rb +205 -157
  85. data/lib/numru/gphys/grib_params.rb +196 -1
  86. data/lib/numru/gphys/grid.rb +214 -83
  87. data/lib/numru/gphys/gtool3.rb +771 -0
  88. data/lib/numru/gphys/interpolate.rb +992 -0
  89. data/lib/numru/gphys/mdstorage.rb +145 -0
  90. data/lib/numru/gphys/narray_ext.rb +34 -0
  91. data/lib/numru/gphys/netcdf_convention.rb +44 -2
  92. data/lib/numru/gphys/subsetmapping.rb +1 -1
  93. data/lib/numru/gphys/unumeric.rb +101 -8
  94. data/lib/numru/gphys/varray.rb +66 -20
  95. data/lib/numru/gphys/varraycomposite.rb +107 -29
  96. data/lib/numru/gphys/varraygrib.rb +70 -8
  97. data/lib/numru/gphys/varraygtool3.rb +226 -0
  98. data/lib/numru/gphys/varrayhdfeos5.rb +451 -0
  99. data/lib/numru/gphys/varraynetcdf.rb +13 -5
  100. data/lib/numru/gphys/version.rb +3 -0
  101. data/sample/druby_cli1.rb +2 -0
  102. data/sample/druby_cli2.rb +0 -6
  103. data/sample/druby_serv2.rb +0 -13
  104. data/sample/ncep_theta_coord.rb +79 -0
  105. data/test/eof_slp.rb +28 -0
  106. data/test/mltbit.dat +0 -0
  107. data/test/test_multibitIO.rb +19 -0
  108. data/testdata/assoc_crds.nc +0 -0
  109. metadata +79 -8
  110. data/lib/numru/dclext_datetime_ax.rb +0 -220
  111. data/lib/numru/vizshot.rb +0 -697
@@ -1,697 +0,0 @@
1
- require "numru/ggraph"
2
- require "yaml"
3
-
4
- module NumRu
5
- class VizShot
6
-
7
- @@ms_windows = false
8
- def self.windows
9
- @@ms_windows = true
10
- end
11
-
12
- @@dumpdir = './'
13
- def self.dumpdir=(dirname)
14
- @@dumpdir = dirname.sub(/([^\/])$/,'\1/') # to end with '/'
15
- end
16
-
17
- @@basename_default = 'vizshot_dump' ## DCL::swcget('FNAME').strip
18
- def self.basename_default=(basename)
19
- @@basename_default = basename
20
- end
21
-
22
- @@plot_methods = Hash.new
23
- @@plot_methods[:plot_1d] = {:ndims=>1,:nvars=>1,:pre_defined=>true}
24
- @@plot_methods[:line] = {:ndims=>1,:nvars=>1,:pre_defined=>true}
25
- @@plot_methods[:mark] = {:ndims=>1,:nvars=>1,:pre_defined=>true}
26
- @@plot_methods[:tone_cont] = {:ndims=>2,:nvars=>1,:pre_defined=>true}
27
- @@plot_methods[:tone] = {:ndims=>2,:nvars=>1,:pre_defined=>true}
28
- @@plot_methods[:contour] = {:ndims=>2,:nvars=>1,:pre_defined=>true}
29
- @@plot_methods[:vector] = {:ndims=>2,:nvars=>2,:pre_defined=>true}
30
-
31
- #<< class methods >>
32
-
33
- class << self
34
- def has_plot_method?(methodname)
35
- @@plot_methods.has_key?(methodname.to_sym)
36
- end
37
- def plot_methods
38
- @@plot_methods.keys
39
- end
40
- def ndims(methodname)
41
- @@plot_methods[methodname.to_sym][:ndims]
42
- end
43
- def nvars(methodname)
44
- @@plot_methods[methodname.to_sym][:nvars]
45
- end
46
- def pre_defined?(methodname)
47
- @@plot_methods[methodname.to_sym][:pre_defined]
48
- end
49
-
50
- def add_extensions(arg)
51
- case arg
52
- when Array
53
- return arg.collect{|hash| add_extensions(hash)}
54
- when Hash
55
- hash = arg
56
- else
57
- raise ArgumentError, "argument must be Hash"
58
- end
59
- name = hash[:name]
60
- hash[:pre_defined] = false
61
- return nil if @@plot_methods[name]
62
- ndims = hash[:ndims] || raise("ndims must be set")
63
- nvars = hash[:nvars] || raise("nvars must be set")
64
- script = hash[:script] || raise("script must be set")
65
- str =<<-"EOS"
66
- def #{name}(gphys, #{nvars>1 ? "gphys1, " : ""} opt)
67
- #{script}
68
- end
69
- private :#{name}
70
- EOS
71
- class_eval(str)
72
- if ggraph = hash[:ggraph]
73
- str =<<-"EOS"
74
- def #{name}(gphys, #{nvars>1 ? "gphys1, " : ""} newframe=true, options=nil)
75
- #{ggraph}
76
- end
77
- module_function :#{name}
78
- EOS
79
- GGraph.module_eval(str)
80
- end
81
- @@plot_methods[name.to_sym] = hash
82
- print "registrated plot method: #{name}\n" if $VERBOSE
83
- return hash
84
- end
85
- end
86
-
87
- #<< methods >>
88
-
89
- def initialize(opt = nil)
90
- opt = opt ? opt.dup : Hash.new
91
- @set = Hash.new
92
- @set[:admin] = Hash.new
93
- @set[:admin][:iwidth] = ( opt.delete(:iwidth) || 700 )
94
- @set[:admin][:iheight] = ( opt.delete(:iheight) || 700 )
95
- @set[:admin][:xdiv] = ( opt.delete(:xdiv) || 1 )
96
- @set[:admin][:ydiv] = ( opt.delete(:ydiv) || 1 )
97
- @set[:admin][:basename] = ( opt.delete(:basename) || @@basename_default)
98
-
99
- if opt.length > 0
100
- raise ArgumentError,"Unsupported option(s) #{opt.keys.inspect}"
101
- end
102
-
103
- @plots = Array.new
104
- end
105
-
106
- def plot(arg)
107
- if (file=arg[:file]) && String===file && !(/http:\/\// =~ file)
108
- arg[:file] = File.expand_path(file)
109
- end
110
- if (file=arg[:file2]) && String===file && !(/http:\/\// =~ file)
111
- arg[:file2] = File.expand_path(file)
112
- end
113
- @plots.push(arg)
114
- @plots.length - 1 # index of the current plot
115
- end
116
-
117
- def add(vizshot)
118
- viz_new = self.semi_deep_clone
119
- vizshot.plots.each{|plot| viz_new.plot(plot)}
120
- viz_new
121
- end
122
-
123
- def replace_plot!(index, arg)
124
- @plots[index].update(arg)
125
- end
126
-
127
- def set_fig(opt)
128
- @set[:fig] = opt
129
- end
130
-
131
- def set_map(opt)
132
- @set[:map] = opt
133
- end
134
-
135
- def set_axes(opt)
136
- @set[:axes] = opt
137
- end
138
-
139
- def set_tone(opt)
140
- @set[:tone] = opt
141
- end
142
-
143
- def set_contour(opt)
144
- @set[:contour] = opt
145
- end
146
-
147
- def execute(opt=nil)
148
- if opt # must be a Hash
149
- opt = opt.dup
150
- postscript = opt.delete(:postscript)
151
- image_dump = opt.delete(:image_dump)
152
- if opt.length > 0
153
- raise ArgumentError,"Unsupported option(s) #{opt.keys.inspect}"
154
- end
155
- end
156
-
157
- setup(postscript,image_dump)
158
- first = true
159
- @plots.each do |p|
160
- exec_plot(p, first)
161
- first = false
162
- end
163
- finish
164
- end
165
-
166
- def dump_code(basename=nil, all_in_one=false, exec_opt=nil)
167
- @set[:admin][:basename] = basename if basename
168
- path = @@dumpdir + @set[:admin][:basename] + '.rb'
169
- File.open(path,'w'){|f| f.print(gen_code(all_in_one, exec_opt))}
170
- path
171
- end
172
-
173
- def dump_code_and_data(basename=nil, all_in_one=false, exec_opt=nil)
174
- @set[:admin][:basename] = basename if basename
175
- viz = self.dup
176
- data_paths = viz.cut_out_data(@set[:admin][:basename])
177
- code_path = viz.dump_code(basename, all_in_one, exec_opt)
178
- [code_path] + data_paths
179
- end
180
-
181
- def gen_code(all_in_one = false, exec_opt=nil)
182
- if all_in_one
183
- libsrc = File.open(__FILE__)
184
- code = ""
185
- while (line=libsrc.gets)
186
- break if /^#.*ENDOFLIB/ =~ line
187
- code << line
188
- end
189
- code << "####################\n"
190
- else
191
- code = 'require "numru/vizshot"'
192
- end
193
- ext_methods = Array.new
194
- @plots.each{|pl|
195
- method = pl[:method]
196
- pm = @@plot_methods[method.to_sym]
197
- unless pm[:pre_defined]
198
- ext_methods.push pm unless ext_methods.include?(pm)
199
- end
200
- }
201
- code += "\next_methods = <<'YML'\n\n#{ext_methods.to_yaml}\nYML\n\n"
202
- code += "\nset = <<YML\n\n#{@set.to_yaml}\nYML\n\n"
203
- code += "\nplots = <<YML\n\n#{@plots.to_yaml}\nYML\n\n"
204
- ecode = <<-EOS
205
- plots = YAML.load(plots)
206
- set = YAML.load(set)
207
- ext_methods = YAML.load(ext_methods)
208
- NumRu::VizShot.add_extensions(ext_methods)
209
- viz = NumRu::VizShot.new(set[:admin])
210
- viz.set_fig(set[:fig]) if set[:fig]
211
- viz.set_map(set[:map]) if set[:map]
212
- viz.set_axes(set[:axes]) if set[:axes]
213
- viz.set_contour(set[:contour]) if set[:contour]
214
- viz.set_tone(set[:tone]) if set[:tone]
215
- plots.each{|p| viz.plot(p)}
216
- viz.execute(#{exec_opt.inspect})
217
- EOS
218
- ecode.gsub!(/^ /,'')
219
- code << ecode
220
- end
221
-
222
- ###################################################
223
- protected
224
-
225
- def semi_deep_clone
226
- viz_new = NumRu::VizShot.new(@set[:admin].dup)
227
- viz_new.set_fig(@set[:fig]) if @set[:fig]
228
- viz_new.set_map(@set[:map]) if @set[:map]
229
- viz_new.set_axes(@set[:axes]) if @set[:axes]
230
- viz_new.set_contour(@set[:contour]) if @set[:contour]
231
- viz_new.set_tone(@set[:tone]) if @set[:tone]
232
- @plots.each{|plot| viz_new.plot(plot.dup) }
233
- return viz_new
234
- end
235
-
236
- def plots
237
- @plots
238
- end
239
-
240
- # for dump_code_and_data
241
- def cut_out_data(basename)
242
- newplots = Array.new
243
- data_paths = Array.new
244
- @plots.each_with_index do |pl, i|
245
- gphys, gphys2 = get_gphyses(pl.dup)
246
- cut = pl[:cut]
247
- slice = pl[:slice]
248
- cut2 = pl[:cut2] || cut
249
- slice2 = pl[:slice2] || slice
250
- method = pl[:method]
251
- if !cut && !slice && self.class.ndims(method) == gphys.rank
252
- # no slicing needed
253
- newplots[i] = pl
254
- else
255
- filename = basename + sprintf("_%03d",i) + '.nc'
256
- path = @@dumpdir + filename
257
- pl = pl.dup
258
- pl[:file] = filename
259
- case self.class.ndims(method)
260
- when 1
261
- gphys = gphys.first1D
262
- when 2
263
- gphys = gphys.first2D
264
- when 3
265
- gphys = gphys.first3D
266
- else
267
- raise "Ploting more-than-3D data is not supported"
268
- end
269
- data_paths.push(path)
270
- file = NetCDF.create(path)
271
- GPhys::IO.write(file,gphys)
272
- file.close
273
- newplots[i] = pl
274
- end
275
- if gphys2
276
- if !cut2 && !slice2 && self.class.ndims(method) == gphys2.rank
277
- # no slicing needed
278
- newplots[i] = pl
279
- else
280
- filename = basename + sprintf("_%03d_2",i) + '.nc'
281
- path = @@dumpdir + filename
282
- pl = pl.dup
283
- pl[:file2] = filename
284
- case self.class.ndims(method)
285
- when 1
286
- gphys2 = gphys2.first1D
287
- when 2
288
- gphys2 = gphys2.first2D
289
- when 3
290
- gphys2 = gphys2.first3D
291
- else
292
- raise "Ploting more-than-3D data is not supported"
293
- end
294
- data_paths.push(path)
295
- file = NetCDF.create(path)
296
- GPhys::IO.write(file,gphys2)
297
- file.close
298
- newplots[i] = pl
299
- end
300
- end
301
- [:cut, :slice, :cut2, :slice2].each{|k| pl.delete(k)}
302
- end
303
- @plots = newplots
304
-
305
- data_paths
306
- end
307
-
308
- ###################################################
309
- private
310
-
311
- def get_gphyses(arg)
312
- file = arg.delete(:file)
313
- var = arg.delete(:var)
314
-
315
- if file && var
316
- gphys = GPhys::IO.open(file,var)
317
- slice = arg.delete(:slice)
318
- cut = arg.delete(:cut)
319
- gphys = gphys[*slice] if slice
320
- case cut
321
- when Hash
322
- gphys = gphys.cut(cut)
323
- when Array
324
- gphys = gphys.cut(*cut)
325
- end
326
- else
327
- raise ArgumentError, "Need to specify a variable by :file and :var"
328
- end
329
-
330
- file2 = arg.delete(:file2)
331
- var2 = arg.delete(:var2)
332
- file2 = file if !file2 && var2
333
- var2 = var if file2 && !var2
334
-
335
- if file2 && var2
336
- gphys2 = GPhys::IO.open(file2,var2)
337
- slice2 = arg.delete(:slice2) || slice
338
- cut2 = arg.delete(:cut2) || cut
339
- gphys2 = gphys2[*slice2] if slice2
340
- case cut2
341
- when Hash
342
- gphys2 = gphys2.cut(cut2)
343
- when Array
344
- gphys2 = gphys2.cut(*cut2)
345
- end
346
- else
347
- gphys2 = nil
348
- end
349
-
350
- [gphys,gphys2]
351
- end
352
-
353
- def exec_plot(arg, first)
354
- arg = arg.dup
355
- arg[:newfrm] = first if arg[:newfrm]==nil
356
-
357
- method = arg.delete(:method) # :tone_cont, :line, ..
358
-
359
- gphys, gphys2 = get_gphyses(arg)
360
-
361
- opt = arg
362
-
363
- pm = @@plot_methods[method.to_sym]
364
- unless pm
365
- raise "#{method.to_s} is not defined"
366
- end
367
- case pm[:nvars]
368
- when 1
369
- self.send(method.to_s, gphys, opt)
370
- when 2
371
- self.send(method.to_s, gphys, gphys2, opt)
372
- end
373
-
374
- end
375
-
376
- def setup(postscript=nil,image_dump=nil)
377
- DCL::swiset("iwidth", @set[:admin][:iwidth])
378
- DCL::swiset("iheight", @set[:admin][:iheight])
379
- if postscript
380
- raise "DCL on MS Windows does not support PostScript file O" if @@ms_windows
381
- DCL::gropn(2)
382
- else
383
- if image_dump
384
- if !@@ms_windows
385
- DCL::swcset("fname", @@dumpdir + @set[:admin][:basename])
386
- DCL::swlset("lwnd", false)
387
- DCL::gropn(4)
388
- print "DUMP IMAGE FILE\n"
389
- else
390
- DCL::swlset("ldump", true)
391
- DCL::gropn(1)
392
- end
393
- else
394
- DCL::gropn(1)
395
- end
396
- end
397
- DCL::sglset("lfull", true)
398
- DCL::sgpset("isub", 96)
399
- DCL::gllset("lmiss", true)
400
-
401
- if ( @set[:admin][:xdiv] > 1 || @set[:admin][:ydiv] > 1)
402
- DCL::sldiv('y',@set[:admin][:xdiv],@set[:admin][:ydiv])
403
- end
404
-
405
- GGraph::set_fig(@set[:fig]) if @set[:fig]
406
- GGraph::set_map(@set[:map]) if @set[:map]
407
- GGraph::set_axes(@set[:axes]) if @set[:axes]
408
- GGraph::set_contour(@set[:contour]) if @set[:contour]
409
- GGraph::set_tone(@set[:tone]) if @set[:tone]
410
- end
411
-
412
- def finish
413
- DCL::grcls
414
- end
415
-
416
- def tone_cont(gphys, opt)
417
- newfrm = opt.delete(:newfrm)
418
- contour = opt.delete(:contour)
419
- tone = opt.delete(:tone)
420
- color_bar = opt.delete(:color_bar)
421
- color_bar_options = opt.delete(:color_bar_options)
422
- if color_bar_options && !color_bar_options.is_a?(Hash)
423
- raise ":color_bar_options must be a Hash"
424
- end
425
-
426
- if @set[:fig] && (itr=@set[:fig]['itr']) && itr>=10
427
- lon = gphys.coord(0)
428
- lat = gphys.coord(1)
429
- if lon.min >= 120 && lon.max <= 150 && lat.min >= 20 && lat.max <=50
430
- GGraph::set_map({'coast_japan'=>true})
431
- else
432
- GGraph::set_map({'coast_world'=>true})
433
- end
434
- if itr==31
435
- DCL.sgpset('lclip',true)
436
- GGraph.set_map('vpt_boundary'=>3)
437
- end
438
- end
439
-
440
- tone = contour = true if !tone && !contour # should be what is meant
441
-
442
- if tone
443
- GGraph::tone(gphys, newfrm, opt)
444
- newfrm = false
445
- end
446
- if contour
447
- GGraph::contour(gphys, newfrm, opt)
448
- newfrm = false
449
- end
450
- if tone && color_bar
451
- cbopt = color_bar_options || Hash.new
452
- cbopt['log'] = true if opt['log']
453
- GGraph::color_bar(cbopt)
454
- end
455
- newfrm
456
- end
457
-
458
- def vector(gpx, gpy, opt)
459
- newfrm = opt.delete(:newfrm)
460
- GGraph::set_unit_vect_options('vyuoff'=>-0.1,'vxuoff'=>0.07)
461
- GGraph::vector(gpx, gpy, newfrm, opt)
462
- end
463
-
464
- def plot_1d(gphys, opt)
465
- newfrm = opt.delete(:newfrm)
466
- contour = opt.delete(:contour)
467
- line = opt.delete(:line)
468
- mark = opt.delete(:mark)
469
-
470
- line = mark = true if !line && !mark # should be what is meant
471
-
472
- if line
473
- GGraph::line(gphys, newfrm, opt)
474
- newfrm = false
475
- end
476
- if mark
477
- GGraph::mark(gphys, newfrm, opt)
478
- newfrm = false
479
- end
480
- newfrm
481
- end
482
-
483
- def tone(gphys, opt)
484
- tone_cont(gphys, opt.update(:tone=>true,:contour=>false))
485
- end
486
- def contour(gphys, opt)
487
- tone_cont(gphys, opt.update(:tone=>false,:contour=>true))
488
- end
489
- def line(gphys, opt)
490
- plot_1d(gphys, opt.update(:line=>true,:mark=>false))
491
- end
492
- def mark(gphys, opt)
493
- plot_1d(gphys, opt.update(:line=>false,:mark=>true))
494
- end
495
-
496
-
497
- end
498
- end
499
-
500
- ########## ENDOFLIB ##########
501
-
502
- if __FILE__ == $0
503
-
504
- if ARGV.length == 0
505
- raise <<-EOS
506
-
507
- USAGE: % ruby #{__FILE__} menu [dumpdir]
508
- where menu=0,1,2,..
509
-
510
- EOS
511
- end
512
-
513
- test_menu = ARGV[0].to_i
514
- NumRu::VizShot.dumpdir = ARGV[1] if ARGV[1]
515
-
516
- case test_menu
517
-
518
- when 0
519
- extdef = YAML.load( DATA.read )
520
- NumRu::VizShot.add_extensions( extdef ) # New one registered but not used
521
-
522
- NumRu::VizShot.plot_methods.each do | method|
523
- print "#{method}\t#{NumRu::VizShot.ndims(method)}\t#{NumRu::VizShot.nvars(method)}\t#{NumRu::VizShot.pre_defined?(method)}\n"
524
- end
525
- p NumRu::VizShot.has_plot_method?(:tone)
526
-
527
- viz = NumRu::VizShot.new(:iwidth=>700,:iheight=>500)
528
- viz.set_fig('viewport'=>[0.15,0.85,0.2,0.55])
529
- viz.set_tone('tonc'=>true)
530
- viz.plot( :method => :tone_cont,
531
- :file => "../../testdata/T.jan.nc",
532
- :var=> "T", :cut => {'level'=>400},
533
- :color_bar=>true, "title"=>"T and [U,V]" )
534
- viz.plot( :method => :vector,
535
- :file => "../../testdata/UV.jan.nc",
536
- :var=> "U", :var2=> "V" , :cut => {'level'=>400},
537
- "unit_vect" => true )
538
- # You can give GGraph options using string keys.
539
-
540
- paths = viz.dump_code_and_data(nil, true)
541
- print "\n!!! Code and data stored in #{paths.inspect} !!!\n\n"
542
-
543
- viz.execute
544
-
545
- when 100 # executable after executing case 0
546
-
547
- system('mv vizshot_dump_000.nc tmp.nc') || raise("mv failed. Call after 0")
548
- viz = NumRu::VizShot.new(:iwidth=>700,:iheight=>500)
549
- viz.set_fig('itr'=>10, 'viewport'=>[0.15,0.85,0.2,0.55])
550
- viz.plot( :method => :tone_cont,
551
- :file => "tmp.nc",
552
- :var=> "T",
553
- :color_bar=>true)
554
-
555
- path = viz.dump_code(nil, true, :image_dump => true)
556
- print "\n!!! Code written in #{path} !!!\n\n"
557
-
558
- viz.execute(:image_dump => true)
559
-
560
- when 2
561
-
562
- viz = NumRu::VizShot.new
563
- viz.set_fig('itr'=>31, 'viewport'=>[0.15,0.85,0.15,0.85])
564
- viz.plot( :method => :tone_cont,
565
- :file => "../../testdata/T.jan.nc",
566
- :var=> "T", :cut => {'lat'=>10..90,'level'=>600},
567
- :color_bar=>true)
568
-
569
- path = viz.dump_code
570
- print "\n!!! Code written in #{path} !!!\n\n"
571
-
572
- viz.execute
573
-
574
- when 3
575
-
576
- viz = NumRu::VizShot.new
577
- viz.plot( :method => :plot_1d,
578
- :file => "../../testdata/T.jan.nc",
579
- :var=> "T", :cut => {'lon'=>135}, "index"=>2,
580
- :line => true, :mark => true )
581
-
582
- path = viz.dump_code
583
- print "\n!!! Code written in #{path} !!!\n\n"
584
-
585
- viz.execute
586
-
587
- when 4
588
-
589
- # you can use :method=>:line instead of :method=>:plot_1d && :line=>true
590
-
591
- viz = NumRu::VizShot.new
592
- viz.plot( :method => :line,
593
- :file => "../../testdata/T.jan.nc",
594
- :var=> "T", :cut => {'lon'=>135}, "index"=>2, "type"=>2 )
595
-
596
- path = viz.dump_code
597
- print "\n!!! Code written in #{path} !!!\n\n"
598
-
599
- viz.execute
600
-
601
- when 5
602
-
603
- viz = NumRu::VizShot.new(:iwidth=>700,:iheight=>500,:xdiv=>2,:ydiv=>2)
604
- viz.set_fig('viewport'=>[0.15,0.85,0.2,0.55])
605
- [1000,600,400,200].each do |lev|
606
- viz.plot( :method => :tone_cont, :newfrm=>true,
607
- :file => "../../testdata/T.jan.nc",
608
- :var=> "T", :cut => {'level'=>lev},
609
- :color_bar=>true)
610
- end
611
-
612
- path = viz.dump_code
613
- print "\n!!! Code written in #{path} !!!\n\n"
614
-
615
- viz.execute
616
-
617
- when 6
618
-
619
- viz = NumRu::VizShot.new(:iwidth=>700,:iheight=>500,:xdiv=>2,:ydiv=>2)
620
- viz.set_fig('viewport'=>[0.2,0.8,0.27,0.6])
621
- viz.plot( :method => :tone_cont, :newfrm=>true,
622
- :file => "../../testdata/T.jan.nc",
623
- :var=> "T", :cut => {'level'=>1000},
624
- :color_bar=>true, :color_bar_options=>{'vlength'=>0.25})
625
- viz.plot( :method => :tone_cont, :newfrm=>true,
626
- :file => "../../testdata/T.jan.nc",
627
- :var=> "T", :cut => {'level'=>1000},
628
- :color_bar=>true, :color_bar_options=>{'labelintv'=>1})
629
- viz.plot( :method => :tone_cont, :newfrm=>true,
630
- :file => "../../testdata/T.jan.nc",
631
- :var=> "T", :cut => {'level'=>1000},
632
- :color_bar=>true,
633
- :color_bar_options=>{'landscape'=>true, 'labelintv'=>1,
634
- 'vlength'=>0.6})
635
-
636
- path = viz.dump_code
637
- print "\n!!! Code written in #{path} !!!\n\n"
638
-
639
- viz.execute
640
-
641
- when 7
642
- # test user-defined method #
643
-
644
- extdef = YAML.load( DATA.read )
645
- NumRu::VizShot.add_extensions( extdef )
646
-
647
- viz = NumRu::VizShot.new(:iwidth=>500,:iheight=>500)
648
- viz.plot( :method => :scatter,
649
- :file => "../../testdata/UV.jan.nc",
650
- :var=> "U", :var2=> "V" , :cut => {'lat'=>0, 'level'=>400} )
651
-
652
- paths = viz.dump_code_and_data
653
- print "\n!!! Code and data stored in #{paths.inspect} !!!\n\n"
654
-
655
- viz.execute
656
-
657
- end
658
-
659
- end
660
-
661
-
662
- __END__
663
- ### The following part is an YAML to define an extension method ###
664
- :name: scatter
665
- :ndims: 1
666
- :nvars: 2
667
- :script: |
668
- newfrm = opt.delete(:newfrm)
669
- GGraph::scatter(gphys, gphys1, newfrm, opt)
670
-
671
- :ggraph: |
672
- gropn_1_if_not_yet
673
- unless defined?(@@scater_options)
674
- @@scater_options = Misc::KeywordOptAutoHelp.new(
675
- ['title', nil, 'Title of the figure'],
676
- ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'],
677
- ['index', 1, 'mark index'],
678
- ['type', 2, 'mark type'],
679
- ['size', 0.01, 'marks size']
680
- )
681
- end
682
- opts = @@scater_options.interpret(options)
683
- gphys = gphys.first1D.copy
684
- gphys1 = gphys1.first1D.copy
685
- len = gphys.length
686
- unless len == gphys1.length
687
- raise ArgumentError, "length of gphys and gphys1 do not agree with each other"
688
- end
689
- x = gphys.data
690
- y = gphys1.data
691
- if newframe
692
- fig(x,y)
693
- axes(x,y)
694
- title( opts['title'] )
695
- annotate(gphys.lost_axes) if opts['annotate']
696
- end
697
- DCL::uumrkz(x.val, y.val, opts['type'], opts['index'], opts['size'])