earth 0.11.20 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/data/automobile/annual_emission_controls.csv +143 -0
  2. data/data/automobile/annual_fuel_consumption.csv +81 -0
  3. data/data/automobile/annual_sizes.csv +541 -0
  4. data/data/automobile/auto_fuel_data.csv +13 -0
  5. data/data/automobile/auto_fuel_efs.csv +9 -0
  6. data/data/automobile/cafe_data.csv +1449 -0
  7. data/data/automobile/emission_control_techs.csv +21 -0
  8. data/data/automobile/hfc_emissions.csv +31 -0
  9. data/data/automobile/hybridity_multipliers.csv +8 -0
  10. data/data/automobile/sizes.csv +16 -0
  11. data/earth.gemspec +3 -2
  12. data/errata/aircraft/faa_errata.csv +1 -1
  13. data/errata/airline/bts_carrier_codes_errata.csv +44 -0
  14. data/errata/airport/openflights_errata.csv +450 -1
  15. data/errata/automobile_make_model_year_variant/feg_errata.csv +363 -1
  16. data/errata/automobile_make_year_fleet/cafe_errata.csv +69 -1
  17. data/errata/bts_aircraft/bts_errata.csv +1 -1
  18. data/errata/country/wri_errata.csv +1 -1
  19. data/errata/electricity/electric_market/nrel_errata.csv +13 -1
  20. data/errata/electricity/electric_utility/eia_errata.csv +18 -1
  21. data/errata/flight_segment/bts_errata.csv +4 -1
  22. data/lib/earth.rb +1 -0
  23. data/lib/earth/acronyms.rb +12 -0
  24. data/lib/earth/air/aircraft.rb +16 -0
  25. data/lib/earth/air/airline.rb +3 -0
  26. data/lib/earth/air/airline/data_miner.rb +18 -3
  27. data/lib/earth/air/airport.rb +2 -0
  28. data/lib/earth/air/bts_aircraft.rb +2 -0
  29. data/lib/earth/air/flight_distance_class.rb +2 -0
  30. data/lib/earth/air/flight_distance_class_seat_class.rb +2 -0
  31. data/lib/earth/air/flight_seat_class.rb +2 -0
  32. data/lib/earth/air/flight_segment.rb +10 -0
  33. data/lib/earth/air/flight_segment/data_miner.rb +10 -13
  34. data/lib/earth/automobile/automobile_activity_year.rb +21 -0
  35. data/lib/earth/automobile/automobile_activity_year/data_miner.rb +27 -0
  36. data/lib/earth/automobile/automobile_activity_year_type.rb +27 -0
  37. data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +27 -0
  38. data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +19 -0
  39. data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +57 -0
  40. data/lib/earth/automobile/automobile_fuel.rb +93 -86
  41. data/lib/earth/automobile/automobile_fuel/data_miner.rb +64 -70
  42. data/lib/earth/automobile/automobile_make.rb +5 -1
  43. data/lib/earth/automobile/automobile_make/data_miner.rb +10 -37
  44. data/lib/earth/automobile/automobile_make_model.rb +22 -3
  45. data/lib/earth/automobile/automobile_make_model/data_miner.rb +41 -15
  46. data/lib/earth/automobile/automobile_make_model_year.rb +18 -7
  47. data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +43 -27
  48. data/lib/earth/automobile/automobile_make_model_year_variant.rb +44 -8
  49. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +182 -8
  50. data/lib/earth/automobile/automobile_make_year.rb +4 -2
  51. data/lib/earth/automobile/automobile_make_year/data_miner.rb +16 -15
  52. data/lib/earth/automobile/automobile_make_year_fleet.rb +2 -1
  53. data/lib/earth/automobile/automobile_make_year_fleet/data_miner.rb +5 -2
  54. data/lib/earth/automobile/automobile_model.rb +2 -1
  55. data/lib/earth/automobile/automobile_model/data_miner.rb +1 -2
  56. data/lib/earth/automobile/automobile_size_class.rb +7 -68
  57. data/lib/earth/automobile/automobile_size_class/data_miner.rb +16 -51
  58. data/lib/earth/automobile/automobile_type_fuel.rb +23 -0
  59. data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +52 -0
  60. data/lib/earth/automobile/automobile_type_fuel_control.rb +2 -33
  61. data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +19 -4
  62. data/lib/earth/automobile/automobile_type_fuel_year.rb +17 -54
  63. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +40 -94
  64. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +25 -23
  65. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +6 -2
  66. data/lib/earth/automobile/automobile_year.rb +38 -1
  67. data/lib/earth/automobile/automobile_year/data_miner.rb +1 -2
  68. data/lib/earth/automobile/dependencies.txt +22 -36
  69. data/lib/earth/bus/bus_class.rb +2 -0
  70. data/lib/earth/bus/bus_fuel.rb +2 -0
  71. data/lib/earth/bus/bus_fuel_control.rb +2 -0
  72. data/lib/earth/bus/bus_fuel_year_control.rb +2 -0
  73. data/lib/earth/computation/computation_carrier.rb +2 -0
  74. data/lib/earth/computation/computation_carrier_instance_class.rb +2 -0
  75. data/lib/earth/computation/computation_carrier_region.rb +2 -0
  76. data/lib/earth/conversions_ext.rb +6 -0
  77. data/lib/earth/diet/diet_class.rb +2 -0
  78. data/lib/earth/diet/food_group.rb +2 -0
  79. data/lib/earth/fuel/fuel.rb +2 -0
  80. data/lib/earth/fuel/fuel/data_miner.rb +15 -0
  81. data/lib/earth/fuel/fuel_price.rb +2 -0
  82. data/lib/earth/fuel/fuel_type.rb +2 -0
  83. data/lib/earth/fuel/fuel_year.rb +2 -0
  84. data/lib/earth/fuel/greenhouse_gas.rb +2 -0
  85. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +7 -7
  86. data/lib/earth/hospitality/lodging_class.rb +2 -0
  87. data/lib/earth/industry/industry.rb +2 -0
  88. data/lib/earth/industry/mecs_energy/data_miner.rb +1 -1
  89. data/lib/earth/industry/mecs_ratio/data_miner.rb +1 -1
  90. data/lib/earth/locality/census_division.rb +2 -0
  91. data/lib/earth/locality/census_region.rb +2 -0
  92. data/lib/earth/locality/climate_division.rb +2 -0
  93. data/lib/earth/locality/country.rb +4 -0
  94. data/lib/earth/locality/egrid_region.rb +3 -0
  95. data/lib/earth/locality/egrid_subregion.rb +2 -0
  96. data/lib/earth/locality/petroleum_administration_for_defense_district.rb +7 -0
  97. data/lib/earth/locality/state.rb +7 -0
  98. data/lib/earth/locality/zip_code.rb +4 -0
  99. data/lib/earth/pet/breed.rb +7 -0
  100. data/lib/earth/pet/breed/data_miner.rb +1 -1
  101. data/lib/earth/pet/breed_gender.rb +2 -0
  102. data/lib/earth/pet/gender.rb +2 -0
  103. data/lib/earth/pet/species.rb +2 -0
  104. data/lib/earth/rail/country_rail_class.rb +2 -0
  105. data/lib/earth/rail/country_rail_traction.rb +2 -0
  106. data/lib/earth/rail/country_rail_traction_class.rb +2 -0
  107. data/lib/earth/rail/national_transit_database_company.rb +7 -0
  108. data/lib/earth/rail/national_transit_database_mode.rb +2 -0
  109. data/lib/earth/rail/national_transit_database_record.rb +22 -0
  110. data/lib/earth/rail/rail_class.rb +2 -0
  111. data/lib/earth/rail/rail_company.rb +16 -0
  112. data/lib/earth/rail/rail_fuel.rb +2 -0
  113. data/lib/earth/rail/rail_traction.rb +2 -0
  114. data/lib/earth/residence/air_conditioner_use.rb +2 -0
  115. data/lib/earth/residence/clothes_machine_use.rb +2 -0
  116. data/lib/earth/residence/dishwasher_use.rb +2 -0
  117. data/lib/earth/residence/residence_appliance.rb +2 -0
  118. data/lib/earth/residence/residence_class.rb +2 -0
  119. data/lib/earth/residence/residence_fuel_price.rb +2 -0
  120. data/lib/earth/residence/residence_fuel_type.rb +2 -0
  121. data/lib/earth/residence/residential_energy_consumption_survey_response.rb +2 -0
  122. data/lib/earth/residence/urbanity.rb +2 -0
  123. data/lib/earth/shipping/carrier.rb +2 -0
  124. data/lib/earth/shipping/carrier_mode.rb +2 -0
  125. data/lib/earth/shipping/shipment_mode.rb +2 -0
  126. data/lib/earth/version.rb +1 -1
  127. data/spec/earth/air/airline_spec.rb +20 -0
  128. data/spec/earth/air/flight_segment_spec.rb +9 -4
  129. data/spec/earth/automobile/automobile_activity_year_spec.rb +30 -0
  130. data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +25 -0
  131. data/spec/earth/automobile/automobile_activity_year_type_spec.rb +38 -0
  132. data/spec/earth/automobile/automobile_fuel_spec.rb +91 -6
  133. data/spec/earth/automobile/automobile_make_model_spec.rb +74 -0
  134. data/spec/earth/automobile/automobile_make_model_year_spec.rb +90 -0
  135. data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +139 -90
  136. data/spec/earth/automobile/automobile_make_spec.rb +27 -0
  137. data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +8 -21
  138. data/spec/earth/automobile/automobile_make_year_spec.rb +28 -0
  139. data/spec/earth/automobile/automobile_model_spec.rb +15 -0
  140. data/spec/earth/automobile/automobile_size_class_spec.rb +31 -0
  141. data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +25 -0
  142. data/spec/earth/automobile/automobile_type_fuel_spec.rb +45 -0
  143. data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +51 -0
  144. data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +65 -0
  145. data/spec/earth/automobile/automobile_year_spec.rb +23 -0
  146. data/spec/earth/fuel/fuel_spec.rb +1 -1
  147. data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +11 -3
  148. data/spec/earth_spec.rb +3 -3
  149. data/spec/spec_helper.rb +1 -0
  150. metadata +78 -25
  151. data/lib/earth/automobile/automobile_size_class_year.rb +0 -44
  152. data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -18
  153. data/lib/earth/automobile/automobile_type_fuel_year_age.rb +0 -68
  154. data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +0 -116
  155. data/lib/earth/automobile/automobile_type_year.rb +0 -58
  156. data/lib/earth/automobile/automobile_type_year/data_miner.rb +0 -30
  157. 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
