earth 0.12.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/Gemfile +0 -5
- data/README.markdown +32 -19
- data/Rakefile +4 -0
- data/bin/earth_tester.rb +66 -54
- data/earth.gemspec +6 -3
- data/lib/earth.rb +67 -114
- data/lib/earth/air.rb +1 -1
- data/lib/earth/air/aircraft.rb +37 -21
- data/lib/earth/air/aircraft/data_miner.rb +0 -4
- data/lib/earth/air/airline.rb +19 -5
- data/lib/earth/air/airline/data_miner.rb +0 -4
- data/lib/earth/air/airport.rb +23 -9
- data/lib/earth/air/airport/data_miner.rb +1 -5
- data/lib/earth/air/bts_aircraft.rb +14 -2
- data/lib/earth/air/flight_distance_class.rb +19 -7
- data/lib/earth/air/flight_distance_class_seat_class.rb +21 -4
- data/lib/earth/air/flight_seat_class.rb +13 -1
- data/lib/earth/air/flight_seat_class/data_miner.rb +2 -0
- data/lib/earth/air/flight_segment.rb +64 -59
- data/lib/earth/air/flight_segment/data_miner.rb +4 -5
- data/lib/earth/all.rb +1 -1
- data/lib/earth/automobile.rb +1 -1
- data/lib/earth/automobile/automobile_activity_year.rb +17 -3
- data/lib/earth/automobile/automobile_activity_year/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_activity_year_type.rb +21 -7
- data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +20 -8
- data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_fuel.rb +37 -23
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +3 -5
- data/lib/earth/automobile/automobile_make.rb +17 -3
- data/lib/earth/automobile/automobile_make/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_make_model.rb +29 -14
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +2 -5
- data/lib/earth/automobile/automobile_make_model_year.rb +31 -18
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +3 -4
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +43 -31
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_make_year.rb +18 -7
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +4 -4
- data/lib/earth/automobile/automobile_make_year_fleet.rb +19 -7
- data/lib/earth/automobile/automobile_make_year_fleet/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_model.rb +13 -1
- data/lib/earth/automobile/automobile_model/data_miner.rb +2 -4
- data/lib/earth/automobile/automobile_size_class.rb +24 -10
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_type_fuel.rb +26 -12
- data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +2 -4
- data/lib/earth/automobile/automobile_type_fuel_control.rb +20 -8
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel_year.rb +25 -11
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +2 -4
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +21 -7
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +0 -4
- data/lib/earth/automobile/automobile_year.rb +13 -1
- data/lib/earth/automobile/automobile_year/data_miner.rb +2 -0
- data/lib/earth/bus.rb +1 -1
- data/lib/earth/bus/bus_class.rb +38 -25
- data/lib/earth/bus/bus_class/data_miner.rb +0 -1
- data/lib/earth/bus/bus_fuel.rb +27 -13
- data/lib/earth/bus/bus_fuel/data_miner.rb +5 -1
- data/lib/earth/bus/bus_fuel_control.rb +19 -7
- data/lib/earth/bus/bus_fuel_control/data_miner.rb +0 -1
- data/lib/earth/bus/bus_fuel_year_control.rb +20 -7
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +2 -1
- data/lib/earth/computation.rb +1 -1
- data/lib/earth/computation/computation_carrier.rb +16 -3
- data/lib/earth/computation/computation_carrier/data_miner.rb +0 -1
- data/lib/earth/computation/computation_carrier_instance_class.rb +21 -6
- data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +0 -1
- data/lib/earth/computation/computation_carrier_region.rb +18 -5
- data/lib/earth/computation/computation_carrier_region/data_miner.rb +0 -1
- data/lib/earth/diet.rb +1 -1
- data/lib/earth/diet/diet_class.rb +25 -13
- data/lib/earth/diet/food_group.rb +18 -7
- data/lib/earth/electricity.rb +1 -1
- data/lib/earth/electricity/electric_market.rb +17 -5
- data/lib/earth/electricity/electric_market/data_miner.rb +0 -2
- data/lib/earth/electricity/electric_utility.rb +22 -7
- data/lib/earth/electricity/electric_utility/data_miner.rb +1 -1
- data/lib/earth/electricity/green_button_adoption.rb +15 -3
- data/lib/earth/fuel.rb +1 -1
- data/lib/earth/fuel/fuel.rb +32 -19
- data/lib/earth/fuel/fuel/data_miner.rb +2 -4
- data/lib/earth/fuel/fuel_price.rb +17 -3
- data/lib/earth/fuel/fuel_type.rb +23 -12
- data/lib/earth/fuel/fuel_year.rb +27 -13
- data/lib/earth/fuel/greenhouse_gas.rb +18 -6
- data/lib/earth/hospitality.rb +1 -1
- data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response.rb +68 -56
- data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +0 -4
- data/lib/earth/hospitality/lodging_class.rb +13 -1
- data/lib/earth/industry.rb +1 -1
- data/lib/earth/industry/cbecs_energy_intensity.rb +43 -32
- data/lib/earth/industry/cbecs_energy_intensity/data_miner.rb +0 -1
- data/lib/earth/industry/industry.rb +20 -2
- data/lib/earth/industry/industry/data_miner.rb +0 -4
- data/lib/earth/industry/industry_product.rb +20 -6
- data/lib/earth/industry/industry_product_line.rb +19 -5
- data/lib/earth/industry/industry_sector.rb +19 -6
- data/lib/earth/industry/mecs_energy.rb +34 -22
- data/lib/earth/industry/mecs_ratio.rb +17 -6
- data/lib/earth/industry/mecs_ratio/data_miner.rb +1 -1
- data/lib/earth/industry/merchant_category.rb +17 -2
- data/lib/earth/industry/merchant_category/data_miner.rb +0 -4
- data/lib/earth/industry/merchant_category_industry.rb +19 -4
- data/lib/earth/industry/naics_2002.rb +20 -3
- data/lib/earth/industry/naics_2002_naics_2007_concordance.rb +19 -4
- data/lib/earth/industry/naics_2002_sic_1987_concordance.rb +19 -4
- data/lib/earth/industry/naics_2007.rb +17 -2
- data/lib/earth/industry/product_line.rb +20 -5
- data/lib/earth/industry/product_line_industry_product.rb +19 -5
- data/lib/earth/industry/sector.rb +18 -5
- data/lib/earth/industry/sic_1987.rb +17 -2
- data/lib/earth/loader.rb +47 -0
- data/lib/earth/locality.rb +1 -1
- data/lib/earth/locality/census_division.rb +32 -13
- data/lib/earth/locality/census_division/data_miner.rb +0 -1
- data/lib/earth/locality/census_region.rb +18 -5
- data/lib/earth/locality/climate_division.rb +21 -6
- data/lib/earth/locality/country.rb +68 -56
- data/lib/earth/locality/country/data_miner.rb +8 -8
- data/lib/earth/locality/egrid_country.rb +22 -10
- data/lib/earth/locality/egrid_region.rb +25 -10
- data/lib/earth/locality/egrid_region/data_miner.rb +0 -4
- data/lib/earth/locality/egrid_subregion.rb +31 -16
- data/lib/earth/locality/egrid_subregion/data_miner.rb +7 -6
- data/lib/earth/locality/electricity_mix.rb +27 -13
- data/lib/earth/locality/electricity_mix/data_miner.rb +8 -8
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +17 -5
- data/lib/earth/locality/state.rb +36 -16
- data/lib/earth/locality/state/data_miner.rb +0 -4
- data/lib/earth/locality/zip_code.rb +34 -15
- data/lib/earth/locality/zip_code/data_miner.rb +0 -4
- data/lib/earth/model.rb +90 -0
- data/lib/earth/pet.rb +1 -1
- data/lib/earth/pet/breed.rb +19 -4
- data/lib/earth/pet/breed_gender.rb +20 -5
- data/lib/earth/pet/gender.rb +15 -1
- data/lib/earth/pet/species.rb +30 -14
- data/lib/earth/rail.rb +1 -1
- data/lib/earth/rail/country_rail_class.rb +26 -15
- data/lib/earth/rail/country_rail_class/data_miner.rb +0 -1
- data/lib/earth/rail/country_rail_traction.rb +21 -11
- data/lib/earth/rail/country_rail_traction/data_miner.rb +2 -2
- data/lib/earth/rail/country_rail_traction_class.rb +22 -12
- data/lib/earth/rail/country_rail_traction_class/data_miner.rb +2 -2
- data/lib/earth/rail/national_transit_database_company.rb +20 -6
- data/lib/earth/rail/national_transit_database_company/data_miner.rb +0 -1
- data/lib/earth/rail/national_transit_database_mode.rb +15 -3
- data/lib/earth/rail/national_transit_database_record.rb +45 -31
- data/lib/earth/rail/national_transit_database_record/data_miner.rb +0 -1
- data/lib/earth/rail/rail_class.rb +13 -1
- data/lib/earth/rail/rail_company.rb +34 -22
- data/lib/earth/rail/rail_company/data_miner.rb +7 -2
- data/lib/earth/rail/rail_company_traction.rb +21 -10
- data/lib/earth/rail/rail_company_traction/data_miner.rb +0 -1
- data/lib/earth/rail/rail_company_traction_class.rb +22 -11
- data/lib/earth/rail/rail_company_traction_class/data_miner.rb +0 -1
- data/lib/earth/rail/rail_fuel.rb +20 -7
- data/lib/earth/rail/rail_fuel/data_miner.rb +3 -1
- data/lib/earth/rail/rail_traction.rb +13 -1
- data/lib/earth/rail/rail_traction/data_miner.rb +5 -0
- data/lib/earth/residence.rb +1 -1
- data/lib/earth/residence/air_conditioner_use.rb +19 -3
- data/lib/earth/residence/clothes_machine_use.rb +17 -3
- data/lib/earth/residence/dishwasher_use.rb +17 -3
- data/lib/earth/residence/residence_appliance.rb +15 -3
- data/lib/earth/residence/residence_appliance/data_miner.rb +2 -0
- data/lib/earth/residence/residence_class.rb +15 -1
- data/lib/earth/residence/residence_fuel_price.rb +25 -12
- data/lib/earth/residence/residence_fuel_price/data_miner.rb +0 -1
- data/lib/earth/residence/residence_fuel_type.rb +17 -6
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +110 -91
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +0 -1
- data/lib/earth/residence/urbanity.rb +15 -1
- data/lib/earth/shipping.rb +1 -1
- data/lib/earth/shipping/carrier.rb +24 -8
- data/lib/earth/shipping/carrier_mode.rb +22 -7
- data/lib/earth/shipping/shipment_mode.rb +18 -4
- data/lib/earth/tasks.rb +62 -0
- data/lib/earth/version.rb +1 -1
- data/lib/earth/warnings.rb +12 -0
- data/spec/data_mining_spec.rb +31 -0
- data/spec/earth/air/aircraft_spec.rb +0 -10
- data/spec/earth/air/airline_spec.rb +1 -11
- data/spec/earth/air/airport_spec.rb +0 -10
- data/spec/earth/air/bts_aircraft_spec.rb +0 -10
- data/spec/earth/air/flight_distance_class_spec.rb +0 -10
- data/spec/earth/air/flight_segment_spec.rb +27 -10
- data/spec/earth/automobile/automobile_activity_year_spec.rb +0 -7
- data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +0 -7
- data/spec/earth/automobile/automobile_activity_year_type_spec.rb +0 -7
- data/spec/earth/automobile/automobile_fuel_spec.rb +0 -10
- data/spec/earth/automobile/automobile_make_model_spec.rb +0 -8
- data/spec/earth/automobile/automobile_make_model_year_spec.rb +0 -8
- data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +0 -8
- data/spec/earth/automobile/automobile_make_spec.rb +0 -11
- data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +0 -11
- data/spec/earth/automobile/automobile_make_year_spec.rb +0 -8
- data/spec/earth/automobile/automobile_model_spec.rb +0 -10
- data/spec/earth/automobile/automobile_size_class_spec.rb +0 -10
- data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +0 -7
- data/spec/earth/automobile/automobile_type_fuel_spec.rb +0 -10
- data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +0 -7
- data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +1 -8
- data/spec/earth/automobile/automobile_year_spec.rb +2 -11
- data/spec/earth/bus/bus_fuel_control_spec.rb +0 -10
- data/spec/earth/bus/bus_fuel_spec.rb +0 -10
- data/spec/earth/bus/bus_fuel_year_control_spec.rb +0 -10
- data/spec/earth/electricity/electric_market_spec.rb +0 -10
- data/spec/earth/electricity/electric_utility_spec.rb +0 -10
- data/spec/earth/electricity/green_button_adoption_spec.rb +0 -10
- data/spec/earth/fuel/fuel_spec.rb +1 -10
- data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +0 -10
- data/spec/earth/hospitality/lodging_class_spec.rb +0 -10
- data/spec/earth/industry/cbecs_energy_intensity_spec.rb +3 -11
- data/spec/earth/industry/industry_spec.rb +0 -10
- data/spec/earth/industry/mecs_energy_spec.rb +0 -9
- data/spec/earth/industry/mecs_ratio_spec.rb +0 -9
- data/spec/earth/industry/merchant_category_spec.rb +2 -7
- data/spec/earth/industry/naics_2002_naics_2007_concordance_spec.rb +1 -12
- data/spec/earth/industry/naics_2002_sic_1987_concordance_spec.rb +3 -13
- data/spec/earth/industry/naics_2002_spec.rb +0 -10
- data/spec/earth/industry/naics_2007_spec.rb +0 -10
- data/spec/earth/industry/sic_1987_spec.rb +0 -10
- data/spec/earth/locality/country_spec.rb +0 -10
- data/spec/earth/locality/egrid_country_spec.rb +0 -11
- data/spec/earth/locality/egrid_region_spec.rb +0 -10
- data/spec/earth/locality/egrid_subregion_spec.rb +0 -10
- data/spec/earth/locality/electricity_mix_spec.rb +0 -10
- data/spec/earth/locality/state_spec.rb +0 -10
- data/spec/earth/locality/zip_code_spec.rb +7 -15
- data/spec/earth/model_spec.rb +27 -0
- data/spec/earth/pet/species_spec.rb +1 -1
- data/spec/earth_spec.rb +1 -30
- data/spec/factories/airline.rb +10 -0
- data/spec/factories/airport.rb +12 -0
- data/spec/factories/flight_segment.rb +38 -0
- data/spec/spec_helper.rb +27 -36
- metadata +249 -223
- data/lib/earth/active_record_base_class_methods.rb +0 -25
- data/lib/earth/air/data_miner.rb +0 -3
- data/lib/earth/automobile/data_miner.rb +0 -3
- data/lib/earth/bus/data_miner.rb +0 -3
- data/lib/earth/computation/data_miner.rb +0 -3
- data/lib/earth/data_miner.rb +0 -3
- data/lib/earth/diet/data_miner.rb +0 -3
- data/lib/earth/fuel/data_miner.rb +0 -3
- data/lib/earth/hospitality/data_miner.rb +0 -3
- data/lib/earth/industry/data_miner.rb +0 -3
- data/lib/earth/locality/data_miner.rb +0 -3
- data/lib/earth/pet/data_miner.rb +0 -3
- data/lib/earth/rail/data_miner.rb +0 -3
- data/lib/earth/residence/data_miner.rb +0 -3
- data/lib/earth/shipping/data_miner.rb +0 -3
@@ -1,11 +1,25 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/residence/residential_energy_consumption_survey_response'
|
4
|
+
|
1
5
|
class DishwasherUse < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE dishwasher_uses
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
annual_energy_from_electricity_for_dishwashers FLOAT,
|
14
|
+
annual_energy_from_electricity_for_dishwashers_units CHARACTER VARYING(255)
|
15
|
+
);
|
16
|
+
|
17
|
+
EOS
|
18
|
+
|
2
19
|
self.primary_key = "name"
|
3
20
|
|
4
21
|
has_many :residential_energy_consumption_survey_responses
|
5
22
|
|
6
|
-
col :name
|
7
|
-
col :annual_energy_from_electricity_for_dishwashers, :type => :float
|
8
|
-
col :annual_energy_from_electricity_for_dishwashers_units
|
9
23
|
|
10
24
|
warn_unless_size 5
|
11
25
|
end
|
@@ -1,4 +1,19 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
1
3
|
class ResidenceAppliance < ActiveRecord::Base
|
4
|
+
extend Earth::Model
|
5
|
+
|
6
|
+
TABLE_STRUCTURE = <<-EOS
|
7
|
+
|
8
|
+
CREATE TABLE residence_appliances
|
9
|
+
(
|
10
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
11
|
+
annual_energy_from_electricity FLOAT,
|
12
|
+
annual_energy_from_electricity_units CHARACTER VARYING(255)
|
13
|
+
);
|
14
|
+
|
15
|
+
EOS
|
16
|
+
|
2
17
|
self.primary_key = "name"
|
3
18
|
|
4
19
|
class << self
|
@@ -10,9 +25,6 @@ class ResidenceAppliance < ActiveRecord::Base
|
|
10
25
|
end
|
11
26
|
end
|
12
27
|
|
13
|
-
col :name
|
14
|
-
col :annual_energy_from_electricity, :type => :float
|
15
|
-
col :annual_energy_from_electricity_units
|
16
28
|
|
17
29
|
warn_unless_size 2
|
18
30
|
end
|
@@ -1,4 +1,19 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/residence/residential_energy_consumption_survey_response'
|
4
|
+
|
1
5
|
class ResidenceClass < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE residence_classes
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY
|
13
|
+
);
|
14
|
+
|
15
|
+
EOS
|
16
|
+
|
2
17
|
self.primary_key = "name"
|
3
18
|
|
4
19
|
has_many :residential_energy_consumption_survey_responses
|
@@ -9,7 +24,6 @@ class ResidenceClass < ActiveRecord::Base
|
|
9
24
|
CLASSIFICATIONS.detect { |c| name.downcase.include? c }
|
10
25
|
end
|
11
26
|
|
12
|
-
col :name
|
13
27
|
|
14
28
|
warn_unless_size 5
|
15
29
|
end
|
@@ -1,21 +1,34 @@
|
|
1
|
-
require 'earth/
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/residence/residence_fuel_type'
|
4
|
+
|
2
5
|
class ResidenceFuelPrice < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE residence_fuel_prices
|
11
|
+
(
|
12
|
+
row_hash CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
residence_fuel_type_name CHARACTER VARYING(255),
|
14
|
+
year INTEGER,
|
15
|
+
month INTEGER,
|
16
|
+
price FLOAT,
|
17
|
+
price_units CHARACTER VARYING(255),
|
18
|
+
price_description CHARACTER VARYING(255),
|
19
|
+
locatable_id CHARACTER VARYING(255),
|
20
|
+
locatable_type CHARACTER VARYING(255)
|
21
|
+
);
|
22
|
+
CREATE INDEX index_residence_fuel_prices_on_price_and_residence_fu239358947 ON residence_fuel_prices (price, residence_fuel_type_name, month, year, locatable_type, locatable_id);
|
23
|
+
CREATE INDEX index_residence_fuel_prices_on_price_and_residence_fu1975072203 ON residence_fuel_prices (price, residence_fuel_type_name)
|
24
|
+
|
25
|
+
EOS
|
26
|
+
|
3
27
|
self.primary_key = "row_hash"
|
4
28
|
|
5
29
|
belongs_to :fuel, :class_name => 'ResidenceFuelType', :foreign_key => 'residence_fuel_type_name'
|
6
30
|
belongs_to :locatable, :polymorphic => true
|
7
31
|
|
8
|
-
col :row_hash
|
9
|
-
col :residence_fuel_type_name
|
10
|
-
col :year, :type => :integer
|
11
|
-
col :month, :type => :integer
|
12
|
-
col :price, :type => :float
|
13
|
-
col :price_units
|
14
|
-
col :price_description
|
15
|
-
col :locatable_id
|
16
|
-
col :locatable_type
|
17
|
-
add_index [:price, :residence_fuel_type_name, :month, :year, :locatable_type, :locatable_id]
|
18
|
-
add_index [:price, :residence_fuel_type_name]
|
19
32
|
|
20
33
|
warn_unless_size 13639
|
21
34
|
end
|
@@ -1,14 +1,25 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/residence/residence_fuel_price'
|
4
|
+
|
1
5
|
class ResidenceFuelType < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE residence_fuel_types
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
emission_factor FLOAT,
|
14
|
+
emission_factor_units CHARACTER VARYING(255)
|
15
|
+
);
|
16
|
+
|
17
|
+
EOS
|
18
|
+
|
2
19
|
self.primary_key = "name"
|
3
20
|
|
4
21
|
has_many :prices, :class_name => 'ResidenceFuelPrice', :foreign_key => 'residence_fuel_type_name'
|
5
22
|
|
6
|
-
col :name
|
7
|
-
col :emission_factor, :type => :float
|
8
|
-
col :emission_factor_units
|
9
|
-
# col :energy_content, :type => :float
|
10
|
-
# col :energy_content_units
|
11
|
-
|
12
23
|
def price_per_unit(relaxations = [])
|
13
24
|
conditions = { :residence_fuel_type_name => self }
|
14
25
|
relaxations.push Hash.new
|
@@ -1,5 +1,114 @@
|
|
1
|
-
require 'earth/
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/locality/census_division'
|
4
|
+
require 'earth/locality/census_region'
|
5
|
+
require 'earth/residence/air_conditioner_use'
|
6
|
+
require 'earth/residence/clothes_machine_use'
|
7
|
+
require 'earth/residence/dishwasher_use'
|
8
|
+
require 'earth/residence/residence_class'
|
9
|
+
require 'earth/residence/urbanity'
|
10
|
+
|
2
11
|
class ResidentialEnergyConsumptionSurveyResponse < ActiveRecord::Base
|
12
|
+
extend Earth::Model
|
13
|
+
|
14
|
+
TABLE_STRUCTURE = <<-EOS
|
15
|
+
|
16
|
+
CREATE TABLE recs_responses
|
17
|
+
(
|
18
|
+
id INTEGER NOT NULL PRIMARY KEY,
|
19
|
+
air_conditioner_use_id CHARACTER VARYING(255),
|
20
|
+
annual_energy_from_electricity_for_air_conditioners FLOAT,
|
21
|
+
annual_energy_from_electricity_for_air_conditioners_units CHARACTER VARYING( 255),
|
22
|
+
annual_energy_from_electricity_for_clothes_driers FLOAT,
|
23
|
+
annual_energy_from_electricity_for_clothes_driers_units CHARACTER VARYING(255),
|
24
|
+
annual_energy_from_electricity_for_dishwashers FLOAT,
|
25
|
+
annual_energy_from_electricity_for_dishwashers_units CHARACTER VARYING(255),
|
26
|
+
annual_energy_from_electricity_for_freezers FLOAT,
|
27
|
+
annual_energy_from_electricity_for_freezers_units CHARACTER VARYING(255),
|
28
|
+
annual_energy_from_electricity_for_heating_space FLOAT,
|
29
|
+
annual_energy_from_electricity_for_heating_space_units CHARACTER VARYING(255),
|
30
|
+
annual_energy_from_electricity_for_heating_water FLOAT,
|
31
|
+
annual_energy_from_electricity_for_heating_water_units CHARACTER VARYING(255),
|
32
|
+
annual_energy_from_electricity_for_other_appliances FLOAT,
|
33
|
+
annual_energy_from_electricity_for_other_appliances_units CHARACTER VARYING( 255),
|
34
|
+
annual_energy_from_electricity_for_refrigerators FLOAT,
|
35
|
+
annual_energy_from_electricity_for_refrigerators_units CHARACTER VARYING(255),
|
36
|
+
annual_energy_from_fuel_oil_for_appliances FLOAT,
|
37
|
+
annual_energy_from_fuel_oil_for_appliances_units CHARACTER VARYING(255),
|
38
|
+
annual_energy_from_fuel_oil_for_heating_space FLOAT,
|
39
|
+
annual_energy_from_fuel_oil_for_heating_space_units CHARACTER VARYING(255),
|
40
|
+
annual_energy_from_fuel_oil_for_heating_water FLOAT,
|
41
|
+
annual_energy_from_fuel_oil_for_heating_water_units CHARACTER VARYING(255),
|
42
|
+
annual_energy_from_kerosene FLOAT,
|
43
|
+
annual_energy_from_kerosene_units CHARACTER VARYING(255),
|
44
|
+
annual_energy_from_natural_gas_for_appliances FLOAT,
|
45
|
+
annual_energy_from_natural_gas_for_appliances_units CHARACTER VARYING(255),
|
46
|
+
annual_energy_from_natural_gas_for_heating_space FLOAT,
|
47
|
+
annual_energy_from_natural_gas_for_heating_space_units CHARACTER VARYING(255),
|
48
|
+
annual_energy_from_natural_gas_for_heating_water FLOAT,
|
49
|
+
annual_energy_from_natural_gas_for_heating_water_units CHARACTER VARYING(255),
|
50
|
+
annual_energy_from_propane_for_appliances FLOAT,
|
51
|
+
annual_energy_from_propane_for_appliances_units CHARACTER VARYING(255),
|
52
|
+
annual_energy_from_propane_for_heating_space FLOAT,
|
53
|
+
annual_energy_from_propane_for_heating_space_units CHARACTER VARYING(255),
|
54
|
+
annual_energy_from_propane_for_heating_water FLOAT,
|
55
|
+
annual_energy_from_propane_for_heating_water_units CHARACTER VARYING(255),
|
56
|
+
annual_energy_from_wood FLOAT,
|
57
|
+
annual_energy_from_wood_units CHARACTER VARYING(255),
|
58
|
+
attached_1car_garage INTEGER,
|
59
|
+
attached_2car_garage INTEGER,
|
60
|
+
attached_3car_garage INTEGER,
|
61
|
+
bathrooms FLOAT,
|
62
|
+
bedrooms INTEGER,
|
63
|
+
census_division_name CHARACTER VARYING(255),
|
64
|
+
census_division_number INTEGER,
|
65
|
+
census_region_name CHARACTER VARYING(255),
|
66
|
+
census_region_number INTEGER,
|
67
|
+
central_ac_use CHARACTER VARYING(255),
|
68
|
+
clothes_dryer_use CHARACTER VARYING(255),
|
69
|
+
clothes_machine_use_id CHARACTER VARYING(255),
|
70
|
+
clothes_washer_use CHARACTER VARYING(255),
|
71
|
+
construction_period CHARACTER VARYING(255),
|
72
|
+
construction_year DATE,
|
73
|
+
cooling_degree_days INTEGER,
|
74
|
+
cooling_degree_days_units CHARACTER VARYING(255),
|
75
|
+
detached_1car_garage INTEGER,
|
76
|
+
detached_2car_garage INTEGER,
|
77
|
+
detached_3car_garage INTEGER,
|
78
|
+
dishwasher_use_id CHARACTER VARYING(255),
|
79
|
+
efficient_lights_on_1_to_4_hours INTEGER,
|
80
|
+
efficient_lights_on_4_to_12_hours INTEGER,
|
81
|
+
efficient_lights_on_over_12_hours INTEGER,
|
82
|
+
floorspace FLOAT,
|
83
|
+
floorspace_units CHARACTER VARYING(255),
|
84
|
+
freezer_count INTEGER,
|
85
|
+
full_bathrooms INTEGER,
|
86
|
+
half_bathrooms INTEGER,
|
87
|
+
heated_garage INTEGER,
|
88
|
+
heating_degree_days INTEGER,
|
89
|
+
heating_degree_days_units CHARACTER VARYING(255),
|
90
|
+
lighting_efficiency FLOAT,
|
91
|
+
lighting_use FLOAT,
|
92
|
+
lighting_use_units CHARACTER VARYING(255),
|
93
|
+
lights_on_1_to_4_hours INTEGER,
|
94
|
+
lights_on_4_to_12_hours INTEGER,
|
95
|
+
lights_on_over_12_hours INTEGER,
|
96
|
+
outdoor_all_night_gas_lights INTEGER,
|
97
|
+
outdoor_all_night_lights INTEGER,
|
98
|
+
ownership BOOLEAN,
|
99
|
+
refrigerator_count INTEGER,
|
100
|
+
residence_class_id CHARACTER VARYING(255),
|
101
|
+
residents INTEGER,
|
102
|
+
rooms FLOAT,
|
103
|
+
thermostat_programmability BOOLEAN,
|
104
|
+
total_rooms INTEGER,
|
105
|
+
urbanity_id CHARACTER VARYING(255),
|
106
|
+
weighting FLOAT,
|
107
|
+
window_ac_use CHARACTER VARYING(255)
|
108
|
+
);
|
109
|
+
|
110
|
+
EOS
|
111
|
+
|
3
112
|
self.primary_key = "id"
|
4
113
|
self.table_name = :recs_responses
|
5
114
|
|
@@ -28,96 +137,6 @@ class ResidentialEnergyConsumptionSurveyResponse < ActiveRecord::Base
|
|
28
137
|
]
|
29
138
|
|
30
139
|
# sabshere 9/20/10 sorted with sort -d -t "'" -k 2 ~/Desktop/parts.txt
|
31
|
-
col :id, :type => :integer
|
32
|
-
col :air_conditioner_use_id
|
33
|
-
col :annual_energy_from_electricity_for_air_conditioners, :type => :float
|
34
|
-
col :annual_energy_from_electricity_for_air_conditioners_units
|
35
|
-
col :annual_energy_from_electricity_for_clothes_driers, :type => :float
|
36
|
-
col :annual_energy_from_electricity_for_clothes_driers_units
|
37
|
-
col :annual_energy_from_electricity_for_dishwashers, :type => :float
|
38
|
-
col :annual_energy_from_electricity_for_dishwashers_units
|
39
|
-
col :annual_energy_from_electricity_for_freezers, :type => :float
|
40
|
-
col :annual_energy_from_electricity_for_freezers_units
|
41
|
-
col :annual_energy_from_electricity_for_heating_space, :type => :float
|
42
|
-
col :annual_energy_from_electricity_for_heating_space_units
|
43
|
-
col :annual_energy_from_electricity_for_heating_water, :type => :float
|
44
|
-
col :annual_energy_from_electricity_for_heating_water_units
|
45
|
-
col :annual_energy_from_electricity_for_other_appliances, :type => :float
|
46
|
-
col :annual_energy_from_electricity_for_other_appliances_units
|
47
|
-
col :annual_energy_from_electricity_for_refrigerators, :type => :float
|
48
|
-
col :annual_energy_from_electricity_for_refrigerators_units
|
49
|
-
col :annual_energy_from_fuel_oil_for_appliances, :type => :float
|
50
|
-
col :annual_energy_from_fuel_oil_for_appliances_units
|
51
|
-
col :annual_energy_from_fuel_oil_for_heating_space, :type => :float
|
52
|
-
col :annual_energy_from_fuel_oil_for_heating_space_units
|
53
|
-
col :annual_energy_from_fuel_oil_for_heating_water, :type => :float
|
54
|
-
col :annual_energy_from_fuel_oil_for_heating_water_units
|
55
|
-
col :annual_energy_from_kerosene, :type => :float
|
56
|
-
col :annual_energy_from_kerosene_units
|
57
|
-
col :annual_energy_from_natural_gas_for_appliances, :type => :float
|
58
|
-
col :annual_energy_from_natural_gas_for_appliances_units
|
59
|
-
col :annual_energy_from_natural_gas_for_heating_space, :type => :float
|
60
|
-
col :annual_energy_from_natural_gas_for_heating_space_units
|
61
|
-
col :annual_energy_from_natural_gas_for_heating_water, :type => :float
|
62
|
-
col :annual_energy_from_natural_gas_for_heating_water_units
|
63
|
-
col :annual_energy_from_propane_for_appliances, :type => :float
|
64
|
-
col :annual_energy_from_propane_for_appliances_units
|
65
|
-
col :annual_energy_from_propane_for_heating_space, :type => :float
|
66
|
-
col :annual_energy_from_propane_for_heating_space_units
|
67
|
-
col :annual_energy_from_propane_for_heating_water, :type => :float
|
68
|
-
col :annual_energy_from_propane_for_heating_water_units
|
69
|
-
col :annual_energy_from_wood, :type => :float
|
70
|
-
col :annual_energy_from_wood_units
|
71
|
-
col :attached_1car_garage, :type => :integer
|
72
|
-
col :attached_2car_garage, :type => :integer
|
73
|
-
col :attached_3car_garage, :type => :integer
|
74
|
-
col :bathrooms, :type => :float
|
75
|
-
col :bedrooms, :type => :integer
|
76
|
-
col :census_division_name
|
77
|
-
col :census_division_number, :type => :integer
|
78
|
-
col :census_region_name
|
79
|
-
col :census_region_number, :type => :integer
|
80
|
-
col :central_ac_use
|
81
|
-
col :clothes_dryer_use
|
82
|
-
col :clothes_machine_use_id
|
83
|
-
col :clothes_washer_use
|
84
|
-
col :construction_period
|
85
|
-
col :construction_year, :type => :date
|
86
|
-
col :cooling_degree_days, :type => :integer
|
87
|
-
col :cooling_degree_days_units
|
88
|
-
col :detached_1car_garage, :type => :integer
|
89
|
-
col :detached_2car_garage, :type => :integer
|
90
|
-
col :detached_3car_garage, :type => :integer
|
91
|
-
col :dishwasher_use_id
|
92
|
-
col :efficient_lights_on_1_to_4_hours, :type => :integer
|
93
|
-
col :efficient_lights_on_4_to_12_hours, :type => :integer
|
94
|
-
col :efficient_lights_on_over_12_hours, :type => :integer
|
95
|
-
col :floorspace, :type => :float
|
96
|
-
col :floorspace_units
|
97
|
-
col :freezer_count, :type => :integer
|
98
|
-
col :full_bathrooms, :type => :integer
|
99
|
-
col :half_bathrooms, :type => :integer
|
100
|
-
col :heated_garage, :type => :integer
|
101
|
-
col :heating_degree_days, :type => :integer
|
102
|
-
col :heating_degree_days_units
|
103
|
-
col :lighting_efficiency, :type => :float
|
104
|
-
col :lighting_use, :type => :float
|
105
|
-
col :lighting_use_units
|
106
|
-
col :lights_on_1_to_4_hours, :type => :integer
|
107
|
-
col :lights_on_4_to_12_hours, :type => :integer
|
108
|
-
col :lights_on_over_12_hours, :type => :integer
|
109
|
-
col :outdoor_all_night_gas_lights, :type => :integer
|
110
|
-
col :outdoor_all_night_lights, :type => :integer
|
111
|
-
col :ownership, :type => :boolean
|
112
|
-
col :refrigerator_count, :type => :integer
|
113
|
-
col :residence_class_id
|
114
|
-
col :residents, :type => :integer
|
115
|
-
col :rooms, :type => :float
|
116
|
-
col :thermostat_programmability, :type => :boolean
|
117
|
-
col :total_rooms, :type => :integer
|
118
|
-
col :urbanity_id
|
119
|
-
col :weighting, :type => :float
|
120
|
-
col :window_ac_use
|
121
140
|
|
122
141
|
warn_unless_size 4382
|
123
142
|
end
|
@@ -1,9 +1,23 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/residence/residential_energy_consumption_survey_response'
|
4
|
+
|
1
5
|
class Urbanity < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE urbanities
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY
|
13
|
+
);
|
14
|
+
|
15
|
+
EOS
|
16
|
+
|
2
17
|
self.primary_key = "name"
|
3
18
|
|
4
19
|
has_many :residential_energy_consumption_survey_responses
|
5
20
|
|
6
|
-
col :name
|
7
21
|
|
8
22
|
warn_unless_size 4
|
9
23
|
end
|
data/lib/earth/shipping.rb
CHANGED
@@ -1,4 +1,28 @@
|
|
1
|
+
require 'falls_back_on'
|
2
|
+
|
3
|
+
require 'earth/model'
|
4
|
+
|
5
|
+
require 'earth/shipping/carrier_mode'
|
6
|
+
|
1
7
|
class Carrier < ActiveRecord::Base
|
8
|
+
extend Earth::Model
|
9
|
+
|
10
|
+
TABLE_STRUCTURE = <<-EOS
|
11
|
+
|
12
|
+
CREATE TABLE carriers
|
13
|
+
(
|
14
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
15
|
+
full_name CHARACTER VARYING(255),
|
16
|
+
package_volume FLOAT,
|
17
|
+
route_inefficiency_factor FLOAT,
|
18
|
+
transport_emission_factor FLOAT,
|
19
|
+
transport_emission_factor_units CHARACTER VARYING(255),
|
20
|
+
corporate_emission_factor FLOAT,
|
21
|
+
corporate_emission_factor_units CHARACTER VARYING(255)
|
22
|
+
);
|
23
|
+
|
24
|
+
EOS
|
25
|
+
|
2
26
|
self.primary_key = "name"
|
3
27
|
|
4
28
|
has_many :carrier_modes, :foreign_key => 'carrier_name', :primary_key => 'name'
|
@@ -8,14 +32,6 @@ class Carrier < ActiveRecord::Base
|
|
8
32
|
:transport_emission_factor => 0.0005266,
|
9
33
|
:corporate_emission_factor => 0.221
|
10
34
|
|
11
|
-
col :name
|
12
|
-
col :full_name
|
13
|
-
col :package_volume, :type => :float
|
14
|
-
col :route_inefficiency_factor, :type => :float
|
15
|
-
col :transport_emission_factor, :type => :float
|
16
|
-
col :transport_emission_factor_units
|
17
|
-
col :corporate_emission_factor, :type => :float
|
18
|
-
col :corporate_emission_factor_units
|
19
35
|
|
20
36
|
# verify "Package volume should be greater than zero" do
|
21
37
|
# Carrier.all.each do |carrier|
|