earth 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/earth_tester.rb +1 -0
- data/data/automobile/annual_emission_controls.csv +1 -1
- data/data/automobile/annual_fuel_consumption.csv +1 -1
- data/data/automobile/auto_fuel_data.csv +1 -1
- data/data/automobile/emission_control_techs.csv +1 -1
- data/data/automobile/trip_distances.csv +5 -0
- data/data/locality/country_flight_data.csv +18 -0
- data/data/locality/egrid_relationships.csv +27 -0
- data/data/locality/misc_zip_data.csv +1 -0
- data/data/locality/us_auto_data.csv +2 -0
- data/data/locality/wri_hdd_cdd_data.csv +174 -0
- data/data/locality/zip_climate_divisions.csv +41359 -0
- data/errata/country/wri_errata.csv +24 -24
- data/lib/earth/automobile/automobile_activity_year/data_miner.rb +4 -3
- data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +4 -3
- data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +1 -1
- data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +4 -4
- data/lib/earth/automobile/automobile_fuel.rb +5 -5
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +18 -13
- data/lib/earth/automobile/automobile_make/data_miner.rb +4 -3
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +6 -7
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +1 -2
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +5 -10
- data/lib/earth/automobile/automobile_type_fuel.rb +2 -2
- data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +8 -7
- data/lib/earth/automobile/automobile_type_fuel_control.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_year.rb +5 -5
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +7 -6
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +4 -4
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +2 -2
- data/lib/earth/conversions_ext.rb +2 -0
- data/lib/earth/industry/industry.rb +0 -2
- data/lib/earth/industry/industry/data_miner.rb +5 -2
- data/lib/earth/locality/census_division.rb +2 -1
- data/lib/earth/locality/country.rb +3 -7
- data/lib/earth/locality/country/data_miner.rb +54 -75
- data/lib/earth/locality/egrid_country.rb +9 -3
- data/lib/earth/locality/egrid_country/data_miner.rb +14 -8
- data/lib/earth/locality/egrid_region.rb +15 -6
- data/lib/earth/locality/egrid_region/data_miner.rb +14 -18
- data/lib/earth/locality/egrid_subregion.rb +21 -19
- data/lib/earth/locality/egrid_subregion/data_miner.rb +27 -47
- data/lib/earth/locality/zip_code.rb +5 -4
- data/lib/earth/locality/zip_code/data_miner.rb +25 -14
- data/lib/earth/rail/rail_company/data_miner.rb +1 -1
- data/lib/earth/version.rb +1 -1
- data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +1 -1
- data/spec/earth/automobile/automobile_fuel_spec.rb +1 -1
- data/spec/earth/automobile/automobile_type_fuel_spec.rb +1 -1
- data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +6 -6
- data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +6 -6
- data/spec/earth/industry/industry_spec.rb +1 -3
- data/spec/earth/locality/country_spec.rb +67 -34
- data/spec/earth/locality/egrid_country_spec.rb +26 -0
- data/spec/earth/locality/egrid_region_spec.rb +27 -0
- data/spec/earth/locality/egrid_subregion_spec.rb +49 -0
- data/spec/earth/locality/zip_code_spec.rb +13 -24
- metadata +17 -4
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/locality/egrid_country'
|
3
|
+
|
4
|
+
describe EgridCountry do
|
5
|
+
describe 'import', :data_miner => true do
|
6
|
+
before do
|
7
|
+
Earth.init :locality, :load_data_miner => true
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should import data' do
|
11
|
+
EgridCountry.delete_all if EgridCountry.table_exists?
|
12
|
+
EgridCountry.run_data_miner!
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'verify imported data', :sanity => true do
|
17
|
+
it { EgridCountry.count.should == 1 }
|
18
|
+
it { EgridCountry.us.loss_factor.should be_within(5e-6).of(0.06503) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.us' do
|
22
|
+
it 'should return the US' do
|
23
|
+
EgridCountry.us.should == EgridCountry.find('U.S.')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/locality/egrid_region'
|
3
|
+
|
4
|
+
describe EgridRegion do
|
5
|
+
describe 'import', :data_miner => true do
|
6
|
+
before do
|
7
|
+
Earth.init :locality, :load_data_miner => true
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should import data' do
|
11
|
+
EgridRegion.run_data_miner!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'verify imported data', :sanity => true do
|
16
|
+
it { EgridRegion.count.should == 5 }
|
17
|
+
it { EgridRegion.where("loss_factor > 0").count.should == EgridRegion.count }
|
18
|
+
|
19
|
+
# spot check
|
20
|
+
it { EgridRegion.first.loss_factor.should be_within(5e-6).of(0.05840) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.fallback' do
|
24
|
+
it { EgridRegion.fallback.name.should == 'fallback' }
|
25
|
+
it { EgridRegion.fallback.loss_factor.should be_within(5e-6).of(0.06503) }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'earth/locality/egrid_subregion'
|
3
|
+
|
4
|
+
describe EgridSubregion do
|
5
|
+
describe 'import', :data_miner => true do
|
6
|
+
before do
|
7
|
+
Earth.init :locality, :load_data_miner => true
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should import data' do
|
11
|
+
EgridSubregion.run_data_miner!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'verify imported data', :sanity => true do
|
16
|
+
it { EgridSubregion.count.should == 26 }
|
17
|
+
it { EgridSubregion.where("net_generation > 0").count.should == EgridSubregion.count }
|
18
|
+
it { EgridSubregion.where("co2_emission_factor > 0").count.should == EgridSubregion.count }
|
19
|
+
it { EgridSubregion.where("co2_biogenic_emission_factor >= 0").count.should == EgridSubregion.count }
|
20
|
+
it { EgridSubregion.where("ch4_emission_factor > 0").count.should == EgridSubregion.count }
|
21
|
+
it { EgridSubregion.where("n2o_emission_factor > 0").count.should == EgridSubregion.count }
|
22
|
+
it { EgridSubregion.where("electricity_emission_factor > 0").count.should == EgridSubregion.count }
|
23
|
+
|
24
|
+
# spot check
|
25
|
+
it { EgridSubregion.first.net_generation.should be_within(5).of(5_337_982) }
|
26
|
+
it { EgridSubregion.first.co2_emission_factor.should be_within(5e-6).of(0.58099) }
|
27
|
+
it { EgridSubregion.first.co2_biogenic_emission_factor.should be_within(5e-6).of(0.0) }
|
28
|
+
it { EgridSubregion.first.ch4_emission_factor.should be_within(5e-6).of(0.00031) }
|
29
|
+
it { EgridSubregion.first.n2o_emission_factor.should be_within(5e-6).of(0.00104) }
|
30
|
+
it { EgridSubregion.first.electricity_emission_factor.should be_within(5e-6).of(0.58234) }
|
31
|
+
|
32
|
+
it { EgridSubregion.first.net_generation_units.should == 'megawatt_hours' }
|
33
|
+
it { EgridSubregion.first.co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
|
34
|
+
it { EgridSubregion.first.co2_biogenic_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
|
35
|
+
it { EgridSubregion.first.ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
36
|
+
it { EgridSubregion.first.n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
37
|
+
it { EgridSubregion.first.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.fallback' do
|
41
|
+
it { EgridSubregion.fallback.name.should == 'fallback' }
|
42
|
+
it { EgridSubregion.fallback.egrid_region.name.should == 'fallback' }
|
43
|
+
it { EgridSubregion.fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
|
44
|
+
it { EgridSubregion.fallback.co2_biogenic_emission_factor.should be_within(5e-6).of(0.0) }
|
45
|
+
it { EgridSubregion.fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
|
46
|
+
it { EgridSubregion.fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
|
47
|
+
it { EgridSubregion.fallback.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
|
48
|
+
end
|
49
|
+
end
|
@@ -13,28 +13,12 @@ describe ZipCode do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'verify imported data', :sanity => true do
|
16
|
-
it
|
17
|
-
|
18
|
-
|
19
|
-
it '
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
it 'has a lat and lng for most zip codes' do
|
24
|
-
ZipCode.where('latitude IS NOT NULL AND longitude IS NOT NULL').count.should == 43191
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'has an eGRID subregion for most zip codes' do
|
28
|
-
ZipCode.where('egrid_subregion_abbreviation IS NOT NULL').count.should == 41297
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'has a climate division for most zip codes' do
|
32
|
-
ZipCode.where('climate_division_name IS NOT NULL').count.should == 41358
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'has a population for all 33120 Census 2010 ZCTAs' do
|
36
|
-
ZipCode.where('population IS NOT NULL').count.should == 33120
|
37
|
-
end
|
16
|
+
it { ZipCode.count.should == 43770 }
|
17
|
+
it { ZipCode.where(:state_postal_abbreviation => nil).count.should == 0 }
|
18
|
+
it { ZipCode.where('latitude IS NOT NULL AND longitude IS NOT NULL').count.should == 43191 }
|
19
|
+
it { ZipCode.where('egrid_subregion_abbreviation IS NOT NULL').count.should == 41334 }
|
20
|
+
it { ZipCode.where('climate_division_name IS NOT NULL').count.should == 41358 }
|
21
|
+
it { ZipCode.where('population IS NOT NULL').count.should == 33120 }
|
38
22
|
end
|
39
23
|
|
40
24
|
describe '#country' do
|
@@ -50,8 +34,13 @@ describe ZipCode do
|
|
50
34
|
|
51
35
|
describe '#latitude_longitude' do
|
52
36
|
it 'should return the lat and lng as an array of strings' do
|
53
|
-
ZipCode.
|
54
|
-
ZipCode.
|
37
|
+
ZipCode.find('00001').latitude_longitude.should == ['55.856236', '21.0960915']
|
38
|
+
ZipCode.find('00002').latitude_longitude.should == [nil, nil]
|
55
39
|
end
|
56
40
|
end
|
41
|
+
|
42
|
+
# from acts_as_mappable
|
43
|
+
describe '.find_within' do
|
44
|
+
it { ZipCode.find_within(15, :units => :kms, :origin => ZipCode.find('05753').latitude_longitude).count.should == 7 }
|
45
|
+
end
|
57
46
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: earth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.12.
|
5
|
+
version: 0.12.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Seamus Abshere
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2012-06-
|
15
|
+
date: 2012-06-14 00:00:00 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activerecord
|
@@ -324,6 +324,13 @@ files:
|
|
324
324
|
- data/automobile/hfc_emissions.csv
|
325
325
|
- data/automobile/hybridity_multipliers.csv
|
326
326
|
- data/automobile/sizes.csv
|
327
|
+
- data/automobile/trip_distances.csv
|
328
|
+
- data/locality/country_flight_data.csv
|
329
|
+
- data/locality/egrid_relationships.csv
|
330
|
+
- data/locality/misc_zip_data.csv
|
331
|
+
- data/locality/us_auto_data.csv
|
332
|
+
- data/locality/wri_hdd_cdd_data.csv
|
333
|
+
- data/locality/zip_climate_divisions.csv
|
327
334
|
- earth.gemspec
|
328
335
|
- errata/aircraft/faa_errata.csv
|
329
336
|
- errata/airline/bts_carrier_codes_errata.csv
|
@@ -608,6 +615,9 @@ files:
|
|
608
615
|
- spec/earth/industry/naics_2007_spec.rb
|
609
616
|
- spec/earth/industry/sic_1987_spec.rb
|
610
617
|
- spec/earth/locality/country_spec.rb
|
618
|
+
- spec/earth/locality/egrid_country_spec.rb
|
619
|
+
- spec/earth/locality/egrid_region_spec.rb
|
620
|
+
- spec/earth/locality/egrid_subregion_spec.rb
|
611
621
|
- spec/earth/locality/state_spec.rb
|
612
622
|
- spec/earth/locality/zip_code_spec.rb
|
613
623
|
- spec/earth/pet/species_spec.rb
|
@@ -671,7 +681,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
671
681
|
requirements:
|
672
682
|
- - ">="
|
673
683
|
- !ruby/object:Gem::Version
|
674
|
-
hash:
|
684
|
+
hash: -2226829993572844929
|
675
685
|
segments:
|
676
686
|
- 0
|
677
687
|
version: "0"
|
@@ -680,7 +690,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
680
690
|
requirements:
|
681
691
|
- - ">="
|
682
692
|
- !ruby/object:Gem::Version
|
683
|
-
hash:
|
693
|
+
hash: -2226829993572844929
|
684
694
|
segments:
|
685
695
|
- 0
|
686
696
|
version: "0"
|
@@ -734,6 +744,9 @@ test_files:
|
|
734
744
|
- spec/earth/industry/naics_2007_spec.rb
|
735
745
|
- spec/earth/industry/sic_1987_spec.rb
|
736
746
|
- spec/earth/locality/country_spec.rb
|
747
|
+
- spec/earth/locality/egrid_country_spec.rb
|
748
|
+
- spec/earth/locality/egrid_region_spec.rb
|
749
|
+
- spec/earth/locality/egrid_subregion_spec.rb
|
737
750
|
- spec/earth/locality/state_spec.rb
|
738
751
|
- spec/earth/locality/zip_code_spec.rb
|
739
752
|
- spec/earth/pet/species_spec.rb
|