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
@@ -2,30 +2,21 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/industry/naics_2002_naics_2007_concordance'
|
3
3
|
|
4
4
|
describe Naics2002Naics2007Concordance do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let(:n2n) { Naics2002Naics2007Concordance }
|
6
|
+
|
7
|
+
describe '.extract_note(description)' do
|
8
|
+
it "extracts a paranthetical note from a description" do
|
9
|
+
n2n.extract_note("Internet Service Providers - Internet services providers providing services via client-supplied telecommunications connection").
|
8
10
|
should == "Internet services providers providing services via client-supplied telecommunications connection"
|
9
11
|
end
|
10
|
-
it 'should have all the data' do
|
11
|
-
Naics2002Naics2007Concordance.count.should == 1200
|
12
|
-
end
|
13
12
|
end
|
14
13
|
|
15
|
-
describe
|
16
|
-
|
17
|
-
|
18
|
-
require 'earth/industry/naics_2007'
|
19
|
-
end
|
20
|
-
|
21
|
-
it "belongs to :naics_2002" do
|
22
|
-
Naics2002Naics2007Concordance.find_by_naics_2002_code("111219").
|
23
|
-
naics_2002.should == Naics2002.find("111219")
|
14
|
+
describe 'Sanity check', :sanity => true do
|
15
|
+
it 'should have all the data' do
|
16
|
+
n2n.count.should == 1200
|
24
17
|
end
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
naics_2007.should == Naics2007.find("111211")
|
29
|
-
end
|
19
|
+
# spot check
|
20
|
+
it { n2n.where(:naics_2002_code => '111219').map(&:naics_2007_code).should == ['111219', '111211'] }
|
30
21
|
end
|
31
22
|
end
|
@@ -2,31 +2,21 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/industry/naics_2002_sic_1987_concordance'
|
3
3
|
|
4
4
|
describe Naics2002Sic1987Concordance do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
5
|
+
let(:n2s) { Naics2002Sic1987Concordance }
|
6
|
+
|
7
|
+
describe '.extract_note(description)' do
|
10
8
|
it "extracts a paranthetical note from a description" do
|
11
|
-
|
9
|
+
n2s.extract_note("Wood Household Furniture, Except Upholstered (wood box spring frames(parts))").
|
12
10
|
should == "wood box spring frames(parts)"
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
describe
|
17
|
-
|
18
|
-
|
19
|
-
require 'earth/industry/sic_1987'
|
20
|
-
end
|
21
|
-
|
22
|
-
it "belongs to :naics_2002" do
|
23
|
-
Naics2002Sic1987Concordance.find_by_naics_2002_code("111150").
|
24
|
-
naics_2002.should == Naics2002.find("111150")
|
14
|
+
describe 'Sanity check', :sanity => true do
|
15
|
+
it 'should have all the data' do
|
16
|
+
n2s.count.should == 2164
|
25
17
|
end
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
sic_1987.should == Sic1987.find("0119")
|
30
|
-
end
|
19
|
+
# spot check
|
20
|
+
it { n2s.where(:naics_2002_code => '111150').map(&:sic_1987_code).should == ['0119', '0115'] }
|
31
21
|
end
|
32
22
|
end
|
@@ -2,20 +2,10 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/industry/naics_2002'
|
3
3
|
|
4
4
|
describe Naics2002 do
|
5
|
-
describe "
|
5
|
+
describe "Sanity check", :sanity => true do
|
6
6
|
it "should have all the data" do
|
7
7
|
Naics2002.count.should == 2341
|
8
8
|
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "code translations" do
|
12
|
-
before do
|
13
|
-
require 'earth/industry/sic_1987'
|
14
|
-
require 'earth/industry/naics_2002_sic_1987_concordance'
|
15
|
-
require 'earth/industry/naics_2007'
|
16
|
-
require 'earth/industry/naics_2002_naics_2007_concordance'
|
17
|
-
require 'earth/industry/industry'
|
18
|
-
end
|
19
9
|
|
20
10
|
it "can be translated to a SIC 1987 code" do
|
21
11
|
{
|
@@ -2,17 +2,8 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/industry/naics_2007'
|
3
3
|
|
4
4
|
describe Naics2007 do
|
5
|
-
describe '
|
6
|
-
it
|
7
|
-
Naics2007.count.should == 2328
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "code translations" do
|
12
|
-
before do
|
13
|
-
require 'earth/industry/naics_2002'
|
14
|
-
require 'earth/industry/naics_2002_naics_2007_concordance'
|
15
|
-
end
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { Naics2007.count.should == 2328 }
|
16
7
|
|
17
8
|
it "can be translated to a NAICS 2002 code" do
|
18
9
|
{
|
@@ -2,20 +2,9 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/industry/sic_1987'
|
3
3
|
|
4
4
|
describe Sic1987 do
|
5
|
-
describe "
|
6
|
-
it
|
7
|
-
|
8
|
-
end
|
9
|
-
it "has a description for every code" do
|
10
|
-
Sic1987.find_by_description(nil).should be_nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "code translations" do
|
15
|
-
before do
|
16
|
-
require 'earth/industry/naics_2002'
|
17
|
-
require 'earth/industry/naics_2002_sic_1987_concordance'
|
18
|
-
end
|
5
|
+
describe "Sanity check", :sanity => true do
|
6
|
+
it { Sic1987.count.should == 1004 }
|
7
|
+
it { Sic1987.where(:description => nil).count.should == 0 }
|
19
8
|
|
20
9
|
it "can be translated to a NAICS 2002 code" do
|
21
10
|
{
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/locality/census_division'
|
3
|
+
|
4
|
+
describe CensusDivision do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { CensusDivision.count.should == 9 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
let(:pacific) { CensusDivision.find 9 }
|
10
|
+
it { pacific.meeting_building_natural_gas_intensity.should be_within(5e-6).of(0.00179) }
|
11
|
+
it { pacific.meeting_building_fuel_oil_intensity.should be_within(5e-10).of(0.000000012) }
|
12
|
+
it { pacific.meeting_building_electricity_intensity.should be_within(5e-6).of(0.04644) }
|
13
|
+
it { pacific.meeting_building_district_heat_intensity.should be_within(5e-6).of(0) }
|
14
|
+
|
15
|
+
describe '.fallback' do
|
16
|
+
let(:fallback) { CensusDivision.fallback }
|
17
|
+
|
18
|
+
it { fallback.name.should == 'fallback' }
|
19
|
+
it { fallback.meeting_building_natural_gas_intensity.should be_within(5e-6).of(0.01327) }
|
20
|
+
it { fallback.meeting_building_fuel_oil_intensity.should be_within(5e-6).of(0.00377) }
|
21
|
+
it { fallback.meeting_building_electricity_intensity.should be_within(5e-6).of(0.09077) }
|
22
|
+
it { fallback.meeting_building_district_heat_intensity.should be_within(5e-6).of(0.00542) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/locality/climate_division'
|
3
|
+
|
4
|
+
describe ClimateDivision do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
let(:total) { ClimateDivision.count }
|
7
|
+
|
8
|
+
it { total.should == 359 }
|
9
|
+
it { ClimateDivision.where('heating_degree_days > 0').count.should == total }
|
10
|
+
it { ClimateDivision.where('cooling_degree_days >= 0 ').count.should == total }
|
11
|
+
it { ClimateDivision.where(:state_postal_abbreviation => nil).count.should == 0 }
|
12
|
+
end
|
13
|
+
end
|
@@ -4,11 +4,18 @@ require 'spec_helper'
|
|
4
4
|
require 'earth/locality/country'
|
5
5
|
|
6
6
|
describe Country do
|
7
|
-
describe '
|
7
|
+
describe '.united_states' do
|
8
|
+
it 'should return the United States' do
|
9
|
+
us = Country.find_or_create_by_iso_3166_code 'US'
|
10
|
+
Country.united_states.should == us
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'Sanity check', :sanity => true do
|
8
15
|
let(:us) { Country.united_states }
|
9
16
|
let(:uk) { Country.find 'GB' }
|
10
17
|
|
11
|
-
it { Country.count.should ==
|
18
|
+
it { Country.count.should == 250 }
|
12
19
|
|
13
20
|
describe 'uses UTF-8 encoding' do
|
14
21
|
it { Country.find('AX').name.should == "Åland Islands" }
|
@@ -83,27 +90,21 @@ describe Country do
|
|
83
90
|
it { uk.rail_trip_diesel_intensity.should be_within(5e-5).of(0.0028) }
|
84
91
|
it { uk.rail_trip_co2_emission_factor.should be_within(5e-5).of(0.0458) }
|
85
92
|
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '.united_states' do
|
89
|
-
it 'should return the United States' do
|
90
|
-
Country.united_states.should == Country.find('US')
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '.fallback' do
|
95
|
-
let(:fallback) { Country.fallback }
|
96
93
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
94
|
+
describe '.fallback' do
|
95
|
+
let(:fallback) { Country.fallback }
|
96
|
+
|
97
|
+
it { fallback.name.should == 'fallback' }
|
98
|
+
it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.62609) }
|
99
|
+
it { fallback.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
100
|
+
it { fallback.electricity_co2_emission_factor.should be_within(5e-6).of(0.62354) }
|
101
|
+
it { fallback.electricity_co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
|
102
|
+
it { fallback.electricity_ch4_emission_factor.should be_within(5e-6).of(0.00021) }
|
103
|
+
it { fallback.electricity_ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
104
|
+
it { fallback.electricity_n2o_emission_factor.should be_within(5e-6).of(0.00234) }
|
105
|
+
it { fallback.electricity_n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
106
|
+
it { fallback.electricity_loss_factor.should be_within(5e-4).of(0.096) }
|
107
|
+
it { fallback.electricity_mix.should == ElectricityMix.fallback }
|
108
|
+
end
|
108
109
|
end
|
109
110
|
end
|
@@ -2,14 +2,15 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/locality/egrid_country'
|
3
3
|
|
4
4
|
describe EgridCountry do
|
5
|
-
describe 'verify imported data', :sanity => true do
|
6
|
-
it { EgridCountry.count.should == 1 }
|
7
|
-
it { EgridCountry.us.loss_factor.should be_within(5e-6).of(0.06503) }
|
8
|
-
end
|
9
|
-
|
10
5
|
describe '.us' do
|
11
6
|
it 'should return the US' do
|
12
|
-
|
7
|
+
us = EgridCountry.find_or_create_by_name 'U.S.'
|
8
|
+
EgridCountry.us.should == us
|
13
9
|
end
|
14
10
|
end
|
11
|
+
|
12
|
+
describe 'Sanity check', :sanity => true do
|
13
|
+
it { EgridCountry.count.should == 1 }
|
14
|
+
it { EgridCountry.us.loss_factor.should be_within(5e-6).of(0.06503) }
|
15
|
+
end
|
15
16
|
end
|
@@ -2,16 +2,16 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/locality/egrid_region'
|
3
3
|
|
4
4
|
describe EgridRegion do
|
5
|
-
describe '
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
6
|
it { EgridRegion.count.should == 5 }
|
7
7
|
it { EgridRegion.where("loss_factor > 0").count.should == EgridRegion.count }
|
8
8
|
|
9
9
|
# spot check
|
10
10
|
it { EgridRegion.first.loss_factor.should be_within(5e-6).of(0.05840) }
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
|
12
|
+
describe '.fallback' do
|
13
|
+
it { EgridRegion.fallback.name.should == 'fallback' }
|
14
|
+
it { EgridRegion.fallback.loss_factor.should be_within(5e-6).of(0.06503) }
|
15
|
+
end
|
16
16
|
end
|
17
17
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/locality/egrid_subregion'
|
3
3
|
|
4
4
|
describe EgridSubregion do
|
5
|
-
describe '
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
6
|
let(:total) { EgridSubregion.count }
|
7
7
|
let(:akgd) { EgridSubregion.find 'akgd' }
|
8
8
|
|
@@ -34,19 +34,19 @@ describe EgridSubregion do
|
|
34
34
|
|
35
35
|
# DEPRECATED
|
36
36
|
it { akgd.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '.fallback' do
|
40
|
-
let(:fallback) { EgridSubregion.fallback }
|
41
|
-
|
42
|
-
it { fallback.name.should == 'fallback' }
|
43
|
-
it { fallback.egrid_region.name.should == 'fallback' }
|
44
|
-
it { fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
|
45
|
-
it { fallback.co2_biogenic_emission_factor.should == nil }
|
46
|
-
it { fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
|
47
|
-
it { fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
|
48
37
|
|
49
|
-
|
50
|
-
|
38
|
+
describe '.fallback' do
|
39
|
+
let(:fallback) { EgridSubregion.fallback }
|
40
|
+
|
41
|
+
it { fallback.name.should == 'fallback' }
|
42
|
+
it { fallback.egrid_region.name.should == 'fallback' }
|
43
|
+
it { fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
|
44
|
+
it { fallback.co2_biogenic_emission_factor.should == nil }
|
45
|
+
it { fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
|
46
|
+
it { fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
|
47
|
+
|
48
|
+
# DEPRECATED
|
49
|
+
it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
|
50
|
+
end
|
51
51
|
end
|
52
52
|
end
|
@@ -2,7 +2,15 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/locality/electricity_mix'
|
3
3
|
|
4
4
|
describe ElectricityMix do
|
5
|
-
describe '
|
5
|
+
describe '#energy_content' do
|
6
|
+
it { ElectricityMix.new.energy_content.should be_within(5e-6).of(3.6) }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#energy_content_units' do
|
10
|
+
it { ElectricityMix.new.energy_content_units.should == 'megajoules_per_kilowatt_hour' }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Sanity check', :sanity => true do
|
6
14
|
let(:total) { ElectricityMix.count }
|
7
15
|
let(:uk) { ElectricityMix.find_by_country_iso_3166_code 'GB' }
|
8
16
|
let(:akgd) { ElectricityMix.find_by_egrid_subregion_abbreviation 'akgd' }
|
@@ -40,21 +48,13 @@ describe ElectricityMix do
|
|
40
48
|
it { ca.ch4_emission_factor.should be_within(5e-6).of(0.00033) }
|
41
49
|
it { ca.n2o_emission_factor.should be_within(5e-6).of(0.00085) }
|
42
50
|
it { ca.loss_factor.should be_within(5e-6).of(0.08208) }
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#energy_content' do
|
54
|
-
it { ElectricityMix.first.energy_content.should be_within(5e-6).of(3.6) }
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#energy_content_units' do
|
58
|
-
it { ElectricityMix.first.energy_content_units.should == 'megajoules_per_kilowatt_hour' }
|
51
|
+
|
52
|
+
describe '.fallback' do
|
53
|
+
it { ElectricityMix.fallback.name.should == 'fallback' }
|
54
|
+
it { ElectricityMix.fallback.co2_emission_factor.should be_within(5e-6).of(0.62354) }
|
55
|
+
it { ElectricityMix.fallback.ch4_emission_factor.should be_within(5e-6).of(0.00021) }
|
56
|
+
it { ElectricityMix.fallback.n2o_emission_factor.should be_within(5e-6).of(0.00234) }
|
57
|
+
it { ElectricityMix.fallback.loss_factor.should be_within(5e-6).of(0.096) }
|
58
|
+
end
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/locality/petroleum_administration_for_defense_district'
|
3
|
+
|
4
|
+
describe PetroleumAdministrationForDefenseDistrict do
|
5
|
+
let(:padd) { PetroleumAdministrationForDefenseDistrict }
|
6
|
+
|
7
|
+
describe '#name' do
|
8
|
+
it 'describes a PADD that is a district' do
|
9
|
+
test = padd.new(:district_code => 1, :district_name => 'East Coast')
|
10
|
+
test.name.should == 'PAD District 1 (East Coast)'
|
11
|
+
end
|
12
|
+
it 'describes a PADD that is a subdistric' do
|
13
|
+
test = padd.new(:district_code => 1, :district_name => 'East Coast', :subdistrict_code => 'A', :subdistrict_name => 'New England')
|
14
|
+
test.name.should == 'PAD District 1 (East Coast) Subdistrict 1A (New England)'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'Sanity check', :sanity => true do
|
19
|
+
it { padd.count.should == 7 }
|
20
|
+
end
|
21
|
+
end
|
@@ -2,7 +2,14 @@ require 'spec_helper'
|
|
2
2
|
require 'earth/locality/state'
|
3
3
|
|
4
4
|
describe State do
|
5
|
-
describe '
|
5
|
+
describe '#country' do
|
6
|
+
it 'should return the United States' do
|
7
|
+
us = Country.find_or_create_by_iso_3166_code 'US'
|
8
|
+
State.new.country.should == us
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Sanity check', :sanity => true do
|
6
13
|
it 'should have all the data' do
|
7
14
|
State.count.should == 51 # includes DC but not any territories
|
8
15
|
end
|
@@ -31,14 +38,4 @@ describe State do
|
|
31
38
|
State.find('NM').electricity_loss_factor.should be_within(5e-6).of(0.08007)
|
32
39
|
end
|
33
40
|
end
|
34
|
-
|
35
|
-
describe '#country' do
|
36
|
-
before do
|
37
|
-
require 'earth/locality/country'
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should return the United States' do
|
41
|
-
State.first.country.should == Country.united_states
|
42
|
-
end
|
43
|
-
end
|
44
41
|
end
|