earth 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. data/data/automobile/annual_emission_controls.csv +1 -1
  2. data/data/automobile/annual_fuel_consumption.csv +1 -1
  3. data/data/automobile/auto_fuel_data.csv +1 -1
  4. data/data/automobile/emission_control_techs.csv +1 -1
  5. data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +1 -1
  6. data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +4 -4
  7. data/lib/earth/automobile/automobile_fuel.rb +3 -3
  8. data/lib/earth/automobile/automobile_fuel/data_miner.rb +1 -1
  9. data/lib/earth/automobile/automobile_type_fuel.rb +2 -2
  10. data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +3 -3
  11. data/lib/earth/automobile/automobile_type_fuel_control.rb +1 -1
  12. data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +1 -1
  13. data/lib/earth/automobile/automobile_type_fuel_year.rb +5 -5
  14. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -1
  15. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +4 -4
  16. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +2 -2
  17. data/lib/earth/version.rb +1 -1
  18. data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +1 -1
  19. data/spec/earth/automobile/automobile_fuel_spec.rb +1 -1
  20. data/spec/earth/automobile/automobile_type_fuel_spec.rb +1 -1
  21. data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +6 -6
  22. data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +6 -6
  23. data/spec/earth/electricity/electric_market_spec.rb +1 -1
  24. data/spec/earth/locality/country_spec.rb +4 -4
  25. data/spec/earth/locality/zip_code_spec.rb +3 -3
  26. metadata +4 -4
@@ -1,4 +1,4 @@
1
- name,type_name,fuel_group,year,control_name,total_travel_percent,source,source_detail,source_url
1
+ name,type_name,fuel_family,year,control_name,total_travel_percent,source,source_detail,source_url
2
2
  Light-duty trucks diesel 1985 moderate,Light-duty trucks,diesel,1985,moderate,1,EPA (2012) Table A-102,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
3
3
  Light-duty trucks diesel 1986 moderate,Light-duty trucks,diesel,1986,moderate,1,EPA (2012) Table A-102,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
4
4
  Light-duty trucks diesel 1987 moderate,Light-duty trucks,diesel,1987,moderate,1,EPA (2012) Table A-102,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
@@ -1,4 +1,4 @@
1
- name,activity_year,type_name,fuel_group,fuel_consumption,fuel_consumption_units,source,source_detail,source_url
1
+ name,activity_year,type_name,fuel_family,fuel_consumption,fuel_consumption_units,source,source_detail,source_url
2
2
  1990 Light-duty trucks diesel,1990,Light-duty trucks,diesel,1118.5,million_gallons,EPA (2012) Table A-88,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
3
3
  1991 Light-duty trucks diesel,1991,Light-duty trucks,diesel,1107.8,million_gallons,EPA (2012) Table A-88,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
4
4
  1992 Light-duty trucks diesel,1992,Light-duty trucks,diesel,1224.7,million_gallons,EPA (2012) Table A-88,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
@@ -1,4 +1,4 @@
1
- name,code,group,distance_key,base_fuel_name,blend_fuel_name,blend_portion
1
+ name,code,family,distance_key,base_fuel_name,blend_fuel_name,blend_portion
2
2
  B100,BP-B100,b100,diesel,Biodiesel
3
3
  B20,BP-B20,b20,diesel,Distillate Fuel Oil No. 2,Biodiesel,0.2
4
4
  B5,BP-B5,b5,diesel,Distillate Fuel Oil No. 2,Biodiesel,0.05
@@ -1,4 +1,4 @@
1
- name,type_name,fuel_group,control_name,ch4_emission_factor,ch4_emission_factor_units,n2o_emission_factor,n2o_emission_factor_units,source,source_detail,source_url
1
+ name,type_name,fuel_family,control_name,ch4_emission_factor,ch4_emission_factor_units,n2o_emission_factor,n2o_emission_factor_units,source,source_detail,source_url
2
2
  Light-duty trucks diesel advanced,Light-duty trucks,diesel,advanced,0.001,grams_per_mile,0.0015,grams_per_mile,EPA (2012) Table A-103,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
