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