rb-grib 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/extconf.rb +2 -1
- data/lib/numru/grib/grib.rb +2 -2
- data/lib/numru/grib/version.rb +1 -1
- data/rb-grib.gemspec +1 -1
- data/spec/grib_read_spec.rb +169 -0
- data/spec/spec_helper.rb +8 -0
- metadata +23 -7
data/ext/extconf.rb
CHANGED
data/lib/numru/grib/grib.rb
CHANGED
data/lib/numru/grib/version.rb
CHANGED
data/rb-grib.gemspec
CHANGED
@@ -0,0 +1,169 @@
|
|
1
|
+
require File.expand_path(File.join('.','spec_helper'), File.dirname(__FILE__))
|
2
|
+
|
3
|
+
dir = File.expand_path(File.join('..','data'), File.dirname(__FILE__))
|
4
|
+
fname_reg_gaus_surf_g1 = File.join(dir, 'regular_gaussian_surface.grib1')
|
5
|
+
fname_reg_gaus_surf_g2 = File.join(dir, 'regular_gaussian_surface.grib2')
|
6
|
+
fname_reg_gaus_ml_g1 = File.join(dir, 'regular_gaussian_model_level.grib1')
|
7
|
+
fname_reg_gaus_ml_g2 = File.join(dir, 'regular_gaussian_model_level.grib2')
|
8
|
+
fname_reg_gaus_pl_g1 = File.join(dir, 'regular_gaussian_pressure_level.grib1')
|
9
|
+
fname_reg_gaus_pl_g2 = File.join(dir, 'regular_gaussian_pressure_level.grib2')
|
10
|
+
fname_reg_gaus_pl_const_g1 = File.join(dir, 'regular_gaussian_pressure_level_constant.grib1')
|
11
|
+
fname_reg_gaus_pl_const_g2 = File.join(dir, 'regular_gaussian_pressure_level_constant.grib2')
|
12
|
+
fname_reg_ll_surf_g1 = File.join(dir, 'regular_latlon_surface.grib1')
|
13
|
+
fname_reg_ll_surf_g2 = File.join(dir, 'regular_latlon_surface.grib2')
|
14
|
+
fname_reg_ll_surf_const_g1 = File.join(dir, 'regular_latlon_surface_constant.grib1')
|
15
|
+
fname_reg_ll_surf_const_g2 = File.join(dir, 'regular_latlon_surface_constant.grib2')
|
16
|
+
fname_not_exist = 'not_exist'
|
17
|
+
fnames = [
|
18
|
+
fname_reg_gaus_surf_g1,
|
19
|
+
fname_reg_gaus_surf_g2,
|
20
|
+
fname_reg_gaus_ml_g1,
|
21
|
+
fname_reg_gaus_ml_g2,
|
22
|
+
fname_reg_gaus_pl_g1,
|
23
|
+
fname_reg_gaus_pl_g2,
|
24
|
+
fname_reg_gaus_pl_const_g1,
|
25
|
+
fname_reg_gaus_pl_const_g2,
|
26
|
+
fname_reg_ll_surf_g1,
|
27
|
+
fname_reg_ll_surf_g2,
|
28
|
+
fname_reg_ll_surf_const_g1
|
29
|
+
]
|
30
|
+
|
31
|
+
describe NumRu::Grib do
|
32
|
+
describe 'Grib.is_a_Grib?' do
|
33
|
+
it 'returns whether the specific file is a GRIB1/2 file' do
|
34
|
+
NumRu::Grib.is_a_Grib?(fname_reg_gaus_surf_g1).should be_true
|
35
|
+
NumRu::Grib.is_a_Grib?(fname_reg_gaus_surf_g2).should be_true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'Grib.open' do
|
40
|
+
context 'specified a file name' do
|
41
|
+
describe 'grib1' do
|
42
|
+
it 'returns Grib object' do
|
43
|
+
(@file = NumRu::Grib.open(fname_reg_gaus_surf_g1)).should be_a_kind_of(NumRu::Grib)
|
44
|
+
end
|
45
|
+
after { @file.close if @file }
|
46
|
+
end
|
47
|
+
describe 'grib2' do
|
48
|
+
it 'returns Grib object' do
|
49
|
+
(@file = NumRu::Grib.open(fname_reg_gaus_surf_g2)).should be_a_kind_of(NumRu::Grib)
|
50
|
+
end
|
51
|
+
after { @file.close if @file }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
context 'specified a file name which does not exist' do
|
55
|
+
it { proc { NumRu::Grib.open(fname_not_exist)}.should raise_error }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#close' do
|
60
|
+
file = NumRu::Grib.open(fname_reg_gaus_surf_g1)
|
61
|
+
it { file.close }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'instance methods' do
|
65
|
+
before do
|
66
|
+
@files = fnames.map{|fname| NumRu::Grib.open(fname)}
|
67
|
+
end
|
68
|
+
after do
|
69
|
+
@files.each{|file| file.close}
|
70
|
+
end
|
71
|
+
it '#path returns path' do
|
72
|
+
@files.each {|file| file.path.should be_a_kind_of(String)}
|
73
|
+
end
|
74
|
+
it '#var_names returns Array of variable names' do
|
75
|
+
@files.each {|file| file.var_names.should be_a_kind_of(Array)}
|
76
|
+
end
|
77
|
+
it '#var returns GribVar object' do
|
78
|
+
@files.each do |file|
|
79
|
+
vname = file.var_names[0]
|
80
|
+
file.var(vname).should be_a_kind_of NumRu::GribVar
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe NumRu::GribVar do
|
87
|
+
before do
|
88
|
+
@vars = []
|
89
|
+
@files = []
|
90
|
+
fnames.each do |fname|
|
91
|
+
file = NumRu::Grib.open(fname)
|
92
|
+
@files.push file
|
93
|
+
file.var_names.each{|vname| @vars.push file.var(vname)}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
after do
|
97
|
+
@files.each{|file| file.close}
|
98
|
+
end
|
99
|
+
it '#rank returns rank' do
|
100
|
+
@vars.each{|var| var.rank.should be_a_kind_of Fixnum}
|
101
|
+
end
|
102
|
+
it '#total returns total length' do
|
103
|
+
@vars.each{|var| var.total.should be_a_kind_of Fixnum}
|
104
|
+
end
|
105
|
+
it '#dim_names returns Array of dimension names' do
|
106
|
+
@vars.each{|var| var.dim_names.should be_a_kind_of Array}
|
107
|
+
end
|
108
|
+
it '#shape returns Array of shape' do
|
109
|
+
@vars.each{|var| var.shape.should be_a_kind_of Array}
|
110
|
+
end
|
111
|
+
it '#dim returns GribDim' do
|
112
|
+
@vars.each do |var|
|
113
|
+
var.dim_names.each{|dname| var.dim(dname).should be_a_kind_of NumRu::GribDim}
|
114
|
+
end
|
115
|
+
end
|
116
|
+
it '#att_names returns Array of attribute names' do
|
117
|
+
@vars.each{|var| var.att_names.should be_a_kind_of Array}
|
118
|
+
end
|
119
|
+
it '#att returns attribute value' do
|
120
|
+
@vars.each do |var|
|
121
|
+
var.att_names.each{|aname| var.att(aname).should_not == nil }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
it '#typecode returns type code' do
|
125
|
+
@vars.each{|var| var.typecode.should be_a_kind_of Fixnum}
|
126
|
+
end
|
127
|
+
it '#missing_value returns missing value' do
|
128
|
+
@vars.each{|var| var.missing_value.should be_a_kind_of Numeric}
|
129
|
+
end
|
130
|
+
it '#get returns value' do
|
131
|
+
@vars.each{|var| var.get.should be_a_kind_of NArrayMiss}
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe NumRu::GribDim do
|
136
|
+
before do
|
137
|
+
@dims = []
|
138
|
+
@files = []
|
139
|
+
fnames.each do |fname|
|
140
|
+
file = NumRu::Grib.open(fname)
|
141
|
+
@files.push file
|
142
|
+
file.var_names.each do |vname|
|
143
|
+
var = file.var(vname)
|
144
|
+
var.dim_names{|dname| @dims.push var.dim(dname)}
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
after do
|
149
|
+
@files.each{|file| file.close}
|
150
|
+
end
|
151
|
+
it '#length returns length' do
|
152
|
+
@dims.each{|dim| dim.length.should be_a_kind_of Integer}
|
153
|
+
end
|
154
|
+
it '#val returns value' do
|
155
|
+
@dims.each{|dim| dim.val.should be_a_kind_of NArray}
|
156
|
+
end
|
157
|
+
it '#typecode returns typecode' do
|
158
|
+
@dims.each{|dim| dim.typecode.should be_a_kind_of Fixnum}
|
159
|
+
end
|
160
|
+
it '#att_names returns Array of attribute names' do
|
161
|
+
@dims.each{|dim| dim.att_names.should be_a_kind_of Array}
|
162
|
+
end
|
163
|
+
it '#att returns attributes value' do
|
164
|
+
@dims.each do |dim|
|
165
|
+
dim.att_names.each{|aname| dim.att(aname).should_not == nil }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.join('..','ext'), File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift File.expand_path(File.join('..','lib'), File.dirname(__FILE__))
|
3
|
+
alias :_require :require
|
4
|
+
def require(arg)
|
5
|
+
arg = "grib.so" if arg == "numru/grib.so"
|
6
|
+
_require(arg)
|
7
|
+
end
|
8
|
+
require "numru/grib"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-grib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seiya Nishizawa
|
@@ -16,8 +16,21 @@ bindir: bin
|
|
16
16
|
cert_chain: []
|
17
17
|
|
18
18
|
date: 2011-11-29 00:00:00 Z
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
21
34
|
description: This class library enable you to handle GRIB file.
|
22
35
|
email:
|
23
36
|
- seiya@gfd-dennou.org
|
@@ -39,6 +52,8 @@ files:
|
|
39
52
|
- lib/numru/grib/grib.rb
|
40
53
|
- lib/numru/grib/version.rb
|
41
54
|
- rb-grib.gemspec
|
55
|
+
- spec/grib_read_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
42
57
|
homepage: http://ruby.gfd-dennou.org/products/rb-grib/
|
43
58
|
licenses: []
|
44
59
|
|
@@ -72,5 +87,6 @@ rubygems_version: 1.8.10
|
|
72
87
|
signing_key:
|
73
88
|
specification_version: 3
|
74
89
|
summary: Ruby class library to hanlde GRIB file
|
75
|
-
test_files:
|
76
|
-
|
90
|
+
test_files:
|
91
|
+
- spec/grib_read_spec.rb
|
92
|
+
- spec/spec_helper.rb
|