3
3
  Light-duty trucks diesel moderate,Light-duty trucks,diesel,moderate,0.0009,grams_per_mile,0.0014,grams_per_mile,EPA (2012) Table A-103,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
4
4
  Light-duty trucks diesel uncontrolled,Light-duty trucks,diesel,uncontrolled,0.0011,grams_per_mile,0.0017,grams_per_mile,EPA (2012) Table A-103,U.S. EPA (2012) Inventory of U.S. Greenhouse Gas Emissions and Sinks: 1990-2010,http://www.epa.gov/climatechange/emissions/usinventoryreport.html
@@ -9,7 +9,7 @@ class AutomobileActivityYearTypeFuel < ActiveRecord::Base
9
9
  col :name
10
10
  col :activity_year, :type => :integer
11
11
  col :type_name
12
- col :fuel_group
12
+ col :fuel_family
13
13
  col :distance, :type => :float
14
14
  col :distance_units
15
15
  col :fuel_consumption, :type => :float
@@ -14,7 +14,7 @@ AutomobileActivityYearTypeFuel.class_eval do
14
14
  key 'name', :synthesize => proc { |row| "#{row['Year']} #{type} gasoline" }
15
15
  store 'activity_year', :field_name => 'Year'
16
16
  store 'type_name', :static => type
17
- store 'fuel_group', :static => 'gasoline'
17
+ store 'fuel_family', :static => 'gasoline'
18
18
  store 'distance', :field_name => type, :from_units => :billion_miles, :to_units => :kilometres
19
19
  end
20
20
 
@@ -27,7 +27,7 @@ AutomobileActivityYearTypeFuel.class_eval do
27
27
  key 'name', :synthesize => proc { |row| "#{row['Year']} #{type} diesel" }
28
28
  store 'activity_year', :field_name => 'Year'
29
29
  store 'type_name', :static => type
30
- store 'fuel_group', :static => 'diesel'
30
+ store 'fuel_family', :static => 'diesel'
31
31
  store 'distance', :field_name => type, :from_units => :billion_miles, :to_units => :kilometres
32
32
  end
33
33
 
@@ -40,7 +40,7 @@ AutomobileActivityYearTypeFuel.class_eval do
40
40
  key 'name', :synthesize => proc { |row| "#{row['Year']} #{type} alternative" }
41
41
  store 'activity_year', :field_name => 'Year'
42
42
  store 'type_name', :static => type
43
- store 'fuel_group', :static => 'alternative'
43
+ store 'fuel_family', :static => 'alternative'
44
44
  store 'distance', :field_name => type, :from_units => :billion_miles, :to_units => :kilometres
45
45
  end
46
46
  end
@@ -50,7 +50,7 @@ AutomobileActivityYearTypeFuel.class_eval do
50
50
  key 'name'
51
51
  store 'activity_year'
52
52
  store 'type_name'
53
- store 'fuel_group'
53
+ store 'fuel_family'
54
54
  store 'fuel_consumption', :from_units => :million_gallons, :to_units => :litres
55
55
  end
56
56
  end
@@ -8,7 +8,7 @@ class AutomobileFuel < ActiveRecord::Base
8
8
  belongs_to :blend_fuel, :class_name => 'Fuel', :foreign_key => 'blend_fuel_name'
9
9
 
10
10
  # for calculating gas and diesel annual distance and ch4 + n2o efs
11
- has_many :type_fuels, :foreign_key => :fuel_group, :primary_key => :group, :class_name => 'AutomobileTypeFuel'
11
+ has_many :type_fuels, :foreign_key => :fuel_family, :primary_key => :family, :class_name => 'AutomobileTypeFuel'
12
12
 
13
13
  # for fallback
14
14
  class << self
@@ -68,7 +68,7 @@ class AutomobileFuel < ActiveRecord::Base
68
68
 
69
69
  col :name
70
70
  col :code
71
- col :group
71
+ col :family
72
72
  col :distance_key
73
73
  col :base_fuel_name
74
74
  col :blend_fuel_name
