knmi 0.3.0 → 0.3.1
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/README.mkdn +56 -50
- data/VERSION +1 -1
- data/knmi.gemspec +1 -1
- data/lib/knmi/calculations.rb +2 -1
- metadata +2 -2
data/README.mkdn
CHANGED
@@ -23,77 +23,83 @@ Installation
|
|
23
23
|
Example Usage
|
24
24
|
-------------
|
25
25
|
|
26
|
-
|
26
|
+
Launch console e.g. irb at the command line
|
27
27
|
|
28
|
-
|
28
|
+
### Quick Script
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
starts = Time.utc(2010, 6, 28) # 2010 April 28th
|
33
|
-
ends = Time.utc(2010, 6, 29) # 2010 April 29th
|
34
|
-
request = KNMI.get_data(station, parameter, starts, ends)
|
35
|
-
data = KNMI::Calculations.convert(request.data)
|
30
|
+
```Ruby
|
31
|
+
require 'knmi'
|
36
32
|
|
37
|
-
|
33
|
+
station = KNMI.station_by_id(235)
|
34
|
+
parameters = KNMI.parameters(period = "daily", params = nil, categories = ["TEMP", "WIND"])
|
35
|
+
starts = Time.utc(2010, 6, 28) # 2010 April 28th
|
36
|
+
ends = Time.utc(2010, 6, 29) # 2010 April 29th
|
37
|
+
request = KNMI.get_data(station, parameters, starts, ends)
|
38
|
+
data = KNMI.convert(parameters, request)
|
39
|
+
```
|
40
|
+
### Elaborated Script
|
38
41
|
|
39
|
-
|
42
|
+
```Ruby
|
43
|
+
require 'knmi'
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
# Get station object by station ID
|
46
|
+
station = KNMI.station_by_id(235)
|
43
47
|
|
44
|
-
|
45
|
-
|
48
|
+
station
|
49
|
+
#=> #<KNMI::Station:0x0000010133c938> # A struct object
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
# Available Instance Variables
|
52
|
+
station.instance_variables
|
53
|
+
#=> [:@id, :@name, :@elevation, :@photo, :@map, :@web, :@instrumentation, :@coordinates]
|
54
|
+
station.id
|
55
|
+
#=> 235
|
56
|
+
station.name
|
57
|
+
#=>"De kooy"
|
58
|
+
station.coordinates
|
59
|
+
#=> 52.924,4.785
|
56
60
|
|
57
61
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
# Get parameter object at the time interval you wish to use "hourly" or "daily"
|
63
|
+
# Params can be a single term or an array of terms such as "TG" or ["TG", TX]
|
64
|
+
# Categories can be a single term or an array of terms such as "WIND" or ["WIND", "TEMP"]
|
65
|
+
parameters = KNMI.parameters(period = "daily", params = nil, categories = ["TEMP", "WIND"])
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
parameters # returns an array of parameter objects
|
68
|
+
#=> [#<KNMI::Parameters:0x000001011387e0 @parameter="TX", @category="TEMP", @description="Maximum Temperature", @validate="n.integer?", @conversion="n / 10", @units="C", @period="daily">]
|
65
69
|
|
66
|
-
|
67
|
-
|
68
|
-
|
70
|
+
# Available Instance Variables
|
71
|
+
parameters[0].instance_variables
|
72
|
+
#=>[:@parameter, :@category, :@description, :@validate, :@conversion, :@units, :@period]
|
69
73
|
|
70
|
-
|
71
|
-
|
74
|
+
parameters[0].parameter
|
75
|
+
#=> "TX"
|
72
76
|
|
73
77
|
|
74
|
-
|
75
|
-
|
76
|
-
|
78
|
+
# Define Time period of interest
|
79
|
+
starts = Time.utc(2010, 6, 28) # 2010 April 28th
|
80
|
+
ends = Time.utc(2010, 7, 01) # 2010 April 29th
|
77
81
|
|
78
|
-
|
79
|
-
|
82
|
+
# Get Data using previously retrieved objects
|
83
|
+
request = KNMI.get_data(station, parameters, starts, ends)
|
80
84
|
|
81
|
-
|
82
|
-
|
83
|
-
|
85
|
+
# Available Instance Variables
|
86
|
+
request.instance_variables
|
87
|
+
#=> [:@query, :@data]
|
84
88
|
|
85
|
-
|
86
|
-
|
89
|
+
request.query
|
90
|
+
#=>["stns=235", "vars=TX", "start=20100628", "end=20100629"]
|
87
91
|
|
88
|
-
|
89
|
-
|
92
|
+
request.data
|
93
|
+
#=>[{:STN=>"235", :YYYYMMDD=>"20100628", :TX=>"263"}, {:STN=>"235", :YYYYMMDD=>"20100629", :TX=>"225"}]
|
90
94
|
|
91
|
-
|
92
|
-
|
95
|
+
request.data[0]
|
96
|
+
#=>{:STN=>"235", :YYYYMMDD=>"20100628", :TX=>"263"}
|
93
97
|
|
94
98
|
|
95
|
-
|
96
|
-
|
99
|
+
# Convert data from storage format to operating format
|
100
|
+
data = KNMI.convert(parameters, request)
|
101
|
+
```
|
102
|
+
|
97
103
|
|
98
104
|
Available Parameters
|
99
105
|
--------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/knmi.gemspec
CHANGED
data/lib/knmi/calculations.rb
CHANGED
@@ -11,7 +11,7 @@ module KNMI
|
|
11
11
|
|
12
12
|
array.each_with_index do |a, index|
|
13
13
|
x[index] = {}
|
14
|
-
x[index][:
|
14
|
+
x[index][:STN] = a[:STN]
|
15
15
|
a.each_pair { |key,value| x[index].merge!( {key => converts_daily(key, value)} ) }
|
16
16
|
|
17
17
|
end
|
@@ -28,6 +28,7 @@ module KNMI
|
|
28
28
|
|
29
29
|
array.each_with_index do |a, index|
|
30
30
|
x[index] = {}
|
31
|
+
x[index][:STN] = a[:STN]
|
31
32
|
a.each_pair { |key,value| x[index].merge!( {key => converts_daily(key, value)} ) }
|
32
33
|
x[index][:Time] = x[index][:YYYYMMDD] + x[index][:HH]
|
33
34
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: knmi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- bullfight
|
@@ -157,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
157
|
requirements:
|
158
158
|
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
hash:
|
160
|
+
hash: -844904374873182274
|
161
161
|
segments:
|
162
162
|
- 0
|
163
163
|
version: "0"
|