earth 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/earth.gemspec +2 -2
  2. data/features/automobile_fuel.feature +100 -0
  3. data/features/bus_class.feature +12 -42
  4. data/features/bus_fuel.feature +114 -0
  5. data/features/egrid_subregion.feature +113 -15
  6. data/features/support/imports/automobile_fuel_bad.csv +3 -3
  7. data/features/support/imports/automobile_fuel_good.csv +3 -3
  8. data/features/support/imports/bus_class_bad.csv +2 -3
  9. data/features/support/imports/bus_class_good.csv +2 -3
  10. data/features/support/imports/bus_fuel_bad.csv +3 -0
  11. data/features/support/imports/bus_fuel_good.csv +3 -0
  12. data/features/support/imports/egrid_subregion_bad.csv +2 -3
  13. data/features/support/imports/egrid_subregion_good.csv +2 -3
  14. data/lib/earth/automobile/automobile_fuel.rb +63 -58
  15. data/lib/earth/automobile/automobile_fuel/data_miner.rb +110 -0
  16. data/lib/earth/bus.rb +3 -0
  17. data/lib/earth/bus/bus_class.rb +21 -2
  18. data/lib/earth/bus/bus_class/data_miner.rb +79 -43
  19. data/lib/earth/bus/bus_fuel.rb +18 -0
  20. data/lib/earth/bus/bus_fuel/data_miner.rb +204 -0
  21. data/lib/earth/bus/bus_fuel_control.rb +7 -0
  22. data/lib/earth/bus/bus_fuel_control/data_miner.rb +41 -0
  23. data/lib/earth/bus/bus_fuel_year_control.rb +13 -0
  24. data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +35 -0
  25. data/lib/earth/bus/data_miner.rb +3 -0
  26. data/lib/earth/fuel/fuel.rb +16 -0
  27. data/lib/earth/fuel/fuel/data_miner.rb +6 -1
  28. data/lib/earth/locality/egrid_region.rb +3 -2
  29. data/lib/earth/locality/egrid_region/data_miner.rb +8 -31
  30. data/lib/earth/locality/egrid_subregion.rb +18 -2
  31. data/lib/earth/locality/egrid_subregion/data_miner.rb +109 -56
  32. data/spec/earth/automobile/automobile_fuel_spec.rb +9 -12
  33. data/spec/earth/bus/bus_class_spec.rb +12 -0
  34. data/spec/earth/bus/bus_fuel_control_spec.rb +12 -0
  35. data/spec/earth/bus/bus_fuel_year_control_spec.rb +16 -0
  36. data/spec/earth/pet/species_spec.rb +0 -1
  37. data/spec/earth_spec.rb +2 -2
  38. metadata +46 -16