@@ -89,7 +89,7 @@ class AutomobileFuel < ActiveRecord::Base
89
89
  col :total_consumption_units
90
90
 
91
91
  warn_unless_size 12
92
- warn_if_blanks :code, :group, :distance_key
92
+ warn_if_blanks :code, :family, :distance_key
93
93
  warn_if do
94
94
  if exists?("name != 'electricity' AND base_fuel_name IS NULL")
95
95
  "Records missing #{col}"
@@ -10,7 +10,7 @@ AutomobileFuel.class_eval do
10
10
  :url => "file://#{Earth::DATA_DIR}/automobile/auto_fuel_data.csv" do
11
11
  key 'name'
12
12
  store 'code'
13
- store 'group'
13
+ store 'family'
14
14
  store 'distance_key'
15
15
  store 'base_fuel_name', :nullify => true
16
16
  store 'blend_fuel_name', :nullify => true
@@ -3,12 +3,12 @@ class AutomobileTypeFuel < ActiveRecord::Base
3
3
 
4
4
  # for calculating vehicles
5
5
  def latest_activity_year_type_fuel
6
- AutomobileActivityYearTypeFuel.latest.where(:type_name => type_name, :fuel_group => fuel_group).first
6
+ AutomobileActivityYearTypeFuel.latest.where(:type_name => type_name, :fuel_family => fuel_family).first
7
7
  end
8
8
 
9
9
  col :name
10
10
  col :type_name
11
- col :fuel_group
11
+ col :fuel_family
12
12
  col :annual_distance, :type => :float
13
13
  col :annual_distance_units
14
14
  col :fuel_consumption, :type => :float
@@ -13,9 +13,9 @@ AutomobileTypeFuel.class_eval do
13
13
  :src => AutomobileTypeFuelYear,
14
14
  :dest => AutomobileTypeFuel,
15
15
  :cols => {
16
- [:type_name, :fuel_group] => :name,
16
+ [:type_name, :fuel_family] => :name,
17
17
  :type_name => :type_name,
18
- :fuel_group => :fuel_group
18
+ :fuel_family => :fuel_family
19
19
  }
20
20
  )
21
21
  end
@@ -23,7 +23,7 @@ AutomobileTypeFuel.class_eval do
23
23
  process "Derive annual distance and emission factors from AutomobileTypeFuelYear" do
24
24
  type_fuels = arel_table
25
25
  type_fuel_years = AutomobileTypeFuelYear.arel_table
26
- join_relation = type_fuel_years[:type_name].eq(type_fuels[:type_name]).and(type_fuel_years[:fuel_group].eq(type_fuels[:fuel_group]))
26
+ join_relation = type_fuel_years[:type_name].eq(type_fuels[:type_name]).and(type_fuel_years[:fuel_family].eq(type_fuels[:fuel_family]))
27
27
 
28
28
  %w{ annual_distance ch4_emission_factor n2o_emission_factor }.each do |item|
29
29
  item_sql = AutomobileTypeFuelYear.where(join_relation).weighted_average_relation(:"#{item}", :weighted_by => :share_of_type).to_sql
@@ -3,7 +3,7 @@ class AutomobileTypeFuelControl < ActiveRecord::Base
3
3
 
4
4
  col :name
5
5
  col :type_name
6
- col :fuel_group
6
+ col :fuel_family
7
7
  col :control_name
8
8
  col :ch4_emission_factor, :type => :float
9
9
  col :ch4_emission_factor_units
@@ -7,7 +7,7 @@ AutomobileTypeFuelControl.class_eval do
7
7
  :url => "file://#{Earth::DATA_DIR}/automobile/emission_control_techs.csv" do
8
8
  key 'name'
9
9
  store 'type_name'
10
- store 'fuel_group'
10
+ store 'fuel_family'
11
11
  store 'control_name'
12
12
  store 'ch4_emission_factor', :from_units => :grams_per_mile, :to_units => :kilograms_per_kilometre
13
13
  store 'n2o_emission_factor', :from_units => :grams_per_mile, :to_units => :kilograms_per_kilometre
