earth 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -5
- data/README.markdown +0 -8
- data/Rakefile +14 -10
- data/bin/earth_tester.rb +12 -12
- data/earth.gemspec +2 -1
- data/features/automobile_make_fleet_year.feature +9 -19
- data/features/automobile_make_model_year.feature +4 -4
- data/features/support/env.rb +11 -7
- data/features/support/imports/automobile_make_fleet_year_bad.csv +1 -1
- data/features/support/imports/automobile_make_fleet_year_good.csv +1 -1
- data/features/support/imports/automobile_make_model_year_bad.csv +1 -1
- data/features/support/imports/automobile_make_model_year_good.csv +1 -1
- data/lib/earth/air/aircraft/data_miner.rb +63 -15
- data/lib/earth/air/aircraft.rb +0 -11
- data/lib/earth/air/aircraft_class/data_miner.rb +0 -13
- data/lib/earth/air/aircraft_class.rb +12 -3
- data/lib/earth/air/aircraft_fuel_use_equation/data_miner.rb +0 -13
- data/lib/earth/air/aircraft_fuel_use_equation.rb +12 -3
- data/lib/earth/air/airline/data_miner.rb +0 -7
- data/lib/earth/air/airline.rb +6 -3
- data/lib/earth/air/airport/data_miner.rb +5 -14
- data/lib/earth/air/airport.rb +9 -7
- data/lib/earth/air/bts_aircraft/data_miner.rb +0 -5
- data/lib/earth/air/bts_aircraft.rb +3 -3
- data/lib/earth/air/data_miner.rb +2 -3
- data/lib/earth/air/flight_distance_class/data_miner.rb +0 -6
- data/lib/earth/air/flight_distance_class.rb +4 -3
- data/lib/earth/air/flight_seat_class/data_miner.rb +0 -7
- data/lib/earth/air/flight_seat_class.rb +6 -3
- data/lib/earth/air/flight_segment/data_miner.rb +30 -112
- data/lib/earth/air/flight_segment.rb +47 -13
- data/lib/earth/air.rb +2 -1
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +1 -25
- data/lib/earth/automobile/automobile_fuel.rb +24 -8
- data/lib/earth/automobile/automobile_make/data_miner.rb +3 -16
- data/lib/earth/automobile/automobile_make.rb +5 -3
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +16 -30
- data/lib/earth/automobile/automobile_make_fleet_year.rb +10 -7
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +1 -11
- data/lib/earth/automobile/automobile_make_model.rb +9 -7
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +4 -17
- data/lib/earth/automobile/automobile_make_model_year.rb +11 -6
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +37 -65
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +36 -6
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +3 -15
- data/lib/earth/automobile/automobile_make_year.rb +8 -7
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +0 -15
- data/lib/earth/automobile/automobile_size_class.rb +13 -2
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -11
- data/lib/earth/automobile/automobile_size_class_year.rb +10 -3
- data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +0 -12
- data/lib/earth/automobile/automobile_type_fuel_age.rb +10 -2
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +0 -11
- data/lib/earth/automobile/automobile_type_fuel_control.rb +9 -3
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -17
- data/lib/earth/automobile/automobile_type_fuel_year.rb +14 -6
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +0 -13
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +12 -7
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +0 -11
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +9 -6
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +0 -10
- data/lib/earth/automobile/automobile_type_year.rb +9 -3
- data/lib/earth/bus/bus_class/data_miner.rb +0 -29
- data/lib/earth/bus/bus_class.rb +27 -2
- data/lib/earth/bus/bus_fuel/data_miner.rb +1 -16
- data/lib/earth/bus/bus_fuel.rb +15 -8
- data/lib/earth/bus/bus_fuel_control/data_miner.rb +0 -10
- data/lib/earth/bus/bus_fuel_control.rb +8 -3
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -10
- data/lib/earth/bus/bus_fuel_year_control.rb +8 -7
- data/lib/earth/bus/data_miner.rb +2 -0
- data/lib/earth/bus.rb +2 -0
- data/lib/earth/computation/computation_carrier/data_miner.rb +0 -5
- data/lib/earth/computation/computation_carrier.rb +3 -2
- data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +0 -8
- data/lib/earth/computation/computation_carrier_instance_class.rb +6 -6
- data/lib/earth/computation/computation_carrier_region/data_miner.rb +0 -7
- data/lib/earth/computation/computation_carrier_region.rb +6 -7
- data/lib/earth/computation/data_miner.rb +2 -0
- data/lib/earth/computation.rb +2 -0
- data/lib/earth/diet/diet_class/data_miner.rb +0 -16
- data/lib/earth/diet/diet_class.rb +16 -4
- data/lib/earth/diet/food_group/data_miner.rb +0 -9
- data/lib/earth/diet/food_group.rb +7 -2
- data/lib/earth/fuel/fuel/data_miner.rb +0 -16
- data/lib/earth/fuel/fuel.rb +14 -2
- data/lib/earth/fuel/fuel_price/data_miner.rb +0 -6
- data/lib/earth/fuel/fuel_price.rb +4 -6
- data/lib/earth/fuel/fuel_type/data_miner.rb +0 -14
- data/lib/earth/fuel/fuel_type.rb +14 -4
- data/lib/earth/fuel/fuel_year/data_miner.rb +0 -16
- data/lib/earth/fuel/fuel_year.rb +14 -2
- data/lib/earth/fuel/greenhouse_gas/data_miner.rb +0 -9
- data/lib/earth/fuel/greenhouse_gas.rb +10 -5
- data/lib/earth/hospitality/lodging_class/data_miner.rb +0 -12
- data/lib/earth/hospitality/lodging_class.rb +10 -2
- data/lib/earth/industry/data_miner.rb +0 -0
- data/lib/earth/industry/industry.rb +3 -10
- data/lib/earth/industry/industry_product.rb +6 -13
- data/lib/earth/industry/industry_product_line.rb +5 -12
- data/lib/earth/industry/industry_sector.rb +5 -12
- data/lib/earth/industry/merchant.rb +4 -11
- data/lib/earth/industry/merchant_category.rb +3 -10
- data/lib/earth/industry/merchant_category_industry.rb +5 -12
- data/lib/earth/industry/product_line.rb +5 -12
- data/lib/earth/industry/product_line_industry_product.rb +5 -12
- data/lib/earth/industry/sector.rb +5 -12
- data/lib/earth/locality/census_division/data_miner.rb +0 -23
- data/lib/earth/locality/census_division.rb +21 -6
- data/lib/earth/locality/census_region/data_miner.rb +0 -5
- data/lib/earth/locality/census_region.rb +3 -2
- data/lib/earth/locality/climate_division/data_miner.rb +0 -7
- data/lib/earth/locality/climate_division.rb +5 -7
- data/lib/earth/locality/country/data_miner.rb +16 -29
- data/lib/earth/locality/country.rb +15 -4
- data/lib/earth/locality/data_miner.rb +3 -0
- data/lib/earth/locality/egrid_region/data_miner.rb +0 -5
- data/lib/earth/locality/egrid_region.rb +5 -8
- data/lib/earth/locality/egrid_subregion/data_miner.rb +1 -20
- data/lib/earth/locality/egrid_subregion.rb +17 -6
- data/lib/earth/locality/petroleum_administration_for_defense_district/data_miner.rb +4 -13
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +8 -4
- data/lib/earth/locality/state/data_miner.rb +0 -8
- data/lib/earth/locality/state.rb +6 -7
- data/lib/earth/locality/urbanity/data_miner.rb +0 -4
- data/lib/earth/locality/urbanity.rb +2 -2
- data/lib/earth/locality/zip_code/data_miner.rb +0 -10
- data/lib/earth/locality/zip_code.rb +8 -6
- data/lib/earth/locality.rb +3 -0
- data/lib/earth/pet/breed/data_miner.rb +0 -7
- data/lib/earth/pet/breed.rb +5 -6
- data/lib/earth/pet/breed_gender/data_miner.rb +0 -8
- data/lib/earth/pet/breed_gender.rb +6 -6
- data/lib/earth/pet/gender/data_miner.rb +0 -3
- data/lib/earth/pet/gender.rb +2 -2
- data/lib/earth/pet/species/data_miner.rb +0 -17
- data/lib/earth/pet/species.rb +17 -4
- data/lib/earth/rail/rail_class/data_miner.rb +0 -14
- data/lib/earth/rail/rail_class.rb +12 -3
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +0 -6
- data/lib/earth/residence/air_conditioner_use.rb +5 -3
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +0 -6
- data/lib/earth/residence/clothes_machine_use.rb +4 -2
- data/lib/earth/residence/data_miner.rb +2 -0
- data/lib/earth/residence/dishwasher_use/data_miner.rb +0 -6
- data/lib/earth/residence/dishwasher_use.rb +5 -3
- data/lib/earth/residence/residence_appliance/data_miner.rb +0 -6
- data/lib/earth/residence/residence_appliance.rb +4 -2
- data/lib/earth/residence/residence_class/data_miner.rb +0 -4
- data/lib/earth/residence/residence_class.rb +2 -2
- data/lib/earth/residence/residence_fuel_price/data_miner.rb +0 -14
- data/lib/earth/residence/residence_fuel_price.rb +12 -7
- data/lib/earth/residence/residence_fuel_type/data_miner.rb +0 -8
- data/lib/earth/residence/residence_fuel_type.rb +6 -2
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +0 -94
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +92 -6
- data/lib/earth/residence.rb +2 -0
- data/lib/earth/shipping/carrier/data_miner.rb +0 -10
- data/lib/earth/shipping/carrier.rb +8 -2
- data/lib/earth/shipping/carrier_mode/data_miner.rb +0 -10
- data/lib/earth/shipping/carrier_mode.rb +9 -3
- data/lib/earth/shipping/shipment_mode/data_miner.rb +0 -7
- data/lib/earth/shipping/shipment_mode.rb +5 -2
- data/lib/earth/version.rb +1 -1
- data/lib/earth.rb +92 -84
- data/spec/earth/air/aircraft_spec.rb +1 -1
- data/spec/earth_spec.rb +15 -15
- data/spec/spec_helper.rb +12 -9
- metadata +175 -171
- data/lib/earth/active_record_ext.rb +0 -9
- data/lib/earth/air/aircraft_manufacturer/data_miner.rb +0 -21
- data/lib/earth/air/aircraft_manufacturer.rb +0 -7
- data/lib/earth/base.rb +0 -7
@@ -1,13 +1,5 @@
|
|
1
1
|
State.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'postal_abbreviation'
|
5
|
-
integer 'fips_code'
|
6
|
-
string 'name'
|
7
|
-
string 'census_division_number'
|
8
|
-
string 'petroleum_administration_for_defense_district_code'
|
9
|
-
end
|
10
|
-
|
11
3
|
# state names, ansi codes, and postal abbreviations
|
12
4
|
import 'the U.S. Census State ANSI Code file',
|
13
5
|
:url => 'http://www.census.gov/geo/www/ansi/state.txt',
|
data/lib/earth/locality/state.rb
CHANGED
@@ -11,12 +11,11 @@ class State < ActiveRecord::Base
|
|
11
11
|
Country.united_states
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
create_table do
|
15
|
+
string 'postal_abbreviation'
|
16
|
+
integer 'fips_code'
|
17
|
+
string 'name'
|
18
|
+
string 'census_division_number'
|
19
|
+
string 'petroleum_administration_for_defense_district_code'
|
20
20
|
end
|
21
|
-
|
22
21
|
end
|
@@ -7,16 +7,6 @@ ZipCode.class_eval do
|
|
7
7
|
# end
|
8
8
|
|
9
9
|
data_miner do
|
10
|
-
schema Earth.database_options do
|
11
|
-
string 'name'
|
12
|
-
string 'state_postal_abbreviation'
|
13
|
-
string 'description'
|
14
|
-
string 'latitude'
|
15
|
-
string 'longitude'
|
16
|
-
string 'egrid_subregion_abbreviation'
|
17
|
-
string 'climate_division_name'
|
18
|
-
end
|
19
|
-
|
20
10
|
import 'the Mapping Hacks zipcode database',
|
21
11
|
:url => 'http://mappinghacks.com/data/zipcode.zip',
|
22
12
|
:filename => 'zipcode.csv' do
|
@@ -11,11 +11,13 @@ class ZipCode < ActiveRecord::Base
|
|
11
11
|
:lat_column_name => :latitude,
|
12
12
|
:lng_column_name => :longitude
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
create_table do
|
15
|
+
string 'name'
|
16
|
+
string 'state_postal_abbreviation'
|
17
|
+
string 'description'
|
18
|
+
string 'latitude'
|
19
|
+
string 'longitude'
|
20
|
+
string 'egrid_subregion_abbreviation'
|
21
|
+
string 'climate_division_name'
|
20
22
|
end
|
21
23
|
end
|
data/lib/earth/locality.rb
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
Breed.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'species_name'
|
6
|
-
float 'weight'
|
7
|
-
string 'weight_units'
|
8
|
-
end
|
9
|
-
|
10
3
|
import "Brighter Planet's list of cat and dog breeds",
|
11
4
|
:url => 'http://static.brighterplanet.com/science/data/consumables/pets/breed_genders.csv',
|
12
5
|
:encoding => 'ISO-8859-1',
|
data/lib/earth/pet/breed.rb
CHANGED
@@ -4,11 +4,10 @@ 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
|
7
|
+
create_table do
|
8
|
+
string 'name'
|
9
|
+
string 'species_name'
|
10
|
+
float 'weight'
|
11
|
+
string 'weight_units'
|
13
12
|
end
|
14
13
|
end
|
@@ -1,13 +1,5 @@
|
|
1
1
|
BreedGender.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'breed_name'
|
6
|
-
string 'gender_name'
|
7
|
-
float 'weight'
|
8
|
-
string 'weight_units'
|
9
|
-
end
|
10
|
-
|
11
3
|
import "Brighter Planet's list of cat and dog breeds, genders, and weights",
|
12
4
|
:url => 'http://static.brighterplanet.com/science/data/consumables/pets/breed_genders.csv',
|
13
5
|
:encoding => 'ISO-8859-1',
|
@@ -4,11 +4,11 @@ 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
|
-
|
7
|
+
create_table do
|
8
|
+
string 'name'
|
9
|
+
string 'breed_name'
|
10
|
+
string 'gender_name'
|
11
|
+
float 'weight'
|
12
|
+
string 'weight_units'
|
13
13
|
end
|
14
14
|
end
|
@@ -1,8 +1,5 @@
|
|
1
1
|
Gender.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
end
|
6
3
|
import "a list of genders derived from pet breed genders",
|
7
4
|
:url => 'http://static.brighterplanet.com/science/data/consumables/pets/breed_genders.csv',
|
8
5
|
:select => lambda { |row| row['gender'].present? } do
|
data/lib/earth/pet/gender.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
1
|
Species.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
integer 'population'
|
6
|
-
float 'diet_emission_intensity'
|
7
|
-
string 'diet_emission_intensity_units'
|
8
|
-
float 'weight'
|
9
|
-
string 'weight_units'
|
10
|
-
float 'marginal_dietary_requirement'
|
11
|
-
string 'marginal_dietary_requirement_units'
|
12
|
-
float 'fixed_dietary_requirement'
|
13
|
-
string 'fixed_dietary_requirement_units'
|
14
|
-
float 'minimum_weight'
|
15
|
-
string 'minimum_weight_units'
|
16
|
-
float 'maximum_weight'
|
17
|
-
string 'maximum_weight_units'
|
18
|
-
end
|
19
|
-
|
20
3
|
process "Define some unit conversions" do
|
21
4
|
# 1 (kilocalories per pound) = 9 224.14105 joules per kilogram
|
22
5
|
Conversions.register :kilocalories_per_pound, :joules_per_kilogram, 9_224.14105
|
data/lib/earth/pet/species.rb
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
class Species < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
+
create_table do
|
5
|
+
string 'name'
|
6
|
+
integer 'population'
|
7
|
+
float 'diet_emission_intensity'
|
8
|
+
string 'diet_emission_intensity_units'
|
9
|
+
float 'weight'
|
10
|
+
string 'weight_units'
|
11
|
+
float 'marginal_dietary_requirement'
|
12
|
+
string 'marginal_dietary_requirement_units'
|
13
|
+
float 'fixed_dietary_requirement'
|
14
|
+
string 'fixed_dietary_requirement_units'
|
15
|
+
float 'minimum_weight'
|
16
|
+
string 'minimum_weight_units'
|
17
|
+
float 'maximum_weight'
|
18
|
+
string 'maximum_weight_units'
|
19
|
+
end
|
20
|
+
|
4
21
|
scope :thoroughly_researched, :conditions => 'marginal_dietary_requirement IS NOT NULL'
|
5
22
|
|
6
23
|
falls_back_on :diet_emission_intensity => lambda { weighted_average :diet_emission_intensity, :weighted_by => :population }, # kg CO2 / joule
|
@@ -8,10 +25,6 @@ class Species < ActiveRecord::Base
|
|
8
25
|
:fixed_dietary_requirement => 0, # force a zero intercept to be respectful of our tiny tiny animal friends
|
9
26
|
:weight => lambda { weighted_average :weight, :weighted_by => :population } # kg
|
10
27
|
|
11
|
-
data_miner do
|
12
|
-
tap "Brighter Planet's species data", Earth.taps_server
|
13
|
-
end
|
14
|
-
|
15
28
|
class << self
|
16
29
|
def [](name)
|
17
30
|
find_by_name name.to_s
|
@@ -1,19 +1,5 @@
|
|
1
1
|
RailClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'description'
|
6
|
-
float 'passengers'
|
7
|
-
float 'distance'
|
8
|
-
string 'distance_units'
|
9
|
-
float 'speed'
|
10
|
-
string 'speed_units'
|
11
|
-
float 'electricity_intensity'
|
12
|
-
string 'electricity_intensity_units'
|
13
|
-
float 'diesel_intensity'
|
14
|
-
string 'diesel_intensity_units'
|
15
|
-
end
|
16
|
-
|
17
3
|
process "Define some unit conversions" do
|
18
4
|
Conversions.register :gallons_per_mile, :litres_per_kilometre, 2.35214583
|
19
5
|
end
|
@@ -1,7 +1,16 @@
|
|
1
1
|
class RailClass < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
create_table do
|
4
|
+
string 'name'
|
5
|
+
string 'description'
|
6
|
+
float 'passengers'
|
7
|
+
float 'distance'
|
8
|
+
string 'distance_units'
|
9
|
+
float 'speed'
|
10
|
+
string 'speed_units'
|
11
|
+
float 'electricity_intensity'
|
12
|
+
string 'electricity_intensity_units'
|
13
|
+
float 'diesel_intensity'
|
14
|
+
string 'diesel_intensity_units'
|
6
15
|
end
|
7
16
|
end
|
@@ -1,11 +1,5 @@
|
|
1
1
|
AirConditionerUse.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema do
|
4
|
-
string 'name'
|
5
|
-
float 'fugitive_emission'
|
6
|
-
string 'fugitive_emission_units'
|
7
|
-
end
|
8
|
-
|
9
3
|
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
4
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
5
|
end
|
@@ -5,8 +5,10 @@ class AirConditionerUse < ActiveRecord::Base
|
|
5
5
|
|
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
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
create_table do
|
10
|
+
string 'name'
|
11
|
+
float 'fugitive_emission'
|
12
|
+
string 'fugitive_emission_units'
|
11
13
|
end
|
12
14
|
end
|
@@ -1,11 +1,5 @@
|
|
1
1
|
ClothesMachineUse.class_eval do
|
2
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
3
|
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
4
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
5
|
end
|
@@ -3,7 +3,9 @@ class ClothesMachineUse < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :residential_energy_consumption_survey_responses
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
float 'annual_energy_from_electricity_for_clothes_driers'
|
9
|
+
string 'annual_energy_from_electricity_for_clothes_driers_units'
|
8
10
|
end
|
9
11
|
end
|
@@ -6,3 +6,5 @@ require 'earth/residence/residence_class/data_miner'
|
|
6
6
|
require 'earth/residence/residence_fuel_price/data_miner'
|
7
7
|
require 'earth/residence/residence_fuel_type/data_miner'
|
8
8
|
require 'earth/residence/residential_energy_consumption_survey_response/data_miner'
|
9
|
+
|
10
|
+
require 'earth/locality/data_miner'
|
@@ -1,11 +1,5 @@
|
|
1
1
|
DishwasherUse.class_eval do
|
2
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
3
|
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
4
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
5
|
end
|
@@ -2,8 +2,10 @@ class DishwasherUse < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
has_many :residential_energy_consumption_survey_responses
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
float 'annual_energy_from_electricity_for_dishwashers'
|
9
|
+
string 'annual_energy_from_electricity_for_dishwashers_units'
|
8
10
|
end
|
9
11
|
end
|
@@ -1,11 +1,5 @@
|
|
1
1
|
ResidenceAppliance.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'annual_energy_from_electricity'
|
6
|
-
string 'annual_energy_from_electricity_units'
|
7
|
-
end
|
8
|
-
|
9
3
|
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
4
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
5
|
end
|
@@ -10,7 +10,9 @@ class ResidenceAppliance < ActiveRecord::Base
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
create_table do
|
14
|
+
string 'name'
|
15
|
+
float 'annual_energy_from_electricity'
|
16
|
+
string 'annual_energy_from_electricity_units'
|
15
17
|
end
|
16
18
|
end
|
@@ -102,20 +102,6 @@ ResidenceFuelPrice.class_eval do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
data_miner do
|
105
|
-
schema Earth.database_options do
|
106
|
-
string 'row_hash'
|
107
|
-
string 'residence_fuel_type_name'
|
108
|
-
integer 'year'
|
109
|
-
integer 'month'
|
110
|
-
float 'price'
|
111
|
-
string 'price_units'
|
112
|
-
string 'price_description'
|
113
|
-
string 'locatable_id'
|
114
|
-
string 'locatable_type'
|
115
|
-
index ['price', 'residence_fuel_type_name', 'month', 'year', 'locatable_type', 'locatable_id']
|
116
|
-
index ['price', 'residence_fuel_type_name']
|
117
|
-
end
|
118
|
-
|
119
105
|
process "Define some unit conversions" do
|
120
106
|
Conversions.register :dollars, :cents, 100
|
121
107
|
Conversions.register :cubic_feet, :cubic_metres, 0.0283168466 # TODO conversions gem has 'cubic_metres'
|
@@ -7,12 +7,17 @@ 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
|
-
|
10
|
+
create_table do
|
11
|
+
string 'row_hash'
|
12
|
+
string 'residence_fuel_type_name'
|
13
|
+
integer 'year'
|
14
|
+
integer 'month'
|
15
|
+
float 'price'
|
16
|
+
string 'price_units'
|
17
|
+
string 'price_description'
|
18
|
+
string 'locatable_id'
|
19
|
+
string 'locatable_type'
|
20
|
+
index ['price', 'residence_fuel_type_name', 'month', 'year', 'locatable_type', 'locatable_id']
|
21
|
+
index ['price', 'residence_fuel_type_name']
|
16
22
|
end
|
17
|
-
|
18
23
|
end
|
@@ -1,13 +1,5 @@
|
|
1
1
|
ResidenceFuelType.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'emission_factor'
|
6
|
-
string 'emission_factor_units'
|
7
|
-
# float 'energy_content'
|
8
|
-
# string 'energy_content_units'
|
9
|
-
end
|
10
|
-
|
11
3
|
import "a list of residential fuels and their emissions factors",
|
12
4
|
:url => 'http://spreadsheets.google.com/pub?key=rukxnmuhhsOsrztTrUaFCXQ&gid=0&output=csv' do
|
13
5
|
key 'name'
|
@@ -3,8 +3,12 @@ class ResidenceFuelType < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :prices, :class_name => 'ResidenceFuelPrice', :foreign_key => 'residence_fuel_type_name'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
float 'emission_factor'
|
9
|
+
string 'emission_factor_units'
|
10
|
+
# float 'energy_content'
|
11
|
+
# string 'energy_content_units'
|
8
12
|
end
|
9
13
|
|
10
14
|
def price_per_unit(relaxations = [])
|
@@ -1,99 +1,5 @@
|
|
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
|
4
|
-
schema Earth.database_options do
|
5
|
-
integer 'id'
|
6
|
-
string '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'
|
25
|
-
float 'annual_energy_from_fuel_oil_for_heating_space'
|
26
|
-
string 'annual_energy_from_fuel_oil_for_heating_space_units'
|
27
|
-
float 'annual_energy_from_fuel_oil_for_heating_water'
|
28
|
-
string 'annual_energy_from_fuel_oil_for_heating_water_units'
|
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'
|
33
|
-
float 'annual_energy_from_natural_gas_for_heating_space'
|
34
|
-
string 'annual_energy_from_natural_gas_for_heating_space_units'
|
35
|
-
float 'annual_energy_from_natural_gas_for_heating_water'
|
36
|
-
string 'annual_energy_from_natural_gas_for_heating_water_units'
|
37
|
-
float 'annual_energy_from_propane_for_appliances'
|
38
|
-
string 'annual_energy_from_propane_for_appliances_units'
|
39
|
-
float 'annual_energy_from_propane_for_heating_space'
|
40
|
-
string 'annual_energy_from_propane_for_heating_space_units'
|
41
|
-
float 'annual_energy_from_propane_for_heating_water'
|
42
|
-
string 'annual_energy_from_propane_for_heating_water_units'
|
43
|
-
float 'annual_energy_from_wood'
|
44
|
-
string 'annual_energy_from_wood_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
|
-
string 'clothes_machine_use_id'
|
57
|
-
string 'clothes_washer_use'
|
58
|
-
string 'construction_period'
|
59
|
-
date 'construction_year'
|
60
|
-
integer 'cooling_degree_days'
|
61
|
-
string 'cooling_degree_days_units'
|
62
|
-
boolean 'detached_1car_garage'
|
63
|
-
boolean 'detached_2car_garage'
|
64
|
-
boolean 'detached_3car_garage'
|
65
|
-
string 'dishwasher_use_id'
|
66
|
-
integer 'efficient_lights_on_1_to_4_hours'
|
67
|
-
integer 'efficient_lights_on_4_to_12_hours'
|
68
|
-
integer 'efficient_lights_on_over_12_hours'
|
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'
|
83
|
-
integer 'outdoor_all_night_gas_lights'
|
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'
|
95
|
-
end
|
96
|
-
|
97
3
|
process "Define some unit conversions" do
|
98
4
|
Conversions.register :kbtus, :joules, 1_000.0 * 1_055.05585
|
99
5
|
Conversions.register :square_feet, :square_metres, 0.09290304
|