Sha256: 93014f5351145bcf4f3b9f405c5a110201c20e9437b0129abfdc54e83a41a4ad

Contents?: true

Size: 960 Bytes

Versions: 8

Compression:

Stored size: 960 Bytes

Contents

AutomobileActivityYearType.class_eval do
  data_miner do
    import "annual automobile air conditioning emissions derived from the 2010 EPA GHG Inventory",
           :url => "file://#{Earth::DATA_DIR}/automobile/hfc_emissions.csv" do
      key   'name'
      store 'activity_year'
      store 'type_name'
      store 'hfc_emissions', :from_units => :teragrams_co2e, :to_units => :kilograms_co2e
    end
    
    process "Ensure AutomobileActivityYearTypeFuel is populated" do
      AutomobileActivityYearTypeFuel.run_data_miner!
    end
    
    process "Derive hfc emission factor from AutomobileActivityYearTypeFuel" do
      safe_find_each do |ayt|
        ayt.update_attributes!(
          :hfc_emission_factor => ayt.hfc_emissions / ayt.activity_year_type_fuels.sum(:distance),
          :hfc_emission_factor_units => ayt.hfc_emissions_units + '_per_' + ayt.activity_year_type_fuels.first.distance_units.singularize
        )
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
earth-1.2.1 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.1.2 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.1.1 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.1.0 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.0.3 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.0.2 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.0.1 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-1.0.0 lib/earth/automobile/automobile_activity_year_type/data_miner.rb