lib/earth/locality/egrid_country/data_miner.rb in earth-0.12.0 vs lib/earth/locality/egrid_country/data_miner.rb in earth-0.12.1

- old
+ new

@@ -1,13 +1,19 @@ EgridCountry.class_eval do data_miner do - import "the US average grid loss factor derived eGRID 2007 data", - :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/eGRID2010V1_1_STIE_USGC.xls', - :sheet => 'USGC', - :skip => 5 do - key 'name', :static => 'US' - store 'generation', :field_name => 'USTNGN07', :units => :gigawatt_hours - store 'imports', :field_name => 'USTNFI07', :units => :gigawatt_hours - store 'consumption', :field_name => 'USTCON07', :units => :gigawatt_hours + import "eGRID 2012 national-level data", + :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/eGRID2012V1_0_year09_DATA.xls', + :sheet => 'GGL09', + :skip => 4, + :select => proc { |row| row['REGION'] == 'U.S.' } do + key 'name', :field_name => 'REGION' + store 'generation', :field_name => 'GENERAT', :units => :megawatt_hours + store 'foreign_interchange', :field_name => 'FRGNINTC', :units => :megawatt_hours + store 'domestic_interchange', :field_name => 'INTRCHNG', :units => :megawatt_hours + store 'consumption', :field_name => 'CONSUMP', :units => :megawatt_hours + end + + process "Calculate loss factor" do + update_all "loss_factor = (1.0 * generation + foreign_interchange + domestic_interchange - consumption) / generation" end end end