@@ -0,0 +1,18 @@
1
+ class BusFuel < ActiveRecord::Base
2
+ set_primary_key :name
3
+
4
+ belongs_to :fuel, :foreign_key => 'fuel_name'
5
+ has_many :fuel_year_controls, :class_name => 'BusFuelYearControl', :foreign_key => 'bus_fuel_name'
6
+
7
+ data_miner do
8
+ tap "Brighter Planet's sanitized bus fuel data", Earth.taps_server
9
+
10
+ process "Pull dependencies" do
11
+ run_data_miner_on_belongs_to_associations
12
+ end
13
+ end
14
+
15
+ def latest_fuel_year_controls
16
+ fuel_year_controls.where(:year => fuel_year_controls.maximum('year'))
17
+ end
18
+ end
@@ -0,0 +1,204 @@
1
+ BusFuel.class_eval do
2
+ data_miner do
3
+ schema Earth.database_options do
4
+ string 'name'
5
+ string 'fuel_name'
6
+ float 'energy_content'
7
+ string 'energy_content_units'
8
+ float 'co2_emission_factor'
9
+ string 'co2_emission_factor_units'
10
+ float 'co2_biogenic_emission_factor'
11
+ string 'co2_biogenic_emission_factor_units'
12
+ float 'ch4_emission_factor'
13
+ string 'ch4_emission_factor_units'
14
+ float 'n2o_emission_factor'
15
+ string 'n2o_emission_factor_units'
16
+ end
17
+
18
+ process "Ensure necessary datasets are imported" do
19
+ Fuel.run_data_miner!
20
+ GreenhouseGas.run_data_miner!
21
+ BusFuelYearControl.run_data_miner!
22
+ end
23
+
24
+ import "a list of bus fuels without emission factors",
25
+ :url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdGNscUdpbkdBUmJkTlFxdEtfSEdJS2c&output=csv' do
26
+ key 'name'
27
+ store 'fuel_name'
28
+ end
29
+
30
+ import "a list of bus fuels and their emission factors",
31
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHAtZ1YyWmxuS1JWUzZYSVhhdUViYmc&output=csv' do
32
+ key 'name'
33
+ store 'fuel_name'
34
+ store 'ch4_emission_factor', :units_field_name => 'ch4_emission_factor_units'
35
+ store 'n2o_emission_factor', :units_field_name => 'n2o_emission_factor_units'
36
+ end
37
+
38
+ import "energy contents for compressed/liquified natural gas fuels",
39
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDFfdHMycVB6dTkyUFFNM0x4b19TQVE&output=csv' do
40
+ key 'name'
41
+ store 'energy_content', :units_field_name => 'energy_content_units'
42
+ end
43
+
44
+ process "Convert emission factors to metric units" do
45
+ conversion_factor = (1 / 1.609344) * (1.0 / 1_000.0 ) # Google: 1 mile / 1.609344 km * 1 kg / 1000 g
46
+ gwp_ch4 = GreenhouseGas[:ch4].global_warming_potential
47
+ connection.execute %{
48
+ UPDATE bus_fuels
49
+ SET ch4_emission_factor = ch4_emission_factor * #{conversion_factor} * #{gwp_ch4},
50
+ ch4_emission_factor_units = 'kilograms_co2e_per_kilometre'
51
+ WHERE ch4_emission_factor_units = 'grams_per_mile'
52
+ }
53
+
54
+ gwp_n2o = GreenhouseGas[:n2o].global_warming_potential
55
+ connection.execute %{
56
+ UPDATE bus_fuels
57
+ SET n2o_emission_factor = n2o_emission_factor * #{conversion_factor} * #{gwp_n2o},
58
+ n2o_emission_factor_units = 'kilograms_co2e_per_kilometre'
59
+ WHERE n2o_emission_factor_units = 'grams_per_mile'
60
+ }
61
+ end
62
+
63
+ process "Convert energy contents to metric units" do
64
+ conversion_factor = (1 / 947.81712) * (1 / 3.78541178) # Google: 1 MJ / 947.81712 btu * 1 gallon / 3.78541178 l
65
+ connection.execute %{
66
+ UPDATE bus_fuels
67
+ SET energy_content = energy_content * #{conversion_factor},
68
+ energy_content_units = 'megajoules_per_litre'
69
+ WHERE energy_content_units = 'btu_per_gallon'
70
+ }
71
+ end
72
+
73
+ process 'Calculate CO2 and CO2 biogenic emission factors and units' do
74
+ BusFuel.all.each do |bus_fuel|
75
+ fuel = bus_fuel.fuel
76
+ if bus_fuel.energy_content.present?
77
+ co2_factor = (bus_fuel.energy_content * fuel.carbon_content * fuel.oxidation_factor * (1 - fuel.biogenic_fraction))
78
+ bus_fuel.co2_emission_factor = co2_factor.grams.to(:kilograms).carbon.to(:co2)
79
+
80
+ co2_prefix = fuel.co2_emission_factor_units.split("_per_")[0]
81
+ co2_suffix = bus_fuel.energy_content_units.split("_per_")[1]
82
+ bus_fuel.co2_emission_factor_units = co2_prefix + "_per_" + co2_suffix
83
+
84
+ co2_biogenic_factor = (bus_fuel.energy_content * fuel.carbon_content * fuel.oxidation_factor * fuel.biogenic_fraction)
85
+ bus_fuel.co2_biogenic_emission_factor = co2_biogenic_factor.grams.to(:kilograms).carbon.to(:co2)
86
+
87
+ co2_biogenic_prefix = fuel.co2_biogenic_emission_factor_units.split("_per_")[0]
88
+ co2_biogenic_suffix = bus_fuel.energy_content_units.split("_per_")[1]
89
+ bus_fuel.co2_biogenic_emission_factor_units = co2_biogenic_prefix + "_per_" + co2_biogenic_suffix
90
+ else
91
+ bus_fuel.co2_emission_factor = fuel.co2_emission_factor
92
+ bus_fuel.co2_emission_factor_units = fuel.co2_emission_factor_units
93
+
94
+ bus_fuel.co2_biogenic_emission_factor = fuel.co2_biogenic_emission_factor
95
+ bus_fuel.co2_biogenic_emission_factor_units = fuel.co2_biogenic_emission_factor_units
96
+ end
97
+
98
+ bus_fuel.save!
99
+ end
100
+ end
101
+
102
+ process 'Calculate CH4 and N2O emission factor and units for BusFuels with BusFuelYearControls' do
103
+ BusFuel.all.each do |bus_fuel|
104
+ if bus_fuel.latest_fuel_year_controls.present?
105
+ ch4_factors_by_year = bus_fuel.latest_fuel_year_controls.map do |fyc|
106
+ fyc.total_travel_percent * fyc.fuel_control.ch4_emission_factor
107
+ end
108
+ bus_fuel.ch4_emission_factor = ch4_factors_by_year.sum * GreenhouseGas[:ch4].global_warming_potential
109
+
110
+ ch4_prefix = bus_fuel.latest_fuel_year_controls.first.fuel_control.ch4_emission_factor_units.split("_per_")[0]
111
+ ch4_suffix = bus_fuel.latest_fuel_year_controls.first.fuel_control.ch4_emission_factor_units.split("_per_")[1]
112
+ bus_fuel.ch4_emission_factor_units = ch4_prefix + "_co2e_per_" + ch4_suffix
113
+
114
+ n2o_factors_by_year = bus_fuel.latest_fuel_year_controls.map do |fyc|
115
+ fyc.total_travel_percent * fyc.fuel_control.n2o_emission_factor
116
+ end
117
+ bus_fuel.n2o_emission_factor = n2o_factors_by_year.sum * GreenhouseGas[:n2o].global_warming_potential
118
+
119
+ n2o_prefix = bus_fuel.latest_fuel_year_controls.first.fuel_control.n2o_emission_factor_units.split("_per_")[0]
120
+ n2o_suffix = bus_fuel.latest_fuel_year_controls.first.fuel_control.n2o_emission_factor_units.split("_per_")[1]
121
+ bus_fuel.n2o_emission_factor_units = n2o_prefix + "_co2e_per_" + n2o_suffix
122
+ end
123
+
124
+ bus_fuel.save!
125
+ end
126
+ end
127
+
128
+ # FIXME TODO verify fuel_name appears in fuels
129
+ verify "Fuel name should never be missing" do
130
+ BusFuel.all.each do |fuel|
131
+ value = fuel.send(:fuel_name)
132
+ unless value.present?
133
+ puts "Missing fuel name for BusFuel #{fuel.name}"
134
+ fail
135
+ end
136
+ end
137
+ end
138
+
139
+ verify "Energy content should be greater than zero if present" do
140
+ BusFuel.all.each do |fuel|
141
+ value = fuel.send(:energy_content)
142
+ if value.present?
143
+ unless value > 0
144
+ puts "Invalid energy content for BusFuel #{fuel.name}: #{value} (should be > 0)"
145
+ fail
146
+ end
147
+ end
148
+ end
149
+ end
150
+
151
+ %w{ co2_emission_factor co2_biogenic_emission_factor }.each do |attribute|
152
+ verify "#{attribute.humanize} should be 0 or more" do
153
+ BusFuel.all.each do |fuel|
154
+ value = fuel.send(attribute)
155
+ unless value >= 0
156
+ puts "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{value} (should be 0 or more)"
157
+ fail
158
+ end
159
+ end
160
+ end
161
+ end
162
+
163
+ %w{ ch4_emission_factor n2o_emission_factor }.each do |attribute|
164
+ verify "#{attribute.humanize} should be > 0" do
165
+ BusFuel.all.each do |fuel|
166
+ value = fuel.send(attribute)
167
+ unless value > 0
168
+ puts "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{value} (should be > 0)"
169
+ fail
170
+ end
171
+ end
172
+ end
173
+ end
174
+
175
+ verify "Energy content units should be megajoules per litre if present" do
176
+ BusFuel.all.each do |fuel|
177
+ units = fuel.send(:energy_content_units)
178
+ if units.present?
179
+ unless units == "megajoules_per_litre"
180
+ puts "Invalid energy content units for BusFuel #{fuel.name}: #{units} (should be megajoules_per_litre)"
181
+ fail
182
+ end
183
+ end
184
+ end
185
+ end
186
+
187
+ [["co2_emission_factor_units", "kilograms_per_litre"],
188
+ ["co2_biogenic_emission_factor_units", "kilograms_per_litre"],
189
+ ["ch4_emission_factor_units", "kilograms_co2e_per_kilometre"],
190
+ ["n2o_emission_factor_units", "kilograms_co2e_per_kilometre"]].each do |pair|
191
+ attribute = pair[0]
192
+ proper_units = pair[1]
193
+ verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
194
+ BusFuel.all.each do |fuel|
195
+ units = fuel.send(:"#{attribute}")
196
+ unless units == proper_units
197
+ puts "Invalid #{attribute.humanize.downcase} for BusFuel #{fuel.name}: #{units} (should be #{proper_units})"
198
+ fail
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,7 @@
1
+ class BusFuelControl < ActiveRecord::Base
2
+ set_primary_key :name
3
+
4
+ data_miner do
5
+ tap "Brighter Planet's sanitized bus fuel data", Earth.taps_server
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ BusFuelControl.class_eval do
2
+ data_miner do
3
+ schema Earth.database_options do
4
+ string 'name'
5
+ string 'bus_fuel_name'
6
+ string 'control'
7
+ float 'ch4_emission_factor'
8
+ string 'ch4_emission_factor_units'
9
+ float 'n2o_emission_factor'
10
+ string 'n2o_emission_factor_units'
11
+ end
12
+
13
+ import "a list of bus fuel controls",
14
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEw1QW80VVJhaXRkUURQSFhHczNyVWc&output=csv' do
15
+ key 'name'
16
+ store 'bus_fuel_name'
17
+ store 'control'
18
+ store 'ch4_emission_factor', :units_field_name => 'ch4_emission_factor_units'
19
+ store 'n2o_emission_factor', :units_field_name => 'n2o_emission_factor_units'
20
+ end
21
+
22
+ process "Convert emission factors to metric units" do
23
+ conversion_factor = (1 / 1.609344) * (1.0 / 1_000.0 ) # Google: 1 mile / 1.609344 km * 1 kg / 1000 g
24
+ connection.execute %{
25
+ UPDATE bus_fuel_controls
26
+ SET ch4_emission_factor = ch4_emission_factor * #{conversion_factor},
27
+ ch4_emission_factor_units = 'kilograms_per_kilometre'
28
+ WHERE ch4_emission_factor_units = 'grams_per_mile'
29
+ }
30
+
31
+ connection.execute %{
32
+ UPDATE bus_fuel_controls
33
+ SET n2o_emission_factor = n2o_emission_factor * #{conversion_factor},
34
+ n2o_emission_factor_units = 'kilograms_per_kilometre'
35
+ WHERE n2o_emission_factor_units = 'grams_per_mile'
36
+ }
37
+ end
38
+
39
+ # FIXME TODO verify this
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ class BusFuelYearControl < ActiveRecord::Base
2
+ set_primary_key :name
3
+
4
+ belongs_to :fuel_control, :class_name => 'BusFuelControl', :foreign_key => 'bus_fuel_control_name'
5
+
6
+ data_miner do
7
+ tap "Brighter Planet's sanitized bus fuel data", Earth.taps_server
8
+
9
+ process "Pull dependencies" do
10
+ run_data_miner_on_belongs_to_associations
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ BusFuelYearControl.class_eval do
2
+ data_miner do
3
+ schema Earth.database_options do
4
+ string 'name'
5
+ string 'bus_fuel_name'
6
+ integer 'year'
7
+ string 'control'
8
+ string 'bus_fuel_control_name'
9
+ float 'total_travel_percent'
10
+ end
11
+
12
+ process "Ensure all BusFuelControls are imported" do
13
+ BusFuelControl.run_data_miner!
14
+ end
15
+
16
+ import "a list of bus fuel year controls",
17
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGhHQkZPZW4zbXYzZ3NkYThBWnQ2QXc&output=csv' do
18
+ key 'name'
19
+ store 'bus_fuel_name'
20
+ store 'year'
21
+ store 'control'
22
+ store 'total_travel_percent'
23
+ end
24
+
25
+ process "Derive bus fuel control name for association with BusFuelControl" do
26
+ if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
27
+ update_all "bus_fuel_control_name = bus_fuel_name || ' ' || control"
28
+ else
29
+ update_all "bus_fuel_control_name = CONCAT(bus_fuel_name, ' ', control)"
30
+ end
31
+ end
32
+
33
+ # FIXME TODO verify that for any year the percentages sum to 1
34
+ end
35
+ end
@@ -1 +1,4 @@
1
1
  require 'earth/bus/bus_class/data_miner'
