Sha256: 921d434bac6c9c4013299ddd14a6a73519a214f685695a040eb0d73f8bd1bb11

Contents?: true

Size: 1021 Bytes

Versions: 3

Compression:

Stored size: 1021 Bytes

Contents

AutomobileActivityYearType.class_eval do
  data_miner do
    process "Start from scratch" do
      delete_all
    end
    
    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
      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

3 entries across 3 versions & 1 rubygems

Version Path
earth-0.12.3 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-0.12.2 lib/earth/automobile/automobile_activity_year_type/data_miner.rb
earth-0.12.1 lib/earth/automobile/automobile_activity_year_type/data_miner.rb