Sha256: 26340d9fda880e262d5b56282d7f35e5d5a52d1a9f2618074716008137a069d8

Contents?: true

Size: 1.66 KB

Versions: 55

Compression:

Stored size: 1.66 KB

Contents

AutomobileFuelType.class_eval do
  data_miner do
    schema Earth.database_options do
      string   'code'
      string   'name'
      float    'emission_factor'
      string   'emission_factor_units'
      float    'annual_distance'
      string   'annual_distance_units'
    end
    
    import("the fuels used in the 2000 EPA fuel economy guide",
           :url => 'http://www.fueleconomy.gov/FEG/epadata/00data.zip',
           :filename => 'Gd6-dsc.txt',
           :format => :fixed_width,
           :crop => 21..26, # inclusive
           :cut => '2-',
           :select => lambda { |row| /\A[A-Z]/.match row[:code] },
           :schema => [[ 'code',   2,  { :type => :string }  ],
                       [ 'spacer', 2 ],
                       [ 'name',   52, { :type => :string } ]]) do
      key   'code'
      store 'name'
    end

    import "a pre-calculated emission factor and average annual distance for each fuel",
           :url => 'http://static.brighterplanet.com/science/data/transport/automobiles/models_export/automobile_fuel_type.csv' do
      key   'code', :field_name => 'code'
      store 'name'
      store 'annual_distance', :units => :kilometres
      store 'emission_factor', :units => :kilograms_per_litre
    end

    # pull electricity emission factor from residential electricity
    import "a pre-calculated emission factor for electricity",
           :url => 'http://spreadsheets.google.com/pub?key=rukxnmuhhsOsrztTrUaFCXQ',
           :select => lambda { |row| row['name'] == 'electricity' } do
      key 'name'
      store 'emission_factor', :units => :kilograms_per_litre
    end
    
    # still need distance estimate for electric cars
  end
end

Version data entries

55 entries across 55 versions & 2 rubygems

Version Path
earth-0.3.9 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.8 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.7 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.6 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.5 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.4 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.3 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.2 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.1 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.3.0 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.14 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.13 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.12 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.11 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.9 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.8 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.7 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.6 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.5 lib/earth/automobile/automobile_fuel_type/data_miner.rb
earth-0.2.4 lib/earth/automobile/automobile_fuel_type/data_miner.rb