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.
- checksums.yaml +4 -4
- data/ChangeLog +5631 -464
- data/LICENSE.txt +34 -0
- data/README +23 -25
- data/bin/gdir_client +25 -7
- data/bin/gdir_server +19 -13
- data/bin/gpaop +41 -28
- data/bin/gpcat +19 -11
- data/bin/gpcut +20 -11
- data/bin/gpedit +37 -1
- data/bin/gplist +5 -4
- data/bin/gpmath +21 -14
- data/bin/gpmaxmin +9 -7
- data/bin/gpprint +15 -11
- data/bin/gpvect +217 -96
- data/bin/gpview +278 -123
- data/bin/grads2nc_with_gphys +11 -6
- data/doc/attribute.html +1 -1
- data/doc/axis.html +85 -66
- data/doc/coordmapping.html +22 -22
- data/doc/dclext.html +709 -0
- data/doc/derivative/gphys-derivative.html +33 -13
- data/doc/derivative/numru-derivative.html +60 -31
- data/doc/gdir.html +76 -76
- data/doc/gdir_server.html +28 -16
- data/doc/ggraph.html +493 -706
- data/doc/gpcat.html +28 -11
- data/doc/gpcut.html +26 -11
- data/doc/gphys.html +195 -71
- data/doc/gphys_fft.html +162 -21
- data/doc/gphys_grads_io.html +9 -9
- data/doc/gphys_grib_io.html +7 -7
- data/doc/gphys_io.html +118 -31
- data/doc/gphys_io_common.html +1 -1
- data/doc/gphys_netcdf_io.html +14 -14
- data/doc/gplist.html +6 -5
- data/doc/gpmath.html +32 -14
- data/doc/gpmaxmin.html +9 -7
- data/doc/gpprint.html +14 -11
- data/doc/gpview.html +254 -146
- data/doc/grads2nc_with_gphys.html +6 -8
- data/doc/grads_gridded.html +77 -77
- data/doc/grib.html +102 -59
- data/doc/grid.html +45 -61
- data/doc/index.html +51 -41
- data/doc/index.rd +47 -36
- data/doc/netcdf_convention.html +39 -39
- data/doc/unumeric.html +79 -30
- data/doc/update +2 -1
- data/doc/varray.html +62 -56
- data/doc/varraycomposite.html +3 -3
- data/ext/ext_coord.c +209 -0
- data/ext/ext_init.c +7 -0
- data/ext/extconf.rb +41 -0
- data/ext/interpo.c +536 -0
- data/ext/multibitIO.c +567 -0
- data/lib/numru/dcl_mouse.rb +71 -0
- data/lib/numru/dclext.rb +2749 -0
- data/lib/numru/derivative.rb +124 -31
- data/lib/numru/ganalysis.rb +7 -0
- data/lib/numru/ganalysis/covariance.rb +154 -0
- data/lib/numru/ganalysis/eof.rb +302 -0
- data/lib/numru/ganalysis/histogram.rb +337 -0
- data/lib/numru/ganalysis/met.rb +872 -0
- data/lib/numru/ganalysis/planet.rb +392 -0
- data/lib/numru/ggraph.rb +1709 -2498
- data/lib/numru/gphys.rb +7 -1
- data/lib/numru/gphys/assoccoords.rb +384 -0
- data/lib/numru/gphys/attribute.rb +10 -11
- data/lib/numru/gphys/axis.rb +97 -25
- data/lib/numru/gphys/coordmapping.rb +2 -2
- data/lib/numru/gphys/derivative.rb +117 -46
- data/lib/numru/gphys/gphys.rb +595 -31
- data/lib/numru/gphys/gphys_fft.rb +365 -13
- data/lib/numru/gphys/gphys_grads_io.rb +6 -5
- data/lib/numru/gphys/gphys_grib_io.rb +6 -6
- data/lib/numru/gphys/gphys_gtool3_io.rb +162 -0
- data/lib/numru/gphys/gphys_hdfeos5_io.rb +672 -0
- data/lib/numru/gphys/gphys_io.rb +260 -20
- data/lib/numru/gphys/gphys_io_common.rb +1 -1
- data/lib/numru/gphys/gphys_netcdf_io.rb +111 -40
- data/lib/numru/gphys/gphys_nusdas_io.rb +64 -7
- data/lib/numru/gphys/grads_gridded.rb +158 -57
- data/lib/numru/gphys/grib.rb +205 -157
- data/lib/numru/gphys/grib_params.rb +196 -1
- data/lib/numru/gphys/grid.rb +214 -83
- data/lib/numru/gphys/gtool3.rb +771 -0
- data/lib/numru/gphys/interpolate.rb +992 -0
- data/lib/numru/gphys/mdstorage.rb +145 -0
- data/lib/numru/gphys/narray_ext.rb +34 -0
- data/lib/numru/gphys/netcdf_convention.rb +44 -2
- data/lib/numru/gphys/subsetmapping.rb +1 -1
- data/lib/numru/gphys/unumeric.rb +101 -8
- data/lib/numru/gphys/varray.rb +66 -20
- data/lib/numru/gphys/varraycomposite.rb +107 -29
- data/lib/numru/gphys/varraygrib.rb +70 -8
- data/lib/numru/gphys/varraygtool3.rb +226 -0
- data/lib/numru/gphys/varrayhdfeos5.rb +451 -0
- data/lib/numru/gphys/varraynetcdf.rb +13 -5
- data/lib/numru/gphys/version.rb +3 -0
- data/sample/druby_cli1.rb +2 -0
- data/sample/druby_cli2.rb +0 -6
- data/sample/druby_serv2.rb +0 -13
- data/sample/ncep_theta_coord.rb +79 -0
- data/test/eof_slp.rb +28 -0
- data/test/mltbit.dat +0 -0
- data/test/test_multibitIO.rb +19 -0
- data/testdata/assoc_crds.nc +0 -0
- metadata +79 -8
- data/lib/numru/dclext_datetime_ax.rb +0 -220
- data/lib/numru/vizshot.rb +0 -697
data/doc/gphys_fft.html
CHANGED
@@ -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
|
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 ­­ 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
|
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
|
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
|
-
|
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.</
|
21
|
+
with that value.</dd>
|
22
22
|
</dl>
|
23
|
-
<h1><a name="label
|
23
|
+
<h1><a name="label-3" id="label-3">methods</a></h1><!-- RDLabel: "methods" -->
|
24
24
|
<dl>
|
25
|
-
<dt><h4><a name="label
|
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
|
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
|
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
|
79
|
+
<li>See <a href="#label-5">detrend</a>.</li>
|
73
80
|
</ul></dd>
|
74
|
-
<dt><h4><a name="label
|
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
|
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
|
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
|
104
|
-
from 0 to K-1, where the wavenumber is
|
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
|
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
|
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
|
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
|
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
|
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
|
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 <= 0; if true, k=0 & 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"=>-30,"max"=>30,"int"=>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"=>-1,"max"=>1,"int"=>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"=>-50,"max"=>50,"int"=>5},
|
319
|
+
kconv, fconv)</pre></li>
|
320
|
+
</ul></dd>
|
180
321
|
</dl>
|
181
322
|
|
182
323
|
</body>
|
data/doc/gphys_grads_io.html
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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
|
-
|
51
|
-
<dt><h4><a name="label
|
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
|
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
|
-
|
65
|
+
same as var_names</dd>
|
66
66
|
</dl>
|
67
67
|
|
68
68
|
</body>
|
data/doc/gphys_grib_io.html
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
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>
|
data/doc/gphys_io.html
CHANGED
@@ -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
|
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
|
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
|
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>
|
28
|
-
<
|
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,
|
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
|
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
|
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
|
-
|
51
|
-
GPhys::GrADS_IO, or GPhys::Grib_IO.</
|
52
|
-
<dt><h4><a name="label
|
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
|
-
|
55
|
-
GrADS_Gridded, or Grib.</
|
56
|
-
<dt><h4><a name="label
|
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
|
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
|
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
|
73
|
-
to be used as GPhys#
|
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
|
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
|
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
|
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
|
177
|
+
<dt><h4><a name="label-16" id="label-16"><code>GTURLfmt</code></a></h4></dt><!-- RDLabel: "GTURLfmt" -->
|
91
178
|
<dd>
|
92
|
-
|
179
|
+
The format of Gtool4URL.</dd>
|
93
180
|
</dl>
|
94
181
|
|
95
182
|
</body>
|