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
@@ -7,22 +7,22 @@
7
7
  <title>../lib/numru/gphys/gphys_fft.rb</title>
8
8
  </head>
9
9
  <body>
10
- <h1><a name="label:0" id="label:0">extention of class NumRu::GPhys -- Fast Fourier transformation and its applications</a></h1><!-- RDLabel: "extention of class NumRu::GPhys &shy;&shy; Fast Fourier transformation and its applications" -->
10
+ <h1><a name="label-0" id="label-0">extension of class NumRu::GPhys -- Fast Fourier transformation and its applications</a></h1><!-- RDLabel: "extension of class NumRu::GPhys &shy;&shy; Fast Fourier transformation and its applications" -->
11
11
  <p>This manual documents the methods of NumRu::GPhys defined in gphys_fft.rb</p>
12
- <h1><a name="label:1" id="label:1">class methods</a></h1><!-- RDLabel: "class methods" -->
12
+ <h1><a name="label-1" id="label-1">class methods</a></h1><!-- RDLabel: "class methods" -->
13
13
  <dl>
14
- <dt><h4><a name="label:2" id="label:2"><code>GPhys::fft_ignore_missing( <var>ignore</var>=<var>true</var>, <var>replace_val</var>=<var>nil</var> )</code></a></h4></dt><!-- RDLabel: "GPhys::fft_ignore_missing" -->
14
+ <dt><h4><a name="label-2" id="label-2"><code>GPhys::fft_ignore_missing( <var>ignore</var>=<var>true</var>, <var>replace_val</var>=<var>nil</var> )</code></a></h4></dt><!-- RDLabel: "GPhys::fft_ignore_missing" -->
15
15
  <dd>
16
- <p>Set a flag (class variable) to ignore missing values.
16
+ Set a flag (class variable) to ignore missing values.
17
17
  This is for data that do not have missing
18
18
  but is treated as potentially having missing (often
19
19
  by having the valid_* attributes of NetCDF.)
20
20
  If replace_val is specified, data missing with replaced
21
- with that value.</p></dd>
21
+ with that value.</dd>
22
22
  </dl>
23
- <h1><a name="label:3" id="label:3">methods</a></h1><!-- RDLabel: "methods" -->
23
+ <h1><a name="label-3" id="label-3">methods</a></h1><!-- RDLabel: "methods" -->
24
24
  <dl>
25
- <dt><h4><a name="label:4" id="label:4"><code>fft(<var>backward</var>=<var>false</var>, *<var>dims</var>)</code></a></h4></dt><!-- RDLabel: "fft" -->
25
+ <dt><h4><a name="label-4" id="label-4"><code>fft(<var>backward</var>=<var>false</var>, *<var>dims</var>)</code></a></h4></dt><!-- RDLabel: "fft" -->
26
26
  <dd>
27
27
  <p>Fast Fourier Transformation (FFT) by using
28
28
  (<a href="http://www.fftw.org">FFTW</a>) ver 3 or ver 2.
@@ -38,7 +38,14 @@ FFTW.</p>
38
38
  <p>Each coordinate is assumed to be equally spaced without checking.
39
39
  The new coordinate variables will be set equal to wavenumbers,
40
40
  derived as 2*PI/(length of the axis)*[0,1,2,..], where the length
41
- of the axis is derieved as (coord.val.max - coord.val.min)*(n+1)/n.</p>
41
+ of the axis is derived as (coord.val.max - coord.val.min)*(n+1)/n.</p>
42
+ <p>REMARK</p>
43
+ <ul>
44
+ <li>If the units of the original coordinate is degree (or its
45
+ equivalent ones such as degrees_east), the wavenumber was
46
+ made in integers by converting the coordinate based on
47
+ radian.</li>
48
+ </ul>
42
49
  <p>ARGUMENTS</p>
43
50
  <ul>
44
51
  <li>backward (true of false) : when true, backward FT is done;
@@ -54,7 +61,7 @@ of the axis is derieved as (coord.val.max - coord.val.min)*(n+1)/n.</p>
54
61
  gphy.fft(true) # backward, for all dimensions
55
62
  gphy.fft(nil, 0,1) # forward, for the first and second dimensions.
56
63
  gphy.fft(true, -1) # backward, for the last dimension.</pre></dd>
57
- <dt><h4><a name="label:5" id="label:5"><code>detrend(<var>dim1</var>[,<var>dim2</var>[,...]])</code></a></h4></dt><!-- RDLabel: "detrend" -->
64
+ <dt><h4><a name="label-5" id="label-5"><code>detrend(<var>dim1</var>[,<var>dim2</var>[,...]])</code></a></h4></dt><!-- RDLabel: "detrend" -->
58
65
  <dd>
59
66
  <p>Remove means and linear trends along dimension(s) specified.
60
67
  Algorithm: 1st order polynomial fitting.</p>
@@ -69,9 +76,9 @@ Algorithm: 1st order polynomial fitting.</p>
69
76
  </ul>
70
77
  <p>EXAMPLE</p>
71
78
  <ul>
72
- <li>See <a href="#label:5">detrend</a>.</li>
79
+ <li>See <a href="#label-5">detrend</a>.</li>
73
80
  </ul></dd>
