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,9 +1,5 @@
|
|
1
1
|
AutomobileTypeFuelYearControl.class_eval do
|
2
2
|
data_miner do
|
3
|
-
process "Start from scratch" do
|
4
|
-
delete_all
|
5
|
-
end
|
6
|
-
|
7
3
|
import "automobile type fuel year control data derived from the 2010 EPA GHG Inventory",
|
8
4
|
:url => "file://#{Earth::DATA_DIR}/automobile/annual_emission_controls.csv" do
|
9
5
|
key 'name'
|
@@ -1,4 +1,17 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
1
3
|
class AutomobileYear < ActiveRecord::Base
|
4
|
+
extend Earth::Model
|
5
|
+
|
6
|
+
TABLE_STRUCTURE = <<-EOS
|
7
|
+
|
8
|
+
CREATE TABLE automobile_years
|
9
|
+
(
|
10
|
+
year INTEGER NOT NULL PRIMARY KEY
|
11
|
+
);
|
12
|
+
|
13
|
+
EOS
|
14
|
+
|
2
15
|
self.primary_key = "year"
|
3
16
|
|
4
17
|
# Estimate of % of vehicles currently in use that were manufactured in each year
|
@@ -37,7 +50,6 @@ class AutomobileYear < ActiveRecord::Base
|
|
37
50
|
}[year]
|
38
51
|
end
|
39
52
|
|
40
|
-
col :year, :type => :integer
|
41
53
|
|
42
54
|
warn_unless_size 28
|
43
55
|
end
|
data/lib/earth/bus.rb
CHANGED
data/lib/earth/bus/bus_class.rb
CHANGED
@@ -1,5 +1,42 @@
|
|
1
|
-
require '
|
1
|
+
require 'falls_back_on'
|
2
|
+
|
3
|
+
require 'earth/model'
|
4
|
+
|
2
5
|
class BusClass < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE bus_classes
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
distance FLOAT,
|
14
|
+
distance_units CHARACTER VARYING(255),
|
15
|
+
passengers FLOAT,
|
16
|
+
speed FLOAT,
|
17
|
+
speed_units CHARACTER VARYING(255),
|
18
|
+
gasoline_intensity FLOAT,
|
19
|
+
gasoline_intensity_units CHARACTER VARYING(255),
|
20
|
+
diesel_intensity FLOAT,
|
21
|
+
diesel_intensity_units CHARACTER VARYING(255),
|
22
|
+
cng_intensity FLOAT,
|
23
|
+
cng_intensity_units CHARACTER VARYING(255),
|
24
|
+
lng_intensity FLOAT,
|
25
|
+
lng_intensity_units CHARACTER VARYING(255),
|
26
|
+
lpg_intensity FLOAT,
|
27
|
+
lpg_intensity_units CHARACTER VARYING(255),
|
28
|
+
methanol_intensity FLOAT,
|
29
|
+
methanol_intensity_units CHARACTER VARYING(255),
|
30
|
+
biodiesel_intensity FLOAT,
|
31
|
+
biodiesel_intensity_units CHARACTER VARYING(255),
|
32
|
+
electricity_intensity FLOAT,
|
33
|
+
electricity_intensity_units CHARACTER VARYING(255),
|
34
|
+
air_conditioning_emission_factor FLOAT,
|
35
|
+
air_conditioning_emission_factor_units CHARACTER VARYING(255)
|
36
|
+
);
|
37
|
+
|
38
|
+
EOS
|
39
|
+
|
3
40
|
self.primary_key = "name"
|
4
41
|
|
5
42
|
# https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHY0R0hjZnhRaTIxTnpvRk1HNThwUmc&hl=en&output=html
|
@@ -27,30 +64,6 @@ class BusClass < ActiveRecord::Base
|
|
27
64
|
:air_conditioning_emission_factor => 0.04779 / 1.miles.to(:kilometres),
|
28
65
|
:air_conditioning_emission_factor_units => 'kilograms_co2e_per_kilometre'
|
29
66
|
|
30
|
-
col :name
|
31
|
-
col :distance, :type => :float
|
32
|
-
col :distance_units
|
33
|
-
col :passengers, :type => :float
|
34
|
-
col :speed, :type => :float
|
35
|
-
col :speed_units
|
36
|
-
col :gasoline_intensity, :type => :float
|
37
|
-
col :gasoline_intensity_units
|
38
|
-
col :diesel_intensity, :type => :float
|
39
|
-
col :diesel_intensity_units
|
40
|
-
col :cng_intensity, :type => :float
|
41
|
-
col :cng_intensity_units
|
42
|
-
col :lng_intensity, :type => :float
|
43
|
-
col :lng_intensity_units
|
44
|
-
col :lpg_intensity, :type => :float
|
45
|
-
col :lpg_intensity_units
|
46
|
-
col :methanol_intensity, :type => :float
|
47
|
-
col :methanol_intensity_units
|
48
|
-
col :biodiesel_intensity, :type => :float
|
49
|
-
col :biodiesel_intensity_units
|
50
|
-
col :electricity_intensity, :type => :float
|
51
|
-
col :electricity_intensity_units
|
52
|
-
col :air_conditioning_emission_factor, :type => :float
|
53
|
-
col :air_conditioning_emission_factor_units
|
54
67
|
|
55
68
|
warn_unless_size 2
|
56
69
|
end
|
data/lib/earth/bus/bus_fuel.rb
CHANGED
@@ -1,5 +1,31 @@
|
|
1
|
-
require 'earth/
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/bus/bus_fuel_year_control'
|
4
|
+
require 'earth/fuel/fuel'
|
5
|
+
|
2
6
|
class BusFuel < ActiveRecord::Base
|
7
|
+
extend Earth::Model
|
8
|
+
|
9
|
+
TABLE_STRUCTURE = <<-EOS
|
10
|
+
|
11
|
+
CREATE TABLE bus_fuels
|
12
|
+
(
|
13
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
14
|
+
fuel_name CHARACTER VARYING(255),
|
15
|
+
energy_content FLOAT,
|
16
|
+
energy_content_units CHARACTER VARYING(255),
|
17
|
+
co2_emission_factor FLOAT,
|
18
|
+
co2_emission_factor_units CHARACTER VARYING(255),
|
19
|
+
co2_biogenic_emission_factor FLOAT,
|
20
|
+
co2_biogenic_emission_factor_units CHARACTER VARYING(255),
|
21
|
+
ch4_emission_factor FLOAT,
|
22
|
+
ch4_emission_factor_units CHARACTER VARYING(255),
|
23
|
+
n2o_emission_factor FLOAT,
|
24
|
+
n2o_emission_factor_units CHARACTER VARYING(255)
|
25
|
+
);
|
26
|
+
|
27
|
+
EOS
|
28
|
+
|
3
29
|
self.primary_key = "name"
|
4
30
|
|
5
31
|
belongs_to :fuel, :foreign_key => 'fuel_name'
|
@@ -9,18 +35,6 @@ class BusFuel < ActiveRecord::Base
|
|
9
35
|
fuel_year_controls.where(:year => fuel_year_controls.maximum('year'))
|
10
36
|
end
|
11
37
|
|
12
|
-
col :name
|
13
|
-
col :fuel_name
|
14
|
-
col :energy_content, :type => :float
|
15
|
-
col :energy_content_units
|
16
|
-
col :co2_emission_factor, :type => :float
|
17
|
-
col :co2_emission_factor_units
|
18
|
-
col :co2_biogenic_emission_factor, :type => :float
|
19
|
-
col :co2_biogenic_emission_factor_units
|
20
|
-
col :ch4_emission_factor, :type => :float
|
21
|
-
col :ch4_emission_factor_units
|
22
|
-
col :n2o_emission_factor, :type => :float
|
23
|
-
col :n2o_emission_factor_units
|
24
38
|
|
25
39
|
# # FIXME TODO verify fuel_name appears in fuels
|
26
40
|
# verify "Fuel name should never be missing" do
|
@@ -1,4 +1,8 @@
|
|
1
|
-
require 'earth/
|
1
|
+
require 'earth/bus/bus_fuel'
|
2
|
+
require 'earth/bus/bus_fuel_year_control'
|
3
|
+
require 'earth/fuel/fuel'
|
4
|
+
require 'earth/fuel/greenhouse_gas'
|
5
|
+
|
2
6
|
BusFuel.class_eval do
|
3
7
|
data_miner do
|
4
8
|
process "Ensure Fuel, GreenhouseGas, and BusFuelYearControl are populated" do
|
@@ -1,13 +1,25 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
1
3
|
require 'earth/fuel'
|
2
4
|
class BusFuelControl < ActiveRecord::Base
|
5
|
+
extend Earth::Model
|
6
|
+
|
7
|
+
TABLE_STRUCTURE = <<-EOS
|
8
|
+
|
9
|
+
CREATE TABLE bus_fuel_controls
|
10
|
+
(
|
11
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
12
|
+
bus_fuel_name CHARACTER VARYING(255),
|
13
|
+
control CHARACTER VARYING(255),
|
14
|
+
ch4_emission_factor FLOAT,
|
15
|
+
ch4_emission_factor_units CHARACTER VARYING(255),
|
16
|
+
n2o_emission_factor FLOAT,
|
17
|
+
n2o_emission_factor_units CHARACTER VARYING(255)
|
18
|
+
);
|
19
|
+
|
20
|
+
EOS
|
21
|
+
|
3
22
|
self.primary_key = "name"
|
4
|
-
col :name
|
5
|
-
col :bus_fuel_name
|
6
|
-
col :control
|
7
|
-
col :ch4_emission_factor, :type => :float
|
8
|
-
col :ch4_emission_factor_units
|
9
|
-
col :n2o_emission_factor, :type => :float
|
10
|
-
col :n2o_emission_factor_units
|
11
23
|
|
12
24
|
warn_unless_size 9
|
13
25
|
end
|
@@ -1,15 +1,28 @@
|
|
1
|
-
require 'earth/
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/bus/bus_fuel_control'
|
4
|
+
|
2
5
|
class BusFuelYearControl < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE bus_fuel_year_controls
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
bus_fuel_name CHARACTER VARYING(255),
|
14
|
+
year INTEGER,
|
15
|
+
control CHARACTER VARYING(255),
|
16
|
+
bus_fuel_control_name CHARACTER VARYING(255),
|
17
|
+
total_travel_percent FLOAT
|
18
|
+
);
|
19
|
+
|
20
|
+
EOS
|
21
|
+
|
3
22
|
self.primary_key = "name"
|
4
23
|
|
5
24
|
belongs_to :fuel_control, :class_name => 'BusFuelControl', :foreign_key => 'bus_fuel_control_name'
|
6
25
|
|
7
|
-
col :name
|
8
|
-
col :bus_fuel_name
|
9
|
-
col :year, :type => :integer
|
10
|
-
col :control
|
11
|
-
col :bus_fuel_control_name
|
12
|
-
col :total_travel_percent, :type => :float
|
13
26
|
|
14
27
|
warn_unless_size 67
|
15
28
|
end
|
data/lib/earth/computation.rb
CHANGED
@@ -1,12 +1,25 @@
|
|
1
|
-
require '
|
1
|
+
require 'falls_back_on'
|
2
|
+
|
3
|
+
require 'earth/model'
|
4
|
+
|
2
5
|
class ComputationCarrier < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE computation_carriers
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
power_usage_effectiveness FLOAT
|
14
|
+
);
|
15
|
+
|
16
|
+
EOS
|
17
|
+
|
3
18
|
self.primary_key = "name"
|
4
19
|
|
5
20
|
falls_back_on :name => 'fallback',
|
6
21
|
:power_usage_effectiveness => lambda { ComputationCarrier.maximum('power_usage_effectiveness') }
|
7
22
|
|
8
|
-
col :name
|
9
|
-
col :power_usage_effectiveness, :type => :float
|
10
23
|
|
11
24
|
# verify "Power usage effectiveness should be one or more" do
|
12
25
|
# ComputationCarrier.all.each do |carrier|
|
@@ -1,5 +1,25 @@
|
|
1
|
-
require '
|
1
|
+
require 'falls_back_on'
|
2
|
+
|
3
|
+
require 'earth/model'
|
4
|
+
|
5
|
+
require 'earth/computation/computation_carrier'
|
6
|
+
|
2
7
|
class ComputationCarrierInstanceClass < ActiveRecord::Base
|
8
|
+
extend Earth::Model
|
9
|
+
|
10
|
+
TABLE_STRUCTURE = <<-EOS
|
11
|
+
|
12
|
+
CREATE TABLE computation_carrier_instance_classes
|
13
|
+
(
|
14
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
15
|
+
computation_carrier_name CHARACTER VARYING(255),
|
16
|
+
instance_class CHARACTER VARYING(255),
|
17
|
+
electricity_intensity FLOAT,
|
18
|
+
electricity_intensity_units CHARACTER VARYING(255)
|
19
|
+
);
|
20
|
+
|
21
|
+
EOS
|
22
|
+
|
3
23
|
self.primary_key = "name"
|
4
24
|
|
5
25
|
belongs_to :carrier, :class_name => 'ComputationCarrier', :foreign_key => 'computation_carrier_name'
|
@@ -8,11 +28,6 @@ class ComputationCarrierInstanceClass < ActiveRecord::Base
|
|
8
28
|
:electricity_intensity => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity },
|
9
29
|
:electricity_intensity_units => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity_units }
|
10
30
|
|
11
|
-
col :name
|
12
|
-
col :computation_carrier_name
|
13
|
-
col :instance_class
|
14
|
-
col :electricity_intensity, :type => :float
|
15
|
-
col :electricity_intensity_units
|
16
31
|
|
17
32
|
# FIXME TODO verify that computation carrier name appears in computation_carriers
|
18
33
|
|
@@ -1,13 +1,26 @@
|
|
1
|
-
require 'earth/
|
1
|
+
require 'earth/model'
|
2
|
+
|
3
|
+
require 'earth/locality/egrid_subregion'
|
4
|
+
|
2
5
|
class ComputationCarrierRegion < ActiveRecord::Base
|
6
|
+
extend Earth::Model
|
7
|
+
|
8
|
+
TABLE_STRUCTURE = <<-EOS
|
9
|
+
|
10
|
+
CREATE TABLE computation_carrier_regions
|
11
|
+
(
|
12
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
13
|
+
computation_carrier_name CHARACTER VARYING(255),
|
14
|
+
region CHARACTER VARYING(255),
|
15
|
+
egrid_subregion_abbreviation CHARACTER VARYING(255)
|
16
|
+
);
|
17
|
+
|
18
|
+
EOS
|
19
|
+
|
3
20
|
self.primary_key = "name"
|
4
21
|
|
5
22
|
belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
|
6
23
|
|
7
|
-
col :name
|
8
|
-
col :computation_carrier_name
|
9
|
-
col :region
|
10
|
-
col :egrid_subregion_abbreviation
|
11
24
|
|
12
25
|
warn_unless_size 4
|
13
26
|
end
|
data/lib/earth/diet.rb
CHANGED
@@ -1,4 +1,29 @@
|
|
1
|
+
require 'earth/model'
|
2
|
+
|
1
3
|
class DietClass < ActiveRecord::Base
|
4
|
+
extend Earth::Model
|
5
|
+
|
6
|
+
TABLE_STRUCTURE = <<-EOS
|
7
|
+
|
8
|
+
CREATE TABLE diet_classes
|
9
|
+
(
|
10
|
+
name CHARACTER VARYING(255) NOT NULL PRIMARY KEY,
|
11
|
+
intensity FLOAT,
|
12
|
+
intensity_units CHARACTER VARYING(255),
|
13
|
+
red_meat_share FLOAT,
|
14
|
+
poultry_share FLOAT,
|
15
|
+
fish_share FLOAT,
|
16
|
+
eggs_share FLOAT,
|
17
|
+
nuts_share FLOAT,
|
18
|
+
dairy_share FLOAT,
|
19
|
+
cereals_and_grains_share FLOAT,
|
20
|
+
fruit_share FLOAT,
|
21
|
+
vegetables_share FLOAT,
|
22
|
+
oils_and_sugars_share FLOAT
|
23
|
+
);
|
24
|
+
|
25
|
+
EOS
|
26
|
+
|
2
27
|
self.primary_key = "name"
|
3
28
|
|
4
29
|
class << self
|
@@ -7,19 +32,6 @@ class DietClass < ActiveRecord::Base
|
|
7
32
|
end
|
8
33
|
end
|
9
34
|
|
10
|
-
col :name
|
11
|
-
col :intensity, :type => :float
|
12
|
-
col :intensity_units
|
13
|
-
col :red_meat_share, :type => :float
|
14
|
-
col :poultry_share, :type => :float
|
15
|
-
col :fish_share, :type => :float
|
16
|
-
col :eggs_share, :type => :float
|
17
|
-
col :nuts_share, :type => :float
|
18
|
-
col :dairy_share, :type => :float
|
19
|
-
col :cereals_and_grains_share, :type => :float
|
20
|
-
col :fruit_share, :type => :float
|
21
|
-
col :vegetables_share, :type => :float
|
22
|
-
col :oils_and_sugars_share, :type => :float
|
23
35
|
|
24
36
|
warn_unless_size 3
|
25
37
|
end
|