@@ -2,22 +2,22 @@ class AutomobileTypeFuelYear < ActiveRecord::Base
2
2
  self.primary_key = "name"
3
3
 
4
4
  # Used by Automobile and AutomobileTrip
5
- def self.find_by_type_name_and_fuel_group_and_closest_year(type_name, fuel_group, year)
5
+ def self.find_by_type_name_and_fuel_family_and_closest_year(type_name, fuel_family, year)
6
6
  if year > maximum(:year)
7
- where(:type_name => type_name, :fuel_group => fuel_group, :year => maximum(:year)).first
7
+ where(:type_name => type_name, :fuel_family => fuel_family, :year => maximum(:year)).first
8
8
  else
9
- where(:type_name => type_name, :fuel_group => fuel_group, :year => [year, minimum(:year)].max).first
9
+ where(:type_name => type_name, :fuel_family => fuel_family, :year => [year, minimum(:year)].max).first
10
10
  end
11
11
  end
12
12
 
13
13
  # for calculating ch4 and n2o ef
14
14
  def type_fuel_year_controls
15
- AutomobileTypeFuelYearControl.find_all_by_type_name_and_fuel_group_and_closest_year(type_name, fuel_group, year)
15
+ AutomobileTypeFuelYearControl.find_all_by_type_name_and_fuel_family_and_closest_year(type_name, fuel_family, year)
16
16
  end
17
17
 
18
18
  col :name
19
19
  col :type_name
20
- col :fuel_group
20
+ col :fuel_family
21
21
  col :year, :type => :integer
22
22
  col :share_of_type, :type => :float
23
23
  col :annual_distance, :type => :float
@@ -16,7 +16,7 @@ AutomobileTypeFuelYear.class_eval do
16
16
  :select => proc { |row| row['age'].to_i.to_s == row['age'] } do
17
17
  key 'name', :synthesize => proc { |row| "#{type} #{fuel} #{2009 - row['age'].to_i}" }
18
18
  store 'type_name', :static => type
19
- store 'fuel_group', :static => fuel
19
+ store 'fuel_family', :static => fuel
20
20
  store 'year', :synthesize => proc { |row| 2009 - row['age'].to_i }
21
21
  store 'share_of_type', :synthesize => proc { |row| row[code].to_f / (code == 'LDDV' ? 57.5 : 100) } # total percent only sums to 57.5 for diesel cars
22
22
  end
@@ -5,11 +5,11 @@ class AutomobileTypeFuelYearControl < ActiveRecord::Base
5
5
  belongs_to :type_fuel_control, :foreign_key => :type_fuel_control_name, :class_name => 'AutomobileTypeFuelControl'
6
6
 
7
7
  # Used by AutomobileTypeFuelYear
8
- def self.find_all_by_type_name_and_fuel_group_and_closest_year(type_name, fuel_group, year)
8
+ def self.find_all_by_type_name_and_fuel_family_and_closest_year(type_name, fuel_family, year)
9
9
  if year > maximum(:year)
10
- where(:type_name => type_name, :fuel_group => fuel_group, :year => maximum(:year))
10
+ where(:type_name => type_name, :fuel_family => fuel_family, :year => maximum(:year))
11
11
  else
12
- where(:type_name => type_name, :fuel_group => fuel_group, :year => [year, minimum(:year)].max)
12
+ where(:type_name => type_name, :fuel_family => fuel_family, :year => [year, minimum(:year)].max)
13
13
  end
14
14
  end
15
15
 
@@ -26,7 +26,7 @@ class AutomobileTypeFuelYearControl < ActiveRecord::Base
26
26
 
27
27
  col :name
28
28
  col :type_name
29
- col :fuel_group
29
+ col :fuel_family
30
30
  col :year, :type => :integer
31
31
  col :control_name
32
32
  col :type_fuel_control_name
@@ -8,10 +8,10 @@ AutomobileTypeFuelYearControl.class_eval do
8
8
  :url => "file://#{Earth::DATA_DIR}/automobile/annual_emission_controls.csv" do
9
9
  key 'name'
10
10
  store 'type_name'
