knmi 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,77 +23,83 @@ Installation
23
23
  Example Usage
24
24
  -------------
25
25
 
26
- # Quick Script
26
+ Launch console e.g. irb at the command line
27
27
 
28
- require 'knmi'
28
+ ### Quick Script
29
29
 
30
- station = KNMI.station_by_id(235)
31
- parameter = KNMI.parameters(period = "daily", params = nil, categories = ["TEMP", "WIND"])
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
- # Elaborated Script
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
- require 'knmi'
42
+ ```Ruby
43
+ require 'knmi'
40
44
 
41
- # Get station object by station ID
42
- station = KNMI.station_by_id(235)
45
+ # Get station object by station ID
46
+ station = KNMI.station_by_id(235)
43
47
 
44
- station
45
- #=> #<KNMI::Station:0x0000010133c938> # A struct object
48
+ station
49
+ #=> #<KNMI::Station:0x0000010133c938> # A struct object
46
50
 
47
- # Available Instance Variables
48
- station.instance_variables
49
- #=> [:@id, :@name, :@elevation, :@photo, :@map, :@web, :@instrumentation, :@coordinates]
50
- station.id
51
- #=> 235
52
- station.name
53
- #=>"De kooy"
54
- station.coordinates
55
- #=> 52.924,4.785
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
- # Get parameter object at the time interval you wish to use "hourly" or "daily"
59
- # Params can be a single term or an array of terms such as "TG" or ["TG", TX]
60
- # Categories can be a single term or an array of terms such as "WIND" or ["WIND", "TEMP"]
61
- parameters = KNMI.parameters(period = "daily", params = nil, categories = ["TEMP", "WIND"])
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
- parameters # returns an array of parameter objects
64
- #=> [#<KNMI::Parameters:0x000001011387e0 @parameter="TX", @category="TEMP", @description="Maximum Temperature", @validate="n.integer?", @conversion="n / 10", @units="C", @period="daily">]
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
- # Available Instance Variables
67
- parameters[0].instance_variables
68
- #=>[:@parameter, :@category, :@description, :@validate, :@conversion, :@units, :@period]
70
+ # Available Instance Variables
71
+ parameters[0].instance_variables
72
+ #=>[:@parameter, :@category, :@description, :@validate, :@conversion, :@units, :@period]
69
73
 
70
- parameters[0].parameter
71
- #=> "TX"
74
+ parameters[0].parameter
75
+ #=> "TX"
72
76
 
73
77
 
74
- # Define Time period of interest
75
- starts = Time.utc(2010, 6, 28) # 2010 April 28th
76
- ends = Time.utc(2010, 7, 01) # 2010 April 29th
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
- # Get Data using previously retrieved objects
79
- request = KNMI.get_data(station, parameters, starts, ends)
82
+ # Get Data using previously retrieved objects
83
+ request = KNMI.get_data(station, parameters, starts, ends)
80
84
 
81
- # Available Instance Variables
82
- request.instance_variables
83
- #=> [:@query, :@data]
85
+ # Available Instance Variables
86
+ request.instance_variables
87
+ #=> [:@query, :@data]
84
88
 
85
- request.query
86
- #=>["stns=235", "vars=TX", "start=20100628", "end=20100629"]
89
+ request.query
90
+ #=>["stns=235", "vars=TX", "start=20100628", "end=20100629"]
87
91
 
88
- request.data
89
- #=>[{:STN=>"235", :YYYYMMDD=>"20100628", :TX=>"263"}, {:STN=>"235", :YYYYMMDD=>"20100629", :TX=>"225"}]
92
+ request.data
93
+ #=>[{:STN=>"235", :YYYYMMDD=>"20100628", :TX=>"263"}, {:STN=>"235", :YYYYMMDD=>"20100629", :TX=>"225"}]
90
94
 
91
- request.data[0]
92
- #=>{:STN=>"235", :YYYYMMDD=>"20100628", :TX=>"263"}
95
+ request.data[0]
96
+ #=>{:STN=>"235", :YYYYMMDD=>"20100628", :TX=>"263"}
93
97
 
94
98
 
95
- # Convert data from storage format to operating format
96
- data = KNMI.convert(parameters, request)
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.0
1
+ 0.3.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knmi}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["bullfight"]
@@ -11,7 +11,7 @@ module KNMI
11
11
 
12
12
  array.each_with_index do |a, index|
13
13
  x[index] = {}
14
- x[index][:stn] = a
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.0
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: 3402158507789262008
160
+ hash: -844904374873182274
161
161
  segments:
162
162
  - 0
163
163
  version: "0"