2
+ require 'earth/bus/bus_fuel/data_miner'
3
+ require 'earth/bus/bus_fuel_control/data_miner'
4
+ require 'earth/bus/bus_fuel_year_control/data_miner'
@@ -43,6 +43,22 @@ class Fuel < ActiveRecord::Base
43
43
  end
44
44
  end
45
45
 
46
+ def oxidation_factor
47
+ if oxidation_factor = super
48
+ oxidation_factor
49
+ elsif fuel_years.present?
50
+ latest_year.oxidation_factor
51
+ end
52
+ end
53
+
54
+ def biogenic_fraction
55
+ if biogenic_fraction = super
56
+ biogenic_fraction
57
+ elsif fuel_years.present?
58
+ latest_year.biogenic_fraction
59
+ end
60
+ end
61
+
46
62
  def co2_emission_factor
47
63
  if ef = super
48
64
  ef
@@ -18,8 +18,13 @@ Fuel.class_eval do
18
18
 
19
19
  process "Derive fuel names from FuelYear" do
20
20
  FuelYear.run_data_miner!
21
+ if Fuel.connection.adapter_name.downcase == 'sqlite'
22
+ ignorance = ''
23
+ else
24
+ ignorance = 'IGNORE'
25
+ end
21
26
  connection.execute %{
22
- INSERT IGNORE INTO fuels(name)
27
+ INSERT #{ignorance} INTO fuels(name)
23
28
  SELECT DISTINCT fuel_years.fuel_name FROM fuel_years
24
29
  }