11
- store 'fuel_group'
11
+ store 'fuel_family'
12
12
  store 'year'
13
13
  store 'control_name'
14
- store 'type_fuel_control_name', :synthesize => proc { |row| [row['type_name'], row['fuel_group'], row['control_name']].join(' ') }
14
+ store 'type_fuel_control_name', :synthesize => proc { |row| [row['type_name'], row['fuel_family'], row['control_name']].join(' ') }
15
15
  store 'total_travel_percent'
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Earth
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.2"
3
3
  end
@@ -16,7 +16,7 @@ describe AutomobileActivityYearTypeFuel do
16
16
  describe 'verify', :sanity => true do
17
17
  it { AAYTF.count.should == 120 }
18
18
  it { AAYTF.where(:distance => nil).count.should == 0 }
19
- it { AAYTF.where("fuel_group != 'alternative' AND fuel_consumption IS NULL").count.should == 0 }
19
+ it { AAYTF.where("fuel_family != 'alternative' AND fuel_consumption IS NULL").count.should == 0 }
20
20
  end
21
21
 
22
22
  describe '.latest' do
@@ -54,7 +54,7 @@ describe AutomobileFuel do
54
54
 
55
55
  it "all grades of gasoline should have same annual distance and emission factors" do
56
56
  AutomobileFuel.where("name LIKE '%gasoline'").each do |fuel|
57
- fuel.group.should == 'gasoline'
57
+ fuel.family.should == 'gasoline'
58
58
  fuel.annual_distance.should == AutomobileFuel.gasoline.annual_distance
59
59
  fuel.co2_emission_factor.should == AutomobileFuel.gasoline.co2_emission_factor
60
60
  fuel.ch4_emission_factor.should == AutomobileFuel.gasoline.ch4_emission_factor
@@ -37,7 +37,7 @@ describe AutomobileTypeFuel do
37
37
  it 'should always be a match from 2009' do
38
38
  AutomobileTypeFuel.find_each do |atf|
39
39
  atf.latest_activity_year_type_fuel.type_name.should == atf.type_name
40
- atf.latest_activity_year_type_fuel.fuel_group.should == atf.fuel_group
40
+ atf.latest_activity_year_type_fuel.fuel_family.should == atf.fuel_family
41
41
  atf.latest_activity_year_type_fuel.activity_year.should == 2009
42
42
  end
43
43
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'earth/automobile/automobile_type_fuel_year_control'
3
3
 
4
4
  describe AutomobileTypeFuelYearControl do
5
- let(:test_year_control) { ATFYC.where(:type_name => 'Passenger cars', :fuel_group => 'gasoline', :year => 2005).first }
5
+ let(:test_year_control) { ATFYC.where(:type_name => 'Passenger cars', :fuel_family => 'gasoline', :year => 2005).first }
6
6
 
7
7
  before :all do
8
8
  Earth.init :automobile, :load_data_miner => true
@@ -19,7 +19,7 @@ describe AutomobileTypeFuelYearControl do
19
19
  it { ATFYC.count.should == 142 }
20
20
 
21
21
  it 'total travel percent should sum to 1' do
22
- ATFYC.group([:type_name, :fuel_group, :year]).sum(:total_travel_percent).each do |grouping_criteria, total|
22
+ ATFYC.group([:type_name, :fuel_family, :year]).sum(:total_travel_percent).each do |grouping_criteria, total|
23
23
  total.should be_within(1e-5).of(1.0)
24
24
  end
25
25
  end
@@ -27,10 +27,10 @@ describe AutomobileTypeFuelYearControl do
27
27
  it { ATFYC.where(:type_fuel_control_name => nil).count.should == 0 }
28
28
  end
29
29
 
