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
@@ -0,0 +1,3 @@
1
+ class GPhys
2
+ VERSION = "1.3.1.1"
3
+ end
@@ -4,6 +4,8 @@
4
4
  # See ./druby_serv1.rb
5
5
 
6
6
  require "drb/drb"
7
+ require "numru/gphys"
8
+ include NumRu
7
9
 
8
10
  DRb.start_service
9
11
  uri = ARGV.shift || raise("Usage: % #{$0} uri")
@@ -17,10 +17,6 @@ p gp.grid.axis(0).pos.name
17
17
  gpmean = gp.mean(0)
18
18
  p gpmean.class, gpmean.name, gpmean.rank
19
19
 
20
- class NArray
21
- def self._load(o) to_na(*Marshal::load(o)).ntoh end
22
- end
23
-
24
20
  p ( gpmean_copy = gpmean.copy )
25
21
  DCL.gropn(1)
26
22
  DCL.sgpset('lfull',true)
@@ -30,5 +26,3 @@ GGraph.set_fig('viewport'=>[0.25,0.7,0.15,0.6], 'itr'=>2 )
30
26
  GGraph.contour( gpmean_copy )
31
27
  DCL.grcls
32
28
 
33
- print "\nThe following will be a DRbObject rather than GPhys since the size is too large\n(see druby_serv2.rb):\n"
34
- p ( gpcopy = gp.copy )
@@ -41,19 +41,6 @@ port = ARGV.shift
41
41
  usage if port && port.to_i.to_s != port
42
42
  usage if ARGV.length > 0
43
43
 
44
- class NArray
45
- DUMP_SIZE_LIMIT = 5000
46
- def self._load(o) to_na(*Marshal::load(o)).ntoh end
47
- def _dump(limit)
48
- if size <= DUMP_SIZE_LIMIT
49
- Marshal::dump([hton.to_s, typecode, *shape])
50
- else
51
- raise "size of the NArray (#{size}) is too large to dump "+
52
- "(limit: #{DUMP_SIZE_LIMIT})"
53
- end
54
- end
55
- end
56
-
57
44
  file = NetCDF.open("../testdata/T.jan.nc")
58
45
  gp = GPhys::NetCDF_IO.open(file,"T")
59
46
 
