earth 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
data/earth.gemspec CHANGED
@@ -5,7 +5,7 @@ require "earth/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "earth"
7
7
  s.version = Earth::VERSION
8
- s.date = "2011-03-04"
8
+ s.date = "2011-03-10"
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Seamus Abshere", "Derek Kastner", "Andy Rossmeissl"]
11
11
  s.email = %q{andy@rossmeissl.net}
@@ -112,7 +112,7 @@ AutomobileTypeFuelYearAge.class_eval do
112
112
  end
113
113
 
114
114
  process "Derive type fuel year name for association with AutomobileTypeFuelYear" do
115
- if ActiveRecord::Base.connection.adapter_name == 'sqlite'
115
+ if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
116
116
  update_all "type_fuel_year_name = type_name || ' ' || fuel_common_name || ' ' year"
117
117
  else
118
118
  update_all "type_fuel_year_name = CONCAT(type_name, ' ', fuel_common_name, ' ', year)"
@@ -1,7 +1,17 @@
1
1
  class Country < ActiveRecord::Base
2
2
  set_primary_key :iso_3166_code
3
3
 
4
- falls_back_on :flight_route_inefficiency_factor => 1.10 # for international flights - this is the larger (European) factor from Kettunen et al. (2005) http://www.atmseminar.org/seminarContent/seminar6/papers/p_055_MPM.pdf
4
+ falls_back_on :name => 'fallback',
5
+ :automobile_urbanity => lambda { Country.united_states.automobile_urbanity }, # for now assume US represents world
6
+ :automobile_fuel_efficiency => ((22.5 + 16.2) / 2.0).miles_per_gallon.to(:kilometres_per_litre), # average of passenger car fuel unknown and light goods vehicle fuel unknown - WRI Mobile Combustion calculation tool v2.0
7
+ :automobile_fuel_efficiency_units => 'kilometres_per_litre',
8
+ :automobile_city_speed => lambda { Country.united_states.automobile_city_speed }, # for now assume US represents world
9
+ :automobile_city_speed_units => lambda { Country.united_states.automobile_city_speed_units }, # for now assume US represents world
10
+ :automobile_highway_speed => lambda { Country.united_states.automobile_highway_speed }, # for now assume US represents world
11
+ :automobile_highway_speed_units => lambda { Country.united_states.automobile_highway_speed_units }, # for now assume US represents world
12
+ :automobile_trip_distance => lambda { Country.united_states.automobile_trip_distance }, # for now assume US represents world
13
+ :automobile_trip_distance_units => lambda { Country.united_states.automobile_trip_distance_units }, # for now assume US represents world
14
+ :flight_route_inefficiency_factor => lambda { Country.maximum(:flight_route_inefficiency_factor) } # default to the largest inefficiency factor
5
15
 
6
16
  data_miner do
7
17
  tap "Brighter Planet's sanitized countries list", Earth.taps_server
@@ -3,6 +3,15 @@ Country.class_eval do
3
3
  schema Earth.database_options do
4
4
  string 'iso_3166_code'
5
5
  string 'name'
6
+ float 'automobile_urbanity'
7
+ float 'automobile_fuel_efficiency'
8
+ string 'automobile_fuel_efficiency_units'
9
+ float 'automobile_city_speed'
10
+ string 'automobile_city_speed_units'
11
+ float 'automobile_highway_speed'
12
+ string 'automobile_highway_speed_units'
13
+ float 'automobile_trip_distance'
14
+ string 'automobile_trip_distance_units'
6
15
  float 'flight_route_inefficiency_factor'
7
16
  end
8
17
 
@@ -21,5 +30,62 @@ Country.class_eval do
21
30
  key 'iso_3166_code'
22
31
  store 'flight_route_inefficiency_factor'
23
32
  end
