Sha256: b4c7e77d7c8118168f5816a04d2f7be39b28117dd5e0a467d7864defe7aedd86

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

require 'earth/fuel/greenhouse_gas'
require 'earth/fuel/greenhouse_gas/data_miner'

AutomobileTypeFuelControl.class_eval do
  data_miner do
    import "automobile type fuel control data derived from the 2010 EPA GHG Inventory",
           :url => "file://#{Earth::DATA_DIR}/automobile/emission_control_techs.csv" do
      key   'name'
      store 'type_name'
      store 'fuel_family'
      store 'control_name'
      store 'ch4_emission_factor', :from_units => :grams_per_mile, :to_units => :kilograms_per_kilometre
      store 'n2o_emission_factor', :from_units => :grams_per_mile, :to_units => :kilograms_per_kilometre
    end
    
    process "Ensure GreenhouseGas is populated" do
      GreenhouseGas.run_data_miner!
    end
    
    process "Convert emission factors to co2e" do
      %w{ ch4 n2o }.each do |gas|
        where("#{gas}_emission_factor_units = 'kilograms_per_kilometre'").update_all %{
          #{gas}_emission_factor = #{gas}_emission_factor * #{GreenhouseGas[gas].global_warming_potential},
          #{gas}_emission_factor_units = 'kilograms_co2e_per_kilometre'
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
earth-0.12.4 lib/earth/automobile/automobile_type_fuel_control/data_miner.rb
earth-0.12.3 lib/earth/automobile/automobile_type_fuel_control/data_miner.rb
earth-0.12.2 lib/earth/automobile/automobile_type_fuel_control/data_miner.rb