@@ -0,0 +1,79 @@
1
+ # = Sample program to use GPhys#interpolation by using NCEP reanalysis data
2
+ #
3
+ # USAGE
4
+ #
5
+ # % ruby ncep_theta_coord.rb [data_directory [varname [year [day_of_yr_from0]]]]
6
+ #
7
+ # COMMAND-LINE OPTIONS
8
+ #
9
+ # * data_directory : directory where the NCEP data situated -- by default
10
+ # an existing OPeNDAP directory is specified -- so it should work,
11
+ # though it may be slow for network data transfer.
12
+ # * others : you can guess -- see the source code.
13
+ #
14
+ # DESCRIPTION
15
+ #
16
+ # Here are two samples: one is a simple interpolation along a coordinate
17
+ # and the other is a coordinate transformation from pressure to potential
18
+ # temperature (isentropic coordinate).
19
+
20
+ require "numru/ggraph"
21
+ include NumRu
22
+
23
+
24
+ dir = ARGV[0] || "http://db-dods.rish.kyoto-u.ac.jp/cgi-bin/nph-dods/ncep/ncep.reanalysis.dailyavgs/pressure"
25
+
26
+ vname = ARGV[1] || "uwnd" # name of the variable to be interpolated
27
+
28
+ year = ARGV[2] || 2008
29
+ iday = ( ARGV[3] || 0 ).to_i # day of the year
30
+
31
+
32
+ xsel = 0
33
+ temp = GPhys::IO.open(dir+"/air.#{year}.nc","air")[xsel,false,2..-1,iday]
34
+ gp = GPhys::IO.open(dir+"/#{vname}.#{year}.nc",vname)[xsel,false,2..-1,iday]
35
+
36
+ prs = temp.axis("level").to_gphys
37
+ p00 = UNumeric[1000.0, "millibar"]
38
+ kappa = 2.0 / 7.0
39
+ pfact = (prs/p00)**(-kappa)
40
+
41
+ theta = temp * pfact
42
+ theta.name = "theta"
43
+ theta.long_name = "potential theta"
44
+
45
+ gp.set_assoc_coords([theta])
46
+
47
+ tht_crd = VArray.new( NArray[300.0,350.0, 400.0, 500.0, 700.0, 800.0] ).rename("theta")
48
+ gp_ontht = gp.interpolate("level"=>tht_crd)
49
+
50
+ p_crd = VArray.new( NArray[25.0, 15.0] ).rename("level")
51
+ p_crd.units = "hPa"
52
+ gp_onp = gp.interpolate(p_crd) # 1D: same as interpolate("level"=>p_crd)
53
+
54
+ DCL.swpset('iwidth',800)
55
+ DCL.swpset('iheight',800)
56
+
57
+ DCL.gropn(1)
58
+ DCL.sgpset('isub', 96) # control character of subscription: '_' --> '`'
59
+ DCL.glpset('lmiss',true)
60
+ DCL.sldiv('y',2,2)
61
+
62
+ GGraph::set_fig "itr"=>2
63
+
64
+ GGraph::tone_and_contour theta[false],true,"int"=>50
65
+ GGraph::color_bar
66
+
67
+ GGraph::tone_and_contour gp[false],true
68
+ GGraph::color_bar
69
+
70
+ GGraph::set_fig "itr"=>1
71
+
72
+ GGraph::tone_and_contour gp_onp[false],true,"keep"=>true
73
+ GGraph::color_bar
74
+
75
+ GGraph::tone_and_contour gp_ontht[false],true,"keep"=>true
76
+ GGraph::color_bar
77
+
78
+
79
+ DCL.grcls
@@ -0,0 +1,28 @@
1
+ require "numru/gphys"
2
+ require "numru/ganalysis"
3
+ require "numru/ggraph"
4
+ include NumRu
5
+
6
+ slp = GPhys::IO.open("slp.mon.mean.nc","slp") # ftp://ftp.cdc.noaa.gov/Datasets/ncep.reanalysis.derived/surface/slp.mon.mean.nc
7
+ slp = slp.cut("lat"=>30..90) # 北緯30度以北のデータを使用する
8
+ slp = slp[{0..-1,4},{0..-1,2},true] # 経度, 緯度について4, 2点おきに読む
9
+ # 計算時間を速めるため(∴不要)
10
+ nt = slp.shape[2]
11
+ mon = NArray.sint(12,nt/12).indgen #=> [ [0,1,..,11], [12,13,..,23], .. ]
12
+ mon = mon[[0,1,11],true] # [0,1,11]: Jan,Feb,Dec (use [0] to include only Jan)
13
+ mon = mon.reshape!(mon.total) # to 1D (list of months to use)
14
+ slp = slp[true,true,mon] # 12,1,2月のデータを切取り
15
+
16
+ vec,val = slp.eof("time","norder"=>2) # EOF第2モードまで計算する
17
+
18
+ DCL::gropn(4)
19
+ GGraph.set_fig("itr"=>32)
20
+ eof = vec[true,true,0]
21
+ if eof.cut("lat"=>90).mean > 0
22
+ eof = -eof # 北極における値がが負になるようにする
23
+ end
24
+ GGraph.tone(eof, true, "min"=>-7.0, "max"=>7.0)
25
+ GGraph.contour(eof,false, "min"=>-7.0, "max"=>7.0)
26
+ GGraph.map("coast_world"=>true)
27
+
28
+ DCL::grcls
Binary file
@@ -0,0 +1,19 @@
1
+ require "numru/gphys"
2
+ include NumRu
3
+ path = "../mltbit.dat"
4
+ mbio = MultibitIO.new("mltbit.dat")
5
+
6
+ 10000.times{|i|
7
+ na = mbio.read2D(12, 15, 100,100, 1,9,2, 1,7,3, nil, nil,
8
+ nil, nil)
9
+ p(na) if i==0
10
+ na = mbio.read2D(12, 15, 100,100,
11
+ nil,nil,nil, 1,5,2, [0,5,3],nil, 0.1, 1000.0)
12
+ p(na) if i==0
13
+
14
+ na = mbio.read2D(12, 15, 100,100,
15
+ nil,nil,nil, nil,nil,nil, [0,5,3],[90,80,5], nil, nil)
16
+ p(na) if i==0
17
+ }
18
+
19
+
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gentooboontoo-gphys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.3
4
+ version: 1.3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi Horinouchi
@@ -56,7 +56,7 @@ dependencies:
56
56
  type: :runtime
