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
@@ -5,9 +5,13 @@ Urbanity.class_eval do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
::Earth::Utils.insert_ignore(
|
9
|
+
:src => ResidentialEnergyConsumptionSurveyResponse,
|
10
|
+
:dest => Urbanity,
|
11
|
+
:cols => {
|
12
|
+
:urbanity_id => :name
|
13
|
+
}
|
14
|
+
)
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -11,13 +11,11 @@ class ZipCode < ActiveRecord::Base
|
|
11
11
|
:lat_column_name => :latitude,
|
12
12
|
:lng_column_name => :longitude
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
14
|
+
col :name
|
15
|
+
col :state_postal_abbreviation
|
16
|
+
col :description
|
17
|
+
col :latitude
|
18
|
+
col :longitude
|
19
|
+
col :egrid_subregion_abbreviation
|
20
|
+
col :climate_division_name
|
21
|
+
end
|
data/lib/earth/pet/breed.rb
CHANGED
@@ -4,10 +4,8 @@ class Breed < ActiveRecord::Base
|
|
4
4
|
has_many :breed_genders, :foreign_key => 'breed_name'
|
5
5
|
belongs_to :species, :foreign_key => 'species_name'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
7
|
+
col :name
|
8
|
+
col :species_name
|
9
|
+
col :weight, :type => :float
|
10
|
+
col :weight_units
|
11
|
+
end
|
@@ -4,11 +4,9 @@ class BreedGender < ActiveRecord::Base
|
|
4
4
|
belongs_to :breed, :foreign_key => 'breed_name'
|
5
5
|
belongs_to :gender, :foreign_key => 'gender_name'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
7
|
+
col :name
|
8
|
+
col :breed_name
|
9
|
+
col :gender_name
|
10
|
+
col :weight, :type => :float
|
11
|
+
col :weight_units
|
12
|
+
end
|
data/lib/earth/pet/gender.rb
CHANGED
data/lib/earth/pet/species.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
class Species < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
string 'maximum_weight_units'
|
19
|
-
end
|
4
|
+
col :name
|
5
|
+
col :population, :type => :integer
|
6
|
+
col :diet_emission_intensity, :type => :float
|
7
|
+
col :diet_emission_intensity_units
|
8
|
+
col :weight, :type => :float
|
9
|
+
col :weight_units
|
10
|
+
col :marginal_dietary_requirement, :type => :float
|
11
|
+
col :marginal_dietary_requirement_units
|
12
|
+
col :fixed_dietary_requirement, :type => :float
|
13
|
+
col :fixed_dietary_requirement_units
|
14
|
+
col :minimum_weight, :type => :float
|
15
|
+
col :minimum_weight_units
|
16
|
+
col :maximum_weight, :type => :float
|
17
|
+
col :maximum_weight_units
|
20
18
|
|
21
19
|
scope :thoroughly_researched, :conditions => 'marginal_dietary_requirement IS NOT NULL'
|
22
20
|
|
@@ -57,4 +55,4 @@ class Species < ActiveRecord::Base
|
|
57
55
|
def cat?
|
58
56
|
eql? self.class[:cat]
|
59
57
|
end
|
60
|
-
end
|
58
|
+
end
|
@@ -1,16 +1,66 @@
|
|
1
1
|
class RailClass < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
col :name
|
4
|
+
col :description
|
5
|
+
col :passengers, :type => :float
|
6
|
+
col :distance, :type => :float
|
7
|
+
col :distance_units
|
8
|
+
col :speed, :type => :float
|
9
|
+
col :speed_units
|
10
|
+
col :electricity_intensity, :type => :float
|
11
|
+
col :electricity_intensity_units
|
12
|
+
col :diesel_intensity, :type => :float
|
13
|
+
col :diesel_intensity_units
|
14
|
+
|
15
|
+
# verify "Passengers, distance, speed, and electricity intensity should be greater than zero" do
|
16
|
+
# RailClass.all.each do |rail_class|
|
17
|
+
# %w{ passengers distance speed electricity_intensity }.each do |attribute|
|
18
|
+
# value = rail_class.send(:"#{attribute}")
|
19
|
+
# unless value > 0
|
20
|
+
# raise "Invalid #{attribute} for RailClass #{rail_class.name}: #{value} (should be > 0)"
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# verify "Distance units should be kilometres" do
|
27
|
+
# RailClass.all.each do |rail_class|
|
28
|
+
# unless rail_class.distance_units == "kilometres"
|
29
|
+
# raise "Invalid distance units for RailClass #{rail_class.name}: #{rail_class.distance_units} (should be kilometres)"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# verify "Speed units should be kilometres per hour" do
|
35
|
+
# RailClass.all.each do |rail_class|
|
36
|
+
# unless rail_class.speed_units == "kilometres_per_hour"
|
37
|
+
# raise "Invalid speed units for RailClass #{rail_class.name}: #{rail_class.speed_units} (should be kilometres_per_hour)"
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# verify "Electricity intensity units should be kilowatt hours per kilometre" do
|
43
|
+
# RailClass.all.each do |rail_class|
|
44
|
+
# unless rail_class.electricity_intensity_units == "kilowatt_hours_per_kilometre"
|
45
|
+
# raise "Invalid electricity intensity units for RailClass #{rail_class.name}: #{rail_class.electricity_intensity_units} (should be kilowatt_hours_per_kilometre)"
|
46
|
+
# end
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# verify "Diesel intensity should be zero or more" do
|
51
|
+
# RailClass.all.each do |rail_class|
|
52
|
+
# unless rail_class.diesel_intensity >= 0
|
53
|
+
# raise "Invalid diesel intensity for RailClass #{rail_class.name}: #{rail_class.diesel_intensity} (should be > 0)"
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# verify "Diesel intensity units should be litres per kilometre" do
|
59
|
+
# RailClass.all.each do |rail_class|
|
60
|
+
# unless rail_class.diesel_intensity_units == "litres_per_kilometre"
|
61
|
+
# raise "Invalid distance units for RailClass #{rail_class.name}: #{rail_class.diesel_intensity_units} (should be litres_per_kilometre)"
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
|
66
|
+
end
|
@@ -14,56 +14,5 @@ RailClass.class_eval do
|
|
14
14
|
store 'electricity_intensity', :units_field_name => 'electricity_intensity_units'
|
15
15
|
store 'diesel_intensity', :units_field_name => 'diesel_intensity_units'
|
16
16
|
end
|
17
|
-
|
18
|
-
verify "Passengers, distance, speed, and electricity intensity should be greater than zero" do
|
19
|
-
RailClass.all.each do |rail_class|
|
20
|
-
%w{ passengers distance speed electricity_intensity }.each do |attribute|
|
21
|
-
value = rail_class.send(:"#{attribute}")
|
22
|
-
unless value > 0
|
23
|
-
raise "Invalid #{attribute} for RailClass #{rail_class.name}: #{value} (should be > 0)"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
verify "Distance units should be kilometres" do
|
30
|
-
RailClass.all.each do |rail_class|
|
31
|
-
unless rail_class.distance_units == "kilometres"
|
32
|
-
raise "Invalid distance units for RailClass #{rail_class.name}: #{rail_class.distance_units} (should be kilometres)"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
verify "Speed units should be kilometres per hour" do
|
38
|
-
RailClass.all.each do |rail_class|
|
39
|
-
unless rail_class.speed_units == "kilometres_per_hour"
|
40
|
-
raise "Invalid speed units for RailClass #{rail_class.name}: #{rail_class.speed_units} (should be kilometres_per_hour)"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
verify "Electricity intensity units should be kilowatt hours per kilometre" do
|
46
|
-
RailClass.all.each do |rail_class|
|
47
|
-
unless rail_class.electricity_intensity_units == "kilowatt_hours_per_kilometre"
|
48
|
-
raise "Invalid electricity intensity units for RailClass #{rail_class.name}: #{rail_class.electricity_intensity_units} (should be kilowatt_hours_per_kilometre)"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
verify "Diesel intensity should be zero or more" do
|
54
|
-
RailClass.all.each do |rail_class|
|
55
|
-
unless rail_class.diesel_intensity >= 0
|
56
|
-
raise "Invalid diesel intensity for RailClass #{rail_class.name}: #{rail_class.diesel_intensity} (should be > 0)"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
verify "Diesel intensity units should be litres per kilometre" do
|
62
|
-
RailClass.all.each do |rail_class|
|
63
|
-
unless rail_class.diesel_intensity_units == "litres_per_kilometre"
|
64
|
-
raise "Invalid distance units for RailClass #{rail_class.name}: #{rail_class.diesel_intensity_units} (should be litres_per_kilometre)"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
17
|
end
|
69
18
|
end
|
@@ -6,9 +6,7 @@ class AirConditionerUse < ActiveRecord::Base
|
|
6
6
|
falls_back_on :fugitive_emission => 0.102295.pounds_per_square_foot.to(:kilograms_per_square_metre), # https://brighterplanet.sifterapp.com/projects/30/issues/430
|
7
7
|
:fugitive_emission_units => 'kilograms_per_square_metre'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
9
|
+
col :name
|
10
|
+
col :fugitive_emission, :type => :float
|
11
|
+
col :fugitive_emission_units
|
12
|
+
end
|
@@ -5,9 +5,13 @@ AirConditionerUse.class_eval do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
::Earth::Utils.insert_ignore(
|
9
|
+
:src => ResidentialEnergyConsumptionSurveyResponse,
|
10
|
+
:dest => AirConditionerUse,
|
11
|
+
:cols => {
|
12
|
+
:central_ac_use => :name
|
13
|
+
}
|
14
|
+
)
|
11
15
|
end
|
12
16
|
|
13
17
|
import "Ian's precalculated fugitive emissions values", :url => 'http://spreadsheets.google.com/pub?key=ri_380yQZAqBKeqie_TECgg&gid=0&output=csv' do
|
@@ -3,9 +3,7 @@ class ClothesMachineUse < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :residential_energy_consumption_survey_responses
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
6
|
+
col :name
|
7
|
+
col :annual_energy_from_electricity_for_clothes_driers, :type => :float
|
8
|
+
col :annual_energy_from_electricity_for_clothes_driers_units
|
9
|
+
end
|
@@ -5,19 +5,21 @@ ClothesMachineUse.class_eval do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
::Earth::Utils.insert_ignore(
|
9
|
+
:src => ResidentialEnergyConsumptionSurveyResponse,
|
10
|
+
:dest => ClothesMachineUse,
|
11
|
+
:cols => {
|
12
|
+
:clothes_washer_use => :name
|
13
|
+
}
|
14
|
+
)
|
11
15
|
end
|
12
16
|
|
13
17
|
# sabshere 5/20/10 weird that this uses cohort
|
14
18
|
process "precalculate annual energy use" do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
record.save!
|
20
|
-
end
|
19
|
+
find_each do |record|
|
20
|
+
record.annual_energy_from_electricity_for_clothes_driers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:clothes_machine_use_id => record.name).weighted_average :annual_energy_from_electricity_for_clothes_driers
|
21
|
+
record.annual_energy_from_electricity_for_clothes_driers_units = 'joules'
|
22
|
+
record.save!
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -3,9 +3,7 @@ class DishwasherUse < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :residential_energy_consumption_survey_responses
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
6
|
+
col :name
|
7
|
+
col :annual_energy_from_electricity_for_dishwashers, :type => :float
|
8
|
+
col :annual_energy_from_electricity_for_dishwashers_units
|
9
|
+
end
|
@@ -5,19 +5,21 @@ DishwasherUse.class_eval do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
::Earth::Utils.insert_ignore(
|
9
|
+
:src => ResidentialEnergyConsumptionSurveyResponse,
|
10
|
+
:dest => DishwasherUse,
|
11
|
+
:cols => {
|
12
|
+
:dishwasher_use_id => :name
|
13
|
+
}
|
14
|
+
)
|
11
15
|
end
|
12
16
|
|
13
17
|
# sabshere 5/25/10 weird that this uses cohort
|
14
18
|
process "precalculate annual energy" do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
record.save!
|
20
|
-
end
|
19
|
+
find_each do |record|
|
20
|
+
record.annual_energy_from_electricity_for_dishwashers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:dishwasher_use_id => record.name).weighted_average :annual_energy_from_electricity_for_dishwashers
|
21
|
+
record.annual_energy_from_electricity_for_dishwashers_units = 'joules'
|
22
|
+
record.save!
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -10,9 +10,7 @@ class ResidenceAppliance < ActiveRecord::Base
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
13
|
+
col :name
|
14
|
+
col :annual_energy_from_electricity, :type => :float
|
15
|
+
col :annual_energy_from_electricity_units
|
16
|
+
end
|
@@ -5,9 +5,13 @@ ResidenceClass.class_eval do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
::Earth::Utils.insert_ignore(
|
9
|
+
:src => ResidentialEnergyConsumptionSurveyResponse,
|
10
|
+
:dest => ResidenceClass,
|
11
|
+
:cols => {
|
12
|
+
:residence_class_id => :name
|
13
|
+
}
|
14
|
+
)
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -7,17 +7,15 @@ class ResidenceFuelPrice < ActiveRecord::Base
|
|
7
7
|
belongs_to :fuel, :class_name => 'ResidenceFuelType', :foreign_key => 'residence_fuel_type_name'
|
8
8
|
belongs_to :locatable, :polymorphic => true
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
10
|
+
col :row_hash
|
11
|
+
col :residence_fuel_type_name
|
12
|
+
col :year, :type => :integer
|
13
|
+
col :month, :type => :integer
|
14
|
+
col :price, :type => :float
|
15
|
+
col :price_units
|
16
|
+
col :price_description
|
17
|
+
col :locatable_id
|
18
|
+
col :locatable_type
|
19
|
+
add_index [:price, :residence_fuel_type_name, :month, :year, :locatable_type, :locatable_id]
|
20
|
+
add_index [:price, :residence_fuel_type_name]
|
21
|
+
end
|