- # %w{ type_name fuel_common_name control_name type_fuel_control_name type_fuel_year_name }.each do |attribute|
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 => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGpQV2xMdlZkV1JzVlVTeU5ZalF6elE&hl=en&gid=0&output=csv' do
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 automobile make model year variants" do
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
- MakeYearFleet
5
- MakeModelYearVariant
17
+ MakeYear
18
+ MakeModelYearVariant
19
+ MakeYearFleet
6
20
 
7
21
  Model
8
- MakeYearFleet
9
- MakeModelYearVariant
22
+ MakeModelYearVariant
10
23
 
11
24
  Year
12
- MakeYearFleet
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
- TypeYear
39
- TypeFuelYear
40
- TypeFuelControl
41
- TypeFuelYearControl
42
- TypeFuelYearAge
43
- TypeFuelYear
44
- TypeFuelControl
45
- TypeFuelYearControl
28
+
29
+ ActivityYear
30
+ ActivityYearType
31
+ ActivityYearTypeFuel
@@ -51,4 +51,6 @@ class BusClass < ActiveRecord::Base
51
51
  col :electricity_intensity_units
52
52
  col :air_conditioning_emission_factor, :type => :float
53
53
  col :air_conditioning_emission_factor_units
54
+
55
+ warn_unless_size 2
54
56
  end
