Sha256: dc6d0ec1848bc7c2c5f40aea3f4c2aab766388d558019dfddcc24801847be1cd

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

require 'earth/fuel/data_miner'
AutomobileTypeYear.class_eval do
  data_miner do
    import "automobile type year air conditioning emissions derived from the 2010 EPA GHG Inventory",
           :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFoyTWhDeHpndTV5Ny1aX0sxR1ljSFE&hl=en&gid=0&output=csv' do
      key   'name'
      store 'type_name'
      store 'year'
      store 'hfc_emissions', :units_field_name => 'hfc_emissions_units'
    end
    
    process "Ensure AutomobileTypeFuelYear is populated" do
      AutomobileTypeFuelYear.run_data_miner!
    end
    
    process "Calculate HFC emission factor from AutomobileTypeFuelYear" do
      total_fuel_consumption = %{
        SELECT SUM(src.fuel_consumption)
        FROM #{AutomobileTypeFuelYear.quoted_table_name} AS src
        WHERE
          src.type_name = #{quoted_table_name}.type_name
          AND src.year = #{quoted_table_name}.year
      }
      where("(#{total_fuel_consumption}) > 0").update_all(%{
        hfc_emission_factor = 1.0 * hfc_emissions / (#{total_fuel_consumption}),
        hfc_emission_factor_units = 'kilograms_co2e_per_litre'
      })
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
earth-0.11.20 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.19 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.18 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.17 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.16 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.15 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.14 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.13 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.12 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.11 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.10 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.9 lib/earth/automobile/automobile_type_year/data_miner.rb
earth-0.11.8 lib/earth/automobile/automobile_type_year/data_miner.rb