25
30
  end
@@ -5,11 +5,12 @@ class EgridRegion < ActiveRecord::Base
5
5
 
6
6
  data_miner do
7
7
  tap "Brighter Planet's egrid region data", Earth.taps_server
8
-
8
+
9
9
  process "pull dependencies" do
10
10
  run_data_miner_on_belongs_to_associations
11
11
  end
12
12
  end
13
13
 
14
- falls_back_on :loss_factor => 0.061311 # Ian
14
+ # FIXME TODO someday should calculate this from eGRID data: (USTNGN05 + USTNFI05 - USTCON05) / USTNGN05
15
+ falls_back_on :loss_factor => 0.061879 # calculated using above formula 2/21/2011
15
16
  end
@@ -5,31 +5,14 @@ EgridRegion.class_eval do
5
5
  float 'loss_factor'
6
6
  end
7
7
 
8
- # NOTE: the following import uses an 18 Mb zip - don't know if two imports will cause it to be downloaded twice...
9
- #
10
- # import "eGRID regions and loss factors derived from eGRID 2007 data",
11
- # :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/eGRID2007_Version1-1.zip',
12
- # :filename => 'eGRID2007_Version1-1/eGRID2007V1_1_year0504_STIE_USGC.xls',
13
- # :sheet => 'STIE05',
14
- # :skip => 4,
15
- # :select => lambda { |row| row['eGRID2007 2005 file State sequence number'].to_i.between?(1, 51) } do
16
- # key 'name', :field_name => 'Grid region (E=Eastern grid, W=Western grid, AK=Alaska, HI=Hawaii, TX=Texas)'
17
- # store 'loss_factor', :field_name => '2005 grid gross loss factor'
18
- # end
19
- #
20
- # import "the US average grid loss factor derived eGRID 2007 data"
21
- # :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/eGRID2007_Version1-1.zip',
22
- # :filename => 'eGRID2007_Version1-1/eGRID2007V1_1_year0504_STIE_USGC.xls',
23
- # :sheet => 'USGC',
24
- # :skip => 5 do
25
- # key # the name should be 'US'
26
- # store # store the result of (USTNGN05 + USTNFI05 - USTCON05) / USTNGN05
27
- # end
28
-
29
8
  import "eGRID regions and loss factors derived from eGRID 2007 data",