30
- describe '.find_all_by_type_name_and_fuel_group_and_closest_year' do
31
- it { ATFYC.find_all_by_type_name_and_fuel_group_and_closest_year('Passenger cars', 'gasoline', 1980).should == ATFYC.find_all_by_type_name_and_fuel_group_and_year('Passenger cars', 'gasoline', 1985) }
32
- it { ATFYC.find_all_by_type_name_and_fuel_group_and_closest_year('Passenger cars', 'gasoline', 2005).should == ATFYC.find_all_by_type_name_and_fuel_group_and_year('Passenger cars', 'gasoline', 2005) }
33
- it { ATFYC.find_all_by_type_name_and_fuel_group_and_closest_year('Passenger cars', 'gasoline', 2012).should == ATFYC.find_all_by_type_name_and_fuel_group_and_year('Passenger cars', 'gasoline', 2010) }
30
+ describe '.find_all_by_type_name_and_fuel_family_and_closest_year' do
31
+ it { ATFYC.find_all_by_type_name_and_fuel_family_and_closest_year('Passenger cars', 'gasoline', 1980).should == ATFYC.find_all_by_type_name_and_fuel_family_and_year('Passenger cars', 'gasoline', 1985) }
32
+ it { ATFYC.find_all_by_type_name_and_fuel_family_and_closest_year('Passenger cars', 'gasoline', 2005).should == ATFYC.find_all_by_type_name_and_fuel_family_and_year('Passenger cars', 'gasoline', 2005) }
33
+ it { ATFYC.find_all_by_type_name_and_fuel_family_and_closest_year('Passenger cars', 'gasoline', 2012).should == ATFYC.find_all_by_type_name_and_fuel_family_and_year('Passenger cars', 'gasoline', 2010) }
34
34
  end
35
35
 
36
36
  describe '#ch4_emission_factor' do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'earth/automobile/automobile_type_fuel_year'
3
3
 
4
4
  describe AutomobileTypeFuelYear do
5
- let(:test_atfy) { ATFY.where(:type_name => 'Passenger cars', :fuel_group => 'gasoline', :year => 2005).first }
5
+ let(:test_atfy) { ATFY.where(:type_name => 'Passenger cars', :fuel_family => 'gasoline', :year => 2005).first }
6
6
 
7
7
  before :all do
8
8
  Earth.init :automobile, :load_data_miner => true
@@ -19,7 +19,7 @@ describe AutomobileTypeFuelYear do
19
19
  it { ATFY.count.should == 124 }
20
20
 
21
21
  it 'shares should sum to 1' do
22
- ATFY.sum(:share_of_type, :group => [:type_name, :fuel_group]).each do |groupers, total|
22
+ ATFY.sum(:share_of_type, :group => [:type_name, :fuel_family]).each do |groupers, total|
23
23
  total.should be_within(1e-2).of(1.0)
24
24
  end
25
25
  end
@@ -37,10 +37,10 @@ describe AutomobileTypeFuelYear do
37
37
  it { test_atfy.n2o_emission_factor_units.should == 'kilograms_co2e_per_kilometre' }
38
38
  end
39
39
 
40
- describe '.find_by_type_name_and_fuel_group_and_closest_year' do
41
- it { ATFY.find_by_type_name_and_fuel_group_and_closest_year('Passenger cars', 'gasoline', 1970).should == ATFY.find_by_type_name_and_fuel_group_and_year('Passenger cars', 'gasoline', 1979) }
42
- it { ATFY.find_by_type_name_and_fuel_group_and_closest_year('Passenger cars', 'gasoline', 2005).should == ATFY.find_by_type_name_and_fuel_group_and_year('Passenger cars', 'gasoline', 2005) }
43
- it { ATFY.find_by_type_name_and_fuel_group_and_closest_year('Passenger cars', 'gasoline', 2012).should == ATFY.find_by_type_name_and_fuel_group_and_year('Passenger cars', 'gasoline', 2009) }
40
+ describe '.find_by_type_name_and_fuel_family_and_closest_year' do
41
+ it { ATFY.find_by_type_name_and_fuel_family_and_closest_year('Passenger cars', 'gasoline', 1970).should == ATFY.find_by_type_name_and_fuel_family_and_year('Passenger cars', 'gasoline', 1979) }
42
+ it { ATFY.find_by_type_name_and_fuel_family_and_closest_year('Passenger cars', 'gasoline', 2005).should == ATFY.find_by_type_name_and_fuel_family_and_year('Passenger cars', 'gasoline', 2005) }
43
+ it { ATFY.find_by_type_name_and_fuel_family_and_closest_year('Passenger cars', 'gasoline', 2012).should == ATFY.find_by_type_name_and_fuel_family_and_year('Passenger cars', 'gasoline', 2009) }
44
44
  end
