rb-grib 0.2.2 → 0.3.0
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.
- checksums.yaml +7 -0
- data/BSDL +1 -1
- data/README.rdoc +1 -1
- data/ext/extconf.rb +15 -5
- data/ext/grib.c +8 -5
- data/lib/numru/grib/setenv.rb +9 -1
- data/lib/numru/grib/version.rb +1 -1
- data/rb-grib.gemspec +1 -1
- data/spec/grib_read_spec.rb +28 -23
- metadata +56 -75
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f8f3d0dfbd8bcdf02783485139224e0e0c151071
|
4
|
+
data.tar.gz: 6fc49fc43aa1af1fd981803253b40281d2850350
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c1a614dd1264329f35793a828cb074d7f5e4603ee21ee22ef5014a73a695b14871e4e3fb750693a5014820b380a31dd4603316fdebcd0d46c350bddd1773092
|
7
|
+
data.tar.gz: c1d07b21d120b59563f2bce553676a8448d4179de0b90f7c8a5cdf3db59f9efd7613140978ccd64d062469a969f04b31fa4d1c707f4237b2cc92df85c7e8e111
|
data/BSDL
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (C) 2011 Seiya Nishizawa and GFD Dennou Club. All rights reserved.
|
1
|
+
Copyright (C) 2011-2016 Seiya Nishizawa and GFD Dennou Club. All rights reserved.
|
2
2
|
|
3
3
|
Redistribution and use in source and binary forms, with or without
|
4
4
|
modification, are permitted provided that the following conditions
|
data/README.rdoc
CHANGED
@@ -12,7 +12,7 @@ The URL of the rb-GRIB home-page is:
|
|
12
12
|
= Requires
|
13
13
|
|
14
14
|
* Ruby (http://www.ruby-lang.org/)
|
15
|
-
* NArray (
|
15
|
+
* NumRu-NArray (https://github.com/seiya/numru-narray) or NArray (https://masa16.github.io/narray/index.html)
|
16
16
|
* NArrayMiss (http://ruby.gfd-dennou.org/products/narray_miss/)
|
17
17
|
* GRIB API (http://www.ecmwf.int/products/data/software/grib_api.html)
|
18
18
|
|
data/ext/extconf.rb
CHANGED
@@ -2,13 +2,23 @@ require "mkmf"
|
|
2
2
|
|
3
3
|
begin
|
4
4
|
require "rubygems"
|
5
|
-
|
5
|
+
if Gem::Specification.respond_to?(:find_by_name)
|
6
|
+
if spec = ( Gem::Specification.find_by_name("numru-narray") || Gem::Specification.find_by_name("narray") )
|
7
|
+
gem_path = spec.full_gem_path
|
8
|
+
end
|
9
|
+
else
|
10
|
+
if (spec = (Gem.source_index.find_name("numru-narray") || Gem.source_index.find_name("narray")) ).any?
|
11
|
+
gem_path = spec.full_gem_path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
gem_path = File.join(gem_path, "ext", "numru", "narray")
|
6
15
|
rescue LoadError
|
7
|
-
|
16
|
+
dir_config("narray", RbConfig::CONFIG["sitearchdir"])
|
17
|
+
end
|
18
|
+
|
19
|
+
unless find_header("narray.h", gem_path)
|
20
|
+
find_header("narray.h", File.join(gem_path,"src"))
|
8
21
|
end
|
9
|
-
paths += [$archdir, $sitearchdir, $vendorarchdir]
|
10
|
-
dir_config("narray")
|
11
|
-
find_header("narray.h", *paths)
|
12
22
|
|
13
23
|
dir_config("grib_api")
|
14
24
|
if have_header("grib_api.h") && have_library("grib_api")
|
data/ext/grib.c
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
#include "grib_api.h"
|
5
5
|
#include "narray.h"
|
6
6
|
|
7
|
+
#ifndef NARRAY_BIGMEM
|
8
|
+
typedef int na_shape_t;
|
9
|
+
#endif
|
7
10
|
|
8
11
|
#define MAX_VALUE_LENGTH 1024
|
9
12
|
|
@@ -11,7 +14,7 @@
|
|
11
14
|
static void
|
12
15
|
check_error(int code)
|
13
16
|
{
|
14
|
-
if (code) rb_raise(rb_eRuntimeError, grib_get_error_message(code));
|
17
|
+
if (code) rb_raise(rb_eRuntimeError, "%s", grib_get_error_message(code));
|
15
18
|
};
|
16
19
|
|
17
20
|
|
@@ -681,7 +684,7 @@ rg_message_get_value(int argc, VALUE *argv, VALUE self)
|
|
681
684
|
ret = LONG2NUM(l);
|
682
685
|
}
|
683
686
|
} else {
|
684
|
-
|
687
|
+
na_shape_t shape[1];
|
685
688
|
struct NARRAY *nary;
|
686
689
|
shape[0] = len;
|
687
690
|
VALUE rnary = na_make_object(NA_LINT, 1, shape, cNArray);
|
@@ -698,7 +701,7 @@ rg_message_get_value(int argc, VALUE *argv, VALUE self)
|
|
698
701
|
if (grib_get_double(message->handle, name, &value) == GRIB_SUCCESS)
|
699
702
|
ret = rb_float_new(value);
|
700
703
|
} else {
|
701
|
-
|
704
|
+
na_shape_t shape[1];
|
702
705
|
struct NARRAY *nary;
|
703
706
|
shape[0] = len;
|
704
707
|
VALUE rnary = na_make_object(NA_DFLOAT, 1, shape, cNArray);
|
@@ -730,7 +733,7 @@ rg_message_get_data(VALUE self)
|
|
730
733
|
double *lon, *lat, *value;
|
731
734
|
VALUE na_lon, na_lat, na_value;
|
732
735
|
struct NARRAY *nary;
|
733
|
-
|
736
|
+
na_shape_t shape[1];
|
734
737
|
shape[0] = np;
|
735
738
|
na_lon = na_make_object(NA_DFLOAT, 1, shape, cNArray);
|
736
739
|
GetNArray(na_lon, nary);
|
@@ -757,7 +760,7 @@ rg_message_get_data(VALUE self)
|
|
757
760
|
|
758
761
|
void Init_grib()
|
759
762
|
{
|
760
|
-
rb_require("narray");
|
763
|
+
// rb_require("narray");
|
761
764
|
|
762
765
|
id_init = rb_intern("init");
|
763
766
|
|
data/lib/numru/grib/setenv.rb
CHANGED
@@ -4,7 +4,15 @@ if File.exist?(def_path)
|
|
4
4
|
if gdp = ENV[env_name]
|
5
5
|
ENV[env_name] = "#{gdp}:#{def_path}"
|
6
6
|
else
|
7
|
-
|
7
|
+
begin
|
8
|
+
path = `grib_info -d`.strip
|
9
|
+
rescue
|
10
|
+
$stderr.print <<-EOM
|
11
|
+
The 'grib_info' command cannot be found.
|
12
|
+
If you have the command, please set the PATH environment variable.
|
13
|
+
EOM
|
14
|
+
exit(-1)
|
15
|
+
end
|
8
16
|
if File.exist?(path)
|
9
17
|
ENV[env_name] = "#{path}:#{def_path}"
|
10
18
|
end
|
data/lib/numru/grib/version.rb
CHANGED
data/rb-grib.gemspec
CHANGED
data/spec/grib_read_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.join('.','spec_helper'), File.dirname(__FILE__))
|
2
|
+
include NumRu
|
2
3
|
|
3
4
|
dir = File.expand_path(File.join('..','data'), File.dirname(__FILE__))
|
4
5
|
GribData = {
|
@@ -48,7 +49,7 @@ describe NumRu::Grib do
|
|
48
49
|
describe 'Grib.is_a_Grib?' do
|
49
50
|
it 'returns whether the specific file is a GRIB1/2 file' do
|
50
51
|
GribData.each do |fname, hash|
|
51
|
-
NumRu::Grib.is_a_Grib?(fname).
|
52
|
+
expect(NumRu::Grib.is_a_Grib?(fname)).to eq true
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -59,12 +60,12 @@ describe NumRu::Grib do
|
|
59
60
|
it 'returns Grib object' do
|
60
61
|
GribData.each do |fname, hash|
|
61
62
|
file = NumRu::Grib.open(fname)
|
62
|
-
file.
|
63
|
+
expect(file).to be_instance_of(NumRu::Grib)
|
63
64
|
@files.push file
|
64
65
|
end
|
65
66
|
end
|
66
67
|
it 'raise exception when file name which does not exist is given' do
|
67
|
-
|
68
|
+
expect { NumRu::Grib.open(fname_not_exist) }.to raise_error(RuntimeError)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -75,7 +76,7 @@ describe NumRu::Grib do
|
|
75
76
|
end
|
76
77
|
it do
|
77
78
|
@files.each do |file|
|
78
|
-
|
79
|
+
expect {file.close}.not_to raise_error
|
79
80
|
end
|
80
81
|
end
|
81
82
|
end
|
@@ -89,15 +90,19 @@ describe NumRu::Grib do
|
|
89
90
|
@files.each{|fname,file| file.close}
|
90
91
|
end
|
91
92
|
it '#path returns path' do
|
92
|
-
@files.each
|
93
|
+
@files.each do |fname,file|
|
94
|
+
expect( file.path ).to eq fname
|
95
|
+
end
|
93
96
|
end
|
94
97
|
it '#var_names returns Array of variable names' do
|
95
|
-
@files.each
|
98
|
+
@files.each do |fname, file|
|
99
|
+
expect( file.var_names ).to eq GribData[fname].keys
|
100
|
+
end
|
96
101
|
end
|
97
102
|
it '#var returns GribVar object' do
|
98
103
|
@files.each do |fname, file|
|
99
104
|
GribData[fname].each do |vname, hash|
|
100
|
-
file.var(vname).
|
105
|
+
expect( file.var(vname) ).to be_instance_of NumRu::GribVar
|
101
106
|
end
|
102
107
|
end
|
103
108
|
end
|
@@ -116,41 +121,41 @@ describe NumRu::GribVar do
|
|
116
121
|
end
|
117
122
|
after { @files.each{|file| file.close}}
|
118
123
|
it '#rank returns rank' do
|
119
|
-
@vars.each{|var,hash| var.rank.
|
124
|
+
@vars.each{|var,hash| expect(var.rank).to eq hash[:shape].length}
|
120
125
|
end
|
121
126
|
it '#total returns total length' do
|
122
|
-
@vars.each{|var,hash| var.total.
|
127
|
+
@vars.each{|var,hash| expect(var.total).to eq hash[:shape].inject(1,:*)}
|
123
128
|
end
|
124
129
|
it '#dim_names returns Array of dimension names' do
|
125
|
-
@vars.each{|var,hash| var.dim_names.
|
130
|
+
@vars.each{|var,hash| expect(var.dim_names).to eq hash[:dims]}
|
126
131
|
end
|
127
132
|
it '#shape returns Array of shape' do
|
128
|
-
@vars.each{|var,hash| var.shape.
|
133
|
+
@vars.each{|var,hash| expect(var.shape).to eq hash[:shape]}
|
129
134
|
end
|
130
135
|
it '#dim returns GribDim' do
|
131
136
|
@vars.each do |var,hash|
|
132
|
-
hash[:dims].each{|dname| var.dim(dname).
|
137
|
+
hash[:dims].each{|dname| expect(var.dim(dname)).to be_instance_of NumRu::GribDim}
|
133
138
|
end
|
134
139
|
end
|
135
140
|
it '#att_names returns Array of attribute names' do
|
136
|
-
@vars.each{|var,hash| var.att_names.
|
141
|
+
@vars.each{|var,hash| expect(var.att_names).to be_instance_of Array}
|
137
142
|
end
|
138
143
|
it '#att returns attribute value' do
|
139
144
|
@vars.each do |var,hash|
|
140
|
-
var.att_names.each{|aname| var.att(aname).
|
145
|
+
var.att_names.each{|aname| expect(var.att(aname)).to_not eq nil }
|
141
146
|
end
|
142
147
|
end
|
143
148
|
it '#typecode returns type code' do
|
144
|
-
@vars.each{|var,hash| var.typecode.
|
149
|
+
@vars.each{|var,hash| expect(var.typecode).to be_instance_of Fixnum}
|
145
150
|
end
|
146
151
|
it '#missing_value returns missing value' do
|
147
|
-
@vars.each{|var,hash| var.missing_value.
|
152
|
+
@vars.each{|var,hash| expect(var.missing_value).to be_kind_of Numeric}
|
148
153
|
end
|
149
154
|
it '#get returns value' do
|
150
155
|
@vars.each do |var,hash|
|
151
156
|
hash[:val].each do |idx,val|
|
152
157
|
v = var.get[*idx]
|
153
|
-
((v-val).abs/((v+val)/2)).
|
158
|
+
expect((v-val).abs/((v+val)/2)).to be < 1e-10
|
154
159
|
end
|
155
160
|
end
|
156
161
|
end
|
@@ -175,23 +180,23 @@ describe NumRu::GribDim do
|
|
175
180
|
@files.each{|file| file.close}
|
176
181
|
end
|
177
182
|
it '#length returns length' do
|
178
|
-
@dims.each{|dim,len| dim.length.
|
183
|
+
@dims.each{|dim,len| expect(dim.length).to eq len}
|
179
184
|
end
|
180
185
|
it '#val returns value' do
|
181
186
|
@dims.each do |dim,len|
|
182
|
-
dim.val.
|
183
|
-
dim.val.length.
|
187
|
+
expect(dim.val).to be_instance_of NArray
|
188
|
+
expect(dim.val.length).to eq len
|
184
189
|
end
|
185
190
|
end
|
186
191
|
it '#typecode returns typecode' do
|
187
|
-
@dims.each{|dim,len| dim.typecode.
|
192
|
+
@dims.each{|dim,len| expect(dim.typecode).to be_instance_of Fixnum}
|
188
193
|
end
|
189
194
|
it '#att_names returns Array of attribute names' do
|
190
|
-
@dims.each{|dim,len| dim.att_names.
|
195
|
+
@dims.each{|dim,len| expect(dim.att_names).to be_instance_of Array}
|
191
196
|
end
|
192
197
|
it '#att returns attributes value' do
|
193
198
|
@dims.each do |dim,len|
|
194
|
-
dim.att_names.each{|aname| dim.att(aname).
|
199
|
+
dim.att_names.each{|aname| expect(dim.att(aname)).to_not eq nil }
|
195
200
|
end
|
196
201
|
end
|
197
202
|
|
metadata
CHANGED
@@ -1,75 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-grib
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 2
|
10
|
-
version: 0.2.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Seiya Nishizawa
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rspec
|
22
|
-
|
23
|
-
|
24
|
-
none: false
|
25
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
26
17
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
32
20
|
type: :development
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: narray
|
36
21
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: numru-narray
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
40
31
|
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
46
34
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: narray_miss
|
50
35
|
prerelease: false
|
51
|
-
|
52
|
-
|
53
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
54
38
|
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: narray_miss
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
60
48
|
type: :runtime
|
61
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
62
55
|
description: This class library enable you to handle GRIB file.
|
63
|
-
email:
|
56
|
+
email:
|
64
57
|
- seiya@gfd-dennou.org
|
65
58
|
executables: []
|
66
|
-
|
67
|
-
extensions:
|
59
|
+
extensions:
|
68
60
|
- ext/extconf.rb
|
69
61
|
extra_rdoc_files: []
|
70
|
-
|
71
|
-
|
72
|
-
- .gitignore
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
73
64
|
- BSDL
|
74
65
|
- Gemfile
|
75
66
|
- LICENSE.txt
|
@@ -108,37 +99,27 @@ files:
|
|
108
99
|
- spec/spec_helper.rb
|
109
100
|
homepage: http://ruby.gfd-dennou.org/products/rb-grib/
|
110
101
|
licenses: []
|
111
|
-
|
102
|
+
metadata: {}
|
112
103
|
post_install_message:
|
113
104
|
rdoc_options: []
|
114
|
-
|
115
|
-
require_paths:
|
105
|
+
require_paths:
|
116
106
|
- lib
|
117
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
-
|
119
|
-
requirements:
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
120
109
|
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
version: "0"
|
126
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
|
-
requirements:
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
129
114
|
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
version: "0"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
135
117
|
requirements: []
|
136
|
-
|
137
118
|
rubyforge_project: rb-grib
|
138
|
-
rubygems_version:
|
119
|
+
rubygems_version: 2.4.8
|
139
120
|
signing_key:
|
140
|
-
specification_version:
|
121
|
+
specification_version: 4
|
141
122
|
summary: Ruby class library to hanlde GRIB file
|
142
|
-
test_files:
|
123
|
+
test_files:
|
143
124
|
- spec/grib_read_spec.rb
|
144
125
|
- spec/spec_helper.rb
|