earth 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/TODO +2 -0
- data/bin/earth_tester.rb +62 -9
- data/earth.gemspec +7 -4
- data/lib/earth.rb +18 -17
- data/lib/earth/air.rb +2 -0
- data/lib/earth/air/aircraft.rb +76 -19
- data/lib/earth/air/aircraft/data_miner.rb +1 -63
- data/lib/earth/air/aircraft_class.rb +48 -12
- data/lib/earth/air/aircraft_class/data_miner.rb +3 -46
- data/lib/earth/air/aircraft_fuel_use_equation.rb +11 -13
- data/lib/earth/air/aircraft_instance.rb +9 -0
- data/lib/earth/air/aircraft_instance_seat_class.rb +12 -0
- data/lib/earth/air/airline.rb +6 -8
- data/lib/earth/air/airline/data_miner.rb +3 -3
- data/lib/earth/air/airport.rb +8 -10
- data/lib/earth/air/airport/data_miner.rb +1 -1
- data/lib/earth/air/bts_aircraft.rb +3 -5
- data/lib/earth/air/flight_distance_class.rb +4 -6
- data/lib/earth/air/flight_seat_class.rb +5 -7
- data/lib/earth/air/flight_segment.rb +58 -42
- data/lib/earth/air/flight_segment/data_miner.rb +11 -26
- data/lib/earth/automobile.rb +1 -0
- data/lib/earth/automobile/automobile_fuel.rb +78 -25
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +5 -72
- data/lib/earth/automobile/automobile_make.rb +14 -6
- data/lib/earth/automobile/automobile_make/data_miner.rb +20 -35
- data/lib/earth/automobile/automobile_make_fleet_year.rb +39 -10
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +0 -29
- data/lib/earth/automobile/automobile_make_model.rb +30 -9
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +11 -26
- data/lib/earth/automobile/automobile_make_model_year.rb +41 -12
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +14 -34
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +56 -38
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +15 -61
- data/lib/earth/automobile/automobile_make_year.rb +15 -8
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +17 -51
- data/lib/earth/automobile/automobile_size_class.rb +78 -14
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +0 -66
- data/lib/earth/automobile/automobile_size_class_year.rb +38 -10
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -30
- data/lib/earth/automobile/automobile_type_fuel_age.rb +60 -11
- data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +10 -65
- data/lib/earth/automobile/automobile_type_fuel_control.rb +41 -10
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +0 -33
- data/lib/earth/automobile/automobile_type_fuel_year.rb +60 -15
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -52
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +64 -12
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +1 -59
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +31 -10
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +2 -32
- data/lib/earth/automobile/automobile_type_year.rb +51 -10
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -43
- data/lib/earth/automobile/data_miner.rb +1 -0
- data/lib/earth/bus/bus_class.rb +108 -28
- data/lib/earth/bus/bus_class/data_miner.rb +0 -88
- data/lib/earth/bus/bus_fuel.rb +83 -15
- data/lib/earth/bus/bus_fuel/data_miner.rb +0 -76
- data/lib/earth/bus/bus_fuel_control.rb +8 -10
- data/lib/earth/bus/bus_fuel_year_control.rb +7 -9
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -5
- data/lib/earth/computation/computation_carrier.rb +11 -5
- data/lib/earth/computation/computation_carrier/data_miner.rb +0 -7
- data/lib/earth/computation/computation_carrier_instance_class.rb +25 -8
- data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +0 -18
- data/lib/earth/computation/computation_carrier_region.rb +5 -7
- data/lib/earth/diet/diet_class.rb +14 -16
- data/lib/earth/diet/food_group.rb +7 -9
- data/lib/earth/fuel/fuel.rb +14 -16
- data/lib/earth/fuel/fuel/data_miner.rb +7 -3
- data/lib/earth/fuel/fuel_price.rb +4 -6
- data/lib/earth/fuel/fuel_type.rb +12 -14
- data/lib/earth/fuel/fuel_year.rb +57 -16
- data/lib/earth/fuel/fuel_year/data_miner.rb +0 -43
- data/lib/earth/fuel/greenhouse_gas.rb +46 -9
- data/lib/earth/fuel/greenhouse_gas/data_miner.rb +0 -38
- data/lib/earth/hospitality/lodging_class.rb +10 -12
- data/lib/earth/industry/industry.rb +3 -5
- data/lib/earth/industry/industry_product.rb +6 -8
- data/lib/earth/industry/industry_product_line.rb +5 -7
- data/lib/earth/industry/industry_sector.rb +5 -7
- data/lib/earth/industry/merchant.rb +4 -6
- data/lib/earth/industry/merchant_category.rb +3 -5
- data/lib/earth/industry/merchant_category_industry.rb +5 -7
- data/lib/earth/industry/product_line.rb +5 -7
- data/lib/earth/industry/product_line_industry_product.rb +5 -7
- data/lib/earth/industry/sector.rb +5 -7
- data/lib/earth/locality/census_division.rb +21 -23
- data/lib/earth/locality/census_region.rb +3 -5
- data/lib/earth/locality/climate_division.rb +5 -7
- data/lib/earth/locality/country.rb +13 -15
- data/lib/earth/locality/egrid_region.rb +14 -5
- data/lib/earth/locality/egrid_region/data_miner.rb +0 -10
- data/lib/earth/locality/egrid_subregion.rb +71 -18
- data/lib/earth/locality/egrid_subregion/data_miner.rb +0 -59
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +6 -8
- data/lib/earth/locality/state.rb +6 -8
- data/lib/earth/locality/urbanity.rb +2 -4
- data/lib/earth/locality/urbanity/data_miner.rb +7 -3
- data/lib/earth/locality/zip_code.rb +8 -10
- data/lib/earth/pet/breed.rb +5 -7
- data/lib/earth/pet/breed_gender.rb +6 -8
- data/lib/earth/pet/gender.rb +2 -4
- data/lib/earth/pet/species.rb +15 -17
- data/lib/earth/rail/rail_class.rb +64 -14
- data/lib/earth/rail/rail_class/data_miner.rb +0 -51
- data/lib/earth/residence/air_conditioner_use.rb +4 -6
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +7 -3
- data/lib/earth/residence/clothes_machine_use.rb +4 -6
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +11 -9
- data/lib/earth/residence/dishwasher_use.rb +4 -6
- data/lib/earth/residence/dishwasher_use/data_miner.rb +11 -9
- data/lib/earth/residence/residence_appliance.rb +4 -6
- data/lib/earth/residence/residence_class.rb +2 -4
- data/lib/earth/residence/residence_class/data_miner.rb +7 -3
- data/lib/earth/residence/residence_fuel_price.rb +12 -14
- data/lib/earth/residence/residence_fuel_price/data_miner.rb +7 -0
- data/lib/earth/residence/residence_fuel_type.rb +6 -8
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +91 -93
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +9 -8
- data/lib/earth/shipping/carrier.rb +57 -10
- data/lib/earth/shipping/carrier/data_miner.rb +0 -48
- data/lib/earth/shipping/carrier_mode.rb +41 -10
- data/lib/earth/shipping/carrier_mode/data_miner.rb +0 -33
- data/lib/earth/shipping/shipment_mode.rb +30 -7
- data/lib/earth/shipping/shipment_mode/data_miner.rb +0 -23
- data/lib/earth/utils.rb +45 -0
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/aircraft_spec.rb +1 -1
- data/vendor/clean_find_in_batches/init.rb +35 -0
- metadata +74 -47
@@ -17,93 +17,5 @@ BusClass.class_eval do
|
|
17
17
|
store 'air_conditioning_emission_factor', :units_field_name => 'air_conditioning_emission_factor_units'
|
18
18
|
store 'alternative_fuels_intensity', :units_field_name => 'alternative_fuels_intensity_units'
|
19
19
|
end
|
20
|
-
|
21
|
-
verify "Some attributes should be greater than zero" do
|
22
|
-
BusClass.all.each do |bus_class|
|
23
|
-
%w{ distance passengers speed diesel_intensity air_conditioning_emission_factor }.each do |attribute|
|
24
|
-
value = bus_class.send(:"#{attribute}")
|
25
|
-
unless value > 0
|
26
|
-
puts "Invalid #{attribute.humanize.downcase} for BusClass #{bus_class.name}: #{value} (should be > 0)"
|
27
|
-
fail
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
verify "Some attributes should be zero or more" do
|
34
|
-
BusClass.all.each do |bus_class|
|
35
|
-
%w{ gasoline_intensity cng_intensity lng_intensity lpg_intensity methanol_intensity biodiesel_intensity electricity_intensity alternative_fuels_intensity }.each do |attribute|
|
36
|
-
value = bus_class.send(:"#{attribute}")
|
37
|
-
unless value >= 0
|
38
|
-
puts "Invalid #{attribute.humanize.downcase} for BusClass #{bus_class.name}: #{value} (should be >= 0)"
|
39
|
-
fail
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
verify "Units should be correct" do
|
46
|
-
BusClass.all.each do |bus_class|
|
47
|
-
[["distance_units", "kilometres"],
|
48
|
-
["speed_units", "kilometres_per_hour"],
|
49
|
-
["diesel_intensity_units", "litres_per_kilometre"],
|
50
|
-
["gasoline_intensity_units", "litres_per_kilometre"],
|
51
|
-
["cng_intensity_units", "litres_per_kilometre"],
|
52
|
-
["lng_intensity_units", "litres_per_kilometre"],
|
53
|
-
["lpg_intensity_units", "litres_per_kilometre"],
|
54
|
-
["methanol_intensity_units", "litres_per_kilometre"],
|
55
|
-
["biodiesel_intensity_units", "litres_per_kilometre"],
|
56
|
-
["electricity_intensity_units", "kilowatt_hours_per_kilometre"],
|
57
|
-
["air_conditioning_emission_factor_units", "kilograms_co2e_per_kilometre"],
|
58
|
-
["alternative_fuels_intensity_units", "litres_per_kilometre"]].each do |pair|
|
59
|
-
attribute = pair[0]
|
60
|
-
proper_units = pair[1]
|
61
|
-
units = bus_class.send(:"#{attribute}")
|
62
|
-
unless units == proper_units
|
63
|
-
puts "Invalid #{attribute.humanize.downcase} for BusClass #{bus_class.name}: #{units} (should be #{proper_units})"
|
64
|
-
fail
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
verify "Fallbacks should satisfy same constraints as data" do
|
71
|
-
%w{ distance passengers speed diesel_intensity air_conditioning_emission_factor }.each do |attribute|
|
72
|
-
value = BusClass.fallback.send(:"#{attribute}")
|
73
|
-
unless value > 0
|
74
|
-
puts "Invalid #{attribute.humanize.downcase} for fallback BusClass: #{value} (should be > 0)"
|
75
|
-
fail
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
%w{ gasoline_intensity cng_intensity lng_intensity lpg_intensity methanol_intensity biodiesel_intensity electricity_intensity alternative_fuels_intensity }.each do |attribute|
|
80
|
-
value = BusClass.fallback.send(:"#{attribute}")
|
81
|
-
unless value >= 0
|
82
|
-
puts "Invalid #{attribute.humanize.downcase} for fallback BusClass: #{value} (should be >= 0)"
|
83
|
-
fail
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
[["distance_units", "kilometres"],
|
88
|
-
["speed_units", "kilometres_per_hour"],
|
89
|
-
["diesel_intensity_units", "litres_per_kilometre"],
|
90
|
-
["gasoline_intensity_units", "litres_per_kilometre"],
|
91
|
-
["cng_intensity_units", "litres_per_kilometre"],
|
92
|
-
["lng_intensity_units", "litres_per_kilometre"],
|
93
|
-
["lpg_intensity_units", "litres_per_kilometre"],
|
94
|
-
["methanol_intensity_units", "litres_per_kilometre"],
|
95
|
-
["biodiesel_intensity_units", "litres_per_kilometre"],
|
96
|
-
["electricity_intensity_units", "kilowatt_hours_per_kilometre"],
|
97
|
-
["air_conditioning_emission_factor_units", "kilograms_co2e_per_kilometre"],
|
98
|
-
["alternative_fuels_intensity_units", "litres_per_kilometre"]].each do |pair|
|
99
|
-
attribute = pair[0]
|
100
|
-
proper_units = pair[1]
|
101
|
-
units = BusClass.fallback.send(:"#{attribute}")
|
102
|
-
unless units == proper_units
|
103
|
-
puts "Invalid #{attribute.humanize.downcase} for fallback BusClass: #{units} (should be #{proper_units})"
|
104
|
-
fail
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
20
|
end
|
109
21
|
end
|
data/lib/earth/bus/bus_fuel.rb
CHANGED
@@ -8,18 +8,86 @@ class BusFuel < ActiveRecord::Base
|
|
8
8
|
fuel_year_controls.where(:year => fuel_year_controls.maximum('year'))
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
11
|
+
col :name
|
12
|
+
col :fuel_name
|
13
|
+
col :energy_content, :type => :float
|
14
|
+
col :energy_content_units
|
15
|
+
col :co2_emission_factor, :type => :float
|
16
|
+
col :co2_emission_factor_units
|
17
|
+
col :co2_biogenic_emission_factor, :type => :float
|
18
|
+
col :co2_biogenic_emission_factor_units
|
19
|
+
col :ch4_emission_factor, :type => :float
|
20
|
+
col :ch4_emission_factor_units
|
21
|
+
col :n2o_emission_factor, :type => :float
|
22
|
+
col :n2o_emission_factor_units
|
23
|
+
|
24
|
+
# # FIXME TODO verify fuel_name appears in fuels
|
25
|
+
# verify "Fuel name should never be missing" do
|
26
|
+
# BusFuel.all.each do |fuel|
|
27
|
+
# value = fuel.send(:fuel_name)
|
28
|
+
# unless value.present?
|
29
|
+
# raise "Missing fuel name for BusFuel #{fuel.name}"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# verify "Energy content should be greater than zero if present" do
|
35
|
+
# BusFuel.all.each do |fuel|
|
36
|
+
# value = fuel.send(:energy_content)
|
37
|
+
# if value.present?
|
38
|
+
# unless value > 0
|
39
|
+
# raise "Invalid energy content for BusFuel #{fuel.name}: #{value} (should be > 0)"
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# %w{ co2_emission_factor co2_biogenic_emission_factor }.each do |attribute|
|
46
|
+
# verify "#{attribute.humanize} should be 0 or more" do
|
47
|
+
# BusFuel.all.each do |fuel|
|
48
|
+
# value = fuel.send(attribute)
|
49
|
+
# unless value >= 0
|
50
|
+
# raise "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{value} (should be 0 or more)"
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# %w{ ch4_emission_factor n2o_emission_factor }.each do |attribute|
|
57
|
+
# verify "#{attribute.humanize} should be > 0" do
|
58
|
+
# BusFuel.all.each do |fuel|
|
59
|
+
# value = fuel.send(attribute)
|
60
|
+
# unless value > 0
|
61
|
+
# raise "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{value} (should be > 0)"
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# verify "Energy content units should be megajoules per litre if present" do
|
68
|
+
# BusFuel.all.each do |fuel|
|
69
|
+
# units = fuel.send(:energy_content_units)
|
70
|
+
# if units.present?
|
71
|
+
# unless units == "megajoules_per_litre"
|
72
|
+
# raise "Invalid energy content units for BusFuel #{fuel.name}: #{units} (should be megajoules_per_litre)"
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# [["co2_emission_factor_units", "kilograms_per_litre"],
|
79
|
+
# ["co2_biogenic_emission_factor_units", "kilograms_per_litre"],
|
80
|
+
# ["ch4_emission_factor_units", "kilograms_co2e_per_kilometre"],
|
81
|
+
# ["n2o_emission_factor_units", "kilograms_co2e_per_kilometre"]].each do |pair|
|
82
|
+
# attribute = pair[0]
|
83
|
+
# proper_units = pair[1]
|
84
|
+
# verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
|
85
|
+
# BusFuel.all.each do |fuel|
|
86
|
+
# units = fuel.send(:"#{attribute}")
|
87
|
+
# unless units == proper_units
|
88
|
+
# raise "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{units} (should be #{proper_units})"
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
end
|
@@ -109,81 +109,5 @@ BusFuel.class_eval do
|
|
109
109
|
bus_fuel.save!
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
113
|
-
# FIXME TODO verify fuel_name appears in fuels
|
114
|
-
verify "Fuel name should never be missing" do
|
115
|
-
BusFuel.all.each do |fuel|
|
116
|
-
value = fuel.send(:fuel_name)
|
117
|
-
unless value.present?
|
118
|
-
puts "Missing fuel name for BusFuel #{fuel.name}"
|
119
|
-
fail
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
verify "Energy content should be greater than zero if present" do
|
125
|
-
BusFuel.all.each do |fuel|
|
126
|
-
value = fuel.send(:energy_content)
|
127
|
-
if value.present?
|
128
|
-
unless value > 0
|
129
|
-
puts "Invalid energy content for BusFuel #{fuel.name}: #{value} (should be > 0)"
|
130
|
-
fail
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
%w{ co2_emission_factor co2_biogenic_emission_factor }.each do |attribute|
|
137
|
-
verify "#{attribute.humanize} should be 0 or more" do
|
138
|
-
BusFuel.all.each do |fuel|
|
139
|
-
value = fuel.send(attribute)
|
140
|
-
unless value >= 0
|
141
|
-
puts "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{value} (should be 0 or more)"
|
142
|
-
fail
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
%w{ ch4_emission_factor n2o_emission_factor }.each do |attribute|
|
149
|
-
verify "#{attribute.humanize} should be > 0" do
|
150
|
-
BusFuel.all.each do |fuel|
|
151
|
-
value = fuel.send(attribute)
|
152
|
-
unless value > 0
|
153
|
-
puts "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{value} (should be > 0)"
|
154
|
-
fail
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
verify "Energy content units should be megajoules per litre if present" do
|
161
|
-
BusFuel.all.each do |fuel|
|
162
|
-
units = fuel.send(:energy_content_units)
|
163
|
-
if units.present?
|
164
|
-
unless units == "megajoules_per_litre"
|
165
|
-
puts "Invalid energy content units for BusFuel #{fuel.name}: #{units} (should be megajoules_per_litre)"
|
166
|
-
fail
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
[["co2_emission_factor_units", "kilograms_per_litre"],
|
173
|
-
["co2_biogenic_emission_factor_units", "kilograms_per_litre"],
|
174
|
-
["ch4_emission_factor_units", "kilograms_co2e_per_kilometre"],
|
175
|
-
["n2o_emission_factor_units", "kilograms_co2e_per_kilometre"]].each do |pair|
|
176
|
-
attribute = pair[0]
|
177
|
-
proper_units = pair[1]
|
178
|
-
verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
|
179
|
-
BusFuel.all.each do |fuel|
|
180
|
-
units = fuel.send(:"#{attribute}")
|
181
|
-
unless units == proper_units
|
182
|
-
puts "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{units} (should be #{proper_units})"
|
183
|
-
fail
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
112
|
end
|
189
113
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
class BusFuelControl < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
3
|
+
col :name
|
4
|
+
col :bus_fuel_name
|
5
|
+
col :control
|
6
|
+
col :ch4_emission_factor, :type => :float
|
7
|
+
col :ch4_emission_factor_units
|
8
|
+
col :n2o_emission_factor, :type => :float
|
9
|
+
col :n2o_emission_factor_units
|
10
|
+
end
|
@@ -3,12 +3,10 @@ class BusFuelYearControl < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :fuel_control, :class_name => 'BusFuelControl', :foreign_key => 'bus_fuel_control_name'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
6
|
+
col :name
|
7
|
+
col :bus_fuel_name
|
8
|
+
col :year, :type => :integer
|
9
|
+
col :control
|
10
|
+
col :bus_fuel_control_name
|
11
|
+
col :total_travel_percent, :type => :float
|
12
|
+
end
|
@@ -14,11 +14,7 @@ BusFuelYearControl.class_eval do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
process "Derive bus fuel control name for association with BusFuelControl" do
|
17
|
-
|
18
|
-
update_all "bus_fuel_control_name = bus_fuel_name || ' ' || control"
|
19
|
-
else
|
20
|
-
update_all "bus_fuel_control_name = CONCAT(bus_fuel_name, ' ', control)"
|
21
|
-
end
|
17
|
+
update_all "bus_fuel_control_name = bus_fuel_name || ' ' || control"
|
22
18
|
end
|
23
19
|
|
24
20
|
# FIXME TODO verify that for any year the percentages sum to 1
|
@@ -4,8 +4,14 @@ class ComputationCarrier < ActiveRecord::Base
|
|
4
4
|
falls_back_on :name => 'fallback',
|
5
5
|
:power_usage_effectiveness => lambda { ComputationCarrier.maximum('power_usage_effectiveness') }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
col :name
|
8
|
+
col :power_usage_effectiveness, :type => :float
|
9
|
+
|
10
|
+
# verify "Power usage effectiveness should be one or more" do
|
11
|
+
# ComputationCarrier.all.each do |carrier|
|
12
|
+
# unless carrier.power_usage_effectiveness >= 1.0
|
13
|
+
# raise "Invalid power usage effectiveness for ComputationCarrier #{carrier.name}: #{carrier.power_usage_effectiveness} (should be >= 1.0)"
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
end
|
@@ -6,12 +6,5 @@ ComputationCarrier.class_eval do
|
|
6
6
|
store 'power_usage_effectiveness'
|
7
7
|
end
|
8
8
|
|
9
|
-
verify "Power usage effectiveness should be one or more" do
|
10
|
-
ComputationCarrier.all.each do |carrier|
|
11
|
-
unless carrier.power_usage_effectiveness >= 1.0
|
12
|
-
raise "Invalid power usage effectiveness for ComputationCarrier #{carrier.name}: #{carrier.power_usage_effectiveness} (should be >= 1.0)"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
9
|
end
|
17
10
|
end
|
@@ -7,11 +7,28 @@ class ComputationCarrierInstanceClass < ActiveRecord::Base
|
|
7
7
|
:electricity_intensity => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity },
|
8
8
|
:electricity_intensity_units => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity_units }
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
col :name
|
11
|
+
col :computation_carrier_name
|
12
|
+
col :instance_class
|
13
|
+
col :electricity_intensity, :type => :float
|
14
|
+
col :electricity_intensity_units
|
15
|
+
|
16
|
+
# FIXME TODO verify that computation carrier name appears in computation_carriers
|
17
|
+
|
18
|
+
# verify "Electricity intensity should be more than zero" do
|
19
|
+
# ComputationCarrierInstanceClass.all.each do |instance_class|
|
20
|
+
# unless instance_class.electricity_intensity > 0
|
21
|
+
# raise "Invalid electricity intensity for ComputationCarrierInstanceClass #{instance_class.name}: #{instance_class.electricity_intensity} (should be > 0)"
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# verify "Electricity intensity units should be kilowatts" do
|
27
|
+
# ComputationCarrierInstanceClass.all.each do |instance_class|
|
28
|
+
# unless instance_class.electricity_intensity_units == 'kilowatts'
|
29
|
+
# raise "Invalid electricity intensity units for ComputationCarrierInstanceClass #{instance_class.name}: #{instance_class.electricity_intensity_units} (should be kilowatts)"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
|
34
|
+
end
|
@@ -7,23 +7,5 @@ ComputationCarrierInstanceClass.class_eval do
|
|
7
7
|
store 'instance_class'
|
8
8
|
store 'electricity_intensity', :units_field_name => 'electricity_intensity_units'
|
9
9
|
end
|
10
|
-
|
11
|
-
# FIXME TODO verify that computation carrier name appears in computation_carriers
|
12
|
-
|
13
|
-
verify "Electricity intensity should be more than zero" do
|
14
|
-
ComputationCarrierInstanceClass.all.each do |instance_class|
|
15
|
-
unless instance_class.electricity_intensity > 0
|
16
|
-
raise "Invalid electricity intensity for ComputationCarrierInstanceClass #{instance_class.name}: #{instance_class.electricity_intensity} (should be > 0)"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
verify "Electricity intensity units should be kilowatts" do
|
22
|
-
ComputationCarrierInstanceClass.all.each do |instance_class|
|
23
|
-
unless instance_class.electricity_intensity_units == 'kilowatts'
|
24
|
-
raise "Invalid electricity intensity units for ComputationCarrierInstanceClass #{instance_class.name}: #{instance_class.electricity_intensity_units} (should be kilowatts)"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
10
|
end
|
29
11
|
end
|
@@ -3,10 +3,8 @@ class ComputationCarrierRegion < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
6
|
+
col :name
|
7
|
+
col :computation_carrier_name
|
8
|
+
col :region
|
9
|
+
col :egrid_subregion_abbreviation
|
10
|
+
end
|
@@ -7,19 +7,17 @@ class DietClass < ActiveRecord::Base
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
10
|
+
col :name
|
11
|
+
col :intensity, :type => :float
|
12
|
+
col :intensity_units
|
13
|
+
col :red_meat_share, :type => :float
|
14
|
+
col :poultry_share, :type => :float
|
15
|
+
col :fish_share, :type => :float
|
16
|
+
col :eggs_share, :type => :float
|
17
|
+
col :nuts_share, :type => :float
|
18
|
+
col :dairy_share, :type => :float
|
19
|
+
col :cereals_and_grains_share, :type => :float
|
20
|
+
col :fruit_share, :type => :float
|
21
|
+
col :vegetables_share, :type => :float
|
22
|
+
col :oils_and_sugars_share, :type => :float
|
23
|
+
end
|