30
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHoydC1MdDY0YVZkRE5zN0huOUZYbnc&hl=en&single=true&gid=0&output=csv' do
31
- key 'name'
32
- store 'loss_factor'
9
+ :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/eGRID2007_Version1-1.zip',
10
+ :filename => 'eGRID2007_Version1-1/eGRID2007V1_1_year0504_STIE_USGC.xls',
11
+ :sheet => 'STIE05',
12
+ :skip => 4,
13
+ :select => lambda { |row| row['eGRID2007 2005 file State sequence number'].to_i.between?(1, 51) } do
14
+ key 'name', :field_name => 'Grid region (E=Eastern grid, W=Western grid, AK=Alaska, HI=Hawaii, TX=Texas)'
15
+ store 'loss_factor', :field_name => '2005 grid gross loss factor'
33
16
  end
34
17
 
35
18
  verify "Loss factor should be greater than zero and less than one" do
@@ -40,12 +23,6 @@ EgridRegion.class_eval do
40
23
  end
41
24
  end
42
25
 
43
- # FIXME TODO get this verification to work
44
- # verify "Fallback loss factor should be greater than zero and less than one" do
45
- # factor = EgridRegion.fallback.loss_factor
46
- # unless factor > 0 and factor < 1
47
- # raise "Invalid EgridRegion fallback loss factor: #{factor} (should be 0 < loss_factor < 1)"
48
- # end
49
- # end
26
+ # FIXME TODO verify fallback loss factor
50
27
  end
