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
@@ -1,42 +1,49 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require
|
2
|
+
require "#{Earth::FACTORY_DIR}/zip_code"
|
3
3
|
|
4
4
|
describe ZipCode do
|
5
|
-
describe 'verify imported data', :sanity => true do
|
6
|
-
it { ZipCode.count.should == 43770 }
|
7
|
-
it { ZipCode.where(:state_postal_abbreviation => nil).count.should == 0 }
|
8
|
-
it { ZipCode.where('latitude IS NOT NULL AND longitude IS NOT NULL').count.should == 43191 }
|
9
|
-
it { ZipCode.where('egrid_subregion_abbreviation IS NOT NULL').count.should == 41333 }
|
10
|
-
it { ZipCode.where('climate_division_name IS NOT NULL').count.should == 41358 }
|
11
|
-
it { ZipCode.where('population IS NOT NULL').count.should == 33120 }
|
12
|
-
end
|
13
|
-
|
14
5
|
# from acts_as_mappable
|
15
|
-
describe '.find_within' do
|
16
|
-
it
|
6
|
+
describe '.find_within(radius, units, lat/lng)' do
|
7
|
+
it 'returns all zips within radius of the lat/lng' do
|
8
|
+
zip1 = FactoryGirl.create :zip_code, :zip1
|
9
|
+
zip2 = FactoryGirl.create :zip_code, :zip2
|
10
|
+
zip3 = FactoryGirl.create :zip_code, :zip3
|
11
|
+
|
12
|
+
ZipCode.find_within(15, :units => :kms, :origin => zip1.latitude_longitude).should == [zip1, zip2]
|
13
|
+
end
|
17
14
|
end
|
18
15
|
|
19
16
|
describe '.known_subregion' do
|
20
|
-
it
|
17
|
+
it 'returns all zips with an egrid subregion abbreviation' do
|
18
|
+
zip1 = FactoryGirl.create :zip_code, :zip1
|
19
|
+
zip2 = FactoryGirl.create :zip_code, :zip2
|
20
|
+
ZipCode.known_subregion.count.should > 0
|
21
|
+
ZipCode.known_subregion.where(:egrid_subregion_abbreviation => nil).count.should == 0
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
describe '#country' do
|
24
|
-
before do
|
25
|
-
require 'earth/locality/country'
|
26
|
-
end
|
27
|
-
|
28
26
|
it 'returns the US' do
|
29
|
-
|
27
|
+
us = Country.find_or_create_by_iso_3166_code 'US'
|
28
|
+
ZipCode.new.country.should == us
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
describe '#latitude_longitude' do
|
33
|
+
it 'returns the lat and lng as an array of strings' do
|
34
|
+
FactoryGirl.create(:zip_code, :zip1).latitude_longitude.should == ['50', '-75']
|
35
|
+
end
|
34
36
|
it 'returns an array of nils for missing lat/lon' do
|
35
37
|
ZipCode.new.latitude_longitude.should == [nil, nil]
|
36
38
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'Sanity check', :sanity => true do
|
42
|
+
it { ZipCode.count.should == 43770 }
|
43
|
+
it { ZipCode.where(:state_postal_abbreviation => nil).count.should == 0 }
|
44
|
+
it { ZipCode.where('latitude IS NOT NULL AND longitude IS NOT NULL').count.should == 43191 }
|
45
|
+
it { ZipCode.where('egrid_subregion_abbreviation IS NOT NULL').count.should == 41333 }
|
46
|
+
it { ZipCode.where('climate_division_name IS NOT NULL').count.should == 41358 }
|
47
|
+
it { ZipCode.where('population IS NOT NULL').count.should == 33120 }
|
41
48
|
end
|
42
49
|
end
|
@@ -1,13 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'earth/pet/species'
|
2
3
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
describe Species do
|
5
|
+
# FIXME TODO method tests
|
6
|
+
|
7
|
+
describe 'Sanity check', :sanity => true do
|
8
|
+
it { Species.count.should == 18 }
|
9
|
+
|
10
|
+
describe 'fallback' do
|
11
|
+
it 'should have marginal dietary requirement of 0 when there is no data' do
|
8
12
|
Species.delete_all
|
9
13
|
Species.fallback.marginal_dietary_requirement.should == 0
|
10
14
|
end
|
11
15
|
end
|
16
|
+
|
17
|
+
# FIXME TODO more sanity checks
|
12
18
|
end
|
13
19
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/rail/country_rail_class'
|
3
|
+
|
4
|
+
describe CountryRailClass do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { CountryRailClass.count.should == 4 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
let(:us_heavy) { CountryRailClass.find 'US heavy' }
|
10
|
+
it { us_heavy.speed.should be_within(5e-3).of(32.7) }
|
11
|
+
it { us_heavy.trip_distance.should be_within(5e-3).of(7.7) }
|
12
|
+
it { us_heavy.electricity_intensity.should be_within(5e-5).of(0.1585) }
|
13
|
+
it { us_heavy.diesel_intensity.should be_within(5e-5).of(0) }
|
14
|
+
it { us_heavy.co2_emission_factor.should be_within(5e-5).of(0.1024) }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/rail/country_rail_traction_class'
|
3
|
+
|
4
|
+
describe CountryRailTractionClass do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { CountryRailTractionClass.count.should == 125 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
let(:gb_elec_highspeed) { CountryRailTractionClass.find 'GB electric highspeed' }
|
10
|
+
it { gb_elec_highspeed.electricity_intensity.should be_within(5e-5).of(0.07) }
|
11
|
+
it { gb_elec_highspeed.diesel_intensity.should be_within(5e-6).of(0) }
|
12
|
+
it { gb_elec_highspeed.co2_emission_factor.should be_within(5e-6).of(0.04153) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/rail/country_rail_traction'
|
3
|
+
|
4
|
+
describe CountryRailTraction do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { CountryRailTraction.count.should == 50 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
let(:gb_diesel) { CountryRailTraction.find 'GB diesel' }
|
10
|
+
it { gb_diesel.electricity_intensity.should be_within(5e-5).of(0) }
|
11
|
+
it { gb_diesel.diesel_intensity.should be_within(5e-6).of(0.02802) }
|
12
|
+
it { gb_diesel.co2_emission_factor.should be_within(5e-6).of(0.08351) }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "#{Earth::FACTORY_DIR}/national_transit_database_company"
|
3
|
+
require "#{Earth::FACTORY_DIR}/national_transit_database_mode"
|
4
|
+
require "#{Earth::FACTORY_DIR}/national_transit_database_record"
|
5
|
+
|
6
|
+
describe NationalTransitDatabaseCompany do
|
7
|
+
describe '.rail_companies' do
|
8
|
+
it "returns all companies that provide rail service" do
|
9
|
+
NationalTransitDatabaseMode.delete_all
|
10
|
+
FactoryGirl.create :ntd_mode, :bus
|
11
|
+
FactoryGirl.create :ntd_mode, :rail
|
12
|
+
FactoryGirl.create :ntd_record, :bus_record
|
13
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
14
|
+
FactoryGirl.create :ntd_company, :bus_company
|
15
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
16
|
+
NationalTransitDatabaseCompany.rail_companies.should == [muni]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#rail_records' do
|
21
|
+
it "returns the company's rail transport records" do
|
22
|
+
NationalTransitDatabaseMode.delete_all
|
23
|
+
FactoryGirl.create :ntd_mode, :rail
|
24
|
+
FactoryGirl.create :ntd_record, :ny_rail_record
|
25
|
+
muni_record = FactoryGirl.create :ntd_record, :sf_rail_record
|
26
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
27
|
+
muni.rail_records.should == [muni_record]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#rail_passengers' do
|
32
|
+
it "calculates the company's rail passengers" do
|
33
|
+
NationalTransitDatabaseMode.delete_all
|
34
|
+
FactoryGirl.create :ntd_mode, :rail
|
35
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
36
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
37
|
+
muni.rail_passengers.should == 5000
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#rail_passenger_distance' do
|
42
|
+
it "calculates the company's rail passenger distance" do
|
43
|
+
NationalTransitDatabaseMode.delete_all
|
44
|
+
FactoryGirl.create :ntd_mode, :rail
|
45
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
46
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
47
|
+
muni.rail_passenger_distance.should == 500000
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#rail_vehicle_distance' do
|
52
|
+
it "calculates the company's vehicle distance" do
|
53
|
+
NationalTransitDatabaseMode.delete_all
|
54
|
+
FactoryGirl.create :ntd_mode, :rail
|
55
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
56
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
57
|
+
muni.rail_vehicle_distance.should == 10000
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#rail_vehicle_time' do
|
62
|
+
it "calculates the company's vehicle time" do
|
63
|
+
NationalTransitDatabaseMode.delete_all
|
64
|
+
FactoryGirl.create :ntd_mode, :rail
|
65
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
66
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
67
|
+
muni.rail_vehicle_time.should == 100
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#rail_electricity' do
|
72
|
+
it "calculates the company's rail electricity use" do
|
73
|
+
NationalTransitDatabaseMode.delete_all
|
74
|
+
FactoryGirl.create :ntd_mode, :rail
|
75
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
76
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
77
|
+
muni.rail_electricity.should == 25000
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#rail_diesel' do
|
82
|
+
it "calculates the company's rail diesel use" do
|
83
|
+
NationalTransitDatabaseMode.delete_all
|
84
|
+
FactoryGirl.create :ntd_mode, :rail
|
85
|
+
FactoryGirl.create :ntd_record, :sf_rail_record
|
86
|
+
muni = FactoryGirl.create :ntd_company, :rail_company
|
87
|
+
muni.rail_diesel.should be_nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'Sanity check', :sanity => true do
|
92
|
+
it { NationalTransitDatabaseCompany.count.should == 710 }
|
93
|
+
it { NationalTransitDatabaseCompany.rail_companies.count.should == 60 }
|
94
|
+
|
95
|
+
# spot check
|
96
|
+
let(:sf_muni) { NationalTransitDatabaseCompany.find '9015' }
|
97
|
+
it { sf_muni.rail_records.count.should == 2 }
|
98
|
+
it { sf_muni.rail_passengers.should be_within(5).of(58657463) }
|
99
|
+
it { sf_muni.rail_passenger_distance.should be_within(5).of(233748847) }
|
100
|
+
it { sf_muni.rail_electricity.should == 58597067 }
|
101
|
+
it { sf_muni.rail_diesel.should be_nil }
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "#{Earth::FACTORY_DIR}/national_transit_database_mode"
|
3
|
+
|
4
|
+
describe NationalTransitDatabaseMode do
|
5
|
+
describe '.rail_modes' do
|
6
|
+
it "should return all rail modes" do
|
7
|
+
NationalTransitDatabaseMode.delete_all
|
8
|
+
FactoryGirl.create :ntd_mode, :bus
|
9
|
+
rail = FactoryGirl.create :ntd_mode, :rail
|
10
|
+
NationalTransitDatabaseMode.rail_modes.should == [rail]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'Sanity check', :sanity => true do
|
15
|
+
it { NationalTransitDatabaseMode.count.should == 14 }
|
16
|
+
|
17
|
+
# spot check
|
18
|
+
it { NationalTransitDatabaseMode.rail_modes.count.should == 8 }
|
19
|
+
it { NationalTransitDatabaseMode.find('HR').rail_mode.should == true }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "#{Earth::FACTORY_DIR}/national_transit_database_mode"
|
3
|
+
require "#{Earth::FACTORY_DIR}/national_transit_database_record"
|
4
|
+
|
5
|
+
describe NationalTransitDatabaseRecord do
|
6
|
+
describe '.rail_records' do
|
7
|
+
it "should return all rail records" do
|
8
|
+
NationalTransitDatabaseMode.delete_all
|
9
|
+
FactoryGirl.create :ntd_mode, :bus
|
10
|
+
FactoryGirl.create :ntd_mode, :rail
|
11
|
+
FactoryGirl.create :ntd_record, :bus_record
|
12
|
+
rail_record = FactoryGirl.create :ntd_record, :sf_rail_record
|
13
|
+
NationalTransitDatabaseRecord.rail_records.should == [rail_record]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'Sanity check', :sanity => true do
|
18
|
+
it { NationalTransitDatabaseRecord.count.should == 1310 }
|
19
|
+
it { NationalTransitDatabaseRecord.rail_records.count.should == 81 }
|
20
|
+
|
21
|
+
# spot check
|
22
|
+
let(:sf_muni_lr) { NationalTransitDatabaseRecord.find '9015 LR DO' }
|
23
|
+
it { sf_muni_lr.passengers.should be_within(50).of(50744862) }
|
24
|
+
it { sf_muni_lr.passenger_distance.should be_within(500).of(217848220) }
|
25
|
+
it { sf_muni_lr.electricity.should be_within(50).of(54532320) }
|
26
|
+
it { sf_muni_lr.diesel.should be_nil }
|
27
|
+
|
28
|
+
let(:sf_muni_bus) { NationalTransitDatabaseRecord.find '9015 MB DO' }
|
29
|
+
it { sf_muni_bus.diesel.should be_within(50).of(19087261) }
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/rail/rail_company'
|
3
|
+
|
4
|
+
describe RailCompany do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { RailCompany.count.should == 97 }
|
7
|
+
|
8
|
+
# sanity check
|
9
|
+
let(:amtrak) { RailCompany.find 'AMTRAK' }
|
10
|
+
it { amtrak.passengers.should == 27279200 }
|
11
|
+
it { amtrak.passenger_distance.should == 9517810000 }
|
12
|
+
it { amtrak.trip_distance.should be_within(5e-4).of(348.904) }
|
13
|
+
it { amtrak.train_distance.should == 61637900 }
|
14
|
+
it { amtrak.train_time.should == 1162250 }
|
15
|
+
it { amtrak.speed.should be_within(5e-5).of(53.0333) }
|
16
|
+
it { amtrak.electricity_intensity.should be_within(5e-5).of(0.0655) }
|
17
|
+
it { amtrak.diesel_intensity.should be_within(5e-5).of(0.0256) }
|
18
|
+
it { amtrak.co2_emission_factor.should be_within(5e-6).of(0.10782) }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/rail/rail_fuel'
|
3
|
+
|
4
|
+
describe RailFuel do
|
5
|
+
describe 'Sanity check', :sanity => true do
|
6
|
+
it { RailFuel.count.should == 1 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
let(:diesel) { RailFuel.find 'diesel' }
|
10
|
+
it { diesel.ch4_emission_factor.should be_within(5e-6).of(0.00529) }
|
11
|
+
it { diesel.n2o_emission_factor.should be_within(5e-6).of(0.02016) }
|
12
|
+
|
13
|
+
let(:distillate) { Fuel.find 'Distillate Fuel Oil No. 2' }
|
14
|
+
it { diesel.fuel.should == distillate }
|
15
|
+
it { diesel.density.should == distillate.density }
|
16
|
+
it { diesel.co2_emission_factor.should == distillate.co2_emission_factor }
|
17
|
+
it { diesel.co2_biogenic_emission_factor.should == distillate.co2_biogenic_emission_factor }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/residence/air_conditioner_use'
|
3
|
+
|
4
|
+
describe AirConditionerUse do
|
5
|
+
describe "Sanity check", :sanity => true do
|
6
|
+
it { AirConditionerUse.count.should == 4 }
|
7
|
+
|
8
|
+
# sanity check
|
9
|
+
it { AirConditionerUse.find('Turned on quite a bit').fugitive_emission.should be_within(5e-6).of(0.5757) }
|
10
|
+
|
11
|
+
describe '.fallback' do
|
12
|
+
let(:fallback) { AirConditionerUse.fallback }
|
13
|
+
it { fallback.fugitive_emission.should be_within(5e-6).of(0.49945) }
|
14
|
+
it { fallback.fugitive_emission_units.should == 'kilograms_per_square_metre' }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/residence/clothes_machine_use'
|
3
|
+
|
4
|
+
describe ClothesMachineUse do
|
5
|
+
describe "Sanity check", :sanity => true do
|
6
|
+
it { ClothesMachineUse.count.should == 5 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
it { ClothesMachineUse.first.annual_energy_from_electricity_for_clothes_driers.should == 2087260000 }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/residence/dishwasher_use'
|
3
|
+
|
4
|
+
describe DishwasherUse do
|
5
|
+
describe "Sanity check", :sanity => true do
|
6
|
+
it { DishwasherUse.count.should == 5 }
|
7
|
+
|
8
|
+
# spot check
|
9
|
+
it { DishwasherUse.first.annual_energy_from_electricity_for_dishwashers.should == 669100000 }
|
10
|
+
end
|
11
|
+
end
|