33
+
34
+ import "automobile trip fallbacks",
35
+ :url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdDdZRm1tNjY0c2dYNG00bXJ3TXRqUVE&gid=0&output=csv' do
36
+ key 'iso_3166_code'
37
+ store 'automobile_urbanity'
38
+ store 'automobile_city_speed', :units_field_name => 'automobile_city_speed_units'
39
+ store 'automobile_highway_speed', :units_field_name => 'automobile_highway_speed_units'
40
+ store 'automobile_trip_distance', :units_field_name => 'automobile_trip_distance_units'
41
+ end
42
+
43
+ # FIXME TODO eventually need to do this for all countries
44
+ process "Derive US average automobile fuel efficiency from AutomobileTypeFuelYear" do
45
+ # AutomobileTypeFuelYear.run_data_miner!
46
+
47
+ scope = AutomobileTypeFuelYear.where(:year => AutomobileTypeFuelYear.maximum(:year))
48
+ fe = scope.sum(:total_travel) / scope.sum(:fuel_consumption)
49
+ units = scope.first.total_travel_units + '_per_' + scope.first.fuel_consumption_units.singularize
50
+
51
+ connection.execute %{
52
+ UPDATE countries
53
+ SET automobile_fuel_efficiency = #{fe},
54
+ automobile_fuel_efficiency_units = '#{units}'
55
+ WHERE iso_3166_code = 'US'
56
+ }
57
+ end
58
+
59
+ process "Convert automobile city speed from miles per hour to kilometres per hour" do
60
+ conversion_factor = 1.miles.to(:kilometres)
61
+ connection.execute %{
62
+ UPDATE countries
63
+ SET automobile_city_speed = automobile_city_speed * #{conversion_factor},
64
+ automobile_city_speed_units = 'kilometres_per_hour'
65
+ WHERE automobile_city_speed_units = 'miles_per_hour'
66
+ }
67
+ end
68
+
69
+ process "Convert automobile highway speed from miles per hour to kilometres per hour" do
70
+ conversion_factor = 1.miles.to(:kilometres)
71
+ connection.execute %{
72
+ UPDATE countries
73
+ SET automobile_highway_speed = automobile_highway_speed * #{conversion_factor},
74
+ automobile_highway_speed_units = 'kilometres_per_hour'
75
+ WHERE automobile_highway_speed_units = 'miles_per_hour'
76
+ }
77
+ end
78
+
79
+ process "Convert automobile trip distance from miles to kilometres" do
80
+ conversion_factor = 1.miles.to(:kilometres)
81
+ connection.execute %{
82
+ UPDATE countries
83
+ SET automobile_trip_distance = automobile_trip_distance * #{conversion_factor},
84
+ automobile_trip_distance_units = 'kilometres'
85
+ WHERE automobile_trip_distance_units = 'miles'
86
+ }
87
+ end
88
+
89
+ # FIXME TODO verify this
24
90
  end
25
91
  end
@@ -27,10 +27,12 @@ ZipCode.class_eval do
27
27
  store 'longitude'
28
28
  end
29
29
 
30
- import 'a Brighter Planet-created list of zipcode eGRID Subregions',
31
- :url => 'http://static.brighterplanet.com/science/data/electricity/egrid/models_export/zip_subregions.csv' do
32
- key 'name', :field_name => 'zip', :sprintf => '%05d'
33
- store 'egrid_subregion_abbreviation', :field_name => 'primary_subregion'
30
+ import 'a list of zipcode states and eGRID Subregions from the US EPA',
31
+ :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/Power_Profiler_Zipcode_Tool_v3-0.xls',
32
+ :sheet => 'Zip-subregion' do
33
+ key 'name', :field_name => 'ZIP (character)'
34
+ store 'state_postal_abbreviation', :field_name => 'State'
35
+ store 'egrid_subregion_abbreviation', :field_name => 'Primary eGRID Subregion'
34
36
  end
35
37
 
36
38
  import 'a Brighter Planet-created list of zipcode Climate Divisions',
@@ -38,5 +40,7 @@ ZipCode.class_eval do
38
40
  key 'name', :field_name => 'zip_code_name', :sprintf => '%05d'
39
41
  store 'climate_division_name'
40
42
  end
43
+
44
+ # FIXME TODO verify this
41
45
  end
42
46
  end
data/lib/earth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Earth
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 6
9
- version: 0.4.6
8
+ - 7
9
+ version: 0.4.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seamus Abshere
@@ -16,11 +16,12 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-04 00:00:00 -05:00
19
+ date: 2011-03-10 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: cohort_scope
24
+ prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
@@ -32,10 +33,10 @@ dependencies:
32
33
  - 5
33
34
  version: 0.1.5
34
35
  type: :runtime
35
- prerelease: false
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: data_miner
39
+ prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
@@ -47,10 +48,10 @@ dependencies:
47
48
  - 4
48
49
  version: 1.1.4
49
50
  type: :runtime
50
- prerelease: false
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
53
  name: falls_back_on
54
+ prerelease: false
54
55
  requirement: &id003 !ruby/object:Gem::Requirement
55
56
  none: false
56
57
  requirements:
@@ -62,10 +63,10 @@ dependencies:
62
63
  - 3
63
64
  version: 0.1.3
64
65
  type: :runtime
65
- prerelease: false
66
66
  version_requirements: *id003
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: geokit-rails
69
+ prerelease: false
69
70
  requirement: &id004 !ruby/object:Gem::Requirement
70
71
  none: false
71
72
  requirements:
@@ -75,10 +76,10 @@ dependencies:
75
76
  - 0
76
77
  version: "0"
77
78
  type: :runtime
78
- prerelease: false
79
79
  version_requirements: *id004
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: loose_tight_dictionary
82
+ prerelease: false
82
83
  requirement: &id005 !ruby/object:Gem::Requirement
83
84
  none: false
84
85
  requirements:
@@ -90,10 +91,10 @@ dependencies:
90
91
  - 10
91
92
  version: 0.0.10
92
93
  type: :runtime
93
- prerelease: false
94
94
  version_requirements: *id005
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: weighted_average
97
+ prerelease: false
97
98
  requirement: &id006 !ruby/object:Gem::Requirement
98
99
  none: false
99
100
  requirements:
@@ -105,10 +106,10 @@ dependencies:
105
106
  - 6
106
107
  version: 0.0.6
107
108
  type: :runtime
108
- prerelease: false
109
109
  version_requirements: *id006
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: bundler
112
+ prerelease: false
112
113
  requirement: &id007 !ruby/object:Gem::Requirement
113
114
  none: false
114
115
  requirements:
@@ -118,10 +119,10 @@ dependencies:
118
119
  - 0
119
120
  version: "0"
120
121
  type: :development
121
- prerelease: false
122
122
  version_requirements: *id007
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: bueller
125
+ prerelease: false
125
126
  requirement: &id008 !ruby/object:Gem::Requirement
126
127
  none: false
127
128
  requirements:
@@ -131,10 +132,10 @@ dependencies:
131
132
  - 0
132
133
  version: "0"
133
134
  type: :development
134
- prerelease: false
135
135
  version_requirements: *id008
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: cucumber
138
+ prerelease: false
138
139
  requirement: &id009 !ruby/object:Gem::Requirement
139
140
  none: false
140
141
  requirements:
@@ -144,10 +145,10 @@ dependencies:
144
145
  - 0
145
146
  version: "0"
146
147
  type: :development
147
- prerelease: false
148
148
  version_requirements: *id009
149
149
  - !ruby/object:Gem::Dependency
150
150
  name: rake
151
+ prerelease: false
151
152
  requirement: &id010 !ruby/object:Gem::Requirement
152
153
  none: false
153
154
  requirements:
@@ -157,10 +158,10 @@ dependencies:
157
158
  - 0
158
159
  version: "0"
159
160
  type: :development
160
- prerelease: false
161
161
  version_requirements: *id010
162
162
  - !ruby/object:Gem::Dependency
163
163
  name: rdoc
164
+ prerelease: false
164
165
  requirement: &id011 !ruby/object:Gem::Requirement
165
166
  none: false
166
167
  requirements:
@@ -170,10 +171,10 @@ dependencies:
170
171
  - 0
171
172
  version: "0"
172
173
  type: :development
173
- prerelease: false
174
174
  version_requirements: *id011
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: rdoc
177
+ prerelease: false
177
178
  requirement: &id012 !ruby/object:Gem::Requirement
178
179
  none: false
179
180
  requirements:
@@ -183,10 +184,10 @@ dependencies:
183
184
  - 0
184
185
  version: "0"
185
186
  type: :development
186
- prerelease: false
187
187
  version_requirements: *id012
188
188
  - !ruby/object:Gem::Dependency
189
189
  name: rspec
190
+ prerelease: false
190
191
  requirement: &id013 !ruby/object:Gem::Requirement
191
192
  none: false
192
193
  requirements:
@@ -196,10 +197,10 @@ dependencies:
196
197
  - 0
197
198
  version: "0"
198
199
  type: :development
199
- prerelease: false
200
200
  version_requirements: *id013
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: sqlite3-ruby
203
+ prerelease: false
203
204
  requirement: &id014 !ruby/object:Gem::Requirement
204
205
  none: false
205
206
  requirements:
@@ -209,7 +210,6 @@ dependencies:
209
210
  - 0
210
211
  version: "0"
211
212
  type: :development
212
- prerelease: false
213
213
  version_requirements: *id014
214
214
  description: An earth-simulation environment with ActiveRecord models and data
215
215
  email: andy@rossmeissl.net
@@ -561,7 +561,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
561
561
  requirements:
562
562
  - - ">="
563
563
  - !ruby/object:Gem::Version
564
- hash: 1235371352071113730
565
564
  segments:
566
565
  - 0
567
566
  version: "0"
@@ -570,7 +569,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
570
569
  requirements:
571
570
  - - ">="
572
571
  - !ruby/object:Gem::Version
573
- hash: 1235371352071113730
574
572
  segments:
575
573
  - 0
576
574
  version: "0"