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
@@ -2,8 +2,14 @@ class AutomobileTypeYear < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
has_many :type_fuel_years, :class_name => 'AutomobileTypeFuelYear', :foreign_key => 'type_year_name'
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
string 'type_name'
|
9
|
+
integer 'year'
|
10
|
+
float 'hfc_emissions'
|
11
|
+
string 'hfc_emissions_units'
|
12
|
+
float 'hfc_emission_factor'
|
13
|
+
string 'hfc_emission_factor_units'
|
8
14
|
end
|
9
15
|
end
|
@@ -1,34 +1,5 @@
|
|
1
1
|
BusClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'distance'
|
6
|
-
string 'distance_units'
|
7
|
-
float 'passengers'
|
8
|
-
float 'speed'
|
9
|
-
string 'speed_units'
|
10
|
-
float 'gasoline_intensity'
|
11
|
-
string 'gasoline_intensity_units'
|
12
|
-
float 'diesel_intensity'
|
13
|
-
string 'diesel_intensity_units'
|
14
|
-
float 'cng_intensity'
|
15
|
-
string 'cng_intensity_units'
|
16
|
-
float 'lng_intensity'
|
17
|
-
string 'lng_intensity_units'
|
18
|
-
float 'lpg_intensity'
|
19
|
-
string 'lpg_intensity_units'
|
20
|
-
float 'methanol_intensity'
|
21
|
-
string 'methanol_intensity_units'
|
22
|
-
float 'biodiesel_intensity'
|
23
|
-
string 'biodiesel_intensity_units'
|
24
|
-
float 'electricity_intensity'
|
25
|
-
string 'electricity_intensity_units'
|
26
|
-
float 'air_conditioning_emission_factor'
|
27
|
-
string 'air_conditioning_emission_factor_units'
|
28
|
-
float 'alternative_fuels_intensity'
|
29
|
-
string 'alternative_fuels_intensity_units'
|
30
|
-
end
|
31
|
-
|
32
3
|
import "a list of bus classes and pre-calculated trip and fuel use characteristics",
|
33
4
|
:url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdGRsSnJoS1hraGJvR012cDROWXFPbVE&gid=0&output=csv' do
|
34
5
|
key 'name'
|
data/lib/earth/bus/bus_class.rb
CHANGED
@@ -28,7 +28,32 @@ class BusClass < ActiveRecord::Base
|
|
28
28
|
:alternative_fuels_intensity => 0.04632038.gallons_per_mile.to(:litres_per_kilometre), # deprecated
|
29
29
|
:alternative_fuels_intensity_units => 'litres_per_kilometre' # deprecated
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
create_table do
|
32
|
+
string 'name'
|
33
|
+
float 'distance'
|
34
|
+
string 'distance_units'
|
35
|
+
float 'passengers'
|
36
|
+
float 'speed'
|
37
|
+
string 'speed_units'
|
38
|
+
float 'gasoline_intensity'
|
39
|
+
string 'gasoline_intensity_units'
|
40
|
+
float 'diesel_intensity'
|
41
|
+
string 'diesel_intensity_units'
|
42
|
+
float 'cng_intensity'
|
43
|
+
string 'cng_intensity_units'
|
44
|
+
float 'lng_intensity'
|
45
|
+
string 'lng_intensity_units'
|
46
|
+
float 'lpg_intensity'
|
47
|
+
string 'lpg_intensity_units'
|
48
|
+
float 'methanol_intensity'
|
49
|
+
string 'methanol_intensity_units'
|
50
|
+
float 'biodiesel_intensity'
|
51
|
+
string 'biodiesel_intensity_units'
|
52
|
+
float 'electricity_intensity'
|
53
|
+
string 'electricity_intensity_units'
|
54
|
+
float 'air_conditioning_emission_factor'
|
55
|
+
string 'air_conditioning_emission_factor_units'
|
56
|
+
float 'alternative_fuels_intensity'
|
57
|
+
string 'alternative_fuels_intensity_units'
|
33
58
|
end
|
34
59
|
end
|
@@ -1,21 +1,6 @@
|
|
1
1
|
BusFuel.class_eval do
|
2
2
|
data_miner do
|
3
|
-
|
4
|
-
string 'name'
|
5
|
-
string 'fuel_name'
|
6
|
-
float 'energy_content'
|
7
|
-
string 'energy_content_units'
|
8
|
-
float 'co2_emission_factor'
|
9
|
-
string 'co2_emission_factor_units'
|
10
|
-
float 'co2_biogenic_emission_factor'
|
11
|
-
string 'co2_biogenic_emission_factor_units'
|
12
|
-
float 'ch4_emission_factor'
|
13
|
-
string 'ch4_emission_factor_units'
|
14
|
-
float 'n2o_emission_factor'
|
15
|
-
string 'n2o_emission_factor_units'
|
16
|
-
end
|
17
|
-
|
18
|
-
process "Ensure necessary datasets are imported" do
|
3
|
+
process "Ensure Fuel, GreenhouseGas, and BusFuelYearControl are populated" do
|
19
4
|
Fuel.run_data_miner!
|
20
5
|
GreenhouseGas.run_data_miner!
|
21
6
|
BusFuelYearControl.run_data_miner!
|
data/lib/earth/bus/bus_fuel.rb
CHANGED
@@ -3,16 +3,23 @@ class BusFuel < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :fuel, :foreign_key => 'fuel_name'
|
5
5
|
has_many :fuel_year_controls, :class_name => 'BusFuelYearControl', :foreign_key => 'bus_fuel_name'
|
6
|
-
|
7
|
-
data_miner do
|
8
|
-
tap "Brighter Planet's sanitized bus fuel data", Earth.taps_server
|
9
6
|
|
10
|
-
process "Pull dependencies" do
|
11
|
-
run_data_miner_on_belongs_to_associations
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
7
|
def latest_fuel_year_controls
|
16
8
|
fuel_year_controls.where(:year => fuel_year_controls.maximum('year'))
|
17
9
|
end
|
10
|
+
|
11
|
+
create_table do
|
12
|
+
string 'name'
|
13
|
+
string 'fuel_name'
|
14
|
+
float 'energy_content'
|
15
|
+
string 'energy_content_units'
|
16
|
+
float 'co2_emission_factor'
|
17
|
+
string 'co2_emission_factor_units'
|
18
|
+
float 'co2_biogenic_emission_factor'
|
19
|
+
string 'co2_biogenic_emission_factor_units'
|
20
|
+
float 'ch4_emission_factor'
|
21
|
+
string 'ch4_emission_factor_units'
|
22
|
+
float 'n2o_emission_factor'
|
23
|
+
string 'n2o_emission_factor_units'
|
24
|
+
end
|
18
25
|
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
BusFuelControl.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'bus_fuel_name'
|
6
|
-
string 'control'
|
7
|
-
float 'ch4_emission_factor'
|
8
|
-
string 'ch4_emission_factor_units'
|
9
|
-
float 'n2o_emission_factor'
|
10
|
-
string 'n2o_emission_factor_units'
|
11
|
-
end
|
12
|
-
|
13
3
|
import "a list of bus fuel controls",
|
14
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEw1QW80VVJhaXRkUURQSFhHczNyVWc&gid=0&output=csv' do
|
15
5
|
key 'name'
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class BusFuelControl < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
create_table do
|
4
|
+
string 'name'
|
5
|
+
string 'bus_fuel_name'
|
6
|
+
string 'control'
|
7
|
+
float 'ch4_emission_factor'
|
8
|
+
string 'ch4_emission_factor_units'
|
9
|
+
float 'n2o_emission_factor'
|
10
|
+
string 'n2o_emission_factor_units'
|
6
11
|
end
|
7
12
|
end
|
@@ -1,15 +1,6 @@
|
|
1
1
|
BusFuelYearControl.class_eval do
|
2
2
|
data_miner do
|
3
|
-
|
4
|
-
string 'name'
|
5
|
-
string 'bus_fuel_name'
|
6
|
-
integer 'year'
|
7
|
-
string 'control'
|
8
|
-
string 'bus_fuel_control_name'
|
9
|
-
float 'total_travel_percent'
|
10
|
-
end
|
11
|
-
|
12
|
-
process "Ensure all BusFuelControls are imported" do
|
3
|
+
process "Ensure BusFuelControl is populated" do
|
13
4
|
BusFuelControl.run_data_miner!
|
14
5
|
end
|
15
6
|
|
@@ -2,12 +2,13 @@ class BusFuelYearControl < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
belongs_to :fuel_control, :class_name => 'BusFuelControl', :foreign_key => 'bus_fuel_control_name'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
string 'bus_fuel_name'
|
9
|
+
integer 'year'
|
10
|
+
string 'control'
|
11
|
+
string 'bus_fuel_control_name'
|
12
|
+
float 'total_travel_percent'
|
12
13
|
end
|
13
14
|
end
|
data/lib/earth/bus/data_miner.rb
CHANGED
data/lib/earth/bus.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
ComputationCarrier.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'power_usage_effectiveness'
|
6
|
-
end
|
7
|
-
|
8
3
|
import "a list of computation carriers and their power usage effectiveness",
|
9
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFlxZVZLai01WWJOOTFiaUd1blF6VkE&gid=0&output=csv' do
|
10
5
|
key 'name'
|
@@ -4,7 +4,8 @@ class ComputationCarrier < ActiveRecord::Base
|
|
4
4
|
falls_back_on :name => 'fallback',
|
5
5
|
:power_usage_effectiveness => lambda { ComputationCarrier.maximum('power_usage_effectiveness') }
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
create_table do
|
8
|
+
string 'name'
|
9
|
+
float 'power_usage_effectiveness'
|
9
10
|
end
|
10
11
|
end
|
@@ -1,13 +1,5 @@
|
|
1
1
|
ComputationCarrierInstanceClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'computation_carrier_name'
|
6
|
-
string 'instance_class'
|
7
|
-
float 'electricity_intensity'
|
8
|
-
string 'electricity_intensity_units'
|
9
|
-
end
|
10
|
-
|
11
3
|
import "a list of computation carrier instance classes and their characteristics",
|
12
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdGExaW1ic2c0d2s1ZmpzeUdOa2kyRlE&gid=0&output=csv' do
|
13
5
|
key 'name'
|
@@ -7,11 +7,11 @@ class ComputationCarrierInstanceClass < ActiveRecord::Base
|
|
7
7
|
:electricity_intensity => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity },
|
8
8
|
:electricity_intensity_units => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity_units }
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
create_table do
|
11
|
+
string 'name'
|
12
|
+
string 'computation_carrier_name'
|
13
|
+
string 'instance_class'
|
14
|
+
float 'electricity_intensity'
|
15
|
+
string 'electricity_intensity_units'
|
16
16
|
end
|
17
17
|
end
|
@@ -1,12 +1,5 @@
|
|
1
1
|
ComputationCarrierRegion.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'computation_carrier_name'
|
6
|
-
string 'region'
|
7
|
-
string 'egrid_subregion_abbreviation'
|
8
|
-
end
|
9
|
-
|
10
3
|
import "a list of computation carrier regions",
|
11
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdGFEU1gtVzFPeS0tV1VnR05WZ2ZFUVE&gid=0&output=csv' do
|
12
5
|
key 'name'
|
@@ -2,12 +2,11 @@ class ComputationCarrierRegion < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
belongs_to :egrid_subregion, :foreign_key => 'egrid_subregion_abbreviation'
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
5
|
+
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
string 'computation_carrier_name'
|
9
|
+
string 'region'
|
10
|
+
string 'egrid_subregion_abbreviation'
|
12
11
|
end
|
13
12
|
end
|
data/lib/earth/computation.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
DietClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'intensity'
|
6
|
-
string 'intensity_units'
|
7
|
-
float 'red_meat_share'
|
8
|
-
float 'poultry_share'
|
9
|
-
float 'fish_share'
|
10
|
-
float 'eggs_share'
|
11
|
-
float 'nuts_share'
|
12
|
-
float 'dairy_share'
|
13
|
-
float 'cereals_and_grains_share'
|
14
|
-
float 'fruit_share'
|
15
|
-
float 'vegetables_share'
|
16
|
-
float 'oils_and_sugars_share'
|
17
|
-
end
|
18
|
-
|
19
3
|
import "a Brighter Planet-defined list of diet classes and food group caloric distributions",
|
20
4
|
:url => 'http://static.brighterplanet.com/science/data/consumables/diets/diet_classes.csv' do
|
21
5
|
key 'name'
|
@@ -1,13 +1,25 @@
|
|
1
1
|
class DietClass < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
data_miner do
|
5
|
-
tap "Brighter Planet's diet class data", Earth.taps_server
|
6
|
-
end
|
7
|
-
|
8
4
|
class << self
|
9
5
|
def fallback
|
10
6
|
find_by_name 'standard'
|
11
7
|
end
|
12
8
|
end
|
9
|
+
|
10
|
+
create_table do
|
11
|
+
string 'name'
|
12
|
+
float 'intensity'
|
13
|
+
string 'intensity_units'
|
14
|
+
float 'red_meat_share'
|
15
|
+
float 'poultry_share'
|
16
|
+
float 'fish_share'
|
17
|
+
float 'eggs_share'
|
18
|
+
float 'nuts_share'
|
19
|
+
float 'dairy_share'
|
20
|
+
float 'cereals_and_grains_share'
|
21
|
+
float 'fruit_share'
|
22
|
+
float 'vegetables_share'
|
23
|
+
float 'oils_and_sugars_share'
|
24
|
+
end
|
13
25
|
end
|
@@ -1,14 +1,5 @@
|
|
1
1
|
FoodGroup.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'intensity'
|
6
|
-
string 'intensity_units'
|
7
|
-
float 'energy'
|
8
|
-
string 'energy_units'
|
9
|
-
string 'suggested_imperial_measurement' # ?
|
10
|
-
end
|
11
|
-
|
12
3
|
import "a list of food groups and their emissions intensities",
|
13
4
|
:url => 'http://static.brighterplanet.com/science/data/consumables/diets/food_groups.csv' do
|
14
5
|
key 'name'
|
@@ -11,7 +11,12 @@ class FoodGroup < ActiveRecord::Base
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
create_table do
|
15
|
+
string 'name'
|
16
|
+
float 'intensity'
|
17
|
+
string 'intensity_units'
|
18
|
+
float 'energy'
|
19
|
+
string 'energy_units'
|
20
|
+
string 'suggested_imperial_measurement' # ?
|
16
21
|
end
|
17
22
|
end
|
@@ -1,21 +1,5 @@
|
|
1
1
|
Fuel.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'density'
|
6
|
-
string 'density_units'
|
7
|
-
float 'energy_content'
|
8
|
-
string 'energy_content_units'
|
9
|
-
float 'carbon_content'
|
10
|
-
string 'carbon_content_units'
|
11
|
-
float 'oxidation_factor'
|
12
|
-
float 'biogenic_fraction'
|
13
|
-
float 'co2_emission_factor'
|
14
|
-
string 'co2_emission_factor_units'
|
15
|
-
float 'co2_biogenic_emission_factor'
|
16
|
-
string 'co2_biogenic_emission_factor_units'
|
17
|
-
end
|
18
|
-
|
19
3
|
process "Ensure FuelYear is populated" do
|
20
4
|
FuelYear.run_data_miner!
|
21
5
|
end
|
data/lib/earth/fuel/fuel.rb
CHANGED
@@ -3,8 +3,20 @@ class Fuel < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :fuel_years, :foreign_key => 'fuel_name'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
float 'density'
|
9
|
+
string 'density_units'
|
10
|
+
float 'energy_content'
|
11
|
+
string 'energy_content_units'
|
12
|
+
float 'carbon_content'
|
13
|
+
string 'carbon_content_units'
|
14
|
+
float 'oxidation_factor'
|
15
|
+
float 'biogenic_fraction'
|
16
|
+
float 'co2_emission_factor'
|
17
|
+
string 'co2_emission_factor_units'
|
18
|
+
float 'co2_biogenic_emission_factor'
|
19
|
+
string 'co2_biogenic_emission_factor_units'
|
8
20
|
end
|
9
21
|
|
10
22
|
def latest_year
|
@@ -4,12 +4,6 @@ FuelPrice.class_eval do
|
|
4
4
|
# month/year
|
5
5
|
|
6
6
|
data_miner do
|
7
|
-
schema Earth.database_options do
|
8
|
-
string 'name'
|
9
|
-
float 'price'
|
10
|
-
string 'price_units'
|
11
|
-
end
|
12
|
-
|
13
7
|
import 'fuel prices derived from the EIA',
|
14
8
|
:url => 'http://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHlSdXJoOFB5aEpHenJQbTVJdS1pMVE&gid=0&output=csv',
|
15
9
|
:select => lambda { |row| row['fuel_type_name'].present? } do
|
@@ -3,11 +3,9 @@ class FuelPrice < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :fuel_type, :foreign_key => 'name' # weird
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
run_data_miner_on_belongs_to_associations
|
11
|
-
end
|
6
|
+
create_table do
|
7
|
+
string 'name'
|
8
|
+
float 'price'
|
9
|
+
string 'price_units'
|
12
10
|
end
|
13
11
|
end
|
@@ -5,20 +5,6 @@ FuelType.class_eval do
|
|
5
5
|
# gas-specific emissions factors
|
6
6
|
|
7
7
|
data_miner do
|
8
|
-
schema Earth.database_options do
|
9
|
-
string 'name'
|
10
|
-
float 'emission_factor'
|
11
|
-
string 'emission_factor_units'
|
12
|
-
float 'density'
|
13
|
-
string 'density_units'
|
14
|
-
float 'average_purchase_volume'
|
15
|
-
string 'average_purchase_volume_units'
|
16
|
-
# float 'energy_content'
|
17
|
-
# string 'energy_content_units'
|
18
|
-
# float 'carbon_content'
|
19
|
-
# string 'carbon_content_units'
|
20
|
-
end
|
21
|
-
|
22
8
|
# process "Define some necessary conversions" do
|
23
9
|
# Conversions.register :teragrams_per_quadrillion_british_thermal_units, :kilograms_per_joule, 0.000000000947817123
|
24
10
|
# Conversions.register :million_british_thermal_units_per_short_ton, :joules_per_kilogram, 1.16300000
|
data/lib/earth/fuel/fuel_type.rb
CHANGED
@@ -8,11 +8,21 @@ class FuelType < ActiveRecord::Base
|
|
8
8
|
:average_purchase_volume => 100, #FIXME TODO put a real value here - also do we want to do volumes in kJ?
|
9
9
|
:average_purchase_volume_units => 'FIXME'
|
10
10
|
|
11
|
-
data_miner do
|
12
|
-
tap "Brighter Planet's fuel types data", Earth.taps_server
|
13
|
-
end
|
14
|
-
|
15
11
|
def price
|
16
12
|
prices.average :price
|
17
13
|
end
|
14
|
+
|
15
|
+
create_table do
|
16
|
+
string 'name'
|
17
|
+
float 'emission_factor'
|
18
|
+
string 'emission_factor_units'
|
19
|
+
float 'density'
|
20
|
+
string 'density_units'
|
21
|
+
float 'average_purchase_volume'
|
22
|
+
string 'average_purchase_volume_units'
|
23
|
+
# float 'energy_content'
|
24
|
+
# string 'energy_content_units'
|
25
|
+
# float 'carbon_content'
|
26
|
+
# string 'carbon_content_units'
|
27
|
+
end
|
18
28
|
end
|
@@ -1,21 +1,5 @@
|
|
1
1
|
FuelYear.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'fuel_name'
|
6
|
-
integer 'year'
|
7
|
-
float 'energy_content'
|
8
|
-
string 'energy_content_units'
|
9
|
-
float 'carbon_content'
|
10
|
-
string 'carbon_content_units'
|
11
|
-
float 'oxidation_factor'
|
12
|
-
float 'biogenic_fraction'
|
13
|
-
float 'co2_emission_factor'
|
14
|
-
string 'co2_emission_factor_units'
|
15
|
-
float 'co2_biogenic_emission_factor'
|
16
|
-
string 'co2_biogenic_emission_factor_units'
|
17
|
-
end
|
18
|
-
|
19
3
|
import "fuels with annually variable characteristics, derived from the 2010 EPA GHG Inventory",
|
20
4
|
:url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdFZVSlZ3SUZsTzZLVTB5bVk5THdBN2c&gid=0&output=csv' do
|
21
5
|
key 'name'
|
data/lib/earth/fuel/fuel_year.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
class FuelYear < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
create_table do
|
5
|
+
string 'name'
|
6
|
+
string 'fuel_name'
|
7
|
+
integer 'year'
|
8
|
+
float 'energy_content'
|
9
|
+
string 'energy_content_units'
|
10
|
+
float 'carbon_content'
|
11
|
+
string 'carbon_content_units'
|
12
|
+
float 'oxidation_factor'
|
13
|
+
float 'biogenic_fraction'
|
14
|
+
float 'co2_emission_factor'
|
15
|
+
string 'co2_emission_factor_units'
|
16
|
+
float 'co2_biogenic_emission_factor'
|
17
|
+
string 'co2_biogenic_emission_factor_units'
|
6
18
|
end
|
7
19
|
end
|
@@ -1,14 +1,5 @@
|
|
1
1
|
GreenhouseGas.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
string 'abbreviation'
|
6
|
-
string 'ipcc_report'
|
7
|
-
integer 'time_horizon'
|
8
|
-
string 'time_horizon_units'
|
9
|
-
integer 'global_warming_potential'
|
10
|
-
end
|
11
|
-
|
12
3
|
import "greenhouse gas global warming potentials taken from the IPCC AR4",
|
13
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdE1tUjBwS1ZHZnBUUG1XcVpkOTVHOVE&gid=0&output=csv' do
|
14
5
|
key 'name'
|
@@ -1,13 +1,18 @@
|
|
1
1
|
class GreenhouseGas < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
|
-
|
4
|
-
data_miner do
|
5
|
-
tap "Brighter Planet's greenhouse gas data", Earth.taps_server
|
6
|
-
end
|
7
|
-
|
3
|
+
|
8
4
|
class << self
|
9
5
|
def [](abbreviation)
|
10
6
|
find_by_abbreviation abbreviation.to_s
|
11
7
|
end
|
12
8
|
end
|
9
|
+
|
10
|
+
create_table do
|
11
|
+
string 'name'
|
12
|
+
string 'abbreviation'
|
13
|
+
string 'ipcc_report'
|
14
|
+
integer 'time_horizon'
|
15
|
+
string 'time_horizon_units'
|
16
|
+
integer 'global_warming_potential'
|
17
|
+
end
|
13
18
|
end
|
@@ -1,17 +1,5 @@
|
|
1
1
|
LodgingClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
schema Earth.database_options do
|
4
|
-
string 'name'
|
5
|
-
float 'electricity_intensity'
|
6
|
-
string 'electricity_intensity'
|
7
|
-
float 'natural_gas_intensity'
|
8
|
-
string 'natural_gas_intensity'
|
9
|
-
float 'fuel_oil_intensity'
|
10
|
-
string 'fuel_oil_intensity'
|
11
|
-
float 'district_heat_intensity'
|
12
|
-
string 'district_heat_intensity'
|
13
|
-
end
|
14
|
-
|
15
3
|
import "a list of lodging classes and pre-calculated emission factors",
|
16
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGZZWmZtWEJlYzhRNXlPdWpBTldlcUE&hl=en&gid=0&output=csv' do
|
17
5
|
key 'name'
|