@@ -91,4 +91,6 @@ class BusFuel < ActiveRecord::Base
91
91
  # end
92
92
  # end
93
93
  # end
94
+
95
+ warn_unless_size 7
94
96
  end
@@ -8,4 +8,6 @@ class BusFuelControl < ActiveRecord::Base
8
8
  col :ch4_emission_factor_units
9
9
  col :n2o_emission_factor, :type => :float
10
10
  col :n2o_emission_factor_units
11
+
12
+ warn_unless_size 9
11
13
  end
@@ -10,4 +10,6 @@ class BusFuelYearControl < ActiveRecord::Base
10
10
  col :control
11
11
  col :bus_fuel_control_name
12
12
  col :total_travel_percent, :type => :float
13
+
14
+ warn_unless_size 67
13
15
  end
@@ -15,4 +15,6 @@ class ComputationCarrier < ActiveRecord::Base
15
15
  # end
16
16
  # end
17
17
  # end
18
+
19
+ warn_unless_size 1
18
20
  end
@@ -32,4 +32,6 @@ class ComputationCarrierInstanceClass < ActiveRecord::Base
32
32
  # end
33
33
  # end
34
34
 
35
+
36
+ warn_unless_size 8
35
37
  end
@@ -8,4 +8,6 @@ class ComputationCarrierRegion < ActiveRecord::Base
8
8
  col :computation_carrier_name
