earth 0.1.2 → 0.1.3
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/lib/earth/air/aircraft.rb +5 -16
- data/lib/earth/air/flight_configuration.rb +1 -12
- data/lib/earth/air/flight_configuration/data_miner.rb +14 -2
- data/lib/earth/air/flight_fuel_type.rb +1 -6
- data/lib/earth/air/flight_fuel_type/data_miner.rb +10 -2
- data/lib/earth/air/flight_propulsion.rb +1 -12
- data/lib/earth/air/flight_propulsion/data_miner.rb +14 -2
- data/lib/earth/air/flight_service.rb +1 -12
- data/lib/earth/air/flight_service/data_miner.rb +14 -2
- data/lib/earth/locality/urbanity.rb +1 -11
- data/lib/earth/locality/urbanity/data_miner.rb +13 -2
- data/lib/earth/locality/zip_code.rb +0 -6
- data/lib/earth/locality/zip_code/data_miner.rb +7 -0
- data/lib/earth/residence/air_conditioner_use.rb +1 -18
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +20 -2
- data/lib/earth/residence/clothes_machine_use.rb +1 -35
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +26 -2
- data/lib/earth/residence/dishwasher_use.rb +2 -25
- data/lib/earth/residence/dishwasher_use/data_miner.rb +26 -2
- data/lib/earth/residence/residence_class.rb +1 -11
- data/lib/earth/residence/residence_class/data_miner.rb +13 -2
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +0 -28
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +91 -66
- metadata +5 -5
data/lib/earth/air/aircraft.rb
CHANGED
@@ -5,22 +5,11 @@ class Aircraft < ActiveRecord::Base
|
|
5
5
|
belongs_to :manufacturer, :foreign_key => 'manufacturer_name', :class_name => 'AircraftManufacturer'
|
6
6
|
has_many :segments, :foreign_key => 'bts_aircraft_type_code', :class_name => "FlightSegment", :primary_key => 'bts_aircraft_type_code'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}, #
|
12
|
-
:
|
13
|
-
weighted_average(:m2, :weighted_by => [:segments, :passengers])
|
14
|
-
}, # -0.000134350543484608 r7110: -0.00015337661447817 r6972: -4.09e-5
|
15
|
-
:m1 => lambda {
|
16
|
-
weighted_average(:m1, :weighted_by => [:segments, :passengers])
|
17
|
-
}, # 6.7728101555467 r7110: 4.7781966869412 r6972: 7.85
|
18
|
-
:endpoint_fuel => lambda {
|
19
|
-
weighted_average(:endpoint_fuel, :weighted_by => [:segments, :passengers])
|
20
|
-
}, # 1527.81790006167 r7110: 1065.3476555284 r6972: 1.72e3
|
21
|
-
:seats => lambda {
|
22
|
-
weighted_average(:seats, :weighted_by => [:segments, :passengers])
|
23
|
-
} # 62.1741
|
8
|
+
falls_back_on :m3 => lambda { weighted_average(:m3, :weighted_by => [:segments, :passengers]) }, # 9.73423082858437e-08 r7110: 8.6540464368905e-8 r6972: 8.37e-8
|
9
|
+
:m2 => lambda { weighted_average(:m2, :weighted_by => [:segments, :passengers]) }, # -0.000134350543484608 r7110: -0.00015337661447817 r6972: -4.09e-5
|
10
|
+
:m1 => lambda { weighted_average(:m1, :weighted_by => [:segments, :passengers]) }, # 6.7728101555467 r7110: 4.7781966869412 r6972: 7.85
|
11
|
+
:endpoint_fuel => lambda { weighted_average(:endpoint_fuel, :weighted_by => [:segments, :passengers]) }, # 1527.81790006167 r7110: 1065.3476555284 r6972: 1.72e3
|
12
|
+
:seats => lambda { weighted_average(:seats, :weighted_by => [:segments, :passengers]) } # 62.1741
|
24
13
|
|
25
14
|
data_miner do
|
26
15
|
tap "Brighter Planet's sanitized aircraft data", Earth.taps_server
|
@@ -2,17 +2,6 @@ class FlightConfiguration < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
data_miner do
|
5
|
-
|
6
|
-
string 'name'
|
7
|
-
string 'bts_aircraft_configuration_code'
|
8
|
-
end
|
9
|
-
|
10
|
-
process "derive from flight segments" do
|
11
|
-
FlightSegment.run_data_miner!
|
12
|
-
connection.execute %{
|
13
|
-
INSERT IGNORE INTO flight_configurations(name, bts_aircraft_configuration_code)
|
14
|
-
SELECT flight_segments.configuration_id, flight_segments.bts_aircraft_configuration_code FROM flight_segments WHERE LENGTH(flight_segments.configuration_id) > 0
|
15
|
-
}
|
16
|
-
end
|
5
|
+
tap "Brighter Planet's flight configuration data", Earth.taps_server
|
17
6
|
end
|
18
7
|
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
FlightConfiguration.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
string 'bts_aircraft_configuration_code'
|
6
|
+
end
|
7
|
+
|
8
|
+
process "derive from flight segments" do
|
9
|
+
FlightSegment.run_data_miner!
|
10
|
+
connection.execute %{
|
11
|
+
INSERT IGNORE INTO flight_configurations(name, bts_aircraft_configuration_code)
|
12
|
+
SELECT flight_segments.configuration_id, flight_segments.bts_aircraft_configuration_code FROM flight_segments WHERE LENGTH(flight_segments.configuration_id) > 0
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
4
16
|
end
|
@@ -5,12 +5,7 @@ class FlightFuelType < ActiveRecord::Base
|
|
5
5
|
:density => 3.057 # kg / gal
|
6
6
|
|
7
7
|
data_miner do
|
8
|
-
|
9
|
-
string 'name'
|
10
|
-
float 'emission_factor'
|
11
|
-
float 'radiative_forcing_index'
|
12
|
-
float 'density'
|
13
|
-
end
|
8
|
+
tap "Brighter Planet's sanitized flight fuel type data", Earth.taps_server
|
14
9
|
|
15
10
|
# we just always use the fallback
|
16
11
|
end
|
@@ -2,17 +2,6 @@ class FlightPropulsion < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
data_miner do
|
5
|
-
|
6
|
-
string 'name'
|
7
|
-
string 'bts_aircraft_group_code'
|
8
|
-
end
|
9
|
-
|
10
|
-
process "derive from flight segments" do
|
11
|
-
FlightSegment.run_data_miner!
|
12
|
-
connection.execute %{
|
13
|
-
INSERT IGNORE INTO flight_propulsions(name, bts_aircraft_group_code)
|
14
|
-
SELECT flight_segments.propulsion_id, flight_segments.bts_aircraft_group_code FROM flight_segments WHERE LENGTH(flight_segments.propulsion_id) > 0
|
15
|
-
}
|
16
|
-
end
|
5
|
+
tap "Brighter Planet's sanitized flight propulsion data", Earth.taps_server
|
17
6
|
end
|
18
7
|
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
FlightPropulsion.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
string 'bts_aircraft_group_code'
|
6
|
+
end
|
7
|
+
|
8
|
+
process "derive from flight segments" do
|
9
|
+
FlightSegment.run_data_miner!
|
10
|
+
connection.execute %{
|
11
|
+
INSERT IGNORE INTO flight_propulsions(name, bts_aircraft_group_code)
|
12
|
+
SELECT flight_segments.propulsion_id, flight_segments.bts_aircraft_group_code FROM flight_segments WHERE LENGTH(flight_segments.propulsion_id) > 0
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
4
16
|
end
|
@@ -2,17 +2,6 @@ class FlightService < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
data_miner do
|
5
|
-
|
6
|
-
string 'name'
|
7
|
-
string 'bts_service_class_code'
|
8
|
-
end
|
9
|
-
|
10
|
-
process "derive from flight segments" do
|
11
|
-
FlightSegment.run_data_miner!
|
12
|
-
connection.execute %{
|
13
|
-
INSERT IGNORE INTO flight_services(name, bts_service_class_code)
|
14
|
-
SELECT flight_segments.service_class_id, flight_segments.bts_service_class_code FROM flight_segments WHERE LENGTH(flight_segments.service_class_id) > 0
|
15
|
-
}
|
16
|
-
end
|
5
|
+
tap "Brighter Planet's sanitized flight service data", Earth.taps_server
|
17
6
|
end
|
18
7
|
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
FlightService.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
string 'bts_service_class_code'
|
6
|
+
end
|
7
|
+
|
8
|
+
process "derive from flight segments" do
|
9
|
+
FlightSegment.run_data_miner!
|
10
|
+
connection.execute %{
|
11
|
+
INSERT IGNORE INTO flight_services(name, bts_service_class_code)
|
12
|
+
SELECT flight_segments.service_class_id, flight_segments.bts_service_class_code FROM flight_segments WHERE LENGTH(flight_segments.service_class_id) > 0
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
4
16
|
end
|
@@ -5,16 +5,6 @@ class Urbanity < ActiveRecord::Base
|
|
5
5
|
has_many :residential_energy_consumption_survey_responses
|
6
6
|
|
7
7
|
data_miner do
|
8
|
-
|
9
|
-
string :name
|
10
|
-
end
|
11
|
-
|
12
|
-
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
13
|
-
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
14
|
-
connection.execute %{
|
15
|
-
INSERT IGNORE INTO urbanities(name)
|
16
|
-
SELECT DISTINCT residential_energy_consumption_survey_responses.urbanity_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.urbanity_id) > 0
|
17
|
-
}
|
18
|
-
end
|
8
|
+
tap "Brighter Planet's sanitized urbanity data", Earth.taps_server
|
19
9
|
end
|
20
10
|
end
|
@@ -1,4 +1,15 @@
|
|
1
1
|
Urbanity.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
end
|
6
|
+
|
7
|
+
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
+
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
9
|
+
connection.execute %{
|
10
|
+
INSERT IGNORE INTO urbanities(name)
|
11
|
+
SELECT DISTINCT residential_energy_consumption_survey_responses.urbanity_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.urbanity_id) > 0
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
4
15
|
end
|
@@ -13,12 +13,6 @@ class ZipCode < ActiveRecord::Base
|
|
13
13
|
:lat_column_name => :latitude,
|
14
14
|
:lng_column_name => :longitude
|
15
15
|
|
16
|
-
def set_latitude_and_longitude
|
17
|
-
return if latitude.present? and longitude.present?
|
18
|
-
a = Geokit::Geocoders::YahooGeocoder.geocode name
|
19
|
-
update_attributes! :latitude => a.lat, :longitude => a.lng
|
20
|
-
end
|
21
|
-
|
22
16
|
data_miner do
|
23
17
|
tap "Brighter Planet's sanitized zip codes", Earth.taps_server
|
24
18
|
|
@@ -1,4 +1,11 @@
|
|
1
1
|
ZipCode.class_eval do
|
2
|
+
# sabshere 9/20/10 this isn't called anywhere
|
3
|
+
# def set_latitude_and_longitude
|
4
|
+
# return if latitude.present? and longitude.present?
|
5
|
+
# a = Geokit::Geocoders::YahooGeocoder.geocode name
|
6
|
+
# update_attributes! :latitude => a.lat, :longitude => a.lng
|
7
|
+
# end
|
8
|
+
|
2
9
|
data_miner do
|
3
10
|
schema Earth.database_options do
|
4
11
|
string 'name'
|
@@ -8,23 +8,6 @@ class AirConditionerUse < ActiveRecord::Base
|
|
8
8
|
:fugitive_emission_units => 'kilograms_per_square_metre'
|
9
9
|
|
10
10
|
data_miner do
|
11
|
-
|
12
|
-
string 'name'
|
13
|
-
float 'fugitive_emission'
|
14
|
-
string 'fugitive_emission_units'
|
15
|
-
end
|
16
|
-
|
17
|
-
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
18
|
-
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
19
|
-
connection.execute %{
|
20
|
-
INSERT IGNORE INTO air_conditioner_uses(name)
|
21
|
-
SELECT DISTINCT residential_energy_consumption_survey_responses.central_ac_use FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.central_ac_use) > 0
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
import "Ian's precalculated fugitive emissions values", :url => 'http://spreadsheets.google.com/pub?key=ri_380yQZAqBKeqie_TECgg' do
|
26
|
-
key 'name', :field_name => 'air_conditioner_use_name'
|
27
|
-
store 'fugitive_emission', :units_field_name => 'unit', :to_units => :kilograms_per_square_metre
|
28
|
-
end
|
11
|
+
tap "Brighter Planet's sanitized flight service data", Earth.taps_server
|
29
12
|
end
|
30
13
|
end
|
@@ -1,4 +1,22 @@
|
|
1
1
|
AirConditionerUse.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
float 'fugitive_emission'
|
6
|
+
string 'fugitive_emission_units'
|
7
|
+
end
|
8
|
+
|
9
|
+
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
10
|
+
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
connection.execute %{
|
12
|
+
INSERT IGNORE INTO air_conditioner_uses(name)
|
13
|
+
SELECT DISTINCT residential_energy_consumption_survey_responses.central_ac_use FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.central_ac_use) > 0
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
import "Ian's precalculated fugitive emissions values", :url => 'http://spreadsheets.google.com/pub?key=ri_380yQZAqBKeqie_TECgg' do
|
18
|
+
key 'name', :field_name => 'air_conditioner_use_name'
|
19
|
+
store 'fugitive_emission', :units_field_name => 'unit', :to_units => :kilograms_per_square_metre
|
20
|
+
end
|
21
|
+
end
|
4
22
|
end
|
@@ -4,41 +4,7 @@ class ClothesMachineUse < ActiveRecord::Base
|
|
4
4
|
has_many :residences
|
5
5
|
has_many :residential_energy_consumption_survey_responses
|
6
6
|
|
7
|
-
class << self
|
8
|
-
def derive_annual_energy_from_electricity_for_clothes_driers
|
9
|
-
find_in_batches do |batch|
|
10
|
-
batch.each do |record|
|
11
|
-
record.annual_energy_from_electricity_for_clothes_driers = ResidenceSurveyResponse.cohort(:clothes_drier_use => record).weighted_average :annual_energy_from_electricity_for_clothes_driers
|
12
|
-
record.save
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
7
|
data_miner do
|
19
|
-
|
20
|
-
string 'name'
|
21
|
-
float 'annual_energy_from_electricity_for_clothes_driers'
|
22
|
-
string 'annual_energy_from_electricity_for_clothes_driers_units'
|
23
|
-
end
|
24
|
-
|
25
|
-
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
26
|
-
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
27
|
-
connection.execute %{
|
28
|
-
INSERT IGNORE INTO clothes_machine_uses(name)
|
29
|
-
SELECT DISTINCT residential_energy_consumption_survey_responses.clothes_washer_use FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.clothes_washer_use) > 0
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
# sabshere 5/20/10 weird that this uses cohort
|
34
|
-
process "precalculate annual energy use" do
|
35
|
-
find_in_batches do |batch|
|
36
|
-
batch.each do |record|
|
37
|
-
record.annual_energy_from_electricity_for_clothes_driers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:clothes_machine_use => record).weighted_average :annual_energy_from_electricity_for_clothes_driers
|
38
|
-
record.annual_energy_from_electricity_for_clothes_driers_units = 'joules'
|
39
|
-
record.save!
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
8
|
+
tap "Brighter Planet's sanitized clothes machine use data", Earth.taps_server
|
43
9
|
end
|
44
10
|
end
|
@@ -1,4 +1,28 @@
|
|
1
1
|
ClothesMachineUse.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
float 'annual_energy_from_electricity_for_clothes_driers'
|
6
|
+
string 'annual_energy_from_electricity_for_clothes_driers_units'
|
7
|
+
end
|
8
|
+
|
9
|
+
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
10
|
+
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
connection.execute %{
|
12
|
+
INSERT IGNORE INTO clothes_machine_uses(name)
|
13
|
+
SELECT DISTINCT residential_energy_consumption_survey_responses.clothes_washer_use FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.clothes_washer_use) > 0
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
# sabshere 5/20/10 weird that this uses cohort
|
18
|
+
process "precalculate annual energy use" do
|
19
|
+
find_in_batches do |batch|
|
20
|
+
batch.each do |record|
|
21
|
+
record.annual_energy_from_electricity_for_clothes_driers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:clothes_machine_use => record).weighted_average :annual_energy_from_electricity_for_clothes_driers
|
22
|
+
record.annual_energy_from_electricity_for_clothes_driers_units = 'joules'
|
23
|
+
record.save!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
4
28
|
end
|
@@ -3,31 +3,8 @@ class DishwasherUse < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :residences
|
5
5
|
has_many :residential_energy_consumption_survey_responses
|
6
|
-
|
6
|
+
|
7
7
|
data_miner do
|
8
|
-
|
9
|
-
string 'name'
|
10
|
-
float 'annual_energy_from_electricity_for_dishwashers'
|
11
|
-
string 'annual_energy_from_electricity_for_dishwashers_units'
|
12
|
-
end
|
13
|
-
|
14
|
-
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
15
|
-
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
16
|
-
connection.execute %{
|
17
|
-
INSERT IGNORE INTO dishwasher_uses(name)
|
18
|
-
SELECT DISTINCT residential_energy_consumption_survey_responses.dishwasher_use_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.dishwasher_use_id) > 0
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
# sabshere 5/25/10 weird that this uses cohort
|
23
|
-
process "precalculate annual energy" do
|
24
|
-
find_in_batches do |batch|
|
25
|
-
batch.each do |record|
|
26
|
-
record.annual_energy_from_electricity_for_dishwashers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:dishwasher_use => record).weighted_average :annual_energy_from_electricity_for_dishwashers
|
27
|
-
record.annual_energy_from_electricity_for_dishwashers_units = 'joules'
|
28
|
-
record.save!
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
8
|
+
tap "Brighter Planet's sanitized dishwasher use data", Earth.taps_server
|
32
9
|
end
|
33
10
|
end
|
@@ -1,4 +1,28 @@
|
|
1
1
|
DishwasherUse.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string 'name'
|
5
|
+
float 'annual_energy_from_electricity_for_dishwashers'
|
6
|
+
string 'annual_energy_from_electricity_for_dishwashers_units'
|
7
|
+
end
|
8
|
+
|
9
|
+
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
10
|
+
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
connection.execute %{
|
12
|
+
INSERT IGNORE INTO dishwasher_uses(name)
|
13
|
+
SELECT DISTINCT residential_energy_consumption_survey_responses.dishwasher_use_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.dishwasher_use_id) > 0
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
# sabshere 5/25/10 weird that this uses cohort
|
18
|
+
process "precalculate annual energy" do
|
19
|
+
find_in_batches do |batch|
|
20
|
+
batch.each do |record|
|
21
|
+
record.annual_energy_from_electricity_for_dishwashers = ResidentialEnergyConsumptionSurveyResponse.big_cohort(:dishwasher_use => record).weighted_average :annual_energy_from_electricity_for_dishwashers
|
22
|
+
record.annual_energy_from_electricity_for_dishwashers_units = 'joules'
|
23
|
+
record.save!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
4
28
|
end
|
@@ -11,16 +11,6 @@ class ResidenceClass < ActiveRecord::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
data_miner do
|
14
|
-
|
15
|
-
string :name
|
16
|
-
end
|
17
|
-
|
18
|
-
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
19
|
-
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
20
|
-
connection.execute %{
|
21
|
-
INSERT IGNORE INTO residence_classes(name)
|
22
|
-
SELECT DISTINCT residential_energy_consumption_survey_responses.residence_class_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.residence_class_id) > 0
|
23
|
-
}
|
24
|
-
end
|
14
|
+
tap "Brighter Planet's sanitized residence class data", Earth.taps_server
|
25
15
|
end
|
26
16
|
end
|
@@ -1,4 +1,15 @@
|
|
1
1
|
ResidenceClass.class_eval do
|
2
|
-
|
3
|
-
|
2
|
+
data_miner do
|
3
|
+
schema do
|
4
|
+
string :name
|
5
|
+
end
|
6
|
+
|
7
|
+
process "derive from ResidentialEnergyConsumptionSurveyResponse" do
|
8
|
+
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
9
|
+
connection.execute %{
|
10
|
+
INSERT IGNORE INTO residence_classes(name)
|
11
|
+
SELECT DISTINCT residential_energy_consumption_survey_responses.residence_class_id FROM residential_energy_consumption_survey_responses WHERE LENGTH(residential_energy_consumption_survey_responses.residence_class_id) > 0
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
4
15
|
end
|
@@ -31,34 +31,6 @@ class ResidentialEnergyConsumptionSurveyResponse < ActiveRecord::Base
|
|
31
31
|
|
32
32
|
data_miner do
|
33
33
|
tap "Brighter Planet's sanitized RECS 2005", Earth.taps_server
|
34
|
-
|
35
|
-
process "rename certain columns so that we can use them as association names" do
|
36
|
-
connection.rename_column :residential_energy_consumption_survey_responses, :dishwasher_use, :dishwasher_use_id
|
37
|
-
end
|
38
|
-
|
39
|
-
process "synthesize air conditioner use from central AC and window AC use" do
|
40
|
-
connection.add_column :residential_energy_consumption_survey_responses, :air_conditioner_use_id, :string
|
41
|
-
update_all "air_conditioner_use_id = 'Turned on just about all summer'", " central_ac_use = 'Turned on just about all summer' OR window_ac_use = 'Turned on just about all summer'"
|
42
|
-
update_all "air_conditioner_use_id = 'Turned on quite a bit'", "(central_ac_use = 'Turned on quite a bit' OR window_ac_use = 'Turned on quite a bit') AND air_conditioner_use_id IS NULL"
|
43
|
-
update_all "air_conditioner_use_id = 'Turned on only a few days or nights when really needed'", "(central_ac_use = 'Turned on only a few days or nights when really needed' OR window_ac_use = 'Turned on only a few days or nights when really needed') AND air_conditioner_use_id IS NULL"
|
44
|
-
update_all "air_conditioner_use_id = 'Not used at all'", "(central_ac_use = 'Not used at all' OR window_ac_use = 'Not used at all') AND air_conditioner_use_id IS NULL"
|
45
|
-
end
|
46
|
-
|
47
|
-
process "synthesize clothes machine use from washer and dryer use" do
|
48
|
-
connection.add_column :residential_energy_consumption_survey_responses, :clothes_machine_use_id, :string
|
49
|
-
update_all "clothes_machine_use_id = clothes_washer_use", " clothes_dryer_use = 'Use it every time you wash clothes'"
|
50
|
-
update_all "clothes_machine_use_id = NULL", "clothes_washer_use IS NULL AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
51
|
-
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '1 load or less each week' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
52
|
-
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '2 to 4 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
53
|
-
update_all "clothes_machine_use_id = '2 to 4 loads'", "clothes_washer_use = '5 to 9 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
54
|
-
update_all "clothes_machine_use_id = '5 to 9 loads'", "clothes_washer_use = '10 to 15 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
55
|
-
update_all "clothes_machine_use_id = '10 to 15 loads'", "clothes_washer_use = 'More than 15 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
56
|
-
update_all "clothes_machine_use_id = NULL", "clothes_washer_use IS NULL AND clothes_dryer_use = 'Use it infrequently'"
|
57
|
-
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '1 load or less each week' AND clothes_dryer_use = 'Use it infrequently'"
|
58
|
-
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '5 to 9 loads' AND clothes_dryer_use = 'Use it infrequently'"
|
59
|
-
update_all "clothes_machine_use_id = '2 to 4 loads'", "clothes_washer_use = '10 to 15 loads' AND clothes_dryer_use = 'Use it infrequently'"
|
60
|
-
update_all "clothes_machine_use_id = '5 to 9 loads'", "clothes_washer_use = 'More than 15 loads' AND clothes_dryer_use = 'Use it infrequently'"
|
61
|
-
end
|
62
34
|
|
63
35
|
process "pull dependencies" do
|
64
36
|
run_data_miner_on_belongs_to_associations
|
@@ -1,96 +1,97 @@
|
|
1
1
|
ResidentialEnergyConsumptionSurveyResponse.class_eval do
|
2
2
|
data_miner do
|
3
|
+
# sabshere 9/20/10 sorted with sort -d -t "'" -k 2 ~/Desktop/parts.txt
|
3
4
|
schema Earth.database_options do
|
4
5
|
integer 'department_of_energy_identifier'
|
5
|
-
|
6
|
-
|
7
|
-
string '
|
8
|
-
|
9
|
-
string '
|
10
|
-
|
11
|
-
string '
|
12
|
-
|
13
|
-
string '
|
14
|
-
|
15
|
-
string '
|
16
|
-
|
17
|
-
string '
|
18
|
-
float '
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
integer 'refrigerator_count'
|
25
|
-
integer 'freezer_count'
|
6
|
+
integer 'air_conditioner_use_id'
|
7
|
+
float 'annual_energy_from_electricity_for_air_conditioners'
|
8
|
+
string 'annual_energy_from_electricity_for_air_conditioners_units'
|
9
|
+
float 'annual_energy_from_electricity_for_clothes_driers'
|
10
|
+
string 'annual_energy_from_electricity_for_clothes_driers_units'
|
11
|
+
float 'annual_energy_from_electricity_for_dishwashers'
|
12
|
+
string 'annual_energy_from_electricity_for_dishwashers_units'
|
13
|
+
float 'annual_energy_from_electricity_for_freezers'
|
14
|
+
string 'annual_energy_from_electricity_for_freezers_units'
|
15
|
+
float 'annual_energy_from_electricity_for_heating_space'
|
16
|
+
string 'annual_energy_from_electricity_for_heating_space_units'
|
17
|
+
float 'annual_energy_from_electricity_for_heating_water'
|
18
|
+
string 'annual_energy_from_electricity_for_heating_water_units'
|
19
|
+
float 'annual_energy_from_electricity_for_other_appliances'
|
20
|
+
string 'annual_energy_from_electricity_for_other_appliances_units'
|
21
|
+
float 'annual_energy_from_electricity_for_refrigerators'
|
22
|
+
string 'annual_energy_from_electricity_for_refrigerators_units'
|
23
|
+
float 'annual_energy_from_fuel_oil_for_appliances'
|
24
|
+
string 'annual_energy_from_fuel_oil_for_appliances_units'
|
26
25
|
float 'annual_energy_from_fuel_oil_for_heating_space'
|
27
26
|
string 'annual_energy_from_fuel_oil_for_heating_space_units'
|
28
27
|
float 'annual_energy_from_fuel_oil_for_heating_water'
|
29
28
|
string 'annual_energy_from_fuel_oil_for_heating_water_units'
|
30
|
-
float '
|
31
|
-
string '
|
29
|
+
float 'annual_energy_from_kerosene'
|
30
|
+
string 'annual_energy_from_kerosene_units'
|
31
|
+
float 'annual_energy_from_natural_gas_for_appliances'
|
32
|
+
string 'annual_energy_from_natural_gas_for_appliances_units'
|
32
33
|
float 'annual_energy_from_natural_gas_for_heating_space'
|
33
34
|
string 'annual_energy_from_natural_gas_for_heating_space_units'
|
34
35
|
float 'annual_energy_from_natural_gas_for_heating_water'
|
35
36
|
string 'annual_energy_from_natural_gas_for_heating_water_units'
|
36
|
-
float '
|
37
|
-
string '
|
37
|
+
float 'annual_energy_from_propane_for_appliances'
|
38
|
+
string 'annual_energy_from_propane_for_appliances_units'
|
38
39
|
float 'annual_energy_from_propane_for_heating_space'
|
39
40
|
string 'annual_energy_from_propane_for_heating_space_units'
|
40
41
|
float 'annual_energy_from_propane_for_heating_water'
|
41
42
|
string 'annual_energy_from_propane_for_heating_water_units'
|
42
|
-
float 'annual_energy_from_propane_for_appliances'
|
43
|
-
string 'annual_energy_from_propane_for_appliances_units'
|
44
43
|
float 'annual_energy_from_wood'
|
45
44
|
string 'annual_energy_from_wood_units'
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
string '
|
52
|
-
|
53
|
-
string '
|
54
|
-
|
55
|
-
string '
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
string '
|
60
|
-
|
61
|
-
string 'annual_energy_from_electricity_for_heating_water_units'
|
62
|
-
float 'annual_energy_from_electricity_for_other_appliances'
|
63
|
-
string 'annual_energy_from_electricity_for_other_appliances_units'
|
64
|
-
float 'weighting'
|
65
|
-
float 'lighting_use'
|
66
|
-
string 'lighting_use_units'
|
67
|
-
float 'lighting_efficiency'
|
68
|
-
integer 'heating_degree_days'
|
69
|
-
string 'heating_degree_days_units'
|
45
|
+
boolean 'attached_1car_garage'
|
46
|
+
boolean 'attached_2car_garage'
|
47
|
+
boolean 'attached_3car_garage'
|
48
|
+
float 'bathrooms'
|
49
|
+
integer 'bedrooms'
|
50
|
+
string 'census_division_name'
|
51
|
+
integer 'census_division_number'
|
52
|
+
string 'census_region_name'
|
53
|
+
integer 'census_region_number'
|
54
|
+
string 'central_ac_use'
|
55
|
+
string 'clothes_dryer_use'
|
56
|
+
integer 'clothes_machine_use_id'
|
57
|
+
string 'clothes_washer_use'
|
58
|
+
string 'construction_period'
|
59
|
+
date 'construction_year'
|
70
60
|
integer 'cooling_degree_days'
|
71
61
|
string 'cooling_degree_days_units'
|
72
|
-
integer 'total_rooms'
|
73
|
-
integer 'full_bathrooms'
|
74
|
-
integer 'bedrooms'
|
75
|
-
integer 'half_bathrooms'
|
76
|
-
float 'bathrooms'
|
77
|
-
boolean 'heated_garage'
|
78
|
-
boolean 'attached_1car_garage'
|
79
62
|
boolean 'detached_1car_garage'
|
80
|
-
boolean 'attached_2car_garage'
|
81
63
|
boolean 'detached_2car_garage'
|
82
|
-
boolean 'attached_3car_garage'
|
83
64
|
boolean 'detached_3car_garage'
|
84
|
-
|
65
|
+
string 'dishwasher_use_id'
|
85
66
|
integer 'efficient_lights_on_1_to_4_hours'
|
86
|
-
integer 'lights_on_4_to_12_hours'
|
87
67
|
integer 'efficient_lights_on_4_to_12_hours'
|
88
|
-
integer 'lights_on_over_12_hours'
|
89
68
|
integer 'efficient_lights_on_over_12_hours'
|
90
|
-
|
69
|
+
float 'floorspace'
|
70
|
+
string 'floorspace_units'
|
71
|
+
integer 'freezer_count'
|
72
|
+
integer 'full_bathrooms'
|
73
|
+
integer 'half_bathrooms'
|
74
|
+
boolean 'heated_garage'
|
75
|
+
integer 'heating_degree_days'
|
76
|
+
string 'heating_degree_days_units'
|
77
|
+
float 'lighting_efficiency'
|
78
|
+
float 'lighting_use'
|
79
|
+
string 'lighting_use_units'
|
80
|
+
integer 'lights_on_1_to_4_hours'
|
81
|
+
integer 'lights_on_4_to_12_hours'
|
82
|
+
integer 'lights_on_over_12_hours'
|
91
83
|
integer 'outdoor_all_night_gas_lights'
|
92
|
-
integer '
|
93
|
-
|
84
|
+
integer 'outdoor_all_night_lights'
|
85
|
+
boolean 'ownership'
|
86
|
+
integer 'refrigerator_count'
|
87
|
+
string 'residence_class_id'
|
88
|
+
integer 'residents'
|
89
|
+
float 'rooms'
|
90
|
+
boolean 'thermostat_programmability'
|
91
|
+
integer 'total_rooms'
|
92
|
+
string 'urbanity_id'
|
93
|
+
float 'weighting'
|
94
|
+
string 'window_ac_use'
|
94
95
|
end
|
95
96
|
|
96
97
|
process "Define some unit conversions" do
|
@@ -254,6 +255,30 @@ ResidentialEnergyConsumptionSurveyResponse.class_eval do
|
|
254
255
|
update_all 'lighting_efficiency = (2*efficient_lights_on_1_to_4_hours + 8*efficient_lights_on_4_to_12_hours + 16*efficient_lights_on_over_12_hours) / lighting_use'
|
255
256
|
end
|
256
257
|
|
258
|
+
process "synthesize air conditioner use from central AC and window AC use" do
|
259
|
+
connection.add_column :residential_energy_consumption_survey_responses, :air_conditioner_use_id, :string
|
260
|
+
update_all "air_conditioner_use_id = 'Turned on just about all summer'", " central_ac_use = 'Turned on just about all summer' OR window_ac_use = 'Turned on just about all summer'"
|
261
|
+
update_all "air_conditioner_use_id = 'Turned on quite a bit'", "(central_ac_use = 'Turned on quite a bit' OR window_ac_use = 'Turned on quite a bit') AND air_conditioner_use_id IS NULL"
|
262
|
+
update_all "air_conditioner_use_id = 'Turned on only a few days or nights when really needed'", "(central_ac_use = 'Turned on only a few days or nights when really needed' OR window_ac_use = 'Turned on only a few days or nights when really needed') AND air_conditioner_use_id IS NULL"
|
263
|
+
update_all "air_conditioner_use_id = 'Not used at all'", "(central_ac_use = 'Not used at all' OR window_ac_use = 'Not used at all') AND air_conditioner_use_id IS NULL"
|
264
|
+
end
|
265
|
+
|
266
|
+
process "synthesize clothes machine use from washer and dryer use" do
|
267
|
+
connection.add_column :residential_energy_consumption_survey_responses, :clothes_machine_use_id, :string
|
268
|
+
update_all "clothes_machine_use_id = clothes_washer_use", " clothes_dryer_use = 'Use it every time you wash clothes'"
|
269
|
+
update_all "clothes_machine_use_id = NULL", "clothes_washer_use IS NULL AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
270
|
+
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '1 load or less each week' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
271
|
+
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '2 to 4 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
272
|
+
update_all "clothes_machine_use_id = '2 to 4 loads'", "clothes_washer_use = '5 to 9 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
273
|
+
update_all "clothes_machine_use_id = '5 to 9 loads'", "clothes_washer_use = '10 to 15 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
274
|
+
update_all "clothes_machine_use_id = '10 to 15 loads'", "clothes_washer_use = 'More than 15 loads' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
|
275
|
+
update_all "clothes_machine_use_id = NULL", "clothes_washer_use IS NULL AND clothes_dryer_use = 'Use it infrequently'"
|
276
|
+
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '1 load or less each week' AND clothes_dryer_use = 'Use it infrequently'"
|
277
|
+
update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '5 to 9 loads' AND clothes_dryer_use = 'Use it infrequently'"
|
278
|
+
update_all "clothes_machine_use_id = '2 to 4 loads'", "clothes_washer_use = '10 to 15 loads' AND clothes_dryer_use = 'Use it infrequently'"
|
279
|
+
update_all "clothes_machine_use_id = '5 to 9 loads'", "clothes_washer_use = 'More than 15 loads' AND clothes_dryer_use = 'Use it infrequently'"
|
280
|
+
end
|
281
|
+
|
257
282
|
# FIXME add precalc bathrooms per https://github.com/brighterplanet/cm1/commit/77df97c50311f3c59aad891f018bf3d487afeb98
|
258
283
|
end
|
259
284
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: earth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seamus Abshere
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-09-20 00:00:00 -
|
20
|
+
date: 2010-09-20 00:00:00 -05:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
31
|
+
hash: 299253624
|
32
32
|
segments:
|
33
33
|
- 3
|
34
34
|
- 0
|