74
- <dt><h4><a name="label:6" id="label:6"><code>cos_taper(<var>dim1</var>[,<var>dim2</var>[,...]])</code></a></h4></dt><!-- RDLabel: "cos_taper" -->
81
+ <dt><h4><a name="label-6" id="label-6"><code>cos_taper(<var>dim1</var>[,<var>dim2</var>[,...]])</code></a></h4></dt><!-- RDLabel: "cos_taper" -->
75
82
  <dd>
76
83
  <p>Cosine tapering along dimension(s) specified.</p>
77
84
  <p>Algorithm: to multiply with the half cosine curves at the both
@@ -83,7 +90,7 @@ Algorithm: 1st order polynomial fitting.</p>
83
90
  T/10 T/10
84
91
  half-cosine half-cosine
85
92
  shaped shaped</pre>
86
- <p>The spectra of tapered data should be multilied by 1/0.875,
93
+ <p>The spectra of tapered data should be multiplied by 1/0.875,
87
94
  which is stored as GPhys::COS_TAPER_SP_FACTOR (==1/0.875).</p>
88
95
  <p>ARGUMENTS</p>
89
96
  <ul>
@@ -98,10 +105,10 @@ which is stored as GPhys::COS_TAPER_SP_FACTOR (==1/0.875).</p>
98
105
  <pre>dim = 0 # for the 1st dimension
99
106
  fc = gphys.detrend(dim).cos_taper(dim).fft(nil,dim)
100
107
  sp = fc.abs**2 * GPhys::COS_TAPER_SP_FACTOR</pre></dd>
101
- <dt><h4><a name="label:7" id="label:7"><code>spect_zero_centering(<var>dim</var>)</code></a></h4></dt><!-- RDLabel: "spect_zero_centering" -->
108
+ <dt><h4><a name="label-7" id="label-7"><code>spect_zero_centering(<var>dim</var>)</code></a></h4></dt><!-- RDLabel: "spect_zero_centering" -->
102
109
  <dd>
103
- <p>Shifts the waveneumber axis to cover from -K/2 to K/2 instead of
104
- from 0 to K-1, where the wavenumber is simbolically treated as integer,
110
+ <p>Shifts the wavenumber axis to cover from -K/2 to K/2 instead of
111
+ from 0 to K-1, where the wavenumber is symbolically treated as integer,
105
112
  which is actually not the case, though. Since the first (-K/2) and
106
113
  the last (K/2) elements are duplicated, both are divided by 2.
107
114
  Therefore, this method is to be used for spectra (squared quantity)
@@ -133,9 +140,9 @@ sp = ( fc.abs**2 ).spect_zero_centering(0).spect_one_sided(1)</pre></li>
133
140
  fc2 = var2.fft(nil, 0,1)
134
141
  xsp = (fc1 * fc2.conj).spect_zero_centering(0).spect_zero_centering(1)</pre></li>
135
142
  </ul></dd>
136
- <dt><h4><a name="label:8" id="label:8"><code>spect_one_sided(<var>dim</var>)</code></a></h4></dt><!-- RDLabel: "spect_one_sided" -->
143
+ <dt><h4><a name="label-8" id="label-8"><code>spect_one_sided(<var>dim</var>)</code></a></h4></dt><!-- RDLabel: "spect_one_sided" -->
137
144
  <dd>
138
- <p>Similar to <a href="#label:7">spect_zero_centering</a> but to make one-sided spectra.
145
+ <p>Similar to <a href="#label-7">spect_zero_centering</a> but to make one-sided spectra.
139
146
  Namely, to convert from 0..K-1 to 0..K/2. To be applied for spectra;
140
147
  wavenumber 2..K/2-1 are multiplied by 2.</p>
141
148
  <p>ARGUMENTS</p>
@@ -149,13 +156,13 @@ wavenumber 2..K/2-1 are multiplied by 2.</p>
149
156
  </ul>
150
157
  <p>EXAMPLE</p>
151
158
  <ul>
152
- <li>See the 2nd example of <a href="#label:7">spect_zero_centering</a>.</li>
159
+ <li>See the 2nd example of <a href="#label-7">spect_zero_centering</a>.</li>
153
160
  </ul></dd>
154
- <dt><h4><a name="label:9" id="label:9"><code>rawspect2powerspect(*<var>dims</var>)</code></a></h4></dt><!-- RDLabel: "rawspect2powerspect" -->
161
+ <dt><h4><a name="label-9" id="label-9"><code>rawspect2powerspect(*<var>dims</var>)</code></a></h4></dt><!-- RDLabel: "rawspect2powerspect" -->
155
162
  <dd>
156
163
  <p>Converts raw spectra obtained by gphys.fft.abs**2 into
157
164
  power spectra by dividing by wavenumber increments
158
- along the dimensions spcified by dims.</p>
165
+ along the dimensions specified by dims.</p>
159
166
  <p>ARGUMENTS</p>
160
167
  <ul>
161
168
  <li>dims (integers): the dimensions corresponding to wavenumbers.</li>
@@ -170,13 +177,147 @@ along the dimensions spcified by dims.</p>
170
177
  <pre>fc = gphys.fft(nil, 0, 1)
171
178
  sp = fc.abs**2
172
179
  ps = sp.rawspect2powerspect(0,1)</pre>
173
- <p>Here, sp is the raw spectum of gphys, and ps is the power spectrum.
180
+ <p>Here, sp is the raw spectrum of gphys, and ps is the power spectrum.
174
181
  The Parseval relation for them are as follows:</p>