57
57
  version_requirements: *id004
58
58
  - !ruby/object:Gem::Dependency
59
- name: gentooboontoo-ruby-netcdf
59
+ name: ruby-netcdf
60
60
  prerelease: false
61
61
  requirement: &id005 !ruby/object:Gem::Requirement
62
62
  requirements:
@@ -66,15 +66,55 @@ dependencies:
66
66
  type: :runtime
67
67
  version_requirements: *id005
68
68
  - !ruby/object:Gem::Dependency
69
- name: gentooboontoo-ruby-fftw3
69
+ name: ruby-dcl
70
70
  prerelease: false
71
71
  requirement: &id006 !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: "0.4"
75
+ version: 1.6.1
76
76
  type: :runtime
77
77
  version_requirements: *id006
78
+ - !ruby/object:Gem::Dependency
79
+ name: ruby-fftw3
80
+ prerelease: false
81
+ requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0.3"
86
+ type: :runtime
87
+ version_requirements: *id007
88
+ - !ruby/object:Gem::Dependency
89
+ name: gsl
90
+ prerelease: false
91
+ requirement: &id008 !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "1.14"
96
+ type: :runtime
97
+ version_requirements: *id008
98
+ - !ruby/object:Gem::Dependency
99
+ name: ruby-lapack
100
+ prerelease: false
101
+ requirement: &id009 !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "1.5"
106
+ type: :runtime
107
+ version_requirements: *id009
108
+ - !ruby/object:Gem::Dependency
109
+ name: rb-grib
110
+ prerelease: false
111
+ requirement: &id010 !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 0.2.0
116
+ type: :development
117
+ version_requirements: *id010
78
118
  description: a multi-purpose class to handle Gridded Physical quantities.
79
119
  email:
80
120
  - julien.sanchez@gmail.com
@@ -92,49 +132,65 @@ executables:
92
132
  - grads2nc_with_gphys
93
133
  - gpmath
94
134
  - gpcut
95
- extensions: []
96
-
135
+ extensions:
136
+ - ext/extconf.rb
97
137
  extra_rdoc_files: []
98
138
 
99
139
  files:
100
140
  - lib/numru/htdir.rb
101
- - lib/numru/vizshot.rb
141
+ - lib/numru/ganalysis/covariance.rb
142
+ - lib/numru/ganalysis/planet.rb
143
+ - lib/numru/ganalysis/histogram.rb
144
+ - lib/numru/ganalysis/met.rb
145
+ - lib/numru/ganalysis/eof.rb
102
146
  - lib/numru/gphys.rb
103
147
  - lib/numru/gdir_connect_ftp-like.rb
104
148
  - lib/numru/ggraph_on_merdional_section.rb
105
149
  - lib/numru/derivative.rb
150
+ - lib/numru/ganalysis.rb
106
151
  - lib/numru/gdir.rb
107
152
  - lib/numru/ggraph.rb
108
- - lib/numru/dclext_datetime_ax.rb
109
153
  - lib/numru/gphys/gphys_io_common.rb
110
154
  - lib/numru/gphys/unumeric.rb
111
155
  - lib/numru/gphys/attributenetcdf.rb
156
+ - lib/numru/gphys/interpolate.rb
112
157
  - lib/numru/gphys/gphys_io.rb
113
158
  - lib/numru/gphys/grid.rb
114
159
  - lib/numru/gphys/gphys_fft.rb
115
160
  - lib/numru/gphys/gphys.rb
116
161
  - lib/numru/gphys/gphys_grads_io.rb
162
+ - lib/numru/gphys/narray_ext.rb
117
163
  - lib/numru/gphys/grib_params.rb
164
+ - lib/numru/gphys/gphys_gtool3_io.rb
118
165
  - lib/numru/gphys/gphys_nusdas_io.rb