45
45
 
46
46
  describe '#type_fuel_year_controls' do
@@ -18,7 +18,7 @@ describe ElectricMarket do
18
18
 
19
19
  it { ElectricMarket.where(:electric_utility_eia_id => nil).count.should == 0 } # some ids aren't found in our electric_utilities table
20
20
 
21
- it 'Properly links 53704 to MG&E' do
21
+ it 'links 53704 to MG&E' do
22
22
  ZipCode.find('53704').electric_utilities.should include(ElectricUtility.find 11479)
23
23
  end
24
24
  end
@@ -71,12 +71,12 @@ describe Country do
71
71
  it { Country.where("rail_trip_co2_emission_factor > 0").count.should == 26 }
72
72
 
73
73
  # spot checks
74
- it { us.rail_passengers.should == 4467000000 }
74
+ it { us.rail_passengers.should be_within(10_000).of(4_466_991_391) }
75
75
  it { us.rail_trip_distance.should be_within(5e-5).of(12.9952) }
76
76
  it { us.rail_speed.should be_within(5e-5).of(32.4972) }
77
- it { us.rail_trip_electricity_intensity.should be_within(5e-5).of(0.140512) }
78
- it { us.rail_trip_diesel_intensity.should be_within(5e-5).of(0.0194) }
79
- it { us.rail_trip_co2_emission_factor.should be_within(5e-5).of(0.0958) }
77
+ it { us.rail_trip_electricity_intensity.should be_within(5e-5).of(0.14051) }
78
+ it { us.rail_trip_diesel_intensity.should be_within(5e-5).of(0.01942) }
79
+ it { us.rail_trip_co2_emission_factor.should be_within(5e-5).of(0.0909) }
80
80
 
81
81
  it { uk.rail_passengers.should == 1352150000 }
82
82
  it { uk.rail_trip_distance.should be_within(5e-5).of(40.6904) }
@@ -16,7 +16,7 @@ describe ZipCode do
16
16
  it { ZipCode.count.should == 43770 }
17
17
  it { ZipCode.where(:state_postal_abbreviation => nil).count.should == 0 }
18
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 }
19
+ it { ZipCode.where('egrid_subregion_abbreviation IS NOT NULL').count.should == 41333 }
20
20
  it { ZipCode.where('climate_division_name IS NOT NULL').count.should == 41358 }
21
21
  it { ZipCode.where('population IS NOT NULL').count.should == 33120 }
22
22
  end
@@ -34,8 +34,8 @@ describe ZipCode do
34
34
 
35
35
  describe '#latitude_longitude' do
36
36
  it 'should return the lat and lng as an array of strings' do
37
- ZipCode.find('00001').latitude_longitude.should == ['55.856236', '21.0960915']
38
- ZipCode.find('00002').latitude_longitude.should == [nil, nil]
37
+ ZipCode.find('00001').latitude_longitude.should == [nil, nil]
38
+ ZipCode.find('00210').latitude_longitude.should == ['43.005895', '-71.013202']
39
39
  end
40
40
  end
41
41
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.12.1
5
+ version: 0.12.2
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-14 00:00:00 Z
15
+ date: 2012-06-15 00:00:00 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -681,7 +681,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
681
681
  requirements:
682
682
  - - ">="
683
683
  - !ruby/object:Gem::Version
684
- hash: -2226829993572844929
684
+ hash: 2577779194019475364
685
685
  segments:
686
686
  - 0
687
687
  version: "0"
@@ -690,7 +690,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
690
690
  requirements:
691
691
  - - ">="
692
692
  - !ruby/object:Gem::Version
693
- hash: -2226829993572844929
693
+ hash: 2577779194019475364
694
694
  segments:
695
695
  - 0
696
696
  version: "0"