51
28
  end
@@ -4,11 +4,27 @@ class EgridSubregion < ActiveRecord::Base
4
4
  has_many :zip_codes, :foreign_key => 'egrid_subregion_abbreviation'
5
5
  belongs_to :egrid_region, :foreign_key => 'egrid_region_name'
6
6
 
7
- falls_back_on :electricity_emission_factor => 1.404.pounds.to(:kilograms) # kg CO2 / kWh https://brighterplanet.sifterapp.com/projects/30/issues/437?return_uri=%2Fprojects%2F30%2Fissues%3Fa%3D79%26s%3D1-2
7
+ class << self
8
+ def fallback_egrid_region
9
+ EgridRegion.fallback
10
+ end
11
+ end
12
+
13
+ falls_back_on :egrid_region => lambda { EgridSubregion.fallback_egrid_region },
14
+ :electricity_co2_emission_factor => lambda { weighted_average(:electricity_co2_emission_factor, :weighted_by => :net_generation) },
15
+ :electricity_co2_emission_factor_units => 'kilograms_per_kilowatt_hour',
16
+ :electricity_co2_biogenic_emission_factor => lambda { weighted_average(:electricity_co2_biogenic_emission_factor, :weighted_by => :net_generation) },
17
+ :electricity_co2_biogenic_emission_factor_units => 'kilograms_per_kilowatt_hour',
18
+ :electricity_ch4_emission_factor => lambda { weighted_average(:electricity_ch4_emission_factor, :weighted_by => :net_generation) },
19
+ :electricity_ch4_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour',
20
+ :electricity_n2o_emission_factor => lambda { weighted_average(:electricity_n2o_emission_factor, :weighted_by => :net_generation) },
21
+ :electricity_n2o_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour',
22
+ :electricity_emission_factor => lambda { weighted_average(:electricity_emission_factor, :weighted_by => :net_generation) }, # DEPRECATED
23
+ :electricity_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour' # DEPRECATED
8
24
 
9
25
  data_miner do
10
26
  tap "Brighter Planet's egrid subregion data", Earth.taps_server
11
-
27
+
12
28
  process "pull dependencies" do
13
29
  run_data_miner_on_belongs_to_associations
14
30
  end