9
9
  col :region
10
10
  col :egrid_subregion_abbreviation
11
+
12
+ warn_unless_size 4
11
13
  end
@@ -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))
@@ -20,4 +20,6 @@ class DietClass < ActiveRecord::Base
20
20
  col :fruit_share, :type => :float
21
21
  col :vegetables_share, :type => :float
22
22
  col :oils_and_sugars_share, :type => :float
23
+
24
+ warn_unless_size 3
23
25
  end
@@ -17,4 +17,6 @@ class FoodGroup < ActiveRecord::Base
17
17
  col :energy, :type => :float
18
18
  col :energy_units
19
19
  col :suggested_imperial_measurement # ?
20
+
21
+ warn_unless_size 10
20
22
  end
@@ -109,4 +109,6 @@ class Fuel < ActiveRecord::Base
109
109
  latest_fuel_year.co2_biogenic_emission_factor_units
110
110
  end
111
111
  end
112
+
113
+ warn_unless_size 21
112
114
  end
@@ -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'
@@ -6,4 +6,6 @@ class FuelPrice < ActiveRecord::Base
6
6
  col :name
7
7
  col :price, :type => :float
8
8
  col :price_units
9
+
10
+ warn_unless_size 34
9
11
  end
@@ -24,4 +24,6 @@ class FuelType < ActiveRecord::Base
24
24
  # col :energy_content_units
25
25
  # col :carbon_content, :type => :float
26
26
  # col :carbon_content_units
27
+
28
+ warn_unless_size 36
27
29
  end
@@ -59,4 +59,6 @@ class FuelYear < ActiveRecord::Base
59
59
  # end
60
60
  #
61
61
  # FIXME TODO verify units
62
+
63
+ warn_unless_size 171
62
64
  end
@@ -52,4 +52,6 @@ class GreenhouseGas < ActiveRecord::Base
52
52
  # end
53
53
  # end
54
54
 
55
+
56
+ warn_unless_size 4
55
57
  end
@@ -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', :field_name => 'ELBTU8', :from_units => :kbtus, :to_units => :megajoules
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', :field_name => 'NGCNS8', :from_units => :hundred_cubic_feet, :to_units => :cubic_metres
63
- store 'natural_gas_energy', :field_name => 'NGBTU8', :from_units => :kbtus, :to_units => :megajoules
64
- store 'fuel_oil_use', :field_name => 'FKCNS8', :from_units => :gallons, :to_units => :litres
65
- store 'fuel_oil_energy', :field_name => 'FKBTU8', :from_units => :kbtus, :to_units => :megajoules
66
- store 'district_heat_use', :field_name => 'DHBTU8', :from_units => :kbtus, :to_units => :megajoules
67
- store 'district_heat_energy', :field_name => 'DHBTU8', :from_units => :kbtus, :to_units => :megajoules
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
@@ -3,4 +3,6 @@ class LodgingClass < ActiveRecord::Base
3
3
  self.primary_key = "name"
4
4
 
5
5
  col :name
6
+
7
+ warn_unless_size 3
6
8
  end
@@ -25,4 +25,6 @@ class Industry < ActiveRecord::Base
25
25
  prefix = naics_code.to_s[0,2]
26
26
  %w{42 44 45}.include?(prefix)
27
27
  end
28
+
29
+ warn_unless_size 2341
28
30
  end
@@ -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://205.254.135.24/emeu/mecs/mecs2006/excel/Table3_2.xls",
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://205.254.135.24/emeu/mecs/mecs2006/excel/Table6_1.xls",
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]}" }
@@ -26,4 +26,6 @@ class CensusDivision < ActiveRecord::Base
26
26
  col :meeting_building_electricity_intensity_units
27
27
  col :meeting_building_district_heat_intensity, :type => :float
28
28
  col :meeting_building_district_heat_intensity_units
29
+
30
+ warn_unless_size 9
29
31
  end