earth 0.11.20 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/data/automobile/annual_emission_controls.csv +143 -0
- data/data/automobile/annual_fuel_consumption.csv +81 -0
- data/data/automobile/annual_sizes.csv +541 -0
- data/data/automobile/auto_fuel_data.csv +13 -0
- data/data/automobile/auto_fuel_efs.csv +9 -0
- data/data/automobile/cafe_data.csv +1449 -0
- data/data/automobile/emission_control_techs.csv +21 -0
- data/data/automobile/hfc_emissions.csv +31 -0
- data/data/automobile/hybridity_multipliers.csv +8 -0
- data/data/automobile/sizes.csv +16 -0
- data/earth.gemspec +3 -2
- data/errata/aircraft/faa_errata.csv +1 -1
- data/errata/airline/bts_carrier_codes_errata.csv +44 -0
- data/errata/airport/openflights_errata.csv +450 -1
- data/errata/automobile_make_model_year_variant/feg_errata.csv +363 -1
- data/errata/automobile_make_year_fleet/cafe_errata.csv +69 -1
- data/errata/bts_aircraft/bts_errata.csv +1 -1
- data/errata/country/wri_errata.csv +1 -1
- data/errata/electricity/electric_market/nrel_errata.csv +13 -1
- data/errata/electricity/electric_utility/eia_errata.csv +18 -1
- data/errata/flight_segment/bts_errata.csv +4 -1
- data/lib/earth.rb +1 -0
- data/lib/earth/acronyms.rb +12 -0
- data/lib/earth/air/aircraft.rb +16 -0
- data/lib/earth/air/airline.rb +3 -0
- data/lib/earth/air/airline/data_miner.rb +18 -3
- data/lib/earth/air/airport.rb +2 -0
- data/lib/earth/air/bts_aircraft.rb +2 -0
- data/lib/earth/air/flight_distance_class.rb +2 -0
- data/lib/earth/air/flight_distance_class_seat_class.rb +2 -0
- data/lib/earth/air/flight_seat_class.rb +2 -0
- data/lib/earth/air/flight_segment.rb +10 -0
- data/lib/earth/air/flight_segment/data_miner.rb +10 -13
- data/lib/earth/automobile/automobile_activity_year.rb +21 -0
- data/lib/earth/automobile/automobile_activity_year/data_miner.rb +27 -0
- data/lib/earth/automobile/automobile_activity_year_type.rb +27 -0
- data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +27 -0
- data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +19 -0
- data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +57 -0
- data/lib/earth/automobile/automobile_fuel.rb +93 -86
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +64 -70
- data/lib/earth/automobile/automobile_make.rb +5 -1
- data/lib/earth/automobile/automobile_make/data_miner.rb +10 -37
- data/lib/earth/automobile/automobile_make_model.rb +22 -3
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +41 -15
- data/lib/earth/automobile/automobile_make_model_year.rb +18 -7
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +43 -27
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +44 -8
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +182 -8
- data/lib/earth/automobile/automobile_make_year.rb +4 -2
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +16 -15
- data/lib/earth/automobile/automobile_make_year_fleet.rb +2 -1
- data/lib/earth/automobile/automobile_make_year_fleet/data_miner.rb +5 -2
- data/lib/earth/automobile/automobile_model.rb +2 -1
- data/lib/earth/automobile/automobile_model/data_miner.rb +1 -2
- data/lib/earth/automobile/automobile_size_class.rb +7 -68
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +16 -51
- data/lib/earth/automobile/automobile_type_fuel.rb +23 -0
- data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +52 -0
- data/lib/earth/automobile/automobile_type_fuel_control.rb +2 -33
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +19 -4
- data/lib/earth/automobile/automobile_type_fuel_year.rb +17 -54
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +40 -94
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +25 -23
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +6 -2
- data/lib/earth/automobile/automobile_year.rb +38 -1
- data/lib/earth/automobile/automobile_year/data_miner.rb +1 -2
- data/lib/earth/automobile/dependencies.txt +22 -36
- data/lib/earth/bus/bus_class.rb +2 -0
- data/lib/earth/bus/bus_fuel.rb +2 -0
- data/lib/earth/bus/bus_fuel_control.rb +2 -0
- data/lib/earth/bus/bus_fuel_year_control.rb +2 -0
- data/lib/earth/computation/computation_carrier.rb +2 -0
- data/lib/earth/computation/computation_carrier_instance_class.rb +2 -0
- data/lib/earth/computation/computation_carrier_region.rb +2 -0
- data/lib/earth/conversions_ext.rb +6 -0
- data/lib/earth/diet/diet_class.rb +2 -0
- data/lib/earth/diet/food_group.rb +2 -0
- data/lib/earth/fuel/fuel.rb +2 -0
- data/lib/earth/fuel/fuel/data_miner.rb +15 -0
- data/lib/earth/fuel/fuel_price.rb +2 -0
- data/lib/earth/fuel/fuel_type.rb +2 -0
- data/lib/earth/fuel/fuel_year.rb +2 -0
- data/lib/earth/fuel/greenhouse_gas.rb +2 -0
- data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +7 -7
- data/lib/earth/hospitality/lodging_class.rb +2 -0
- data/lib/earth/industry/industry.rb +2 -0
- data/lib/earth/industry/mecs_energy/data_miner.rb +1 -1
- data/lib/earth/industry/mecs_ratio/data_miner.rb +1 -1
- data/lib/earth/locality/census_division.rb +2 -0
- data/lib/earth/locality/census_region.rb +2 -0
- data/lib/earth/locality/climate_division.rb +2 -0
- data/lib/earth/locality/country.rb +4 -0
- data/lib/earth/locality/egrid_region.rb +3 -0
- data/lib/earth/locality/egrid_subregion.rb +2 -0
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +7 -0
- data/lib/earth/locality/state.rb +7 -0
- data/lib/earth/locality/zip_code.rb +4 -0
- data/lib/earth/pet/breed.rb +7 -0
- data/lib/earth/pet/breed/data_miner.rb +1 -1
- data/lib/earth/pet/breed_gender.rb +2 -0
- data/lib/earth/pet/gender.rb +2 -0
- data/lib/earth/pet/species.rb +2 -0
- data/lib/earth/rail/country_rail_class.rb +2 -0
- data/lib/earth/rail/country_rail_traction.rb +2 -0
- data/lib/earth/rail/country_rail_traction_class.rb +2 -0
- data/lib/earth/rail/national_transit_database_company.rb +7 -0
- data/lib/earth/rail/national_transit_database_mode.rb +2 -0
- data/lib/earth/rail/national_transit_database_record.rb +22 -0
- data/lib/earth/rail/rail_class.rb +2 -0
- data/lib/earth/rail/rail_company.rb +16 -0
- data/lib/earth/rail/rail_fuel.rb +2 -0
- data/lib/earth/rail/rail_traction.rb +2 -0
- data/lib/earth/residence/air_conditioner_use.rb +2 -0
- data/lib/earth/residence/clothes_machine_use.rb +2 -0
- data/lib/earth/residence/dishwasher_use.rb +2 -0
- data/lib/earth/residence/residence_appliance.rb +2 -0
- data/lib/earth/residence/residence_class.rb +2 -0
- data/lib/earth/residence/residence_fuel_price.rb +2 -0
- data/lib/earth/residence/residence_fuel_type.rb +2 -0
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +2 -0
- data/lib/earth/residence/urbanity.rb +2 -0
- data/lib/earth/shipping/carrier.rb +2 -0
- data/lib/earth/shipping/carrier_mode.rb +2 -0
- data/lib/earth/shipping/shipment_mode.rb +2 -0
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/airline_spec.rb +20 -0
- data/spec/earth/air/flight_segment_spec.rb +9 -4
- data/spec/earth/automobile/automobile_activity_year_spec.rb +30 -0
- data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +25 -0
- data/spec/earth/automobile/automobile_activity_year_type_spec.rb +38 -0
- data/spec/earth/automobile/automobile_fuel_spec.rb +91 -6
- data/spec/earth/automobile/automobile_make_model_spec.rb +74 -0
- data/spec/earth/automobile/automobile_make_model_year_spec.rb +90 -0
- data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +139 -90
- data/spec/earth/automobile/automobile_make_spec.rb +27 -0
- data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +8 -21
- data/spec/earth/automobile/automobile_make_year_spec.rb +28 -0
- data/spec/earth/automobile/automobile_model_spec.rb +15 -0
- data/spec/earth/automobile/automobile_size_class_spec.rb +31 -0
- data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +25 -0
- data/spec/earth/automobile/automobile_type_fuel_spec.rb +45 -0
- data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +51 -0
- data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +65 -0
- data/spec/earth/automobile/automobile_year_spec.rb +23 -0
- data/spec/earth/fuel/fuel_spec.rb +1 -1
- data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +11 -3
- data/spec/earth_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +78 -25
- data/lib/earth/automobile/automobile_size_class_year.rb +0 -44
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -18
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +0 -68
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +0 -116
- data/lib/earth/automobile/automobile_type_year.rb +0 -58
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +0 -30
- data/spec/earth/automobile/automobile_type_fuel_year_age_spec.rb +0 -20
data/lib/earth/locality/state.rb
CHANGED
@@ -20,4 +20,11 @@ class State < ActiveRecord::Base
|
|
20
20
|
col :electricity_emission_factor, :type => :float
|
21
21
|
col :electricity_emission_factor_units
|
22
22
|
col :electricity_loss_factor, :type => :float
|
23
|
+
|
24
|
+
warn_if_nulls_except(
|
25
|
+
:census_division_number,
|
26
|
+
:petroleum_administration_for_defense_district_code
|
27
|
+
)
|
28
|
+
|
29
|
+
warn_unless_size 57
|
23
30
|
end
|
data/lib/earth/pet/breed.rb
CHANGED
@@ -10,7 +10,7 @@ Breed.class_eval do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
import "a list of horse breeds", :url => 'http://www.freebase.com/type/exporttypeinstances/base/horses/horse_breed?page=0&filter_mode=type&filter_view=table&show%01p%3D%2Ftype%2Fobject%2Fname%01index=0&show%01p%3D%2Fcommon%2Ftopic%2Fimage%01index=1&show%01p%3D%2Fcommon%2Ftopic%2Farticle%01index=2&sort%01p%3D%2Ftype%2Fobject%2Ftype%01p%3Dlink%01p%3D%2Ftype%2Flink%2Ftimestamp%01index=false&=&exporttype=csv-8' do
|
13
|
-
key 'name'
|
13
|
+
key 'name', :field_name => 'Name'
|
14
14
|
store 'species_name', :static => 'horse'
|
15
15
|
end
|
16
16
|
end
|
data/lib/earth/pet/gender.rb
CHANGED
data/lib/earth/pet/species.rb
CHANGED
@@ -39,4 +39,26 @@ class NationalTransitDatabaseRecord < ActiveRecord::Base
|
|
39
39
|
col :other_fuel, :type => :float
|
40
40
|
col :other_fuel_units
|
41
41
|
col :other_fuel_description
|
42
|
+
|
43
|
+
warn_if_nulls_except(
|
44
|
+
:electricity,
|
45
|
+
:electricity_units,
|
46
|
+
:diesel,
|
47
|
+
:diesel_units,
|
48
|
+
:lpg,
|
49
|
+
:lpg_units,
|
50
|
+
:lng,
|
51
|
+
:lng_units,
|
52
|
+
:cng,
|
53
|
+
:cng_units,
|
54
|
+
:kerosene,
|
55
|
+
:kerosene_units,
|
56
|
+
:biodiesel,
|
57
|
+
:biodiesel_units,
|
58
|
+
:other_fuel,
|
59
|
+
:other_fuel_units,
|
60
|
+
:other_fuel_description
|
61
|
+
)
|
62
|
+
|
63
|
+
warn_unless_size 1310
|
42
64
|
end
|
@@ -25,4 +25,20 @@ class RailCompany < ActiveRecord::Base
|
|
25
25
|
col :diesel_intensity_units
|
26
26
|
col :co2_emission_factor, :type => :float
|
27
27
|
col :co2_emission_factor_units
|
28
|
+
|
29
|
+
warn_if_nulls_except(
|
30
|
+
:duns_number,
|
31
|
+
:train_time,
|
32
|
+
:train_time_units,
|
33
|
+
:speed,
|
34
|
+
:speed_units,
|
35
|
+
:electricity_intensity,
|
36
|
+
:electricity_intensity_units,
|
37
|
+
:diesel_intensity,
|
38
|
+
:diesel_intensity_units,
|
39
|
+
:co2_emission_factor,
|
40
|
+
:co2_emission_factor_units
|
41
|
+
)
|
42
|
+
|
43
|
+
warn_unless_size 97
|
28
44
|
end
|
data/lib/earth/rail/rail_fuel.rb
CHANGED
data/lib/earth/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/air/airline'
|
3
|
+
|
4
|
+
describe Airline do
|
5
|
+
before :all do
|
6
|
+
Earth.init :air, :load_data_miner => true, :skip_parent_associations => :true
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'import', :data_miner => true do
|
10
|
+
it 'should import data' do
|
11
|
+
Airline.run_data_miner!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "verify imported data", :sanity => true do
|
16
|
+
it "should have all the data" do
|
17
|
+
Airline.count.should == 1522
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -23,6 +23,12 @@ describe FlightSegment do
|
|
23
23
|
FlightSegment.where("year IS NULL OR year < 2009 OR year > #{::Time.now.year}").count.should == 0
|
24
24
|
end
|
25
25
|
|
26
|
+
it "should have data through 7 months ago" do
|
27
|
+
latest = Date.today << 7
|
28
|
+
FlightSegment.maximum(:year).should == latest.year
|
29
|
+
FlightSegment.where(:year => latest.year).maximum(:month).should == latest.month
|
30
|
+
end
|
31
|
+
|
26
32
|
it "should have origin airport in airports" do
|
27
33
|
# FIXME TODO
|
28
34
|
end
|
@@ -39,10 +45,9 @@ describe FlightSegment do
|
|
39
45
|
# FIXME TODO
|
40
46
|
end
|
41
47
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# end
|
48
|
+
it "should have airline name" do
|
49
|
+
FlightSegment.where(:airline_name => nil).count.should == 0
|
50
|
+
end
|
46
51
|
|
47
52
|
it "should have aircraft description" do
|
48
53
|
FlightSegment.where(:aircraft_description => nil).count.should == 0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/automobile/automobile_activity_year'
|
3
|
+
|
4
|
+
describe AutomobileActivityYear do
|
5
|
+
before :all do
|
6
|
+
Earth.init :automobile, :load_data_miner => true
|
7
|
+
require 'earth/acronyms'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'import', :data_miner => true do
|
11
|
+
it 'should import data' do
|
12
|
+
AAY.run_data_miner!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'verify', :sanity => true do
|
17
|
+
it { AAY.count.should == 15 }
|
18
|
+
it { AAY.where("hfc_emission_factor > 0").count.should == AAY.count }
|
19
|
+
|
20
|
+
# spot check
|
21
|
+
it { AAY.first.hfc_emission_factor.should be_within(1e-5).of(0.01656) }
|
22
|
+
it { AAY.first.hfc_emission_factor_units.should == 'kilograms_co2e_per_kilometre' }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.find_by_closest_year' do
|
26
|
+
it { AAY.find_by_closest_year(1994).should == AAY.find(1995) }
|
27
|
+
it { AAY.find_by_closest_year(2005).should == AAY.find(2005) }
|
28
|
+
it { AAY.find_by_closest_year(2010).should == AAY.find(2009) }
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/automobile/automobile_activity_year_type_fuel'
|
3
|
+
|
4
|
+
describe AutomobileActivityYearTypeFuel do
|
5
|
+
before :all do
|
6
|
+
Earth.init :automobile, :load_data_miner => true
|
7
|
+
require 'earth/acronyms'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'import', :data_miner => true do
|
11
|
+
it 'should import data' do
|
12
|
+
AAYTF.run_data_miner!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'verify', :sanity => true do
|
17
|
+
it { AAYTF.count.should == 120 }
|
18
|
+
it { AAYTF.where(:distance => nil).count.should == 0 }
|
19
|
+
it { AAYTF.where("fuel_common_name != 'alternative' AND fuel_consumption IS NULL").count.should == 0 }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.latest' do
|
23
|
+
it { AAYTF.latest.should == AAYTF.where(:activity_year => 2009) }
|
24
|
+
end
|
25
|
+
end
|