earth 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -21
- data/data/rail/ntd_companies.csv +1 -0
- data/data/rail/ntd_fuel_consumption.csv +1 -0
- data/data/rail/ntd_modes.csv +1 -0
- data/data/rail/ntd_service.csv +1 -0
- data/errata/flight_segment/bts_errata.csv +6 -0
- data/lib/earth.rb +1 -0
- data/lib/earth/air/aircraft.rb +3 -5
- data/lib/earth/air/airline.rb +2 -3
- data/lib/earth/air/airport.rb +4 -5
- data/lib/earth/air/bts_aircraft.rb +1 -1
- data/lib/earth/air/flight_distance_class.rb +0 -1
- data/lib/earth/air/flight_distance_class/data_miner.rb +0 -4
- data/lib/earth/air/flight_distance_class_seat_class.rb +0 -1
- data/lib/earth/air/flight_segment.rb +12 -13
- data/lib/earth/air/flight_segment/data_miner.rb +13 -0
- data/lib/earth/automobile/automobile_activity_year.rb +0 -1
- data/lib/earth/automobile/automobile_activity_year_type.rb +4 -4
- data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +1 -2
- data/lib/earth/automobile/automobile_fuel.rb +1 -2
- data/lib/earth/automobile/automobile_make.rb +0 -1
- data/lib/earth/automobile/automobile_make/data_miner.rb +2 -0
- data/lib/earth/automobile/automobile_make_model.rb +1 -2
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +0 -1
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +2 -223
- data/lib/earth/automobile/automobile_make_model_year_variant/parser.rb +224 -0
- data/lib/earth/automobile/automobile_make_year_fleet.rb +0 -1
- data/lib/earth/automobile/automobile_model.rb +0 -1
- data/lib/earth/automobile/automobile_size_class.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel_control.rb +0 -1
- data/lib/earth/automobile/automobile_type_fuel_year.rb +4 -4
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +7 -15
- data/lib/earth/automobile/automobile_year.rb +0 -1
- data/lib/earth/bus/bus_class.rb +0 -1
- data/lib/earth/bus/bus_fuel.rb +1 -72
- data/lib/earth/bus/bus_fuel_control.rb +0 -1
- data/lib/earth/bus/bus_fuel_control/data_miner.rb +0 -2
- data/lib/earth/bus/bus_fuel_year_control.rb +0 -1
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +0 -2
- data/lib/earth/computation/computation_carrier.rb +1 -11
- data/lib/earth/computation/computation_carrier_instance_class.rb +4 -25
- data/lib/earth/computation/computation_carrier_region.rb +0 -1
- data/lib/earth/computation/computation_carrier_region/data_miner.rb +0 -3
- data/lib/earth/diet/diet_class.rb +0 -1
- data/lib/earth/diet/food_group.rb +1 -1
- data/lib/earth/electricity/electric_market.rb +2 -0
- data/lib/earth/electricity/electric_utility.rb +11 -4
- data/lib/earth/electricity/electric_utility/data_miner.rb +2 -8
- data/lib/earth/electricity/green_button_adoption.rb +2 -1
- data/lib/earth/fuel/fuel.rb +20 -81
- data/lib/earth/fuel/fuel_year.rb +0 -44
- data/lib/earth/fuel/greenhouse_gas.rb +0 -40
- data/lib/earth/hospitality/lodging_class.rb +0 -1
- data/lib/earth/industry/cbecs_energy_intensity.rb +25 -29
- data/lib/earth/industry/cbecs_energy_intensity/data_miner.rb +1 -1
- data/lib/earth/industry/industry.rb +1 -2
- data/lib/earth/industry/mecs_energy.rb +9 -10
- data/lib/earth/industry/mecs_ratio.rb +2 -1
- data/lib/earth/industry/merchant_category.rb +1 -0
- data/lib/earth/industry/naics_2002.rb +2 -0
- data/lib/earth/industry/naics_2002_naics_2007_concordance.rb +1 -0
- data/lib/earth/industry/naics_2002_sic_1987_concordance.rb +1 -0
- data/lib/earth/industry/naics_2007.rb +1 -0
- data/lib/earth/industry/sic_1987.rb +1 -0
- data/lib/earth/locality/census_division.rb +1 -3
- data/lib/earth/locality/climate_division.rb +0 -1
- data/lib/earth/locality/country.rb +1 -2
- data/lib/earth/locality/country/data_miner.rb +4 -0
- data/lib/earth/locality/egrid_country.rb +0 -1
- data/lib/earth/locality/egrid_region.rb +1 -3
- data/lib/earth/locality/egrid_subregion.rb +1 -3
- data/lib/earth/locality/electricity_mix.rb +2 -4
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +0 -1
- data/lib/earth/locality/state.rb +0 -1
- data/lib/earth/locality/zip_code.rb +0 -1
- data/lib/earth/model.rb +1 -1
- data/lib/earth/pet/breed.rb +0 -1
- data/lib/earth/pet/breed_gender.rb +0 -1
- data/lib/earth/pet/gender.rb +0 -1
- data/lib/earth/pet/species.rb +1 -3
- data/lib/earth/rail/country_rail_class.rb +0 -1
- data/lib/earth/rail/country_rail_traction.rb +0 -1
- data/lib/earth/rail/country_rail_traction_class.rb +0 -1
- data/lib/earth/rail/national_transit_database_company.rb +1 -3
- data/lib/earth/rail/national_transit_database_company/data_miner.rb +1 -1
- data/lib/earth/rail/national_transit_database_mode.rb +0 -1
- data/lib/earth/rail/national_transit_database_mode/data_miner.rb +1 -1
- data/lib/earth/rail/national_transit_database_record.rb +0 -1
- data/lib/earth/rail/national_transit_database_record/data_miner.rb +2 -2
- data/lib/earth/rail/rail_class.rb +0 -1
- data/lib/earth/rail/rail_class/data_miner.rb +5 -4
- data/lib/earth/rail/rail_company.rb +0 -1
- data/lib/earth/rail/rail_fuel.rb +0 -1
- data/lib/earth/rail/rail_traction.rb +0 -1
- data/lib/earth/rail/rail_traction/data_miner.rb +2 -8
- data/lib/earth/residence/air_conditioner_use.rb +0 -1
- data/lib/earth/residence/clothes_machine_use.rb +0 -1
- data/lib/earth/residence/dishwasher_use.rb +0 -1
- data/lib/earth/residence/residence_appliance.rb +0 -1
- data/lib/earth/residence/residence_class.rb +0 -1
- data/lib/earth/residence/residence_fuel_price.rb +1 -2
- data/lib/earth/residence/urbanity.rb +0 -1
- data/lib/earth/shipping/carrier.rb +1 -52
- data/lib/earth/shipping/carrier_mode.rb +0 -34
- data/lib/earth/shipping/shipment_mode.rb +0 -26
- data/lib/earth/tasks.rb +14 -4
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/aircraft_spec.rb +9 -1
- data/spec/earth/air/airline_spec.rb +2 -2
- data/spec/earth/air/airport_spec.rb +1 -2
- data/spec/earth/air/bts_aircraft_spec.rb +2 -2
- data/spec/earth/air/flight_distance_class_seat_class_spec.rb +22 -0
- data/spec/earth/air/flight_distance_class_spec.rb +26 -18
- data/spec/earth/air/flight_seat_class_spec.rb +12 -0
- data/spec/earth/air/flight_segment_spec.rb +38 -33
- data/spec/earth/automobile/automobile_activity_year_spec.rb +20 -14
- data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +14 -10
- data/spec/earth/automobile/automobile_activity_year_type_spec.rb +28 -20
- data/spec/earth/automobile/automobile_fuel_spec.rb +106 -52
- data/spec/earth/automobile/automobile_make_model_spec.rb +103 -62
- data/spec/earth/automobile/automobile_make_model_year_spec.rb +69 -46
- data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +108 -109
- data/spec/earth/automobile/automobile_make_spec.rb +8 -8
- data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +10 -6
- data/spec/earth/automobile/automobile_make_year_spec.rb +10 -9
- data/spec/earth/automobile/automobile_model_spec.rb +3 -0
- data/spec/earth/automobile/automobile_size_class_spec.rb +12 -11
- data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +9 -9
- data/spec/earth/automobile/automobile_type_fuel_spec.rb +23 -18
- data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +37 -29
- data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +35 -36
- data/spec/earth/automobile/automobile_year_spec.rb +4 -2
- data/spec/earth/bus/bus_class_spec.rb +10 -0
- data/spec/earth/bus/bus_fuel_control_spec.rb +3 -5
- data/spec/earth/bus/bus_fuel_spec.rb +16 -8
- data/spec/earth/bus/bus_fuel_year_control_spec.rb +7 -7
- data/spec/earth/computation/computation_carrrier_instance_class_spec.rb +17 -0
- data/spec/earth/computation/computation_carrrier_region_spec.rb +10 -0
- data/spec/earth/computation/computation_carrrier_spec.rb +17 -0
- data/spec/earth/diet/diet_class_spec.rb +14 -0
- data/spec/earth/diet/food_group_spec.rb +26 -0
- data/spec/earth/electricity/electric_market_spec.rb +4 -5
- data/spec/earth/electricity/electric_utility_spec.rb +30 -19
- data/spec/earth/electricity/green_button_adoption_spec.rb +29 -7
- data/spec/earth/fuel/fuel_spec.rb +88 -14
- data/spec/earth/fuel/fuel_year_spec.rb +21 -0
- data/spec/earth/fuel/greenhouse_gas_spec.rb +23 -0
- data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +13 -10
- data/spec/earth/hospitality/lodging_class_spec.rb +1 -1
- data/spec/earth/industry/cbecs_energy_intensity_spec.rb +72 -72
- data/spec/earth/industry/industry_spec.rb +16 -9
- data/spec/earth/industry/mecs_energy_spec.rb +76 -72
- data/spec/earth/industry/mecs_ratio_spec.rb +35 -31
- data/spec/earth/industry/merchant_category_spec.rb +7 -5
- data/spec/earth/industry/naics_2002_naics_2007_concordance_spec.rb +10 -19
- data/spec/earth/industry/naics_2002_sic_1987_concordance_spec.rb +9 -19
- data/spec/earth/industry/naics_2002_spec.rb +1 -11
- data/spec/earth/industry/naics_2007_spec.rb +2 -11
- data/spec/earth/industry/sic_1987_spec.rb +3 -14
- data/spec/earth/locality/census_division_spec.rb +25 -0
- data/spec/earth/locality/census_region_spec.rb +8 -0
- data/spec/earth/locality/climate_division_spec.rb +13 -0
- data/spec/earth/locality/country_spec.rb +24 -23
- data/spec/earth/locality/egrid_country_spec.rb +7 -6
- data/spec/earth/locality/egrid_region_spec.rb +6 -6
- data/spec/earth/locality/egrid_subregion_spec.rb +14 -14
- data/spec/earth/locality/electricity_mix_spec.rb +17 -17
- data/spec/earth/locality/padd_spec.rb +21 -0
- data/spec/earth/locality/state_spec.rb +8 -11
- data/spec/earth/locality/zip_code_spec.rb +29 -22
- data/spec/earth/pet/breed_gender_spec.rb +8 -0
- data/spec/earth/pet/breed_spec.rb +8 -0
- data/spec/earth/pet/gender_spec.rb +8 -0
- data/spec/earth/pet/species_spec.rb +11 -5
- data/spec/earth/rail/country_rail_class_spec.rb +16 -0
- data/spec/earth/rail/country_rail_traction_class_spec.rb +14 -0
- data/spec/earth/rail/country_rail_traction_spec.rb +14 -0
- data/spec/earth/rail/national_transit_database_company_spec.rb +103 -0
- data/spec/earth/rail/national_transit_database_mode_spec.rb +21 -0
- data/spec/earth/rail/national_transit_database_record_spec.rb +31 -0
- data/spec/earth/rail/rail_class_spec.rb +8 -0
- data/spec/earth/rail/rail_company_spec.rb +20 -0
- data/spec/earth/rail/rail_fuel_spec.rb +19 -0
- data/spec/earth/rail/rail_traction_spec.rb +8 -0
- data/spec/earth/residence/air_conditioner_use_spec.rb +17 -0
- data/spec/earth/residence/clothes_machine_use_spec.rb +11 -0
- data/spec/earth/residence/dishwasher_use_spec.rb +11 -0
- data/spec/earth/residence/residence_appliance_spec.rb +19 -0
- data/spec/earth/residence/residence_class_spec.rb +15 -0
- data/spec/earth/residence/residence_fuel_price_spec.rb +12 -0
- data/spec/earth/residence/residence_fuel_type_spec.rb +18 -0
- data/spec/earth/residence/residential_energy_consumption_survey_response_spec.rb +13 -0
- data/spec/earth/residence/urbanity_spec.rb +8 -0
- data/spec/earth/shipping/carrier_mode_spec.rb +18 -0
- data/spec/earth/shipping/carrier_spec.rb +27 -0
- data/spec/earth/shipping/shipment_mode_spec.rb +16 -0
- data/spec/earth_spec.rb +1 -1
- data/spec/factories/airline.rb +0 -1
- data/spec/factories/airport.rb +0 -1
- data/spec/factories/automobile_activity_year.rb +8 -0
- data/spec/factories/automobile_activity_year_type.rb +8 -0
- data/spec/factories/automobile_activity_year_type_fuel.rb +9 -0
- data/spec/factories/automobile_fuel.rb +15 -0
- data/spec/factories/automobile_make.rb +9 -0
- data/spec/factories/automobile_make_model.rb +10 -0
- data/spec/factories/automobile_make_model_year.rb +9 -0
- data/spec/factories/automobile_model.rb +9 -0
- data/spec/factories/automobile_type_fuel.rb +7 -0
- data/spec/factories/automobile_type_fuel_control.rb +16 -0
- data/spec/factories/automobile_type_fuel_year.rb +9 -0
- data/spec/factories/automobile_type_fuel_year_control.rb +11 -0
- data/spec/factories/bus_fuel.rb +7 -0
- data/spec/factories/bus_fuel_year_control.rb +9 -0
- data/spec/factories/cbecs_energy_intensity.rb +15 -0
- data/spec/factories/commercial_building_energy_consumption_survey_response.rb +10 -0
- data/spec/factories/electric_utility.rb +8 -0
- data/spec/factories/flight_distance_class.rb +8 -0
- data/spec/factories/flight_segment.rb +0 -1
- data/spec/factories/food_group.rb +8 -0
- data/spec/factories/fuel.rb +8 -0
- data/spec/factories/fuel_year.rb +8 -0
- data/spec/factories/green_button_adoption.rb +8 -0
- data/spec/factories/greenhouse_gas.rb +7 -0
- data/spec/factories/industry.rb +9 -0
- data/spec/factories/mecs_energy.rb +15 -0
- data/spec/factories/mecs_ratio.rb +15 -0
- data/spec/factories/national_transit_database_company.rb +8 -0
- data/spec/factories/national_transit_database_mode.rb +8 -0
- data/spec/factories/national_transit_database_record.rb +9 -0
- data/spec/factories/residence_appliance.rb +7 -0
- data/spec/factories/zip_code.rb +9 -0
- data/spec/spec_helper.rb +36 -19
- metadata +346 -66
- data/lib/earth/acronyms.rb +0 -12
- data/lib/earth/rail/rail_company_traction.rb +0 -24
- data/lib/earth/rail/rail_company_traction/data_miner.rb +0 -4
- data/lib/earth/rail/rail_company_traction_class.rb +0 -26
- data/lib/earth/rail/rail_company_traction_class/data_miner.rb +0 -4
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/computation/computation_carrier_instance_class'
|
3
|
+
|
4
|
+
describe ComputationCarrierInstanceClass do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
let(:ccic) { ComputationCarrierInstanceClass }
|
7
|
+
let(:total) { ccic.count }
|
8
|
+
|
9
|
+
it { total.should == 8 }
|
10
|
+
it { ccic.where('electricity_intensity > 0').count.should == total }
|
11
|
+
|
12
|
+
describe '.fallback' do
|
13
|
+
let(:fallback) { ccic.fallback }
|
14
|
+
it { fallback.electricity_intensity.should be_within(5e-6).of(0.105) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/computation/computation_carrier_region'
|
3
|
+
|
4
|
+
describe ComputationCarrierRegion do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { ComputationCarrierRegion.count.should == 4 }
|
7
|
+
|
8
|
+
# FIXME TODO more sanity checks
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/computation/computation_carrier'
|
3
|
+
|
4
|
+
describe ComputationCarrier do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
let(:total) { ComputationCarrier.count }
|
7
|
+
|
8
|
+
it { total.should == 1 }
|
9
|
+
it { ComputationCarrier.where('power_usage_effectiveness > 1.0').count.should == total }
|
10
|
+
|
11
|
+
describe '.fallback' do
|
12
|
+
let(:fallback) { ComputationCarrier.fallback }
|
13
|
+
|
14
|
+
it { fallback.power_usage_effectiveness.should be_within(5e-3).of(1.5) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/diet/diet_class'
|
3
|
+
|
4
|
+
describe DietClass do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { DietClass.count.should == 3 }
|
7
|
+
|
8
|
+
describe 'fallback' do
|
9
|
+
it { DietClass.fallback.name.should == 'standard' }
|
10
|
+
end
|
11
|
+
|
12
|
+
# FIXME TODO more sanity checks
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "#{Earth::FACTORY_DIR}/food_group"
|
3
|
+
|
4
|
+
describe FoodGroup do
|
5
|
+
describe '.names' do
|
6
|
+
it "returns a list of food group names" do
|
7
|
+
FoodGroup.delete_all
|
8
|
+
FactoryGirl.create :food_group, :meat
|
9
|
+
FactoryGirl.create :food_group, :veg
|
10
|
+
FoodGroup.names.should == ['meat', 'veg']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.[](name)' do
|
15
|
+
it "finds by name" do
|
16
|
+
meat = FactoryGirl.create :food_group, :meat
|
17
|
+
FoodGroup['meat'].should == meat
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'Sanity check', :sanity => true do
|
22
|
+
it { FoodGroup.count.should == 10 }
|
23
|
+
|
24
|
+
# FIXME TODO more sanity checks
|
25
|
+
end
|
26
|
+
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'earth/electricity/electric_market'
|
3
|
-
require 'earth/electricity/electric_utility' # needed for test verifying link with ElectricUtility
|
4
3
|
|
5
4
|
describe ElectricMarket do
|
6
|
-
describe '
|
5
|
+
describe 'Sanity check', :sanity => true do
|
7
6
|
it { ElectricMarket.count.should == 64864 }
|
7
|
+
it { ElectricMarket.where(:electric_utility_eia_id => nil).count.should == 0 }
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# spot check
|
11
10
|
it 'links 53704 to MG&E' do
|
12
|
-
|
11
|
+
ElectricMarket.where(:electric_utility_eia_id => 11479).map(&:zip_code_name).should include('53704')
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -1,44 +1,55 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require
|
2
|
+
require "#{Earth::FACTORY_DIR}/electric_utility"
|
3
|
+
require "#{Earth::FACTORY_DIR}/green_button_adoption"
|
3
4
|
|
4
5
|
describe ElectricUtility do
|
5
|
-
describe '
|
6
|
+
describe '#green_button_committer?' do
|
7
|
+
it 'should reveal which utilities have committed to the Green Button program' do
|
8
|
+
FactoryGirl.create :green_button_adoption, :committed_utility
|
9
|
+
FactoryGirl.create :green_button_adoption, :implemented_utility
|
10
|
+
|
11
|
+
FactoryGirl.create(:electric_utility, :committed_utility).green_button_committer?.should == true
|
12
|
+
FactoryGirl.create(:electric_utility, :implemented_utility).green_button_committer?.should == false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#green_button_implementer?' do
|
17
|
+
it 'should reveal which utilities have implemented the Green Button program' do
|
18
|
+
FactoryGirl.create :green_button_adoption, :committed_utility
|
19
|
+
FactoryGirl.create :green_button_adoption, :implemented_utility
|
20
|
+
|
21
|
+
FactoryGirl.create(:electric_utility, :committed_utility).green_button_implementer?.should == false
|
22
|
+
FactoryGirl.create(:electric_utility, :implemented_utility).green_button_implementer?.should == true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'Sanity check', :sanity => true do
|
6
27
|
it 'should include all U.S. utilities' do
|
7
28
|
ElectricUtility.count.should == 3265
|
8
29
|
end
|
9
|
-
|
10
|
-
it 'should have valid state postal abbreviations' do
|
11
|
-
ElectricUtility.where("state_postal_abbreviation IS NOT NULL").select("DISTINCT state_postal_abbreviation").each do |utility|
|
12
|
-
utility.state.should be_kind_of(State)
|
13
|
-
end
|
14
|
-
end
|
15
30
|
|
16
31
|
it 'should have valid NERC region abbreviations' do
|
17
32
|
ElectricUtility.where("nerc_region_abbreviation IS NOT NULL").select("DISTINCT nerc_region_abbreviation").each do |utility|
|
18
33
|
%w{ NPCC RFC SERC FRCC MRO SPP TRE WECC ASCC HICC}.include?(utility.nerc_region_abbreviation).should be_true
|
19
34
|
end
|
20
35
|
end
|
21
|
-
|
36
|
+
|
22
37
|
it 'should have valid second NERC region abbreviations' do
|
23
38
|
ElectricUtility.where("second_nerc_region_abbreviation IS NOT NULL").select("DISTINCT second_nerc_region_abbreviation").each do |utility|
|
24
39
|
%w{ NPCC RFC SERC FRCC MRO SPP TRE WECC ASCC HICC}.include?(utility.second_nerc_region_abbreviation).should be_true
|
25
40
|
end
|
26
41
|
end
|
27
|
-
|
42
|
+
|
28
43
|
it 'should include, specifically, MG&E' do
|
29
44
|
ElectricUtility.find(11479).name.should == 'Madison Gas & Electric Co'
|
30
45
|
end
|
31
|
-
|
46
|
+
|
32
47
|
it 'should include aliases' do
|
33
48
|
ElectricUtility.find(14328).nickname.should == 'PG&E'
|
34
49
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
it 'should reveal which utilities have committed to the Green Button program' do
|
41
|
-
ElectricUtility.find(14940).green_button_committer?.should == true
|
42
|
-
end
|
50
|
+
|
51
|
+
# spot checks
|
52
|
+
it { ElectricUtility.find(14328).green_button_implementer?.should == true }
|
53
|
+
it { ElectricUtility.find(14940).green_button_committer?.should == true }
|
43
54
|
end
|
44
55
|
end
|
@@ -1,16 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require
|
2
|
+
require "#{Earth::FACTORY_DIR}/green_button_adoption"
|
3
3
|
|
4
4
|
describe GreenButtonAdoption do
|
5
|
-
describe '
|
6
|
-
it
|
7
|
-
|
5
|
+
describe '.committed?(*names)' do
|
6
|
+
it "should return true for a utility that has committed to the green button" do
|
7
|
+
FactoryGirl.create :green_button_adoption, :committed_utility
|
8
|
+
FactoryGirl.create :green_button_adoption, :implemented_utility
|
9
|
+
|
10
|
+
GreenButtonAdoption.committed?('ACU').should == false
|
11
|
+
GreenButtonAdoption.committed?('ACU', 'A committed utility').should == true
|
12
|
+
GreenButtonAdoption.committed?('An implemented utility').should == false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.implemented?(*names)' do
|
17
|
+
it "should return true for a utility that has implemented the green button" do
|
18
|
+
FactoryGirl.create :green_button_adoption, :committed_utility
|
19
|
+
FactoryGirl.create :green_button_adoption, :implemented_utility
|
20
|
+
|
21
|
+
GreenButtonAdoption.implemented?('AIU').should == false
|
22
|
+
GreenButtonAdoption.implemented?('AIU', 'An implemented utility').should == true
|
23
|
+
GreenButtonAdoption.implemented?('A committed utility').should == false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'Sanity check', :sanity => true do
|
28
|
+
it { GreenButtonAdoption.count.should == 23 }
|
29
|
+
|
8
30
|
it 'should recognize that PG&E has implemented' do
|
9
31
|
GreenButtonAdoption.find('PG&E').implemented?.should == true
|
10
32
|
end
|
11
|
-
|
12
|
-
it 'should recognize that
|
13
|
-
GreenButtonAdoption.find('
|
33
|
+
|
34
|
+
it 'should recognize that PPL has committed' do
|
35
|
+
GreenButtonAdoption.find('PPL').committed?.should == true
|
14
36
|
end
|
15
37
|
end
|
16
38
|
end
|
@@ -1,26 +1,100 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'earth/fuel/fuel_year' # methods are delegated to FuelYear if value in fuels is null
|
2
|
+
require "#{Earth::FACTORY_DIR}/fuel"
|
3
|
+
require "#{Earth::FACTORY_DIR}/fuel_year"
|
5
4
|
|
6
5
|
describe Fuel do
|
7
|
-
describe '
|
8
|
-
it
|
9
|
-
|
6
|
+
describe '#latest_fuel_year' do
|
7
|
+
it {
|
8
|
+
FactoryGirl.create :fuel_year, :gas_2008
|
9
|
+
FactoryGirl.create :fuel_year, :gas_2007
|
10
|
+
gas = FactoryGirl.create :fuel, :gas
|
11
|
+
gas.latest_fuel_year.should == FuelYear.find('Gasoline 2008')
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#energy_content' do
|
16
|
+
it "returns energy content if present" do
|
17
|
+
diesel = FactoryGirl.create :fuel, :diesel
|
18
|
+
diesel.energy_content.should be_within(5e-6).of(39)
|
19
|
+
diesel.energy_content_units.should == 'megajoules_per_litre'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "delegates method to FuelYear if energy content missing" do
|
23
|
+
FactoryGirl.create :fuel_year, :gas_2008
|
24
|
+
gas = FactoryGirl.create :fuel, :gas
|
25
|
+
gas.energy_content.should be_within(5e-6).of(35)
|
26
|
+
gas.energy_content_units.should == 'megajoules_per_litre'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#carbon_content' do
|
31
|
+
it "returns carbon content if present" do
|
32
|
+
diesel = FactoryGirl.create :fuel, :diesel
|
33
|
+
diesel.carbon_content.should be_within(5e-6).of(19)
|
34
|
+
diesel.carbon_content_units.should == 'grams_per_megajoule'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "delegates method to FuelYear if carbon content missing" do
|
38
|
+
FactoryGirl.create :fuel_year, :gas_2008
|
39
|
+
gas = FactoryGirl.create :fuel, :gas
|
40
|
+
gas.carbon_content.should be_within(5e-6).of(18)
|
41
|
+
gas.carbon_content_units.should == 'grams_per_megajoule'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#co2_emission_factor' do
|
46
|
+
it "returns co2 emission factor if present" do
|
47
|
+
diesel = FactoryGirl.create :fuel, :diesel
|
48
|
+
diesel.co2_emission_factor.should be_within(5e-6).of(2.717)
|
49
|
+
diesel.co2_emission_factor_units.should == 'kilograms_per_litre'
|
10
50
|
end
|
11
51
|
|
52
|
+
it "delegates method to FuelYear if co2 emission factor missing" do
|
53
|
+
FactoryGirl.create :fuel_year, :gas_2008
|
54
|
+
gas = FactoryGirl.create :fuel, :gas
|
55
|
+
gas.co2_emission_factor.should be_within(5e-6).of(2.31)
|
56
|
+
gas.co2_emission_factor_units.should == 'kilograms_per_litre'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#co2_biogenic_emission_factor' do
|
61
|
+
it "returns co2 biogenic emission factor if present" do
|
62
|
+
diesel = FactoryGirl.create :fuel, :diesel
|
63
|
+
diesel.co2_biogenic_emission_factor.should be_within(5e-6).of(0.0)
|
64
|
+
diesel.co2_biogenic_emission_factor_units.should == 'kilograms_per_litre'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "delegates method to FuelYear if co2 biogenic emission factor missing" do
|
68
|
+
FactoryGirl.create :fuel_year, :gas_2008
|
69
|
+
gas = FactoryGirl.create :fuel, :gas
|
70
|
+
gas.co2_biogenic_emission_factor.should be_within(5e-6).of(0.0)
|
71
|
+
gas.co2_biogenic_emission_factor_units.should == 'kilograms_per_litre'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'Sanity check', :sanity => true do
|
76
|
+
let(:unvarying) { Fuel.where('biogenic_fraction IS NOT NULL') }
|
77
|
+
let(:biogenic) { Fuel.where(:biogenic_fraction => 1) }
|
78
|
+
let(:fossil) { Fuel.where(:biogenic_fraction => 0) }
|
79
|
+
|
80
|
+
it { Fuel.count.should == 23 }
|
81
|
+
it { biogenic.count.should == 3 }
|
82
|
+
it { fossil.count.should == 11 }
|
83
|
+
it { unvarying.where('energy_content > 0').count.should == unvarying.count }
|
84
|
+
it { unvarying.where('carbon_content >= 0').count.should == unvarying.count }
|
85
|
+
it { unvarying.where(:oxidation_factor => 1).count.should == unvarying.count }
|
86
|
+
it { biogenic.where(:co2_emission_factor => 0).count.should == biogenic.count }
|
87
|
+
it { fossil.where('co2_emission_factor >= 0').count.should == fossil.count }
|
88
|
+
it { biogenic.where('co2_biogenic_emission_factor > 0').count.should == biogenic.count }
|
89
|
+
it { fossil.where(:co2_biogenic_emission_factor => 0).count.should == fossil.count }
|
90
|
+
|
12
91
|
it 'should have a record for district heat' do
|
13
92
|
district_heat = Fuel.find 'District Heat'
|
14
93
|
district_heat.co2_emission_factor.should be_within(5e-6).of(0.07598)
|
15
94
|
end
|
16
95
|
|
17
|
-
#
|
18
|
-
it 'should
|
19
|
-
|
20
|
-
gasoline_years = FuelYear.where(:fuel_name => 'Motor Gasoline')
|
21
|
-
latest_gasoline_year = gasoline_years.find_by_year(gasoline_years.maximum(:year))
|
22
|
-
gasoline.energy_content.should == latest_gasoline_year.energy_content
|
23
|
-
gasoline.carbon_content.should == latest_gasoline_year.carbon_content
|
24
|
-
end
|
96
|
+
# spot check
|
97
|
+
it { Fuel.find('Motor Gasoline').co2_emission_factor.should be_within(5e-6).of(2.34183) }
|
98
|
+
it { Fuel.find('Distillate Fuel Oil No. 2').co2_emission_factor.should be_within(5e-6).of(2.70219) }
|
25
99
|
end
|
26
100
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/fuel/fuel_year'
|
3
|
+
|
4
|
+
describe FuelYear do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
let(:total) { FuelYear.count }
|
7
|
+
|
8
|
+
it { total.should == 171 }
|
9
|
+
it { FuelYear.where("carbon_content > 0").count.should == total }
|
10
|
+
it { FuelYear.where("energy_content > 0").count.should == total }
|
11
|
+
it { FuelYear.where("co2_emission_factor > 0").count.should == total }
|
12
|
+
it { FuelYear.where("co2_biogenic_emission_factor >= 0").count.should == total }
|
13
|
+
|
14
|
+
# Spot check
|
15
|
+
let(:gas) { FuelYear.find('Motor Gasoline 2008') }
|
16
|
+
it { gas.carbon_content.should be_within(5e-5).of(18.4445) }
|
17
|
+
it { gas.energy_content.should be_within(5e-5).of(34.6272) }
|
18
|
+
it { gas.co2_emission_factor.should be_within(5e-6).of(2.34183) }
|
19
|
+
it { gas.co2_biogenic_emission_factor.should be_within(5e-6).of(0) }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "#{Earth::FACTORY_DIR}/greenhouse_gas"
|
3
|
+
|
4
|
+
describe GreenhouseGas do
|
5
|
+
describe '.[abbreviation]' do
|
6
|
+
it {
|
7
|
+
GreenhouseGas.delete_all
|
8
|
+
co2 = FactoryGirl.create :ghg, :co2
|
9
|
+
GreenhouseGas['co2'].should == co2
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Sanity check', :sanity => true do
|
14
|
+
let(:total) { GreenhouseGas.count }
|
15
|
+
|
16
|
+
it { total.should == 4 }
|
17
|
+
it { GreenhouseGas.where('abbreviation IS NOT NULL').count.should == total }
|
18
|
+
it { GreenhouseGas.where('ipcc_report IS NOT NULL').count.should == total }
|
19
|
+
it { GreenhouseGas.where(:time_horizon => 100).count.should == total }
|
20
|
+
it { GreenhouseGas.where(:time_horizon_units => 'years').count.should == total }
|
21
|
+
it { GreenhouseGas.where('global_warming_potential >= 1').count.should == total }
|
22
|
+
end
|
23
|
+
end
|
@@ -1,10 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require
|
2
|
+
require "#{Earth::FACTORY_DIR}/commercial_building_energy_consumption_survey_response"
|
3
3
|
|
4
4
|
describe CommercialBuildingEnergyConsumptionSurveyResponse do
|
5
5
|
let(:cbecs) { CommercialBuildingEnergyConsumptionSurveyResponse }
|
6
6
|
|
7
|
-
describe "
|
7
|
+
describe ".lodging_records" do
|
8
|
+
it "should return records representing Hotels, Motels, and Inns with no other activity" do
|
9
|
+
cbecs.delete_all
|
10
|
+
h = FactoryGirl.create :cbecs_response, :hotel
|
11
|
+
m = FactoryGirl.create :cbecs_response, :motel
|
12
|
+
FactoryGirl.create :cbecs_response, :warehouse
|
13
|
+
FactoryGirl.create :cbecs_response, :hotel_warehouse
|
14
|
+
cbecs.lodging_records.should == [h, m]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "Sanity check", :sanity => true do
|
8
19
|
let(:total) { cbecs.count }
|
9
20
|
let(:first_lodging) { cbecs.lodging_records.first }
|
10
21
|
|
@@ -35,12 +46,4 @@ describe CommercialBuildingEnergyConsumptionSurveyResponse do
|
|
35
46
|
first_lodging.fuel_oil_per_room_night_units.should == 'megajoules_per_room_night'
|
36
47
|
end
|
37
48
|
end
|
38
|
-
|
39
|
-
describe ".lodging_records" do
|
40
|
-
it "should return records representing Hotels, Motels, and Inns with no other activity" do
|
41
|
-
cbecs.lodging_records.map(&:detailed_activity).uniq.sort.should == ['Hotel', 'Motel or inn']
|
42
|
-
cbecs.lodging_records.map(&:first_activity).uniq.should == [nil]
|
43
|
-
cbecs.lodging_records.count.should == 192
|
44
|
-
end
|
45
|
-
end
|
46
49
|
end
|