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
@@ -311,6 +311,7 @@ PARAM_CLWMR = 2153
|
|
311
311
|
PARAM_O3MR = 2154
|
312
312
|
PARAM_CIN = 2156
|
313
313
|
PARAM_CAPE = 2157
|
314
|
+
PARAM_VBDSF = 2166
|
314
315
|
PARAM_HPBL = 2221
|
315
316
|
PARAM_5WAVH = 2222
|
316
317
|
PARAM_5WAVA = 2230
|
@@ -455,6 +456,71 @@ PARAM_WATV_NFLX = 4072
|
|
455
456
|
PARAM_DIV_MST_FLX = 4084
|
456
457
|
|
457
458
|
|
459
|
+
## JMA
|
460
|
+
PARAM_BVF2 = 5132
|
461
|
+
PARAM_SRF_UGRDM = 5136
|
462
|
+
PARAM_SRF_VGRDM = 5137
|
463
|
+
PARAM_SRF_TMPM = 5138
|
464
|
+
PARAM_SRF_SPFHM = 5139
|
465
|
+
PARAM_TSC = 5144
|
466
|
+
PARAM_TSG = 5145
|
467
|
+
PARAM_CWORK = 5146
|
468
|
+
PARAM_FGLU = 5147
|
469
|
+
PARAM_FGLV = 5148
|
470
|
+
PARAM_ADVUA = 5151
|
471
|
+
PARAM_VWV = 5152
|
472
|
+
PARAM_FGSV = 5154
|
473
|
+
PARAM_GFLX = 5155
|
474
|
+
PARAM_UWV = 5157
|
475
|
+
PARAM_FGSU = 5159
|
476
|
+
PARAM_CSUSF = 5160
|
477
|
+
PARAM_CSDSF = 5161
|
478
|
+
PARAM_CSULF = 5162
|
479
|
+
PARAM_CSDLF = 5163
|
480
|
+
PARAM_ADVVA = 5165
|
481
|
+
PARAM_FRQP = 5168
|
482
|
+
PARAM_FRQC = 5169
|
483
|
+
PARAM_GWDUA = 5173
|
484
|
+
PARAM_GWDVA = 5174
|
485
|
+
PARAM_HGTM = 5175
|
486
|
+
PARAM_UGRDM = 5176
|
487
|
+
PARAM_VGRDM = 5177
|
488
|
+
PARAM_VVELM = 5178
|
489
|
+
PARAM_TMPM = 5179
|
490
|
+
PARAM_SPFHM = 5180
|
491
|
+
PARAM_VTU = 5200
|
492
|
+
PARAM_VTV = 5201
|
493
|
+
PARAM_LTRS = 5202
|
494
|
+
PARAM_LINT = 5203
|
495
|
+
PARAM_DSWRF = 5204
|
496
|
+
PARAM_DLWRF = 5205
|
497
|
+
PARAM_USWRF = 5211
|
498
|
+
PARAM_ULWRF = 5212
|
499
|
+
PARAM_TTHM = 5218
|
500
|
+
PARAM_WSMX = 5219
|
501
|
+
PARAM_PRMX = 5220
|
502
|
+
PARAM_ADVHR = 5222
|
503
|
+
PARAM_MSC = 5223
|
504
|
+
PARAM_MSG = 5224
|
505
|
+
PARAM_MFLXB = 5230
|
506
|
+
PARAM_MFLUX = 5231
|
507
|
+
PARAM_ADVMR = 5236
|
508
|
+
PARAM_OZONE = 5237
|
509
|
+
PARAM_CNVUh = 5239
|
510
|
+
PARAM_CNVVA = 5240
|
511
|
+
PARAM_LRGHR = 5241
|
512
|
+
PARAM_CNVHR = 5242
|
513
|
+
PARAM_CNVMR = 5243
|
514
|
+
PARAM_VDFHR = 5246
|
515
|
+
PARAM_VDFUA = 5247
|
516
|
+
PARAM_VDFVA = 5248
|
517
|
+
PARAM_VDFMR = 5249
|
518
|
+
PARAM_SWHR = 5250
|
519
|
+
PARAM_LWHR = 5251
|
520
|
+
PARAM_LRGMR = 5253
|
521
|
+
|
522
|
+
|
523
|
+
|
458
524
|
|
459
525
|
NAMES_UNITS = {
|
460
526
|
PARAM_UNKNOWN => ["unknown", "dat", nil, nil],
|
@@ -653,7 +719,7 @@ NAMES_UNITS = {
|
|
653
719
|
#163 CSDLF W/m2 Clear Sky downward long wave flux
|
654
720
|
#164 CFNSF W/m2 Cloud forcing net solar flux
|
655
721
|
#165 CFNLF W/m2 Cloud forcing net long wave flux
|
656
|
-
|
722
|
+
PARAM_VBDSF => ["Visible beam downward solar flux", "VBDSF", "W/m2", nil],
|
657
723
|
#167 VDDSF W/m2 Visible diffuse downward solar flux
|
658
724
|
#168 NBDSF W/m2 Near IR beam downward solar flux
|
659
725
|
#169 NDDSF W/m2 Near IR diffuse downward solar flux
|
@@ -863,6 +929,69 @@ NAMES_UNITS = {
|
|
863
929
|
PARAM_DIV_MST_FLX => ["Vertical integral of divergence of moisture flux", "VIDMOF", "kg/m2/s", nil],
|
864
930
|
|
865
931
|
|
932
|
+
## JMA
|
933
|
+
PARAM_BVF2 => ["Square of Brunt Vaisala frequency", "BVF2", "1/s^2", nil],
|
934
|
+
PARAM_SRF_UGRDM => ["Surface 10m zonal wind", "UGRDM", "m/s", nil],
|
935
|
+
PARAM_SRF_VGRDM => ["Surface 10m meridional wind", "VGRDM", "m/s", nil],
|
936
|
+
PARAM_SRF_TMPM => ["Surface 2m air temperature", "TMPM", "K", nil],
|
937
|
+
PARAM_SRF_SPFHM => ["Surface specific humidity", "SPFHM", "kg/kg", nil],
|
938
|
+
PARAM_TSC => ["Canopy temperature", "TSC", "K", nil],
|
939
|
+
PARAM_TSG => ["Ground temperature", "TSG", "K", nil],
|
940
|
+
PARAM_CWORK => ["Cloud work function", "CWORK", "J/kg", nil],
|
941
|
+
PARAM_FGLU => ["U sfc momentum flux by long gravity wave", "FGLU", "N/m^2", nil],
|
942
|
+
PARAM_FGLV => ["V sfc momentum flux by long gravity wave", "FGLV", "N/m^2", nil],
|
943
|
+
PARAM_ADVUA => ["Advective zonal acceleration", "ADVUA", "m/s/day", nil],
|
944
|
+
PARAM_VWV => ["Column total of meridional water vapor flux", "VWV", "Kg/m/s", nil],
|
945
|
+
PARAM_FGSV => ["V sfc momentum flux by short gravity wave", "FGSV", "N/m^2", nil],
|
946
|
+
PARAM_GFLX => ["Ground heat flux", "GFLX", "W/m^2", nil],
|
947
|
+
PARAM_UWV => ["Column total of zonal water vapor flux", "UWV", "kg/m/s", nil],
|
948
|
+
PARAM_FGSU => ["U sfc momentum flux by short gravity wave", "FGSU", "N/m^2", nil],
|
949
|
+
PARAM_CSUSF => ["Clear sky upward solar flux at surface", "CSUSF", "W/m^2", nil],
|
950
|
+
PARAM_CSDSF => ["Clear sky downward solar flux at surface", "CSDSF", "W/m^2", nil],
|
951
|
+
PARAM_CSULF => ["Clear sky upward long wave flux at top of atm", "CSULF", "W/m^2", nil],
|
952
|
+
PARAM_CSDLF => ["Clear sky downward long wave flux at surface", "CSDLF", "W/m^2", nil],
|
953
|
+
PARAM_ADVVA => ["Advective meridional acceleration", "ADVVA", "m/s/day", nil],
|
954
|
+
PARAM_FRQP => ["Frequency of precipitation", "FRQP", "%", nil],
|
955
|
+
PARAM_FRQC => ["Frequency of cumulus precipitation", "FRQC", "%", nil],
|
956
|
+
PARAM_GWDUA => ["Gravity wave zonal acceleration", "GWDUA", "m/s/day", nil],
|
957
|
+
PARAM_GWDVA => ["Gravity wave meridional acceleration", "GWDVA", "m/s/day", nil],
|
958
|
+
PARAM_HGTM => ["Mean geopotential height", "HGTM", "m", nil],
|
959
|
+
PARAM_UGRDM => ["Mean zonal wind", "UGRDM", "m/s", nil],
|
960
|
+
PARAM_VGRDM => ["Mean meridional wind", "VGRDM", "m/s", nil],
|
961
|
+
PARAM_VVELM => ["Mean pressure vertical velocity", "VVELM", "Pa/s", nil],
|
962
|
+
PARAM_TMPM => ["Mean temperature", "TMPM", "K", nil],
|
963
|
+
PARAM_SPFHM => ["Mean specific humidity", "SPFHM", "kg/kg", nil],
|
964
|
+
PARAM_VTU => ["Column total of TU", "VTU", "KPam/s", nil],
|
965
|
+
PARAM_VTV => ["Column total of TV", "VTV", "KPam/s", nil],
|
966
|
+
PARAM_LTRS => ["Evapotranspiration", "LTRS", "W/m^2", nil],
|
967
|
+
PARAM_LINT => ["Interception loss", "LINT", "W/m^2", nil],
|
968
|
+
PARAM_DSWRF => ["Downward solar radiation flux at surface", "DSWRF", "W/m^2", nil],
|
969
|
+
PARAM_DLWRF => ["Downward long wave radiation flux at surface", "DLWRF", "W/m^2", nil],
|
970
|
+
PARAM_USWRF => ["Upward solar radiation at surface", "USWRF", "W/m^2", nil],
|
971
|
+
PARAM_ULWRF => ["Upward long wave radiation flux at surface", "ULWRF", "W/m^2", nil],
|
972
|
+
PARAM_TTHM => ["Column total of diabatic heat", "TTHM", "W/m^2", nil],
|
973
|
+
PARAM_WSMX => ["Surface 10m maximum surface wind", "WSMX", "m/s", nil],
|
974
|
+
PARAM_PRMX => ["Maximum hourly precipitation", "PRMX", "mm/hour", nil],
|
975
|
+
PARAM_ADVHR => ["Advective heating rate", "ADVHR", "K/day", nil],
|
976
|
+
PARAM_MSC => ["Canopy water content", "MSC", "mm", nil],
|
977
|
+
PARAM_MSG => ["Ground water content", "MSG", "mm", nil],
|
978
|
+
PARAM_MFLXB => ["Upward mass flux at cloud base", "MFLXB", "kg/m^2/s", nil],
|
979
|
+
PARAM_MFLUX => ["Upward mass flux", "MFLUX", "kg/m^2/s", nil],
|
980
|
+
PARAM_ADVMR => ["Advective moistening rate", "ADVMR", "kg/kg/day", nil],
|
981
|
+
PARAM_OZONE => ["Ozone mass mixing ratio", "OZONE", "ppm", nil],
|
982
|
+
PARAM_CNVUh => ["Convective zonal acceleration", "CNVUh", "m/s/day", nil],
|
983
|
+
PARAM_CNVVA => ["Convective meridional acceleration", "CNVVA", "m/s/day", nil],
|
984
|
+
PARAM_LRGHR => ["Large scale condensation heating rate", "LRGHR", "K/day", nil],
|
985
|
+
PARAM_CNVHR => ["Convective heating rate", "CNVHR", "k/day", nil],
|
986
|
+
PARAM_CNVMR => ["Convective moistening rate", "CNVMR", "kg/kg/s", nil],
|
987
|
+
PARAM_VDFHR => ["Vertical diffusion heating rate", "VDFHR", "K/day", nil],
|
988
|
+
PARAM_VDFUA => ["Vertical diffusion zonal acceleration", "VDFUA", "m/s/day", nil],
|
989
|
+
PARAM_VDFVA => ["Vertical diffusion meridional acceleration", "VDFVA", "m/s/day", nil],
|
990
|
+
PARAM_VDFMR => ["Vertical diffusion moistening rate", "VDFMR", "kg/kg/day", nil],
|
991
|
+
PARAM_SWHR => ["Solar radiative heating rate", "SWHR", "k/day", nil],
|
992
|
+
PARAM_LWHR => ["Longwave radiative heating rate", "LWHR", "K/day", nil],
|
993
|
+
PARAM_LRGMR => ["Large scale moistening rate", "LRGMR", "kg/kg/day", nil],
|
994
|
+
|
866
995
|
nil => nil
|
867
996
|
}
|
868
997
|
|
@@ -1268,3 +1397,69 @@ PARAMS_ECMWF_162 = { #inconmplte
|
|
1268
1397
|
72 => PARAM_WATV_NFLX,
|
1269
1398
|
84 => PARAM_DIV_MST_FLX
|
1270
1399
|
}
|
1400
|
+
|
1401
|
+
|
1402
|
+
PARAMS_JMA = {
|
1403
|
+
132 => PARAM_BVF2,
|
1404
|
+
136 => PARAM_SRF_UGRDM,
|
1405
|
+
137 => PARAM_SRF_VGRDM,
|
1406
|
+
138 => PARAM_SRF_TMPM,
|
1407
|
+
139 => PARAM_SRF_SPFHM,
|
1408
|
+
144 => PARAM_TSC,
|
1409
|
+
145 => PARAM_TSG,
|
1410
|
+
146 => PARAM_CWORK,
|
1411
|
+
147 => PARAM_FGLU,
|
1412
|
+
148 => PARAM_FGLV,
|
1413
|
+
151 => PARAM_ADVUA,
|
1414
|
+
152 => PARAM_VWV,
|
1415
|
+
154 => PARAM_FGSV,
|
1416
|
+
155 => PARAM_GFLX,
|
1417
|
+
157 => PARAM_UWV,
|
1418
|
+
159 => PARAM_FGSU,
|
1419
|
+
160 => PARAM_CSUSF,
|
1420
|
+
161 => PARAM_CSDSF,
|
1421
|
+
162 => PARAM_CSULF,
|
1422
|
+
163 => PARAM_CSDLF,
|
1423
|
+
165 => PARAM_ADVVA,
|
1424
|
+
166 => PARAM_VBDSF,
|
1425
|
+
168 => PARAM_FRQP,
|
1426
|
+
169 => PARAM_FRQC,
|
1427
|
+
173 => PARAM_GWDUA,
|
1428
|
+
174 => PARAM_GWDVA,
|
1429
|
+
175 => PARAM_HGTM,
|
1430
|
+
176 => PARAM_UGRDM,
|
1431
|
+
177 => PARAM_VGRDM,
|
1432
|
+
178 => PARAM_VVELM,
|
1433
|
+
179 => PARAM_TMPM,
|
1434
|
+
180 => PARAM_SPFHM,
|
1435
|
+
200 => PARAM_VTU,
|
1436
|
+
201 => PARAM_VTV,
|
1437
|
+
202 => PARAM_LTRS,
|
1438
|
+
203 => PARAM_LINT,
|
1439
|
+
204 => PARAM_DSWRF,
|
1440
|
+
205 => PARAM_DLWRF,
|
1441
|
+
211 => PARAM_USWRF,
|
1442
|
+
212 => PARAM_ULWRF,
|
1443
|
+
218 => PARAM_TTHM,
|
1444
|
+
219 => PARAM_WSMX,
|
1445
|
+
220 => PARAM_PRMX,
|
1446
|
+
222 => PARAM_ADVHR,
|
1447
|
+
223 => PARAM_MSC,
|
1448
|
+
224 => PARAM_MSG,
|
1449
|
+
230 => PARAM_MFLXB,
|
1450
|
+
231 => PARAM_MFLUX,
|
1451
|
+
236 => PARAM_ADVMR,
|
1452
|
+
237 => PARAM_OZONE,
|
1453
|
+
239 => PARAM_CNVUh,
|
1454
|
+
240 => PARAM_CNVVA,
|
1455
|
+
241 => PARAM_LRGHR,
|
1456
|
+
242 => PARAM_CNVHR,
|
1457
|
+
243 => PARAM_CNVMR,
|
1458
|
+
246 => PARAM_VDFHR,
|
1459
|
+
247 => PARAM_VDFUA,
|
1460
|
+
248 => PARAM_VDFVA,
|
1461
|
+
249 => PARAM_VDFMR,
|
1462
|
+
250 => PARAM_SWHR,
|
1463
|
+
251 => PARAM_LWHR,
|
1464
|
+
253 => PARAM_LRGMR,
|
1465
|
+
}
|
data/lib/numru/gphys/grid.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "numru/gphys/axis"
|
2
|
+
require "numru/gphys/assoccoords"
|
2
3
|
|
3
4
|
=begin
|
4
5
|
=class NumRU::Grid
|
@@ -46,6 +47,18 @@ A class to handle discretized grids of physical quantities.
|
|
46
47
|
RETURN VALUE
|
47
48
|
* an Integer
|
48
49
|
|
50
|
+
---coord_dim_indices(coordname)
|
51
|
+
Coordinate name --> dimension indices.
|
52
|
+
|
53
|
+
ARGUMENT
|
54
|
+
* coordname (String) : Name of a coordinate
|
55
|
+
|
56
|
+
RETURN VALUE
|
57
|
+
* Array of Integer or nil --
|
58
|
+
If the coordinate is present it is an Array
|
59
|
+
containing dimension indices (If the coordinate is 1D,
|
60
|
+
the lengthof the array is 1.)
|
61
|
+
|
49
62
|
---set_axis(dim_or_dimname,ax)
|
50
63
|
|
51
64
|
Sets an axis.
|
@@ -139,15 +152,20 @@ A class to handle discretized grids of physical quantities.
|
|
139
152
|
Similar to ((<cut>)), but the rank is conserved by not eliminating
|
140
153
|
any dimension (whose length could be one).
|
141
154
|
|
142
|
-
---
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
155
|
+
---cut_assoccoord(hasharg)
|
156
|
+
Cut with respect to the asscoated coordinates. Similar to cut,
|
157
|
+
when the argeuemnt is a Hash, but hash keys are the names of the
|
158
|
+
asscoated coordinates.
|
159
|
+
|
160
|
+
#---exclude(dim_or_dimname)
|
161
|
+
# Returns a Grid in which an axis is eliminated from self.
|
162
|
+
#
|
163
|
+
# ARGUMENTS
|
164
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
165
|
+
#
|
166
|
+
# RETURN VALUE
|
167
|
+
# * a Grid
|
168
|
+
#
|
151
169
|
---change_axis(dim, axis)
|
152
170
|
Replaces an axis. (Returns a new object)
|
153
171
|
|
@@ -157,36 +175,36 @@ A class to handle discretized grids of physical quantities.
|
|
157
175
|
|
158
176
|
RETURN VALUE
|
159
177
|
* a Grid
|
160
|
-
|
161
|
-
|
162
|
-
Replaces an axis. (overwrites self)
|
178
|
+
#
|
179
|
+
#---change_axis!(dim_or_dimname, axis)
|
180
|
+
# Replaces an axis. (overwrites self)
|
181
|
+
#
|
182
|
+
# ARGUMENTS
|
183
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
184
|
+
# * axis (Axis)
|
185
|
+
#
|
186
|
+
# RETURN VALUE
|
187
|
+
# * self
|
188
|
+
#
|
189
|
+
---insert_axis(dim, axis)
|
190
|
+
Inserts an axis. (non destructive; returns a new object)
|
163
191
|
|
164
192
|
ARGUMENTS
|
165
|
-
*
|
166
|
-
* axis (Axis)
|
167
|
-
|
168
|
-
RETURN VALUE
|
169
|
-
* self
|
170
|
-
|
171
|
-
---insert_axis(dim_or_dimname, axis)
|
172
|
-
Inserts an axis. (Returns a new object)
|
173
|
-
|
174
|
-
ARGUMENTS
|
175
|
-
* dim_or_dimname (String or Integer) to specify an axis.
|
193
|
+
* dim (Integer) to specify the position to insert
|
176
194
|
* axis (Axis)
|
177
195
|
|
178
196
|
RETURN VALUE
|
179
197
|
* a Grid
|
180
198
|
|
181
|
-
|
182
|
-
Inserts an axis. (overwrites self)
|
183
|
-
|
184
|
-
ARGUMENTS
|
185
|
-
* dim_or_dimname (String or Integer) to specify an axis.
|
186
|
-
* axis (Axis)
|
187
|
-
|
188
|
-
RETURN VALUE
|
189
|
-
* self
|
199
|
+
#---insert_axis!(dim_or_dimname, axis)
|
200
|
+
# Inserts an axis. (overwrites self)
|
201
|
+
#
|
202
|
+
# ARGUMENTS
|
203
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
204
|
+
# * axis (Axis)
|
205
|
+
#
|
206
|
+
# RETURN VALUE
|
207
|
+
# * self
|
190
208
|
|
191
209
|
---transpose( *dims )
|
192
210
|
Transpose.
|
@@ -207,20 +225,44 @@ module NumRu
|
|
207
225
|
def initialize( *axes )
|
208
226
|
@axes = Array.new
|
209
227
|
axes.each{|ag|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
228
|
+
### commented out for the duck typing:
|
229
|
+
#if ag.is_a?(Axis)
|
230
|
+
@axes.push(ag)
|
231
|
+
#else
|
232
|
+
# raise ArgumentError, "each argument must be an Axis"
|
233
|
+
#end
|
215
234
|
}
|
216
235
|
@lost_axes = Array.new # Array of String
|
217
236
|
@rank = @axes.length
|
218
237
|
@axnames = Array.new
|
219
238
|
__check_and_set_axnames
|
239
|
+
@assoc_coords = nil
|
240
|
+
end
|
241
|
+
|
242
|
+
# * assoc_crds : an Array of GPhys
|
243
|
+
#
|
244
|
+
def set_assoc_coords(assoc_crds)
|
245
|
+
@assoc_coords = AssocCoords.new(assoc_crds, @axnames)
|
246
|
+
@assoc_coords.axlens.each do |nm,l|
|
247
|
+
if l && l != (l0 = shape[dim_index(nm)])
|
248
|
+
raise ArgumentError, "Length mismatch in coord #{nm} (#{l0}) and assoc_crds (#{l}). You may need to regrid (use GPhys#regrid method) associated coordinate(s) in advance."
|
249
|
+
end
|
250
|
+
end
|
251
|
+
self
|
252
|
+
end
|
253
|
+
|
254
|
+
# * assoc_coords : an AssocCoords
|
255
|
+
#
|
256
|
+
def assoc_coords=(assoc_coords)
|
257
|
+
@assoc_coords = assoc_coords
|
258
|
+
end
|
259
|
+
|
260
|
+
def assoc_coords
|
261
|
+
@assoc_coords
|
220
262
|
end
|
221
263
|
|
222
264
|
def inspect
|
223
|
-
|
265
|
+
"<#{rank}D grid #{@axes.collect{|ax| ax.inspect}.join("\n\t")}#{@assoc_coords ? "\n"+@assoc_coords.inspect.gsub(/^/,"\t") : ''}>"
|
224
266
|
end
|
225
267
|
|
226
268
|
def __check_and_set_axnames
|
@@ -244,6 +286,37 @@ module NumRu
|
|
244
286
|
@lost_axes.dup
|
245
287
|
end
|
246
288
|
|
289
|
+
def coordnames
|
290
|
+
ret = axnames
|
291
|
+
ret.concat(@assoc_coords.coordnames) if @assoc_coords
|
292
|
+
ret
|
293
|
+
end
|
294
|
+
|
295
|
+
def has_axis?(name)
|
296
|
+
@axnames.include?(name)
|
297
|
+
end
|
298
|
+
|
299
|
+
def has_assoccoord?(*arg)
|
300
|
+
if arg.length == 0
|
301
|
+
!@assoc_coords.nil? # if a grid has assoc coords
|
302
|
+
else
|
303
|
+
name = arg[0]
|
304
|
+
if @assoc_coords
|
305
|
+
@assoc_coords.has_coord?(name)
|
306
|
+
else
|
307
|
+
false
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def has_coord?(name)
|
313
|
+
has_axis?(name) || has_assoccoord?(name)
|
314
|
+
end
|
315
|
+
|
316
|
+
def assoccoordnames
|
317
|
+
@assoc_coords && @assoc_coords.coordnames
|
318
|
+
end
|
319
|
+
|
247
320
|
# def axis(i)
|
248
321
|
# @axes[i]
|
249
322
|
# end
|
@@ -254,12 +327,37 @@ module NumRu
|
|
254
327
|
|
255
328
|
alias get_axis axis
|
256
329
|
|
330
|
+
def coord(i)
|
331
|
+
if @assoc_coords && i.is_a?(String) && @assoc_coords.has_coord?(i)
|
332
|
+
@assoc_coords.coord(i)
|
333
|
+
else
|
334
|
+
axis(i).pos
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
def assoc_coord_gphys(name)
|
339
|
+
@assoc_coords && @assoc_coords.coord_gphys(name)
|
340
|
+
end
|
341
|
+
|
257
342
|
def dim_index(dimname)
|
258
343
|
ax_dim(dimname)[1]
|
259
344
|
end
|
260
345
|
|
346
|
+
def coord_dim_indices(coordname)
|
347
|
+
dim = @axnames.index(coordname)
|
348
|
+
if dim
|
349
|
+
[dim]
|
350
|
+
elsif @assoc_coords && @assoc_coords.has_coord?(coordname)
|
351
|
+
axnms = @assoc_coords.coord_gphys(coordname).axnames
|
352
|
+
axnms.collect{|nm| @axnames.index(nm)}
|
353
|
+
else
|
354
|
+
nil
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
261
358
|
def set_axis(dim_or_dimname,ax)
|
262
|
-
@axes[
|
359
|
+
@axes[ i = dim_index(dim_or_dimname) ] = ax
|
360
|
+
@axnames[ i ] = ax.name
|
263
361
|
self
|
264
362
|
end
|
265
363
|
|
@@ -311,6 +409,9 @@ module NumRu
|
|
311
409
|
|
312
410
|
newgrid = self.class.new( *newaxes )
|
313
411
|
newgrid.set_lost_axes( @lost_axes.dup )
|
412
|
+
if @assoc_coords
|
413
|
+
newgrid.assoc_coords=@assoc_coords.subset_having_axnames(newgrid.axnames)
|
414
|
+
end
|
314
415
|
|
315
416
|
if !deleted_by
|
316
417
|
msg = '(deleted) '
|
@@ -333,6 +434,7 @@ module NumRu
|
|
333
434
|
# deep clone onto memory
|
334
435
|
out = self.class.new( *@axes.collect{|ax| ax.copy} )
|
335
436
|
out.set_lost_axes( @lost_axes.dup )
|
437
|
+
out.assoc_coords = @assoc_coords.copy if @assoc_coords
|
336
438
|
out
|
337
439
|
end
|
338
440
|
|
@@ -353,6 +455,10 @@ module NumRu
|
|
353
455
|
end
|
354
456
|
out = self.class.new( *axes )
|
355
457
|
out.set_lost_axes( (@lost_axes.dup + other.lost_axes).uniq )
|
458
|
+
if (oac = other.assoc_coords) || (sac = self.assoc_coords)
|
459
|
+
sac ? ac=sac.merge(oac) : ac=oac.merge(sac)
|
460
|
+
out.assoc_coords = ac
|
461
|
+
end
|
356
462
|
out
|
357
463
|
end
|
358
464
|
|
@@ -366,7 +472,7 @@ module NumRu
|
|
366
472
|
# make a clone
|
367
473
|
axes = Array.new
|
368
474
|
(0...rank).each{ |i| axes.push( @axes[i][0..-1] ) }
|
369
|
-
self.class.new( *axes )
|
475
|
+
grid = self.class.new( *axes )
|
370
476
|
else
|
371
477
|
slicer = __rubber_expansion(slicer)
|
372
478
|
if slicer.length != rank
|
@@ -376,16 +482,20 @@ module NumRu
|
|
376
482
|
lost = self.lost_axes #Array.new
|
377
483
|
for i in 0...rank
|
378
484
|
ax = @axes[i][slicer[i]]
|
379
|
-
if ax.is_a?(
|
380
|
-
|
485
|
+
if ax.is_a?(String)
|
486
|
+
lost.push( ax )
|
381
487
|
else
|
382
|
-
|
488
|
+
axes.push( ax )
|
383
489
|
end
|
384
490
|
end
|
385
491
|
grid = self.class.new( *axes )
|
386
492
|
grid.set_lost_axes( lost ) if lost.length != 0
|
387
493
|
grid
|
388
494
|
end
|
495
|
+
if @assoc_coords
|
496
|
+
grid.assoc_coords = @assoc_coords[*slicer]
|
497
|
+
end
|
498
|
+
grid
|
389
499
|
end
|
390
500
|
|
391
501
|
def __rubber_expansion( args )
|
@@ -404,6 +514,12 @@ module NumRu
|
|
404
514
|
end
|
405
515
|
private :__rubber_expansion
|
406
516
|
|
517
|
+
def cut_assoccoord(hasharg)
|
518
|
+
ac, acsl = @assoc_coords.cut(hasharg)
|
519
|
+
sl = @axnames.collect{|nm| acsl[nm] || true}
|
520
|
+
[ self[*sl], sl ]
|
521
|
+
end
|
522
|
+
|
407
523
|
def cut(*args)
|
408
524
|
_cut_(false, *args)
|
409
525
|
end
|
@@ -411,11 +527,13 @@ module NumRu
|
|
411
527
|
_cut_(true, *args)
|
412
528
|
end
|
413
529
|
|
530
|
+
# cut along the regular coorinates.
|
531
|
+
# assume that the coordinates are monotonic (without checking).
|
414
532
|
def _cut_(conserve_rank, *args)
|
415
533
|
|
416
|
-
|
534
|
+
hasharg = ( args.length==1 && args[0].is_a?(Hash) )
|
417
535
|
|
418
|
-
if
|
536
|
+
if hasharg
|
419
537
|
# specification by axis names
|
420
538
|
spec = args[0]
|
421
539
|
if (spec.keys - axnames).length > 0
|
@@ -447,12 +565,12 @@ module NumRu
|
|
447
565
|
end
|
448
566
|
private :_cut_
|
449
567
|
|
450
|
-
def exclude(dim_or_dimname)
|
451
|
-
dim = dim_index(dim_or_dimname)
|
452
|
-
axes = @axes.dup
|
453
|
-
axes.delete_at(dim)
|
454
|
-
self.class.new( *axes )
|
455
|
-
end
|
568
|
+
# def exclude(dim_or_dimname)
|
569
|
+
# dim = dim_index(dim_or_dimname)
|
570
|
+
# axes = @axes.dup
|
571
|
+
# axes.delete_at(dim)
|
572
|
+
# self.class.new( *axes )
|
573
|
+
# end
|
456
574
|
|
457
575
|
def change_axis(dim, axis)
|
458
576
|
axes = @axes.dup
|
@@ -463,42 +581,49 @@ module NumRu
|
|
463
581
|
lost.push(axis) if axis.is_a?(String)
|
464
582
|
axes.delete_at(dim)
|
465
583
|
end
|
466
|
-
self.class.new( *axes ).add_lost_axes( lost )
|
584
|
+
grid = self.class.new( *axes ).add_lost_axes( lost )
|
585
|
+
if @assoc_coords
|
586
|
+
grid.assoc_coords=@assoc_coords.subset_having_axnames(grid.axnames)
|
587
|
+
end
|
588
|
+
grid
|
467
589
|
end
|
468
590
|
|
469
|
-
def change_axis!(dim_or_dimname, axis)
|
470
|
-
if axis.is_a?(Axis)
|
471
|
-
@axes[
|
472
|
-
else
|
473
|
-
@lost_axes.push(axis) if axis.is_a?(String)
|
474
|
-
@axes.delete_at(
|
475
|
-
end
|
476
|
-
@rank = @axes.length
|
477
|
-
__check_and_set_axnames
|
478
|
-
self
|
479
|
-
end
|
591
|
+
# def change_axis!(dim_or_dimname, axis)
|
592
|
+
# if axis.is_a?(Axis)
|
593
|
+
# @axes[ dim_index(dim_or_dimname) ] = axis
|
594
|
+
# else
|
595
|
+
# @lost_axes.push(axis) if axis.is_a?(String)
|
596
|
+
# @axes.delete_at( dim_index(dim_or_dimname) )
|
597
|
+
# end
|
598
|
+
# @rank = @axes.length
|
599
|
+
# __check_and_set_axnames
|
600
|
+
# self
|
601
|
+
# end
|
480
602
|
|
481
|
-
def insert_axis(dim_or_dimname, axis)
|
482
|
-
dim =
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
603
|
+
# def insert_axis!(dim_or_dimname, axis)
|
604
|
+
# dim = dim_index(dim_or_dimname)
|
605
|
+
# if axis == nil
|
606
|
+
# # do nothing
|
607
|
+
# else
|
608
|
+
# @axes[dim+1,0] = axis # @axes.insert(dim, axis) if ruby 1.7
|
609
|
+
# @rank = @axes.length
|
610
|
+
# __check_and_set_axnames
|
611
|
+
# end
|
612
|
+
# self
|
613
|
+
# end
|
491
614
|
|
492
|
-
def insert_axis
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
615
|
+
def insert_axis(dim, axis)
|
616
|
+
axes = @axes.dup
|
617
|
+
### commented out for the duck typing:
|
618
|
+
#if axis.is_a?(Axis)
|
619
|
+
axes.insert(dim, axis)
|
620
|
+
#else
|
621
|
+
# raise ArgumentError, "2nd arg must be an Axis"
|
622
|
+
#end
|
623
|
+
grid = self.class.new( *axes )
|
624
|
+
grid.set_lost_axes( lost_axes )
|
625
|
+
grid.assoc_coords = @assoc_coords.dup if @assoc_coords
|
626
|
+
grid
|
502
627
|
end
|
503
628
|
|
504
629
|
def transpose( *dims )
|
@@ -512,6 +637,7 @@ module NumRu
|
|
512
637
|
end
|
513
638
|
grid = self.class.new(*axes)
|
514
639
|
grid.set_lost_axes( lost_axes )
|
640
|
+
grid.assoc_coords = @assoc_coords.dup if @assoc_coords
|
515
641
|
grid
|
516
642
|
end
|
517
643
|
|
@@ -598,5 +724,10 @@ if $0 == __FILE__
|
|
598
724
|
|
599
725
|
p grid, grid.transpose(1,0)
|
600
726
|
|
727
|
+
puts "Test insert_axis..."
|
728
|
+
vz = VArray.new( NArray.float(3).indgen! + 10 ).rename("z")
|
729
|
+
zax = Axis.new().set_pos(vz)
|
730
|
+
grid3 = grid.insert_axis(-1,zax)
|
731
|
+
p grid3
|
601
732
|
end
|
602
733
|
|