earth 0.11.20 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/data/automobile/annual_emission_controls.csv +143 -0
- data/data/automobile/annual_fuel_consumption.csv +81 -0
- data/data/automobile/annual_sizes.csv +541 -0
- data/data/automobile/auto_fuel_data.csv +13 -0
- data/data/automobile/auto_fuel_efs.csv +9 -0
- data/data/automobile/cafe_data.csv +1449 -0
- data/data/automobile/emission_control_techs.csv +21 -0
- data/data/automobile/hfc_emissions.csv +31 -0
- data/data/automobile/hybridity_multipliers.csv +8 -0
- data/data/automobile/sizes.csv +16 -0
- data/earth.gemspec +3 -2
- data/errata/aircraft/faa_errata.csv +1 -1
- data/errata/airline/bts_carrier_codes_errata.csv +44 -0
- data/errata/airport/openflights_errata.csv +450 -1
- data/errata/automobile_make_model_year_variant/feg_errata.csv +363 -1
- data/errata/automobile_make_year_fleet/cafe_errata.csv +69 -1
- data/errata/bts_aircraft/bts_errata.csv +1 -1
- data/errata/country/wri_errata.csv +1 -1
- data/errata/electricity/electric_market/nrel_errata.csv +13 -1
- data/errata/electricity/electric_utility/eia_errata.csv +18 -1
- data/errata/flight_segment/bts_errata.csv +4 -1
- data/lib/earth.rb +1 -0
- data/lib/earth/acronyms.rb +12 -0
- data/lib/earth/air/aircraft.rb +16 -0
- data/lib/earth/air/airline.rb +3 -0
- data/lib/earth/air/airline/data_miner.rb +18 -3
- data/lib/earth/air/airport.rb +2 -0
- data/lib/earth/air/bts_aircraft.rb +2 -0
- data/lib/earth/air/flight_distance_class.rb +2 -0
- data/lib/earth/air/flight_distance_class_seat_class.rb +2 -0
- data/lib/earth/air/flight_seat_class.rb +2 -0
- data/lib/earth/air/flight_segment.rb +10 -0
- data/lib/earth/air/flight_segment/data_miner.rb +10 -13
- data/lib/earth/automobile/automobile_activity_year.rb +21 -0
- data/lib/earth/automobile/automobile_activity_year/data_miner.rb +27 -0
- data/lib/earth/automobile/automobile_activity_year_type.rb +27 -0
- data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +27 -0
- data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +19 -0
- data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +57 -0
- data/lib/earth/automobile/automobile_fuel.rb +93 -86
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +64 -70
- data/lib/earth/automobile/automobile_make.rb +5 -1
- data/lib/earth/automobile/automobile_make/data_miner.rb +10 -37
- data/lib/earth/automobile/automobile_make_model.rb +22 -3
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +41 -15
- data/lib/earth/automobile/automobile_make_model_year.rb +18 -7
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +43 -27
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +44 -8
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +182 -8
- data/lib/earth/automobile/automobile_make_year.rb +4 -2
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +16 -15
- data/lib/earth/automobile/automobile_make_year_fleet.rb +2 -1
- data/lib/earth/automobile/automobile_make_year_fleet/data_miner.rb +5 -2
- data/lib/earth/automobile/automobile_model.rb +2 -1
- data/lib/earth/automobile/automobile_model/data_miner.rb +1 -2
- data/lib/earth/automobile/automobile_size_class.rb +7 -68
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +16 -51
- data/lib/earth/automobile/automobile_type_fuel.rb +23 -0
- data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +52 -0
- data/lib/earth/automobile/automobile_type_fuel_control.rb +2 -33
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +19 -4
- data/lib/earth/automobile/automobile_type_fuel_year.rb +17 -54
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +40 -94
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +25 -23
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +6 -2
- data/lib/earth/automobile/automobile_year.rb +38 -1
- data/lib/earth/automobile/automobile_year/data_miner.rb +1 -2
- data/lib/earth/automobile/dependencies.txt +22 -36
- data/lib/earth/bus/bus_class.rb +2 -0
- data/lib/earth/bus/bus_fuel.rb +2 -0
- data/lib/earth/bus/bus_fuel_control.rb +2 -0
- data/lib/earth/bus/bus_fuel_year_control.rb +2 -0
- data/lib/earth/computation/computation_carrier.rb +2 -0
- data/lib/earth/computation/computation_carrier_instance_class.rb +2 -0
- data/lib/earth/computation/computation_carrier_region.rb +2 -0
- data/lib/earth/conversions_ext.rb +6 -0
- data/lib/earth/diet/diet_class.rb +2 -0
- data/lib/earth/diet/food_group.rb +2 -0
- data/lib/earth/fuel/fuel.rb +2 -0
- data/lib/earth/fuel/fuel/data_miner.rb +15 -0
- data/lib/earth/fuel/fuel_price.rb +2 -0
- data/lib/earth/fuel/fuel_type.rb +2 -0
- data/lib/earth/fuel/fuel_year.rb +2 -0
- data/lib/earth/fuel/greenhouse_gas.rb +2 -0
- data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +7 -7
- data/lib/earth/hospitality/lodging_class.rb +2 -0
- data/lib/earth/industry/industry.rb +2 -0
- data/lib/earth/industry/mecs_energy/data_miner.rb +1 -1
- data/lib/earth/industry/mecs_ratio/data_miner.rb +1 -1
- data/lib/earth/locality/census_division.rb +2 -0
- data/lib/earth/locality/census_region.rb +2 -0
- data/lib/earth/locality/climate_division.rb +2 -0
- data/lib/earth/locality/country.rb +4 -0
- data/lib/earth/locality/egrid_region.rb +3 -0
- data/lib/earth/locality/egrid_subregion.rb +2 -0
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +7 -0
- data/lib/earth/locality/state.rb +7 -0
- data/lib/earth/locality/zip_code.rb +4 -0
- data/lib/earth/pet/breed.rb +7 -0
- data/lib/earth/pet/breed/data_miner.rb +1 -1
- data/lib/earth/pet/breed_gender.rb +2 -0
- data/lib/earth/pet/gender.rb +2 -0
- data/lib/earth/pet/species.rb +2 -0
- data/lib/earth/rail/country_rail_class.rb +2 -0
- data/lib/earth/rail/country_rail_traction.rb +2 -0
- data/lib/earth/rail/country_rail_traction_class.rb +2 -0
- data/lib/earth/rail/national_transit_database_company.rb +7 -0
- data/lib/earth/rail/national_transit_database_mode.rb +2 -0
- data/lib/earth/rail/national_transit_database_record.rb +22 -0
- data/lib/earth/rail/rail_class.rb +2 -0
- data/lib/earth/rail/rail_company.rb +16 -0
- data/lib/earth/rail/rail_fuel.rb +2 -0
- data/lib/earth/rail/rail_traction.rb +2 -0
- data/lib/earth/residence/air_conditioner_use.rb +2 -0
- data/lib/earth/residence/clothes_machine_use.rb +2 -0
- data/lib/earth/residence/dishwasher_use.rb +2 -0
- data/lib/earth/residence/residence_appliance.rb +2 -0
- data/lib/earth/residence/residence_class.rb +2 -0
- data/lib/earth/residence/residence_fuel_price.rb +2 -0
- data/lib/earth/residence/residence_fuel_type.rb +2 -0
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +2 -0
- data/lib/earth/residence/urbanity.rb +2 -0
- data/lib/earth/shipping/carrier.rb +2 -0
- data/lib/earth/shipping/carrier_mode.rb +2 -0
- data/lib/earth/shipping/shipment_mode.rb +2 -0
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/airline_spec.rb +20 -0
- data/spec/earth/air/flight_segment_spec.rb +9 -4
- data/spec/earth/automobile/automobile_activity_year_spec.rb +30 -0
- data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +25 -0
- data/spec/earth/automobile/automobile_activity_year_type_spec.rb +38 -0
- data/spec/earth/automobile/automobile_fuel_spec.rb +91 -6
- data/spec/earth/automobile/automobile_make_model_spec.rb +74 -0
- data/spec/earth/automobile/automobile_make_model_year_spec.rb +90 -0
- data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +139 -90
- data/spec/earth/automobile/automobile_make_spec.rb +27 -0
- data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +8 -21
- data/spec/earth/automobile/automobile_make_year_spec.rb +28 -0
- data/spec/earth/automobile/automobile_model_spec.rb +15 -0
- data/spec/earth/automobile/automobile_size_class_spec.rb +31 -0
- data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +25 -0
- data/spec/earth/automobile/automobile_type_fuel_spec.rb +45 -0
- data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +51 -0
- data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +65 -0
- data/spec/earth/automobile/automobile_year_spec.rb +23 -0
- data/spec/earth/fuel/fuel_spec.rb +1 -1
- data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +11 -3
- data/spec/earth_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +78 -25
- data/lib/earth/automobile/automobile_size_class_year.rb +0 -44
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -18
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +0 -68
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +0 -116
- data/lib/earth/automobile/automobile_type_year.rb +0 -58
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +0 -30
- data/spec/earth/automobile/automobile_type_fuel_year_age_spec.rb +0 -20
@@ -1,34 +1,36 @@
|
|
1
|
-
require 'earth/fuel'
|
2
1
|
class AutomobileTypeFuelYearControl < ActiveRecord::Base
|
3
2
|
self.primary_key = "name"
|
4
3
|
|
4
|
+
# Needs to be a belongs_to so that it gets imported with taps for AutomobileTypeFuelYear ch4 and n2o ef calculation
|
5
|
+
belongs_to :type_fuel_control, :foreign_key => :type_fuel_control_name, :class_name => 'AutomobileTypeFuelControl'
|
6
|
+
|
7
|
+
# Used by AutomobileTypeFuelYear
|
8
|
+
def self.find_all_by_type_name_and_fuel_common_name_and_closest_year(type_name, fuel_common_name, year)
|
9
|
+
if year > maximum(:year)
|
10
|
+
where(:type_name => type_name, :fuel_common_name => fuel_common_name, :year => maximum(:year))
|
11
|
+
else
|
12
|
+
where(:type_name => type_name, :fuel_common_name => fuel_common_name, :year => [year, minimum(:year)].max)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
%w{ ch4_emission_factor n2o_emission_factor }.each do |method|
|
17
|
+
define_method method do
|
18
|
+
type_fuel_control.send(method)
|
19
|
+
end
|
20
|
+
|
21
|
+
units_method = method + '_units'
|
22
|
+
define_method units_method do
|
23
|
+
type_fuel_control.send(units_method)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
5
27
|
col :name
|
6
28
|
col :type_name
|
7
29
|
col :fuel_common_name
|
8
30
|
col :year, :type => :integer
|
9
31
|
col :control_name
|
32
|
+
col :type_fuel_control_name
|
10
33
|
col :total_travel_percent, :type => :float
|
11
34
|
|
12
|
-
|
13
|
-
# verify "#{attribute.humanize} should never be missing" do
|
14
|
-
# AutomobileTypeFuelYearControl.all.each do |record|
|
15
|
-
# value = record.send(:"#{attribute}")
|
16
|
-
# unless value.present?
|
17
|
-
# raise "Missing #{attribute.humanize.downcase} for AutomobileTypeFuelYearControl '#{record.name}'"
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# verify "Year should be from 1990 to 2008" do
|
24
|
-
# AutomobileTypeFuelYearControl.all.each do |record|
|
25
|
-
# year = record.send(:year)
|
26
|
-
# unless year > 1989 and year < 2009
|
27
|
-
# raise "Invalid year for AutomobileTypeFuelYearControl '#{record.name}': #{year} (should be from 1990 to 2008)"
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
|
32
|
-
# FIXME TODO verify "Total travel percent for each type fuel year should sum to one"
|
33
|
-
|
35
|
+
warn_unless_size 142
|
34
36
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
-
require 'earth/fuel/data_miner'
|
2
1
|
AutomobileTypeFuelYearControl.class_eval do
|
3
2
|
data_miner do
|
3
|
+
process "Start from scratch" do
|
4
|
+
delete_all
|
5
|
+
end
|
6
|
+
|
4
7
|
import "automobile type fuel year control data derived from the 2010 EPA GHG Inventory",
|
5
|
-
:url =>
|
8
|
+
:url => "file://#{Earth::DATA_DIR}/automobile/annual_emission_controls.csv" do
|
6
9
|
key 'name'
|
7
10
|
store 'type_name'
|
8
11
|
store 'fuel_common_name'
|
9
12
|
store 'year'
|
10
13
|
store 'control_name'
|
14
|
+
store 'type_fuel_control_name', :synthesize => proc { |row| [row['type_name'], row['fuel_common_name'], row['control_name']].join(' ') }
|
11
15
|
store 'total_travel_percent'
|
12
16
|
end
|
13
17
|
end
|
@@ -1,6 +1,43 @@
|
|
1
|
-
require 'earth/fuel'
|
2
1
|
class AutomobileYear < ActiveRecord::Base
|
3
2
|
self.primary_key = "year"
|
4
3
|
|
4
|
+
# Estimate of % of vehicles currently in use that were manufactured in each year
|
5
|
+
# Derived from 2012 EPA GHG inventory appendix tables A-91, A-92, and A-95
|
6
|
+
# Used by AutomobileMakeModelYear and AutomobileMakeYear to get weighting so other classes can derive weighted fuel efficiency
|
7
|
+
def self.weighting(year)
|
8
|
+
{
|
9
|
+
2012 => 0.0607,
|
10
|
+
2011 => 0.0491,
|
11
|
+
2010 => 0.0560,
|
12
|
+
2009 => 0.0669,
|
13
|
+
2008 => 0.0677,
|
14
|
+
2007 => 0.0668,
|
15
|
+
2006 => 0.0641,
|
16
|
+
2005 => 0.0620,
|
17
|
+
2004 => 0.0624,
|
18
|
+
2003 => 0.0625,
|
19
|
+
2002 => 0.0610,
|
20
|
+
2001 => 0.0546,
|
21
|
+
2000 => 0.0467,
|
22
|
+
1999 => 0.0410,
|
23
|
+
1998 => 0.0347,
|
24
|
+
1997 => 0.0289,
|
25
|
+
1996 => 0.0244,
|
26
|
+
1995 => 0.0189,
|
27
|
+
1994 => 0.0139,
|
28
|
+
1993 => 0.0112,
|
29
|
+
1992 => 0.0094,
|
30
|
+
1991 => 0.0084,
|
31
|
+
1990 => 0.0066,
|
32
|
+
1989 => 0.0056,
|
33
|
+
1988 => 0.0047,
|
34
|
+
1987 => 0.0037,
|
35
|
+
1986 => 0.0025,
|
36
|
+
1985 => 0.0054
|
37
|
+
}[year]
|
38
|
+
end
|
39
|
+
|
5
40
|
col :year, :type => :integer
|
41
|
+
|
42
|
+
warn_unless_size 28
|
6
43
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'earth/fuel/data_miner'
|
2
1
|
AutomobileYear.class_eval do
|
3
2
|
data_miner do
|
4
3
|
process "Ensure AutomobileMakeModelYearVariant is populated" do
|
5
4
|
AutomobileMakeModelYearVariant.run_data_miner!
|
6
5
|
end
|
7
6
|
|
8
|
-
process "Derive year names from
|
7
|
+
process "Derive year names from AutomobileMakeModelYearVariant" do
|
9
8
|
::Earth::Utils.insert_ignore(
|
10
9
|
:src => AutomobileMakeModelYearVariant,
|
11
10
|
:dest => AutomobileYear,
|
@@ -1,45 +1,31 @@
|
|
1
1
|
This file shows which additional classes will be data_mined when you run data_miner on an automobile class. To get a complete set of automobile data you only need to data_mine the classes that are not indented.
|
2
2
|
|
3
|
+
MakeModel
|
4
|
+
MakeModelYear
|
5
|
+
MakeModelYearVariant
|
6
|
+
AutomobileFuel (via belongs_to)
|
7
|
+
TypeFuel
|
8
|
+
TypeFuelYear
|
9
|
+
TypeFuelYearControl
|
10
|
+
TypeFuelControl (via belongs_to)
|
11
|
+
ActivityYearTypeFuel
|
12
|
+
Fuel
|
13
|
+
FuelYear
|
14
|
+
GreenhouseGas
|
15
|
+
|
3
16
|
Make
|
4
|
-
|
5
|
-
|
17
|
+
MakeYear
|
18
|
+
MakeModelYearVariant
|
19
|
+
MakeYearFleet
|
6
20
|
|
7
21
|
Model
|
8
|
-
|
9
|
-
MakeModelYearVariant
|
22
|
+
MakeModelYearVariant
|
10
23
|
|
11
24
|
Year
|
12
|
-
|
13
|
-
MakeModelYearVariant
|
14
|
-
|
15
|
-
MakeModel
|
16
|
-
MakeModelYearVariant
|
17
|
-
|
18
|
-
MakeYear
|
19
|
-
MakeYearFleet
|
20
|
-
MakeModelYearVariant
|
21
|
-
|
22
|
-
MakeModelYear
|
23
|
-
MakeModelYearVariant
|
24
|
-
AutomobileFuel
|
25
|
-
GreenhouseGas
|
26
|
-
Fuel
|
27
|
-
FuelYear
|
28
|
-
TypeYear
|
29
|
-
TypeFuelYear
|
30
|
-
TypeFuelControl
|
31
|
-
TypeFuelYearControl
|
32
|
-
TypeFuelYearAge
|
33
|
-
TypeFuelYear
|
34
|
-
TypeFuelControl
|
35
|
-
TypeFuelYearControl
|
25
|
+
MakeModelYearVariant
|
36
26
|
|
37
27
|
SizeClass
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
TypeFuelYearAge
|
43
|
-
TypeFuelYear
|
44
|
-
TypeFuelControl
|
45
|
-
TypeFuelYearControl
|
28
|
+
|
29
|
+
ActivityYear
|
30
|
+
ActivityYearType
|
31
|
+
ActivityYearTypeFuel
|
data/lib/earth/bus/bus_class.rb
CHANGED
data/lib/earth/bus/bus_fuel.rb
CHANGED
@@ -3,6 +3,7 @@ require 'conversions'
|
|
3
3
|
# Distance: base unit = kilometre
|
4
4
|
Conversions.register :kilometres, :miles, 0.621371192
|
5
5
|
Conversions.register :kilometres, :nautical_miles, 0.539956803
|
6
|
+
Conversions.register :kilometres, :billion_miles, 1.kilometres.to(:miles) / 1_000_000_000 # for AutomobileTypeFuelYear
|
6
7
|
|
7
8
|
# Area
|
8
9
|
Conversions.register :square_metres, :square_feet, 10.7639104
|
@@ -68,6 +69,11 @@ Conversions.register :teragrams_per_quadrillion_btu, :grams_per_megajoule
|
|
68
69
|
# Conversions.register :epa_miles_per_gallon_gasoline_equivalent, :cubic_metres_per_hundred_kilometres, (1 / (1.cubic_metres_compressed_natural_gas.to(:epa_gallon_gasoline_equivalents) / 100.kilometres.to(:miles)))
|
69
70
|
# Conversions.register :epa_miles_per_gallon_gasoline_equivalent, :kilograms_per_hundred_kilometres, (1 / (1.kilograms_hydrogen.to(:epa_gallon_gasoline_equivalents) / 100.kilometres.to(:miles)))
|
70
71
|
|
72
|
+
# Odd units for EPA automobile data
|
73
|
+
Conversions.register :grams_per_mile, :kilograms_per_kilometre, 1.grams.to(:kilograms) / 1.miles.to(:kilometres)
|
74
|
+
Conversions.register :teragrams_co2e, :kilograms_co2e, 1_000_000_000.0
|
75
|
+
Conversions.register :million_gallons, :litres, 1_000_000.gallons.to(:litres)
|
76
|
+
|
71
77
|
# Odd units for pet - FIXME use megajoules rather than joules
|
72
78
|
Conversions.register :kilocalories, :joules, 4_184.0
|
73
79
|
Conversions.register :kilocalories_per_pound, :joules_per_kilogram, (1.kilocalories.to(:joules) / 1.pounds.to(:kilograms))
|
data/lib/earth/fuel/fuel.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
Fuel.class_eval do
|
2
2
|
data_miner do
|
3
|
+
process "Start from scratch" do
|
4
|
+
delete_all
|
5
|
+
end
|
6
|
+
|
3
7
|
process "Ensure FuelYear is populated" do
|
4
8
|
FuelYear.run_data_miner!
|
5
9
|
end
|
@@ -34,6 +38,17 @@ Fuel.class_eval do
|
|
34
38
|
store 'biogenic_fraction'
|
35
39
|
end
|
36
40
|
|
41
|
+
import "hydrogen",
|
42
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGJmYkdtajZyV3Byb0lrd21xLVhXUGc&output=csv',
|
43
|
+
:select => proc {|row| row['energy_content_units'] == 'megajoules_per_kilogram'} do
|
44
|
+
key 'name'
|
45
|
+
store 'physical_units', :static => 'kilogram'
|
46
|
+
store 'energy_content', :units_field_name => 'energy_content_units'
|
47
|
+
store 'carbon_content', :units_field_name => 'carbon_content_units'
|
48
|
+
store 'oxidation_factor'
|
49
|
+
store 'biogenic_fraction'
|
50
|
+
end
|
51
|
+
|
37
52
|
import "densities for aircraft fuels",
|
38
53
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHBjTVE4NmRlc05iUHVZR1E3eEJwOGc&hl=en&gid=0&output=csv' do
|
39
54
|
key 'name'
|
data/lib/earth/fuel/fuel_type.rb
CHANGED
data/lib/earth/fuel/fuel_year.rb
CHANGED
data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb
CHANGED
@@ -51,7 +51,7 @@ CommercialBuildingEnergyConsumptionSurveyResponse.class_eval do
|
|
51
51
|
store 'heating_degree_days', :field_name => 'HDD658', :from_units => :degrees_fahrenheit, :to_units => :degrees_celsius
|
52
52
|
store 'cooling_degree_days', :field_name => 'CDD658', :from_units => :degrees_fahrenheit, :to_units => :degrees_celsius
|
53
53
|
store 'electricity_use', :synthesize => proc { |row| row['ELCNS8'].to_i }, :units => :kilowatt_hours
|
54
|
-
store 'electricity_energy', :
|
54
|
+
store 'electricity_energy', :synthesize => proc { |row| row['ELBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
|
55
55
|
end
|
56
56
|
|
57
57
|
import 'fuel use characteristics from the 2003 EIA CBECS',
|
@@ -59,12 +59,12 @@ CommercialBuildingEnergyConsumptionSurveyResponse.class_eval do
|
|
59
59
|
:skip => 1,
|
60
60
|
:headers => ["PUBID8", "REGION8", "CENDIV8", "SQFT8", "SQFTC8", "YRCONC8", "PBA8", "ELUSED8", "NGUSED8", "FKUSED8", "PRUSED8", "STUSED8", "HWUSED8", "ADJWT8", "STRATUM8", "PAIR8", "NGCNS8", "NGBTU8", "NGEXP8", "ZNGCNS8", "ZNGEXP8", "FKCNS8", "FKBTU8", "FKEXP8", "ZFKCNS8", "ZFKEXP8", "DHUSED8", "DHHT18", "DHHT28", "DHCOOL8", "DHWATR8", "DHCOOK8", "DHMANU8", "DHOTH8", "DHCNS8", "DHBTU8", "DHEXP8", "ZDHCNS8", "ZDHEXP8"] do
|
61
61
|
key 'id', :field_name => 'PUBID8'
|
62
|
-
store 'natural_gas_use', :
|
63
|
-
store '
|
64
|
-
store '
|
65
|
-
store '
|
66
|
-
store '
|
67
|
-
store 'district_heat_energy', :
|
62
|
+
store 'natural_gas_use', :synthesize => proc { |row| row['NGCNS8'].to_i.hundred_cubic_feet.to(:cubic_metres) }, :units => :cubic_metres
|
63
|
+
store 'fuel_oil_use', :synthesize => proc { |row| row['FKCNS8'].to_i.gallons.to(:litres) }, :units => :litres
|
64
|
+
store 'district_heat_use', :synthesize => proc { |row| row['DHBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
|
65
|
+
store 'natural_gas_energy', :synthesize => proc { |row| row['NGBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
|
66
|
+
store 'fuel_oil_energy', :synthesize => proc { |row| row['FKBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
|
67
|
+
store 'district_heat_energy', :synthesize => proc { |row| row['DHBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
|
68
68
|
end
|
69
69
|
|
70
70
|
process "Derive room nights for lodging records" do
|
@@ -28,7 +28,7 @@ MecsEnergy.class_eval do
|
|
28
28
|
data_miner do
|
29
29
|
MecsEnergy::CENSUS_REGIONS.each do |region, data|
|
30
30
|
import("MECS table 3.2 #{region}",
|
31
|
-
:url => "http://
|
31
|
+
:url => "http://www.eia.gov/emeu/mecs/mecs2006/excel/Table3_2.xls",
|
32
32
|
:crop => data[:crop],
|
33
33
|
:headers => ["NAICS Code", "Subsector and Industry", "Total", "BLANK", "Net Electricity", "BLANK", "Residual Fuel Oil", "Distillate Fuel Oil", "Natural Gas", "BLANK", "LPG and NGL", "BLANK", "Coal", "Coke and Breeze", "Other"]) do
|
34
34
|
key :name, :synthesize => proc { |row| "#{Industry.format_naics_code(row['NAICS Code'])}-#{data[:code]}" }
|
@@ -28,7 +28,7 @@ MecsRatio.class_eval do
|
|
28
28
|
data_miner do
|
29
29
|
MecsRatio::CENSUS_REGIONS.each do |region, data|
|
30
30
|
import( "MECS table 6.1 #{region}",
|
31
|
-
:url => "http://
|
31
|
+
:url => "http://www.eia.gov/emeu/mecs/mecs2006/excel/Table6_1.xls",
|
32
32
|
:crop => data[:crop],
|
33
33
|
:headers => ["NAICS Code", "Subsector and Industry", "Consumption per Employee", "Consumption per Dollar of Value Added", "Consumption per Dollar of Value of Shipments"]) do
|
34
34
|
key :name, :synthesize => proc { |row| "#{Industry.format_naics_code(row["NAICS Code"])}-#{data[:code]}" }
|