166
+ - lib/numru/gphys/gphys_hdfeos5_io.rb
119
167
  - lib/numru/gphys/coordtransform.rb
120
168
  - lib/numru/gphys/varraygrads.rb
121
169
  - lib/numru/gphys/grads_gridded.rb
122
170
  - lib/numru/gphys/subsetmapping.rb
123
171
  - lib/numru/gphys/grib.rb
172
+ - lib/numru/gphys/mdstorage.rb
124
173
  - lib/numru/gphys/netcdf_convention.rb
125
174
  - lib/numru/gphys/derivative.rb
126
175
  - lib/numru/gphys/varraycomposite.rb
127
176
  - lib/numru/gphys/coordmapping.rb
128
177
  - lib/numru/gphys/varraynetcdf.rb
129
178
  - lib/numru/gphys/gphys_netcdf_io.rb
179
+ - lib/numru/gphys/assoccoords.rb
180
+ - lib/numru/gphys/varraygtool3.rb
130
181
  - lib/numru/gphys/varraygrib.rb
131
182
  - lib/numru/gphys/varraynusdas.rb
132
183
  - lib/numru/gphys/gpcommon.rb
133
184
  - lib/numru/gphys/ep_flux.rb
134
185
  - lib/numru/gphys/gphys_grib_io.rb
186
+ - lib/numru/gphys/varrayhdfeos5.rb
187
+ - lib/numru/gphys/gtool3.rb
135
188
  - lib/numru/gphys/varray.rb
136
189
  - lib/numru/gphys/attribute.rb
190
+ - lib/numru/gphys/version.rb
137
191
  - lib/numru/gphys/axis.rb
192
+ - lib/numru/dclext.rb
193
+ - lib/numru/dcl_mouse.rb
138
194
  - bin/gpprint
139
195
  - bin/gpcat
140
196
  - bin/gplist
@@ -149,6 +205,7 @@ files:
149
205
  - bin/gpmath
150
206
  - bin/gpcut
151
207
  - ChangeLog
208
+ - doc/dclext.html
152
209
  - doc/gdir_client.html
153
210
  - doc/ggraph.html
154
211
  - doc/gphys_grib_io.html
@@ -476,6 +533,11 @@ files:
476
533
  - doc/axis.html
477
534
  - doc/gdir.html
478
535
  - doc/varray.html
536
+ - ext/multibitIO.c
537
+ - ext/interpo.c
538
+ - ext/ext_coord.c
539
+ - ext/ext_init.c
540
+ - LICENSE.txt
479
541
  - README
480
542
  - sample/ggraph_mapfit-axes_dr002687.rb
481
543
  - sample/druby_serv2.rb
@@ -483,19 +545,25 @@ files:
483
545
  - sample/ep_flux/demo_NCEP_2.rb
484
546
  - sample/ep_flux/demo_NCEP_3.rb
485
547
  - sample/ep_flux/demo_NCEP_1.rb
548
+ - sample/ncep_theta_coord.rb
486
549
  - sample/druby_cli1.rb
487
550
  - sample/druby_serv1.rb
488
551
  - sample/map_projection.rb
489
552
  - sample/druby_cli2.rb
490
553
  - sample/cira86_to_nc.rb
491
554
  - test/test_ep_flux.rb
555
+ - test/mltbit.dat
556
+ - test/test_multibitIO.rb
557
+ - test/eof_slp.rb
492
558
  - testdata/T.jan.packed.withmiss.nc
493
559
  - testdata/T.jan.ctl
494
560
  - testdata/T.jan.dat
495
561
  - testdata/T.jan.nc
496
562
  - testdata/T.jan.grib
497
563
  - testdata/UV.jan.nc
564
+ - testdata/assoc_crds.nc
498
565
  - testdata/cira86.dat
566
+ - ext/extconf.rb
499
567
  homepage: https://github.com/gentooboontoo/gentooboontoo-gphys
500
568
  licenses:
501
569
  - Ruby
@@ -525,3 +593,6 @@ specification_version: 4
525
593
  summary: GPhys fork compatible with Rubygems
526
594
  test_files:
527
595
  - test/test_ep_flux.rb
