ruby-netcdf 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/ChangeLog +456 -0
- data/LICENSE.txt +32 -57
- data/ext/numru/netcdfraw.c +287 -321
- data/lib/numru/netcdf/version.rb +1 -1
- data/lib/numru/netcdf.rb +634 -638
- data/ruby-netcdf-bigmem.gemspec +1 -0
- data/ruby-netcdf.gemspec +1 -0
- data/test/aref_aset.rb +63 -33
- data/test/char_var.rb +32 -21
- data/test/clone.rb +46 -51
- data/test/create_tmp.rb +17 -13
- data/test/def_var_with_dim.rb +29 -11
- data/test/factor_offset.rb +77 -46
- data/test/putatt.rb +71 -49
- data/test/test.rb +197 -190
- data/test/type.rb +27 -11
- metadata +18 -4
data/test/test.rb
CHANGED
@@ -1,192 +1,199 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
#require 'narray'
|
4
|
-
#require '../netcdfraw'
|
5
|
-
#require '../lib/netcdf'
|
6
|
-
## <-- to test before make install //
|
7
|
-
|
1
|
+
require 'test/unit'
|
2
|
+
require 'numru/netcdf'
|
8
3
|
include NumRu
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
file.
|
20
|
-
file.put_att("
|
21
|
-
file.put_att("
|
22
|
-
file.put_att("
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
file.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
byte_vara.put(
|
79
|
-
byte_vara.put(
|
80
|
-
byte_vara.put(
|
81
|
-
byte_vara.put(h,{"start"=>[
|
82
|
-
byte_vara.put(h,{
|
83
|
-
byte_vara.put(
|
84
|
-
|
85
|
-
|
86
|
-
sint_vara.put(
|
87
|
-
sint_vara.put(
|
88
|
-
sint_vara.put(
|
89
|
-
sint_vara.put(l,{"start"=>[
|
90
|
-
sint_vara.put(l,{"start"=>[
|
91
|
-
sint_vara.put(
|
92
|
-
|
93
|
-
|
94
|
-
int_vara.put(
|
95
|
-
int_vara.put(
|
96
|
-
int_vara.put(
|
97
|
-
int_vara.put(n,{"start"=>[
|
98
|
-
int_vara.put(n,{"start"=>[
|
99
|
-
int_vara.put(
|
100
|
-
|
101
|
-
|
102
|
-
sfloat_vara.put(
|
103
|
-
sfloat_vara.put(
|
104
|
-
sfloat_vara.put(
|
105
|
-
sfloat_vara.put(p,{"start"=>[
|
106
|
-
sfloat_vara.put(p,{"start"=>[
|
107
|
-
sfloat_vara.put(
|
108
|
-
|
109
|
-
|
110
|
-
float_vara.put(
|
111
|
-
float_vara.put(
|
112
|
-
float_vara.put(
|
113
|
-
float_vara.put(r,{"start"=>[
|
114
|
-
float_vara.put(r,{"start"=>[
|
115
|
-
float_vara.put(
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
copy_byte.
|
163
|
-
copy_byte.
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
copy_sint.
|
170
|
-
|
171
|
-
copy_int.
|
172
|
-
|
173
|
-
copy_sfloat.
|
174
|
-
|
175
|
-
copy_float.
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
file.fill(
|
186
|
-
|
187
|
-
|
188
|
-
float_vara.
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
5
|
+
# What checked?
|
6
|
+
|
7
|
+
class TestCreate < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_create_netcdf_file
|
10
|
+
@filename = "test.nc"
|
11
|
+
file=NetCDF.create(@filename,false,false)
|
12
|
+
assert dimx=file.def_dim("x",15)
|
13
|
+
assert dimy=file.def_dim("y",10)
|
14
|
+
assert dimz=file.def_dim("z",10)
|
15
|
+
batt = file.put_att("type_byte",5,"byte")
|
16
|
+
file.put_att("type_short",[222,333,444],"sint")
|
17
|
+
file.put_att("type_int",[2222,3333,4444])
|
18
|
+
file.put_att("type_float",[2.22,3.33,4.44],"sfloat")
|
19
|
+
file.put_att("type_double",[2.222,3.333,4.444])
|
20
|
+
string = file.put_attraw("string","netCDF for Ruby","string")
|
21
|
+
batt.put(6,"byte")
|
22
|
+
|
23
|
+
assert sint_var=file.def_var("test_sint","sint",["x"])
|
24
|
+
assert byte_var=file.def_var("test_byte","byte",["y"])
|
25
|
+
assert byte_var2=file.def_var("test_byte2","byte",[dimy,dimz])
|
26
|
+
assert int_var=file.def_var("test_int","int",["y"])
|
27
|
+
assert sfloat_var=file.def_var("test_sfloat","sfloat",["z"])
|
28
|
+
assert float_var=file.def_var("test_float","float",["y"])
|
29
|
+
|
30
|
+
assert a=NArray.sint(10).indgen
|
31
|
+
assert b=NArray.sint(10).fill(7)
|
32
|
+
assert c=NArray.byte(10).indgen
|
33
|
+
assert d=NArray.int(10).indgen
|
34
|
+
assert e=NArray.sfloat(10).fill(1.111)
|
35
|
+
assert f=NArray.float(10).fill(5.5555555)
|
36
|
+
file.enddef
|
37
|
+
file2 = file
|
38
|
+
assert_equal file2, file
|
39
|
+
|
40
|
+
assert_nil byte_var.put_var_byte(c)
|
41
|
+
assert_nil int_var.put_var_int(d)
|
42
|
+
assert_nil sfloat_var.put_var_sfloat(e)
|
43
|
+
assert_nil float_var.put_var_float(f)
|
44
|
+
|
45
|
+
file.redef
|
46
|
+
byte_vara=file.def_var("test_byte_vara","byte",[dimy,dimz]);
|
47
|
+
sint_vara=file.def_var("test_sint_vara","sint",["y","z"]);
|
48
|
+
int_vara=file.def_var("test_int_vara","int",["y","z"]);
|
49
|
+
sfloat_vara=file.def_var("test_sfloat_vara","sfloat",["y","z"]);
|
50
|
+
float_vara=file.def_var("test_float_vara","float",["y","z"]);
|
51
|
+
file.enddef
|
52
|
+
|
53
|
+
byte_vara2 = byte_vara
|
54
|
+
assert_equal byte_vara2, byte_vara
|
55
|
+
|
56
|
+
assert g=NArray.byte(10,10).indgen
|
57
|
+
assert h=NArray.byte(2,3).indgen
|
58
|
+
assert gh=NArray.byte(1,1).fill(33)
|
59
|
+
assert k=NArray.sint(10,10).indgen
|
60
|
+
assert l=NArray.sint(2,3).indgen
|
61
|
+
assert kl=NArray.sint(1,1).fill(44)
|
62
|
+
assert m=NArray.int(10,10).indgen
|
63
|
+
assert n=NArray.int(2,3).indgen
|
64
|
+
assert mn=NArray.int(1,1).fill(55)
|
65
|
+
assert o=NArray.sfloat(10,10).fill(1.234567)
|
66
|
+
assert p=NArray.sfloat(2,3).fill(2.345678)
|
67
|
+
assert op=NArray.int(1,1).fill(3.4)
|
68
|
+
assert q=NArray.float(10,10).fill(1.234)
|
69
|
+
assert r=NArray.float(2,3).fill(2.345)
|
70
|
+
assert qr=NArray.float(1,1).fill(4.5)
|
71
|
+
assert s=NArray.float(2,2).fill(10.0)
|
72
|
+
|
73
|
+
assert_nil byte_vara.put(g)
|
74
|
+
assert_nil byte_vara.put(h,{"start"=>[3,5]})
|
75
|
+
assert_nil byte_vara.put(g,{"start"=>[0,0],"end"=>[9,9]})
|
76
|
+
assert_nil byte_vara.put(h,{"start"=>[-8,2]})
|
77
|
+
assert_nil byte_vara.put(h,{"start"=>[0,0],"stride"=>[2,3]})
|
78
|
+
assert_nil byte_vara.put(h,{'start'=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
79
|
+
assert_nil byte_vara.put(gh,{"index"=>[4,7]})
|
80
|
+
|
81
|
+
sint_vara.put(k)
|
82
|
+
sint_vara.put(l,{"start"=>[3,5]})
|
83
|
+
sint_vara.put(k,{"start"=>[0,0],"end"=>[9,9]})
|
84
|
+
sint_vara.put(l,{"start"=>[-8,2]})
|
85
|
+
sint_vara.put(l,{"start"=>[0,0],"stride"=>[2,3]})
|
86
|
+
sint_vara.put(l,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
87
|
+
sint_vara.put(kl,{"index"=>[4,7]})
|
88
|
+
|
89
|
+
int_vara.put(m)
|
90
|
+
int_vara.put(n,{"start"=>[3,5]})
|
91
|
+
int_vara.put(m,{"start"=>[0,0],"end"=>[9,9]})
|
92
|
+
int_vara.put(n,{"start"=>[-8,2]})
|
93
|
+
int_vara.put(n,{"start"=>[0,0],"stride"=>[2,3]})
|
94
|
+
int_vara.put(n,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
95
|
+
int_vara.put(mn,{"index"=>[4,7]})
|
96
|
+
|
97
|
+
sfloat_vara.put(o)
|
98
|
+
sfloat_vara.put(p,{"start"=>[3,5]})
|
99
|
+
sfloat_vara.put(o,{"start"=>[0,0],"end"=>[9,9]})
|
100
|
+
sfloat_vara.put(p,{"start"=>[-8,2]})
|
101
|
+
sfloat_vara.put(p,{"start"=>[0,0],"stride"=>[2,3]})
|
102
|
+
sfloat_vara.put(p,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
103
|
+
sfloat_vara.put(op,{"index"=>[4,7]})
|
104
|
+
|
105
|
+
float_vara.put(q)
|
106
|
+
float_vara.put(r,{"start"=>[3,5]})
|
107
|
+
float_vara.put(q,{"start"=>[0,0],"end"=>[9,9]})
|
108
|
+
float_vara.put(r,{"start"=>[-8,2]})
|
109
|
+
float_vara.put(r,{"start"=>[0,0],"stride"=>[2,3]})
|
110
|
+
float_vara.put(r,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
111
|
+
float_vara.put(qr,{"index"=>[4,7]})
|
112
|
+
|
113
|
+
float_vara.dim_names
|
114
|
+
|
115
|
+
assert na_aaa=byte_vara.get({"start"=>[3,5]})
|
116
|
+
assert na_aab=byte_vara.get({"start"=>[0,0],"end"=>[9,9]})
|
117
|
+
assert na_aac=byte_vara.get({"start"=>[-8,2]})
|
118
|
+
assert na_aad=byte_vara.get({"start"=>[0,0],"stride"=>[2,3]})
|
119
|
+
assert na_aae=byte_vara.get({'start'=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
120
|
+
assert na_aaf=byte_vara.get({"index"=>[4,7]})
|
121
|
+
assert na_aag=byte_vara.get
|
122
|
+
|
123
|
+
assert na_bba=sint_vara.get({"start"=>[3,5]})
|
124
|
+
assert na_bbb=sint_vara.get({"start"=>[0,0],"end"=>[9,9]})
|
125
|
+
assert na_bbc=sint_vara.get({"start"=>[-8,2]})
|
126
|
+
assert na_bbd=sint_vara.get({"start"=>[0,0],"stride"=>[2,3]})
|
127
|
+
assert na_bbf=sint_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
128
|
+
assert na_bbg=sint_vara.get({"index"=>[4,7]})
|
129
|
+
assert na_bbh=sint_vara.get
|
130
|
+
|
131
|
+
assert na_cca=int_vara.get({"start"=>[3,5]})
|
132
|
+
assert na_ccb=int_vara.get({"start"=>[0,0],"end"=>[9,9]})
|
133
|
+
assert na_ccc=int_vara.get({"start"=>[-8,2]})
|
134
|
+
assert na_ccd=int_vara.get({"start"=>[0,0],"stride"=>[2,3]})
|
135
|
+
assert na_cce=int_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
136
|
+
assert na_ccf=int_vara.get({"index"=>[4,7]})
|
137
|
+
assert na_ccg=int_vara.get
|
138
|
+
|
139
|
+
assert na_dda=sfloat_vara.get({"start"=>[3,5]})
|
140
|
+
assert na_ddb=sfloat_vara.get({"start"=>[0,0],"end"=>[9,9]})
|
141
|
+
assert na_ddc=sfloat_vara.get({"start"=>[-8,2]})
|
142
|
+
assert na_ddd=sfloat_vara.get({"start"=>[0,0],"stride"=>[2,3]})
|
143
|
+
assert na_dde=sfloat_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
144
|
+
assert na_ddf=sfloat_vara.get({"index"=>[4,7]})
|
145
|
+
assert na_ddg=sfloat_vara.get
|
146
|
+
|
147
|
+
assert na_eea=float_vara.get({"start"=>[3,5]})
|
148
|
+
assert na_eeb=float_vara.get({"start"=>[0,0],"end"=>[9,9]})
|
149
|
+
assert na_eec=float_vara.get({"start"=>[-8,2]})
|
150
|
+
assert na_eed=float_vara.get({"start"=>[0,0],"stride"=>[2,3]})
|
151
|
+
assert na_eee=float_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
|
152
|
+
assert na_eef=float_vara.get({"index"=>[4,7]})
|
153
|
+
assert na_eeg=float_vara.get
|
154
|
+
|
155
|
+
file.redef
|
156
|
+
|
157
|
+
copy_byte = string.copy(byte_vara)
|
158
|
+
copy_byte.put([0,20],"byte")
|
159
|
+
copy_byte.name="new_name"
|
160
|
+
|
161
|
+
copy_byte2 = copy_byte
|
162
|
+
assert_equal copy_byte2, copy_byte
|
163
|
+
|
164
|
+
copy_sint = string.copy(sint_vara)
|
165
|
+
copy_sint.put("%%%%%")
|
166
|
+
copy_int = string.copy(int_vara)
|
167
|
+
copy_int.put([0,60],"int")
|
168
|
+
copy_sfloat = string.copy(sfloat_vara)
|
169
|
+
copy_sfloat.put([0.01,5.5],"sfloat")
|
170
|
+
copy_float = string.copy(float_vara)
|
171
|
+
copy_float.put([0.0001,5.5555],"float")
|
172
|
+
file.enddef
|
173
|
+
assert nm = copy_byte.name
|
174
|
+
assert att0 = string.get
|
175
|
+
assert att1 = copy_byte.get
|
176
|
+
assert att2 = copy_sint.get
|
177
|
+
assert att3 = copy_int.get
|
178
|
+
assert att4 = copy_sfloat.get
|
179
|
+
assert att5 = copy_float.get
|
180
|
+
file.fill(true)
|
181
|
+
file.fill(false)
|
182
|
+
|
183
|
+
float_vara.dim_names
|
184
|
+
float_vara.att_names
|
185
|
+
|
186
|
+
file.close
|
187
|
+
end
|
188
|
+
|
189
|
+
def teardown
|
190
|
+
if File.exist?(@filename)
|
191
|
+
begin
|
192
|
+
File.delete(@filename)
|
193
|
+
rescue
|
194
|
+
p $!
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
data/test/type.rb
CHANGED
@@ -1,13 +1,29 @@
|
|
1
|
+
require 'test/unit'
|
1
2
|
require 'numru/netcdf'
|
2
3
|
include NumRu
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
v = f.def_var('
|
9
|
-
|
10
|
-
v
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
class TestType < Test::Unit::TestCase
|
5
|
+
def test_type
|
6
|
+
@s = 'tmp.nc'
|
7
|
+
f = NetCDF.create(@s)
|
8
|
+
d = f.def_dim('x',2)
|
9
|
+
v = f.def_var('x','sfloat',[d])
|
10
|
+
assert_equal v.vartype,
|
11
|
+
v.ntype
|
12
|
+
v = f.def_var('x1','sint',[d])
|
13
|
+
assert_equal v.vartype,
|
14
|
+
v.ntype
|
15
|
+
v = f.def_var('x2','byte',[d])
|
16
|
+
assert_equal v.vartype,
|
17
|
+
v.ntype
|
18
|
+
f.close
|
19
|
+
end
|
20
|
+
def teardown
|
21
|
+
if File.exist?(@s)
|
22
|
+
begin
|
23
|
+
File.delete(@s)
|
24
|
+
rescue
|
25
|
+
p $!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-netcdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi Horinouchi
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: narray
|
@@ -42,6 +42,20 @@ dependencies:
|
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: test-unit
|
47
|
+
requirement: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
type: :development
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
45
59
|
description: RubyNetCDF is the Ruby interface to the NetCDF library built on the NArray
|
46
60
|
library, which is an efficient multi-dimensional numeric array class for Ruby. This
|
47
61
|
version works with Ruby2.0.
|
@@ -54,6 +68,7 @@ extra_rdoc_files: []
|
|
54
68
|
files:
|
55
69
|
- ".ChangeLog.until20150117"
|
56
70
|
- ".gitignore"
|
71
|
+
- ChangeLog
|
57
72
|
- Gemfile
|
58
73
|
- INSTALL
|
59
74
|
- LICENSE.txt
|
@@ -110,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
125
|
- !ruby/object:Gem::Version
|
111
126
|
version: '0'
|
112
127
|
requirements: []
|
113
|
-
|
114
|
-
rubygems_version: 2.2.2
|
128
|
+
rubygems_version: 3.2.5
|
115
129
|
signing_key:
|
116
130
|
specification_version: 4
|
117
131
|
summary: Ruby interface to NetCDF
|