175
182
  <pre>(gphys**2).mean == sp.sum
176
183
  == pw.sum*dk*dl (== \int pw dk dl, mathematically),</pre>
177
184
  <p>where, dk = (pw.coord(0)[1] - pw.coord(0)[0]), and
178
185
  dl = (pw.coord(1)[1] - pw.coord(1)[0]).</p></li>
179
186
  </ul></dd>
187
+ <dt><h4><a name="label-10" id="label-10"><code>phase_velocity_filter(<var>xdim</var>, <var>tdim</var>, <var>cmin</var>=<var>nil</var>, <var>cmax</var>=<var>nil</var>, <var>xconv</var>=<var>nil</var>, <var>tconv</var>=<var>nil</var>, <var>remove_xtmean</var>=<var>false</var>)</code></a></h4></dt><!-- RDLabel: "phase_velocity_filter" -->
188
+ <dd>
189
+ <p>Filtering by phase velocity (between cmin and cmax)</p>
190
+ <p>REMARKS</p>
191
+ <ul>
192
+ <li>If the number of the grid points along x or t is an even number,
193
+ the maximum wavenumber or frequency is treated as positive
194
+ and negative, respectively, which results in an asymmetry of
195
+ the treatment of positive and negative phase speeds.
196
+ (That should be ok. -- In case its effect is significant,
197
+ to do the filtering itself is not meaningful.)</li>
198
+ </ul>
199
+ <p>ARGUMENTS</p>
200
+ <ul>
201
+ <li>xdim (Integer or String): spacial dimension</li>
202
+ <li>tdim (Integer or String): time dimension</li>
203
+ <li>cmin (Float or nil): minimum phase velocity. nil means no specification.
204
+ (at least cmin or cmax must be given by Float)</li>
205
+ <li>cmax (Float or nil): maximum phase velocity. nil means no specification.
206
+ (at least cmin or cmax must be given by Float)</li>
207
+ <li>xconv (nil or UNumeric) : (optional) if given, xconv is multiplied
208
+ with the x axis before computing the phase velocity
209
+ (kconv=1/xconv is used to scale wavenumbers)</li>
210
+ <li>tconv (nil or UNumeric) : (optional) if given, tconv is multiplied
211
+ with the t axis before computing the phase velocity
212
+ (fconv=1/tconv is used to scale frequency)</li>
213
+ <li>remove_xtmean (false or true) : if false (default),
214
+ components with k=0 and f=0 are counted as c=0 (stationary),
215
+ (unlike <a href="#label-12">phase_velocity_binning</a>), so they are included if
216
+ cmin*cmax &lt;= 0; if true, k=0 &amp; f=0 components are always removed.</li>
217
+ </ul>
218
+ <p>RETURN VALUE</p>
219
+ <ul>
220
+ <li>a GPhys</li>
221
+ </ul>
222
+ <p>EXAMPLE</p>
223
+ <ul>
224
+ <li><p>For a 4D data with [x,y,z,t] dimensions, filtering by the phase
225
+ velocity in the y dimension greater than 10.0 (in the unit
226
+ of y/t) can be made by</p>
227
+ <pre>cmin = 10.0; cmax = nil
228
+ gpfilt = gp.phase_velocity_filter(1, 3, cmin, cmax)</pre></li>
229
+ <li><p>For a global data (on the Earth's surface) with
230
+ [lon, lat, z, time] axes, where the units of lon is
231
+ "degrees" (or "degrees_east" or "radian")
232
+ and the units of time is "hours", to filter disturbances
233
+ whose zonal phase speed MEASURED AT THE EQUATOR is less or
234
+ equal to 30 m/s can be made by</p>
235
+ <pre>cmin = -30.0; cmax = 30.0
236
+ xconv = UNumeric[6.37e6, "m"] # Earth's radius (i.e., m/radian)
237
+ # This is a special case since "radian" is exceptionally omitted.
238
+ # See the private method __predefined_coord_units_conversion.
239
+ tconv = UNumeric[3.6e3, "s/hours"]
240
+ gpfilt = gp.phase_velocity_filter(1, 3, cmin, cmax, xconv, tconv)</pre></li>
241
+ </ul></dd>
242
+ <dt><h4><a name="label-11" id="label-11"><code>phase_velocity_binning_iso_norml(<var>kdim</var>, <var>fdim</var>, <var>cmin</var>, <var>cmax</var>, <var>cint</var>, <var>kconv</var>=<var>nil</var>, <var>fconv</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "phase_velocity_binning_iso_norml" -->
243
+ <dd>
244
+ <p>Same as <a href="#label-12">phase_velocity_binning</a> but exclusively for
245
+ equal phase velocity spacing. Also, a normalization is
246
+ additionally made, to scale spectra in terms of integration
247
+ along phase velocity axis --- The result of
248
+ <a href="#label-12">phase_velocity_binning</a> called inside
249
+ this method is divided by cint along with corresponding
250
+ units conversion. Therefore, if this method is applied
251
+ to spectra, a normalization is made such that an integration
252
+ (not summation) along the phase velocity gives the variance
253
+ (or covariance etc.) -- This normalization is suitable to
254
+ quadratic quantities (such as spectra) but is not suitable to
255
+ raw Fourier coefficients.</p>
256
+ <p>ARGUMENTS</p>
257
+ <ul>
258
+ <li>kdim (Integer or String): see <a href="#label-12">phase_velocity_binning</a></li>
259
+ <li>fdim (Integer or String): see <a href="#label-12">phase_velocity_binning</a></li>
260
+ <li>cmin (Float) : minimum phase velocity</li>
261
+ <li>cmin (Float) : maximum phase velocity</li>
262
+ <li>cint (Float) : inter val with which the range [cmin and cmax]
263
+ is divided.</li>
264
+ <li>kconv (nil or UNumeric) : see <a href="#label-12">phase_velocity_binning</a></li>
265
+ <li>fconv (nil or UNumeric) : see <a href="#label-12">phase_velocity_binning</a></li>
266
+ </ul>
267
+ <p>RETURN VALUE</p>
268
+ <ul>
269
+ <li>a GPhys</li>
270
+ </ul></dd>
271
+ <dt><h4><a name="label-12" id="label-12"><code>phase_velocity_binning(<var>kdim</var>, <var>fdim</var>, <var>cbins</var>, <var>kconv</var>=<var>nil</var>, <var>fconv</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "phase_velocity_binning" -->
272
+ <dd>
273
+ <p>Bin a 2D spectrum in space and time based on phase velocity.
274
+ The operand (self) must be Fourier coefficients or spectra,
275
+ whose grid has not been altered since the call of the method
276
+ fft (i.e., those that have not applied with zero centering
277
+ etc, since it is done in this method).</p>
278
+ <p>Binning by this method is based on summation, leaving
279
+ the units unchanged.</p>
280
+ <p>REMARKS</p>
281
+ <ul>
282
+ <li>Components whose phase velocities are exactly equal to one
283
+ of the boundaries are divided into the two bins half by half</li>
284
+ <li>components with k=0 and f=0 are excluded -- the spatio-temporal
285
+ mean do not reflect in the result </li>
286
+ </ul>
287
+ <p>ARGUMENTS</p>
288
+ <ul>
289
+ <li>kdim (Integer or String): wavenumber dimension (from spacial dimension)</li>
290
+ <li>fdim (Integer or String): frequency dimension (from time dimension)</li>
291
+ <li>cbins : an Array of bin bounds or a Hash of max, min, int
292
+ e.g., [-10,-1,-0.1,0.1,11,10], {"min"=&gt;-30,"max"=&gt;30,"int"=&gt;5}</li>
293
+ <li>kconv (nil or UNumeric) : (optional) if given, kconv is multiplied
294
+ with the wavenumber axis before computing the phase velocity</li>
295
+ <li>fconv (nil or UNumeric) : (optional) if given, fconv is multiplied
296
+ with the frequency axis before computing the phase velocity</li>
297
+ </ul>
298
+ <p>RETURN VALUE</p>
299
+ <ul>
300
+ <li>a GPhys</li>
301
+ </ul>
302
+ <p>EXAMPLES</p>
303
+ <ul>
304
+ <li><p>Example A</p>
305
+ <pre>fu = u.fft(nil, 0, 2)
306
+ cfu = fu.phase_velocity_binning(0, 2, {"min"=&gt;-1,"max"=&gt;1,"int"=&gt;0.1})</pre></li>
307
+ <li><p>Example B</p>
308
+ <pre>fu = u.fft(nil, 0, 2)
309
+ pw = fu.abs**2rawspect2powerspect(0,2) # power spectrum
310
+ cbins = [-100.0, -10.0, -1.0, 1.0, 10.0, 100.0] # logarithmic spacing
311
+ cpw = pw.phase_velocity_binning(0, 2, cbins)</pre></li>
312
+ <li><p>Example C</p>
313
+ <pre>fu = u.fft(nil, 0, 3)
314
+ fv = v.fft(nil, 0, 3)
315
+ kconv = UNumeric[1/6.37e6, "m-1"]
316
+ fconv = UNumeric[1/3.6e3, "hours/s"]
317
+ fuv = (fu * fv.conj) # cross spectra
318
+ cfuv = fuv.phase_velocity_binning(0, 3, {"min"=&gt;-50,"max"=&gt;50,"int"=&gt;5},
319
+ kconv, fconv)</pre></li>
320
+ </ul></dd>
180
321
  </dl>
181
322
 
182
323
  </body>
@@ -7,11 +7,11 @@
7
7
  <title>../lib/numru/gphys/gphys_grads_io.rb</title>
8
8
  </head>
9
9
  <body>
10
- <h1><a name="label:0" id="label:0">module NumRu::GPhys::GrADS_IO</a></h1><!-- RDLabel: "module NumRu::GPhys::GrADS_IO" -->
10
+ <h1><a name="label-0" id="label-0">module NumRu::GPhys::GrADS_IO</a></h1><!-- RDLabel: "module NumRu::GPhys::GrADS_IO" -->
11
11
  <p>helps read/write GrADS-formatted data</p>
12
- <h2><a name="label:1" id="label:1">Module functions</a></h2><!-- RDLabel: "Module functions" -->
12
+ <h2><a name="label-1" id="label-1">Module functions</a></h2><!-- RDLabel: "Module functions" -->
13
13
  <dl>
14
- <dt><h4><a name="label:2" id="label:2"><code>is_a_GrADS?(<var>filename</var>)</code></a></h4></dt><!-- RDLabel: "is_a_GrADS?" -->
14
+ <dt><h4><a name="label-2" id="label-2"><code>is_a_GrADS?(<var>filename</var>)</code></a></h4></dt><!-- RDLabel: "is_a_GrADS?" -->
15
15
  <dd>
16
16
  <p>test whether the file is a GrADS control file.</p>
17
17
  <p>ARGUMENTS</p>
@@ -22,7 +22,7 @@
22
22
  <ul>
23
23
  <li>true/false</li>
24
24
  </ul></dd>
25
- <dt><h4><a name="label:3" id="label:3"><code>open(<var>file</var>, <var>varname</var>)</code></a></h4></dt><!-- RDLabel: "open" -->
25
+ <dt><h4><a name="label-3" id="label-3"><code>open(<var>file</var>, <var>varname</var>)</code></a></h4></dt><!-- RDLabel: "open" -->
26
26
  <dd>
27
27
  <p>GPhys constructor from GrADS.</p>
28
28
  <p>ARGUMENTS</p>
@@ -45,10 +45,10 @@
45
45
  include GPhys
46
46
  temp = GPhys::GrADS_IO.open("T.jan.ctl","T")</pre></li>
47
47
  </ul></dd>
48
- <dt><h4><a name="label:4" id="label:4"><code>write(<var>file</var>, <var>gphys</var>, <var>name</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "write" -->
48
+ <dt><h4><a name="label-4" id="label-4"><code>write(<var>file</var>, <var>gphys</var>, <var>name</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "write" -->
49
49
  <dd>
50
- <p>writes a GPhys object into a GrADS file. -- !!only 4D data is supported!!</p></dd>
51
- <dt><h4><a name="label:5" id="label:5"><code>var_names(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names" -->
50
+ writes a GPhys object into a GrADS file. -- !!only 4D data is supported!!</dd>
51
+ <dt><h4><a name="label-5" id="label-5"><code>var_names(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names" -->
52
52
  <dd>
53
53
  <p>ARGUMENTS</p>
54
54
  <ul>
@@ -60,9 +60,9 @@ temp = GPhys::GrADS_IO.open("T.jan.ctl","T")</pre></li>
60
60
  <li>names of variables (Array): this return the names of variables
61
61
  which the file has.</li>
62
62
  </ul></dd>
63
- <dt><h4><a name="label:6" id="label:6"><code>var_names_except_coordinates(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names_except_coordinates" -->
63
+ <dt><h4><a name="label-6" id="label-6"><code>var_names_except_coordinates(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names_except_coordinates" -->
64
64
  <dd>
65
- <p>same as var_names</p></dd>
65
+ same as var_names</dd>
66
66
  </dl>
67
67
 
68
68
  </body>
@@ -7,11 +7,11 @@
7
7
  <title>../lib/numru/gphys/gphys_grib_io.rb</title>
8
8
  </head>
9
9
  <body>
10
- <h1><a name="label:0" id="label:0">module NumRu::GPhys::Grib_IO</a></h1><!-- RDLabel: "module NumRu::GPhys::Grib_IO" -->
10
+ <h1><a name="label-0" id="label-0">module NumRu::GPhys::Grib_IO</a></h1><!-- RDLabel: "module NumRu::GPhys::Grib_IO" -->
11
11
  <p>helps read Grib-formatted data</p>
12
- <h2><a name="label:1" id="label:1">Module functions</a></h2><!-- RDLabel: "Module functions" -->
12
+ <h2><a name="label-1" id="label-1">Module functions</a></h2><!-- RDLabel: "Module functions" -->
13
13
  <dl>
14
- <dt><h4><a name="label:2" id="label:2"><code>is_a_Grib? <var>filename</var>)</code></a></h4></dt><!-- RDLabel: "is_a_Grib? filename)" -->
14
+ <dt><h4><a name="label-2" id="label-2"><code>is_a_Grib? <var>filename</var>)</code></a></h4></dt><!-- RDLabel: "is_a_Grib? filename)" -->
15
15
  <dd>
16
16
  <p>test whether the file is a Grib file.</p>
17
17
  <p>ARGUMENTS</p>
@@ -22,7 +22,7 @@
22
22
  <ul>
23
23
  <li>true/false</li>
24
24
  </ul></dd>
25
- <dt><h4><a name="label:3" id="label:3"><code>open(<var>file</var>, <var>varname</var>)</code></a></h4></dt><!-- RDLabel: "open" -->
25
+ <dt><h4><a name="label-3" id="label-3"><code>open(<var>file</var>, <var>varname</var>)</code></a></h4></dt><!-- RDLabel: "open" -->
26
26
  <dd>
27
27
  <p>GPhys constructor from Grib.</p>
28
28
  <p>ARGUMENTS</p>
@@ -45,7 +45,7 @@
45
45
  include GPhys
46
46
  temp = GPhys::Grib_IO.open("temp","T")</pre></li>
47
47
  </ul></dd>
48
- <dt><h4><a name="label:4" id="label:4"><code>write(<var>file</var>, <var>gphys</var>, <var>name_dummy</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "write" -->
48
+ <dt><h4><a name="label-4" id="label-4"><code>write(<var>file</var>, <var>gphys</var>, <var>name_dummy</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "write" -->
49
49
  <dd>
50
50
  <p>Write a GPhys into a Grib file. The whole data under the GPhys
51
51
  (such as coordinate vars) are written self-descriptively.</p>
@@ -59,7 +59,7 @@ temp = GPhys::Grib_IO.open("temp","T")</pre></li>
59
59
  <ul>
60
60
  <li>nil</li>
61
61
  </ul></dd>
62
- <dt><h4><a name="label:5" id="label:5"><code>var_names(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names" -->
62
+ <dt><h4><a name="label-5" id="label-5"><code>var_names(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names" -->
63
63
  <dd>
64
64
  <p>ARGUMENTS</p>
65
65
  <ul>
@@ -71,7 +71,7 @@ temp = GPhys::Grib_IO.open("temp","T")</pre></li>
71
71
  <li>names of variables (Array): this return the names of variables
72
72
  which the file has.</li>
73
73
  </ul></dd>
74
- <dt><h4><a name="label:6" id="label:6"><code>var_names_except_coordinates(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names_except_coordinates" -->
74
+ <dt><h4><a name="label-6" id="label-6"><code>var_names_except_coordinates(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names_except_coordinates" -->
75
75
  <dd>
76
76
  <ul>
77
77
  <li>same as var_names</li>
@@ -7,7 +7,7 @@
7
7
  <title>../lib/numru/gphys/gphys_io.rb</title>
8
8
  </head>
9
9
  <body>
10
- <h1><a name="label:0" id="label:0">module NumRu::GPhys::IO</a></h1><!-- RDLabel: "module NumRu::GPhys::IO" -->
10
+ <h1><a name="label-0" id="label-0">module NumRu::GPhys::IO</a></h1><!-- RDLabel: "module NumRu::GPhys::IO" -->
11
11
  <p>A module to handle file IO regarding GPhys. </p>
12
12
  <p>Many of the functionality of this module is implemented in the modules
13
13
  for specific file types such as NumRu::GPhys::NetCDF_IO, to which this
@@ -15,81 +15,168 @@ module directs operations.</p>
15
15
  <p>For example, GPhys::IO.open(file, name) simply calls
16
16
  GPhys::*_IO.open(file, name), where '*' is
17
17
  NetCDF, GrADS, or grib.</p>
18
- <h2><a name="label:1" id="label:1">Module functions</a></h2><!-- RDLabel: "Module functions" -->
18
+ <h2><a name="label-1" id="label-1">Module functions</a></h2><!-- RDLabel: "Module functions" -->
19
19
  <dl>
20
- <dt><h4><a name="label:2" id="label:2"><code>open(<var>files</var>, <var>varname</var>)</code></a><!-- RDLabel: "open" -->
21
- <dt><h4><a name="label:3" id="label:3"><code>write(<var>file</var>, <var>gphys</var>, <var>name</var>=<var>nil</var>)</code></a><!-- RDLabel: "write" -->
22
- <dt><h4><a name="label:4" id="label:4"><code>write_grid(<var>file</var>, <var>grid_or_gphys</var>)</code></a><!-- RDLabel: "write_grid" -->
23
- <dt><h4><a name="label:5" id="label:5"><code>each_along_dims_write(<var>gphyses</var>, <var>files</var>, *<var>loopdims</var>){...} # <var>a</var> <var>block</var> <var>is</var> <var>expected</var></code></a><!-- RDLabel: "each_along_dims_write" -->
24
- <dt><h4><a name="label:6" id="label:6"><code>var_names(<var>file</var>)</code></a><!-- RDLabel: "var_names" -->
25
- <dt><h4><a name="label:7" id="label:7"><code>var_names_except_coordinates(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names_except_coordinates" -->
20
+ <dt><h4><a name="label-2" id="label-2"><code>open(<var>file</var>, <var>varname</var>)</code></a></h4></dt><!-- RDLabel: "open" -->
26
21
  <dd>
27
- <p>See the manual of NumRu::GPhys::NetCDF_IO for the methods listed above.</p></dd>
28
- <dt><h4><a name="label:8" id="label:8"><code>file2type(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "file2type" -->
22
+ <p>Opens a GPhys in <code>file</code> having the name <code>varname</code>.</p>
23
+ <p>ARGUMENTS</p>
24
+ <ul>
25
+ <li>file (String, NetCDF, GRIB,.. etc, or Array, NArray, Regexp) :
26
+ Specifies the file. Path if String; a File pointer if NetCDF etc..
27
+ The processing is forwarded to open_multi, if this argument is
28
+ an Array, NArray, or Regexp. </li>
29
+ <li>varname (String) : name of the variable</li>
30
+ </ul>
31
+ <p>RETURN VALUE</p>
32
+ <ul>
33
+ <li>a GPhys</li>
34
+ </ul></dd>
35
+ <dt><h4><a name="label-3" id="label-3"><code>open_multi(<var>files</var>, <var>varname</var>)</code></a></h4></dt><!-- RDLabel: "open_multi" -->
36
+ <dd>
37
+ <p>Opens a GPhys by combining a variable across multiple files.
38
+ It initializes GPhys objects over the files by calling open and
39
+ unites them into a single GPhys object by using <code>GPhys.join</code> or
40
+ <code>GPhys.join_md</code>.</p>
41
+ <p>ARGUMENTS</p>
42
+ <ul>
43
+ <li>files (Array, NArray (NArray.object), or Regexp) : Specifies the files.
44
+ <ul>
45
+ <li>when Array, it must consist of paths or file pointers
46
+ (that are accepted by open).
47
+ All coordinates of the variable in the files are scanned,
48
+ and a joined object is constructed properly.
49
+ Thus, you can simply put subsets of a 2D tiling in a simple
50
+ non-nested 1D Array. <code>GPhys.join</code> is used in this case.</li>
51
+ <li><p>when NArray, it must consist of paths or file pointers
52
+ (that are accepted by open).
53
+ Each dimension with multiple elements must correspond
54
+ to a dimension along which joining is made.
55
+ For example, a 2D tiling can be specified as</p>
56
+ <pre>files = NArray.to_na([['f00.nc','f10.nc'],['f01.nc','f11.nc']])
57
+ gp = GPhys::IO.open_multi( files, "f" )</pre>
58
+ <p><code>GPhys.join_md</code> is used in this case.</p></li>
59
+ <li><p>When Regexp, similar to when NArray, but expresses the paths.
60
+ The dimensions to join is specified by "captures"
61
+ (parentheses). For example, the above 2D tiling can be specified as</p>
62
+ <pre>files = /f(\d)(\d).nc/
63
+ gp = GPhys::IO.open_multi( files, "f" )</pre>
64
+ <p>The regexp can contain a directory path (e.g., /dir\/sub\/f(\d)(d).nc/),
65
+ but the directory part must be unique (i.e., a simple string),
66
+ so only a single directly can be specified. All captures must
67
+ be in the part representing the file names (in the directory).
68
+ <code>GPhys.join_md</code> is used in this case.</p></li>
69
+ </ul></li>
70
+ <li>varname (String) : name of the variable</li>
71
+ </ul>
72
+ <p>RETURN VALUE</p>
73
+ <ul>
74
+ <li>a GPhys</li>
75
+ </ul></dd>
76
+ <dt><h4><a name="label-4" id="label-4"><code>write(<var>file</var>, <var>gphys</var>, <var>name</var>=<var>nil</var>)</code></a></h4></dt><!-- RDLabel: "write" -->
77
+ <dd>
78
+ <p>Writes a GPhys object in a file</p>
79
+ <p>ARGUMENTS</p>
80
+ <ul>
81
+ <li>file (NetCDF, GRIB,.. etc) : the file. Writing must be permitted.
82
+ To close (finalize) it after writing is left to the user.</li>
83
+ <li>gphys (GPhys) : the GPhys object to write</li>
84
+ <li>name (String; optional) : if specified, this name is used in the file
85
+ rather than the name of gphys</li>
86
+ </ul></dd>
87
+ <dt><h4><a name="label-5" id="label-5"><code>write_grid(<var>file</var>, <var>grid_or_gphys</var>)</code></a></h4></dt><!-- RDLabel: "write_grid" -->
88
+ <dt><h4><a name="label-6" id="label-6"><code>each_along_dims_write(<var>gphyses</var>, <var>files</var>, *<var>loopdims</var>){...} # <var>a</var> <var>block</var> <var>is</var> <var>expected</var></code></a></h4></dt><!-- RDLabel: "each_along_dims_write" -->
89
+ <dt><h4><a name="label-7" id="label-7"><code>var_names(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names" -->
90
+ <dt><h4><a name="label-8" id="label-8"><code>var_names_except_coordinates(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "var_names_except_coordinates" -->
91
+ <dd>
92
+ See the manual of NumRu::GPhys::NetCDF_IO for the methods listed above.</dd>
93
+ <dt><h4><a name="label-9" id="label-9"><code>file2type(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "file2type" -->
29
94
  <dd>
30
95
  <p>Figures out the file type supported in this module.</p>
31
96
  <p>ARGUMENTS</p>
32
97
  <ul>
33
- <li>file (String, Regexp, NetCDF, Grib, or GrADS_Gridded) :
98
+ <li>file (String, NetCDF, Grib, or GrADS_Gridded) :
34
99
  What to return is of course obvious if it is
35
100
  NetCDF, Grib, or GrADS_Gridded. If it is a String,
36
101
  it is assumed to be a path of a file, and the file type
37
102
  is determined by its suffix when 'nc', 'ctl', or 'grib';
38
103
  In other cases, the type is figured out by reading in
39
- a few bytes from the beginning. If Regexp, currently,
40
- a NetCDF is assumed, since only NetCDF_IO.open supports
41
- Regexp.</li>
104
+ a few bytes from the beginning.</li>
42
105
  </ul>
43
106
  <p>RETURN VALUE</p>
44
107
  <ul>
45
108
  <li>GPhys::IO::NETCDF, GPhys::IO::GRIB, or GPhys::IO::GRADS,
46
109
  which are string constants.</li>
47
110
  </ul></dd>
48
- <dt><h4><a name="label:9" id="label:9"><code>file2specific_module(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "file2specific_module" -->
111
+ <dt><h4><a name="label-10" id="label-10"><code>file2specific_module(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "file2specific_module" -->
49
112
  <dd>
50
- <p>Same as <a href="#label:8">file2type</a>, but returns GPhys::NetCDF_IO,
51
- GPhys::GrADS_IO, or GPhys::Grib_IO.</p></dd>
52
- <dt><h4><a name="label:10" id="label:10"><code>file2file_class(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "file2file_class" -->
113
+ Same as <a href="#label-9">file2type</a>, but returns GPhys::NetCDF_IO,
114
+ GPhys::GrADS_IO, or GPhys::Grib_IO.</dd>
115
+ <dt><h4><a name="label-11" id="label-11"><code>file2file_class(<var>file</var>)</code></a></h4></dt><!-- RDLabel: "file2file_class" -->
53
116
  <dd>
54
- <p>Same as <a href="#label:8">file2type</a>, but returns NetCDF,
55
- GrADS_Gridded, or Grib.</p></dd>
56
- <dt><h4><a name="label:11" id="label:11"><code>parse_gturl(<var>gturl</var>)</code></a></h4></dt><!-- RDLabel: "parse_gturl" -->
117
+ Same as <a href="#label-9">file2type</a>, but returns NetCDF,
118
+ GrADS_Gridded, or Grib.</dd>
119
+ <dt><h4><a name="label-12" id="label-12"><code>parse_gturl(<var>gturl</var>)</code></a></h4></dt><!-- RDLabel: "parse_gturl" -->
57
120
  <dd>
58
121
  <p>Parses GTOOL4-type URLs to specify path, variable name,
59
122
  and optionally subsets, whose format is
60
- path@varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]</p>
123
+ path[@|/]varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]</p>
61
124
  <p>ARGUMENTS</p>
62
125
  <ul>
63
126
  <li>gturl (String) GTOOL4 URL, whose format is
64
- path@varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]</li>
127
+ path[@|/]varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]</li>
65
128
  </ul>
66
129
  <p>RETURN VALUES</p>
67
130
  <ul>
68
- <li>An Array consisting of [file, var, slice, thinning], where
131
+ <li>An Array consisting of [file, var, slice, cut_slice, thinning], where
69
132
  <ul>
70
133
  <li>file (String) : path</li>
71
134
  <li>var (String) : variable name</li>
72
- <li>slice (Array) : subset specifier in physical coordinate
73
- to be used as GPhys#cut[slice].</li>
135
+ <li>slice (Array) : subset specifier by the grid numbers
136
+ to be used as GPhys#[slice].</li>
137
+ <li>cut_slice (Array) : subset specifier in physical coordinate
138
+ to be used as GPhys#cut[cut_slice].</li>
74
139
  <li>thinning (Array) : additional subset specifier for thinning
75
140
  with uniform intervals if needed to be used GPhys#[thinning]
76
141
  after appling GPhys#cut.</li>
77
142
  </ul></li>
78
143
  </ul></dd>
79
- <dt><h4><a name="label:12" id="label:12"><code>open_gturl(<var>gturl</var>)</code></a></h4></dt><!-- RDLabel: "open_gturl" -->
144
+ <dt><h4><a name="label-13" id="label-13"><code>open_gturl(<var>gturl</var>)</code></a></h4></dt><!-- RDLabel: "open_gturl" -->
80
145
  <dd>
81
146
  <p>a GPhys constructor from a Gtool4-type URL.
82
- See <a href="#label:11">parse_gturl</a> for its format.</p>
147
+ See <a href="#label-12">parse_gturl</a> for its format.</p>
148
+ <p>RETURN VALUE</p>
149
+ <ul>
150
+ <li>a GPhys</li>
151
+ </ul></dd>
152
+ <dt><h4><a name="label-14" id="label-14"><code>str2gphys(<var>str</var>)</code></a></h4></dt><!-- RDLabel: "str2gphys" -->
153
+ <dd>
154
+ <p>Open a GPhys from a slash("/")-separated String
155
+ such as "U.nc/U" and "U.nc".</p>
156
+ <ul>
157
+ <li>Aimed to help quick jobs with interactive sessions
158
+ -- This method do not handle a GPhys across multiple files.</li>
159
+ <li>if the variable path is ommited such as "U.nc",
160
+ try to find the variable in it -- read the file and if
161
+ only one variable is found, assume that is the
162
+ variable specified; otherwise, an exception is raised.</li>
163
+ <li>URL is accepted, but it's only thru NetCDF assuming OPeNDAP.</li>
164
+ </ul>
165
+ <p>ARGUMENTS</p>
166
+ <ul>
167
+ <li>a String (file_path[/variable_path])
168
+ e.g. "U.nc/U", "U.nc", "http://.../U.nc/U"</li>
169
+ </ul>
83
170
  <p>RETURN VALUE</p>
84
171
  <ul>
85
172
  <li>a GPhys</li>
86
173
  </ul></dd>
87
174
  </dl>
88
- <h2><a name="label:13" id="label:13">Module constants</a></h2><!-- RDLabel: "Module constants" -->
175
+ <h2><a name="label-15" id="label-15">Module constants</a></h2><!-- RDLabel: "Module constants" -->
89
176
  <dl>
90
- <dt><h4><a name="label:14" id="label:14"><code>GTURLfmt</code></a></h4></dt><!-- RDLabel: "GTURLfmt" -->
177
+ <dt><h4><a name="label-16" id="label-16"><code>GTURLfmt</code></a></h4></dt><!-- RDLabel: "GTURLfmt" -->
91
178
  <dd>
92
- <p>The format of Gtool4URL.</p></dd>
179
+ The format of Gtool4URL.</dd>
93
180
  </dl>
94
181
 
95
182
  </body>