596
+ - test/mltbit.dat
597
+ - test/test_multibitIO.rb
598
+ - test/eof_slp.rb
@@ -1,220 +0,0 @@
1
- require "numru/dcl"
2
- require "numru/misc"
3
- require "date" # needs ruby >= 1.8 for DateTime class
4
-
5
-
6
- module NumRu
7
- module DCLExt
8
-
9
- module_function
10
-
11
- @@datetime_ax_options = Misc::KeywordOptAutoHelp.new(
12
- ['yax', false, 'true => y-axis, false => x-axis'],
13
- ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'],
14
- ['dtick1', 1, 'small tick interval in hours'],
15
- ['dtick2', nil, 'large tick (with hour labels) interval in hours'],
16
- ['year', false, 'true => add year to date label'],
17
- ['month', true, 'true => add month to date label']
18
- )
19
-
20
- def datetime_ax(date_from, date_to, options=nil)
21
- # date_from [a DateTime] : start on this date&time
22
- # date_to [a DateTime] : end on this date&time
23
-
24
- opt = @@datetime_ax_options.interpret(options)
25
-
26
- yax = opt['yax']
27
- xax = !yax
28
- if xax
29
- xy='x'
30
- else
31
- xy='y'
32
- end
33
-
34
- if opt['cside']
35
- cside = opt['cside']
36
- elsif opt['cside'].nil?
37
- if xax
38
- cside='b'
39
- else
40
- cside='l'
41
- end
42
- else
43
- if xax
44
- cside='t'
45
- else
46
- cside='r'
47
- end
48
- end
49
-
50
- if opt['year']
51
- datefmt = '%Y/%m/%d'
52
- elsif opt['month']
53
- datefmt = '%m/%d'
54
- else
55
- datefmt = '%d'
56
- end
57
-
58
- # < window parameters >
59
-
60
- ux1,ux2,uy1,uy2 = DCL.sgqwnd
61
- if xax
62
- u1, u2 = ux1, ux2
63
- else
64
- u1, u2 = uy1, uy2
65
- end
66
-
67
- loffset_save = DCL.uzpget('loffset')
68
- xyfact_save = DCL.uzpget(xy+'fact')
69
- xyoffset_save = DCL.uzpget(xy+'offset')
70
-
71
- tu1 = date_from.day_fraction.to_f
72
- range_day = date_to - date_from # time btwn start and end (in days)
73
- tu2 = tu1 + range_day
74
-
75
- # < axis in hours >
76
-
77
- DCL.uzpset('loffset',true)
78
-
79
- DCL.uzpset(xy+'fact',24.0)
80
- DCL.uzpset(xy+'offset',(tu1-u1)*24)
81
-
82
- dtick1 = opt['dtick1']
83
- if opt['dtick2']
84
- dtick2 = opt['dtick2']
85
- else
86
- if range_day >= 4
87
- dtick2 = 24
88
- elsif range_day >= 2
89
- dtick2 = 12
90
- elsif range_day >= 1
91
- dtick2 = 6
92
- elsif range_day >= 0.5
93
- dtick2 = 3
94
- elsif range_day >= 0.25
95
- dtick2 = 2
96
- else
97
- dtick2 = 1
98
- end
99
- end
100
-
101
- str_hour = (tu1*24).ceil
102
- end_hour = (tu2*24).floor
103
- tick1=Array.new
104
- tick2=Array.new
105
- labels=Array.new
106
- h1 = str_hour + (-str_hour % dtick1)
107
- (h1..end_hour).step(dtick1){|i| tick1.push(i)}
108
- h2 = str_hour + (-str_hour % dtick2)
109
- (h2..end_hour).step(dtick2) do |i|
110
- tick2.push(i)
111
- labels.push((i%24).to_s)
112
- end
113
- if xax
114
- DCL.uxaxlb(cside, tick1, tick2, labels, 2)
115
- else
116
- irotl_save = DCL.uzpget('irotly'+cside)
117
- icent_save = DCL.uzpget('icenty'+cside)
118
- DCL.uzpset('irotly'+cside,1)
119
- DCL.uzpset('icenty'+cside,0)
120
- DCL.uyaxlb(cside, tick1, tick2, labels, 2)
121
- end
122
-
123
- # < labels in days >
124
-
125
- if DCL.uzpget('label'+xy+cside)
126
- DCL.uzpset(xy+'fact',1.0)
127
- DCL.uzpset(xy+'offset',0.0)
128
-
129
- str_day = tu1.floor
130
- end_day = tu2.floor
131
- pos=Array.new
132
- labels=Array.new
133
- (str_day..end_day).step(1) do |i|
134
- u = i.to_f + 0.5 + (u1- tu1)
135
- u = (u1+u+0.5)/2 if u < u1
136
- u = (u2+u-0.5)/2 if u > u2
137
- pos.push(u)
138
- str = (date_from+i).strftime(datefmt)
139
- str.sub!(/^0/,'') if !opt['year'] && opt['month']
140
- labels.push(str)
141
- end
142
-
143
- if xax
144
- DCL.uxsaxz(cside,DCL.uzpget('roffx'+cside))
145
- DCL.uxplbl(cside,1,pos,labels,10)
146
- else
147
- DCL.uysaxz(cside,DCL.uzpget('roffy'+cside))
148
- DCL.uyplbl(cside,1,pos,labels,10)
149
- # DCL.uzpset('irotly'+cside,irotl_save)
150
- # DCL.uzpset('icenty'+cside,icent_save)
151
- end
152
-
153
- end
154
-
155
- if xax
156
- else
157
- DCL.uzpset('irotly'+cside,irotl_save)
158
- DCL.uzpset('icenty'+cside,icent_save)
159
- end
160
-
161
- # < to finish >
162
-
163
- DCL.uzpset('loffset',loffset_save)
164
- DCL.uzpset(xy+'fact',xyfact_save)
165
- DCL.uzpset(xy+'offset',xyoffset_save)
166
-
167
- end
168
- end
169
- end
170
-
171
-
172
- ######## test program ######
173
-
174
- if $0 == __FILE__
175
-
176
- include NumRu
177
-
178
- iws = (ARGV[0] || (puts ' WORKSTATION ID (I) ? ;'; DCL.sgpwsn; gets)).to_i
179
- DCL.swpset('ldump',true) if iws==4
180
- DCL.gropn iws
181
- DCL.sldiv('y',2,1)
182
-
183
- date_from = DateTime.parse('2005-06-30 17:00')
184
- date_to = DateTime.parse('2005-07-01 5:00')
185
- date_from2 = DateTime.parse('2005-06-29 17:00')
186
- date_to2 = DateTime.parse('2005-07-02 5:00')
187
-
188
- any_offst = 10
189
-
190
- DCL.grfrm
191
- DCL.grswnd(0.0, date_to-date_from, any_offst, date_to2-date_from2+any_offst)
192
- DCL.grsvpt(0.2, 0.8, 0.2, 0.8)
193
- DCL.grstrn(1)
194
- DCL.grstrf
195
- DCLExt.datetime_ax(date_from, date_to, 'year'=>true)
196
- DCLExt.datetime_ax(date_from, date_to, 'cside'=>'t', 'year'=>true)
197
- DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true)
198
- DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true, 'cside'=>'r')
199
- DCL.uxsttl('b','TIME AND DATE',0.0)
200
- DCL.uysttl('l','TIME AND DATE',0.0)
201
-
202
- DCL.grfrm
203
- DCL.grswnd(0.0, date_to-date_from, 0, date_to2-date_from2)
204
- DCL.grsvpt(0.2, 0.8, 0.2, 0.8)
205
- DCL.grstrn(1)
206
- DCL.grstrf
207
- DCL.uzpset('inner',-1)
208
- DCLExt.datetime_ax(date_from, date_to, 'dtick2'=>2)
209
- DCLExt.datetime_ax(date_from, date_to, 'cside'=>'t', 'dtick2'=>2)
210
- DCL.uzpset('inner',1)
211
- DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true,
212
- 'dtick1'=>2, 'dtick2'=>24)
213
- DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true, 'cside'=>'r',
214
- 'dtick1'=>2, 'dtick2'=>24)
215
- DCL.uxsttl('b','TIME AND DATE',0.0)
216
- DCL.uysttl('l','TIME AND DATE',0.0)
217
-
218
- DCL.grcls
219
-
220
- end