earth 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/TODO +2 -0
- data/bin/earth_tester.rb +62 -9
- data/earth.gemspec +7 -4
- data/lib/earth.rb +18 -17
- data/lib/earth/air.rb +2 -0
- data/lib/earth/air/aircraft.rb +76 -19
- data/lib/earth/air/aircraft/data_miner.rb +1 -63
- data/lib/earth/air/aircraft_class.rb +48 -12
- data/lib/earth/air/aircraft_class/data_miner.rb +3 -46
- data/lib/earth/air/aircraft_fuel_use_equation.rb +11 -13
- data/lib/earth/air/aircraft_instance.rb +9 -0
- data/lib/earth/air/aircraft_instance_seat_class.rb +12 -0
- data/lib/earth/air/airline.rb +6 -8
- data/lib/earth/air/airline/data_miner.rb +3 -3
- data/lib/earth/air/airport.rb +8 -10
- data/lib/earth/air/airport/data_miner.rb +1 -1
- data/lib/earth/air/bts_aircraft.rb +3 -5
- data/lib/earth/air/flight_distance_class.rb +4 -6
- data/lib/earth/air/flight_seat_class.rb +5 -7
- data/lib/earth/air/flight_segment.rb +58 -42
- data/lib/earth/air/flight_segment/data_miner.rb +11 -26
- data/lib/earth/automobile.rb +1 -0
- data/lib/earth/automobile/automobile_fuel.rb +78 -25
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +5 -72
- data/lib/earth/automobile/automobile_make.rb +14 -6
- data/lib/earth/automobile/automobile_make/data_miner.rb +20 -35
- data/lib/earth/automobile/automobile_make_fleet_year.rb +39 -10
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +0 -29
- data/lib/earth/automobile/automobile_make_model.rb +30 -9
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +11 -26
- data/lib/earth/automobile/automobile_make_model_year.rb +41 -12
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +14 -34
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +56 -38
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +15 -61
- data/lib/earth/automobile/automobile_make_year.rb +15 -8
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +17 -51
- data/lib/earth/automobile/automobile_size_class.rb +78 -14
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +0 -66
- data/lib/earth/automobile/automobile_size_class_year.rb +38 -10
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -30
- data/lib/earth/automobile/automobile_type_fuel_age.rb +60 -11
- data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +10 -65
- data/lib/earth/automobile/automobile_type_fuel_control.rb +41 -10
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +0 -33
- data/lib/earth/automobile/automobile_type_fuel_year.rb +60 -15
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -52
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +64 -12
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +1 -59
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +31 -10
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +2 -32
- data/lib/earth/automobile/automobile_type_year.rb +51 -10
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -43
- data/lib/earth/automobile/data_miner.rb +1 -0
- data/lib/earth/bus/bus_class.rb +108 -28
- data/lib/earth/bus/bus_class/data_miner.rb +0 -88
- data/lib/earth/bus/bus_fuel.rb +83 -15
- data/lib/earth/bus/bus_fuel/data_miner.rb +0 -76
- data/lib/earth/bus/bus_fuel_control.rb +8 -10
- data/lib/earth/bus/bus_fuel_year_control.rb +7 -9
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -5
- data/lib/earth/computation/computation_carrier.rb +11 -5
- data/lib/earth/computation/computation_carrier/data_miner.rb +0 -7
- data/lib/earth/computation/computation_carrier_instance_class.rb +25 -8
- data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +0 -18
- data/lib/earth/computation/computation_carrier_region.rb +5 -7
- data/lib/earth/diet/diet_class.rb +14 -16
- data/lib/earth/diet/food_group.rb +7 -9
- data/lib/earth/fuel/fuel.rb +14 -16
- data/lib/earth/fuel/fuel/data_miner.rb +7 -3
- data/lib/earth/fuel/fuel_price.rb +4 -6
- data/lib/earth/fuel/fuel_type.rb +12 -14
- data/lib/earth/fuel/fuel_year.rb +57 -16
- data/lib/earth/fuel/fuel_year/data_miner.rb +0 -43
- data/lib/earth/fuel/greenhouse_gas.rb +46 -9
- data/lib/earth/fuel/greenhouse_gas/data_miner.rb +0 -38
- data/lib/earth/hospitality/lodging_class.rb +10 -12
- data/lib/earth/industry/industry.rb +3 -5
- data/lib/earth/industry/industry_product.rb +6 -8
- data/lib/earth/industry/industry_product_line.rb +5 -7
- data/lib/earth/industry/industry_sector.rb +5 -7
- data/lib/earth/industry/merchant.rb +4 -6
- data/lib/earth/industry/merchant_category.rb +3 -5
- data/lib/earth/industry/merchant_category_industry.rb +5 -7
- data/lib/earth/industry/product_line.rb +5 -7
- data/lib/earth/industry/product_line_industry_product.rb +5 -7
- data/lib/earth/industry/sector.rb +5 -7
- data/lib/earth/locality/census_division.rb +21 -23
- data/lib/earth/locality/census_region.rb +3 -5
- data/lib/earth/locality/climate_division.rb +5 -7
- data/lib/earth/locality/country.rb +13 -15
- data/lib/earth/locality/egrid_region.rb +14 -5
- data/lib/earth/locality/egrid_region/data_miner.rb +0 -10
- data/lib/earth/locality/egrid_subregion.rb +71 -18
- data/lib/earth/locality/egrid_subregion/data_miner.rb +0 -59
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +6 -8
- data/lib/earth/locality/state.rb +6 -8
- data/lib/earth/locality/urbanity.rb +2 -4
- data/lib/earth/locality/urbanity/data_miner.rb +7 -3
- data/lib/earth/locality/zip_code.rb +8 -10
- data/lib/earth/pet/breed.rb +5 -7
- data/lib/earth/pet/breed_gender.rb +6 -8
- data/lib/earth/pet/gender.rb +2 -4
- data/lib/earth/pet/species.rb +15 -17
- data/lib/earth/rail/rail_class.rb +64 -14
- data/lib/earth/rail/rail_class/data_miner.rb +0 -51
- data/lib/earth/residence/air_conditioner_use.rb +4 -6
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +7 -3
- data/lib/earth/residence/clothes_machine_use.rb +4 -6
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +11 -9
- data/lib/earth/residence/dishwasher_use.rb +4 -6
- data/lib/earth/residence/dishwasher_use/data_miner.rb +11 -9
- data/lib/earth/residence/residence_appliance.rb +4 -6
- data/lib/earth/residence/residence_class.rb +2 -4
- data/lib/earth/residence/residence_class/data_miner.rb +7 -3
- data/lib/earth/residence/residence_fuel_price.rb +12 -14
- data/lib/earth/residence/residence_fuel_price/data_miner.rb +7 -0
- data/lib/earth/residence/residence_fuel_type.rb +6 -8
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +91 -93
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +9 -8
- data/lib/earth/shipping/carrier.rb +57 -10
- data/lib/earth/shipping/carrier/data_miner.rb +0 -48
- data/lib/earth/shipping/carrier_mode.rb +41 -10
- data/lib/earth/shipping/carrier_mode/data_miner.rb +0 -33
- data/lib/earth/shipping/shipment_mode.rb +30 -7
- data/lib/earth/shipping/shipment_mode/data_miner.rb +0 -23
- data/lib/earth/utils.rb +45 -0
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/aircraft_spec.rb +1 -1
- data/vendor/clean_find_in_batches/init.rb +35 -0
- metadata +74 -47
@@ -4,10 +4,8 @@ class MerchantCategoryIndustry < ActiveRecord::Base
|
|
4
4
|
belongs_to :merchant_category, :foreign_key => 'mcc'
|
5
5
|
belongs_to :industry, :foreign_key => 'naics_code'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
7
|
+
col :row_hash
|
8
|
+
col :mcc
|
9
|
+
col :ratio, :type => :float
|
10
|
+
col :naics_code
|
11
|
+
end
|
@@ -6,10 +6,8 @@ class ProductLine < ActiveRecord::Base
|
|
6
6
|
has_many :product_line_industry_products, :foreign_key => 'ps_code'
|
7
7
|
has_many :industry_products, :through => :product_line_industry_products
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
9
|
+
col :ps_code
|
10
|
+
col :description
|
11
|
+
col :broadline # FIXME TODO do we need this?
|
12
|
+
col :parent # FIXME TODO do we need this?
|
13
|
+
end
|
@@ -4,10 +4,8 @@ class ProductLineIndustryProduct < ActiveRecord::Base
|
|
4
4
|
belongs_to :product_line, :foreign_key => 'ps_code'
|
5
5
|
belongs_to :industry_product, :foreign_key => 'naics_product_code'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
7
|
+
col :row_hash
|
8
|
+
col :ps_code
|
9
|
+
col :ratio, :type => :float
|
10
|
+
col :naics_product_code
|
11
|
+
end
|
@@ -3,10 +3,8 @@ class Sector < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
has_many :industry_sectors, :foreign_key => 'io_code'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
6
|
+
col :io_code
|
7
|
+
col :description
|
8
|
+
col :value, :type => :float
|
9
|
+
col :value_units
|
10
|
+
end
|
@@ -13,26 +13,24 @@ class CensusDivision < ActiveRecord::Base
|
|
13
13
|
:meeting_building_electricity_intensity => 0.0084323684 / 1.square_feet.to(:square_metres),
|
14
14
|
:meeting_building_district_heat_intensity => 0.0004776370.kbtus.to(:megajoules) / 1.square_feet.to(:square_metres)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
16
|
+
col :number, :type => :integer
|
17
|
+
col :name
|
18
|
+
col :census_region_name
|
19
|
+
col :census_region_number, :type => :integer
|
20
|
+
col :meeting_building_natural_gas_intensity, :type => :float
|
21
|
+
col :meeting_building_natural_gas_intensity_units
|
22
|
+
col :meeting_building_fuel_oil_intensity, :type => :float
|
23
|
+
col :meeting_building_fuel_oil_intensity_units
|
24
|
+
col :meeting_building_electricity_intensity, :type => :float
|
25
|
+
col :meeting_building_electricity_intensity_units
|
26
|
+
col :meeting_building_district_heat_intensity, :type => :float
|
27
|
+
col :meeting_building_district_heat_intensity_units
|
28
|
+
col :lodging_building_natural_gas_intensity, :type => :float
|
29
|
+
col :lodging_building_natural_gas_intensity_units
|
30
|
+
col :lodging_building_fuel_oil_intensity, :type => :float
|
31
|
+
col :lodging_building_fuel_oil_intensity_units
|
32
|
+
col :lodging_building_electricity_intensity, :type => :float
|
33
|
+
col :lodging_building_electricity_intensity_units
|
34
|
+
col :lodging_building_district_heat_intensity, :type => :float
|
35
|
+
col :lodging_building_district_heat_intensity_units
|
36
|
+
end
|
@@ -7,8 +7,6 @@ class CensusRegion < ActiveRecord::Base
|
|
7
7
|
# has_many :zip_codes, :through => :census_divisions
|
8
8
|
has_many :residential_energy_consumption_survey_responses, :foreign_key => 'census_region_number'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
10
|
+
col :number, :type => :integer
|
11
|
+
col :name
|
12
|
+
end
|
@@ -6,10 +6,8 @@ class ClimateDivision < ActiveRecord::Base
|
|
6
6
|
|
7
7
|
RADIUS = 750
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
9
|
+
col :name
|
10
|
+
col :heating_degree_days, :type => :float
|
11
|
+
col :cooling_degree_days, :type => :float
|
12
|
+
col :state_postal_abbreviation
|
13
|
+
end
|
@@ -19,18 +19,16 @@ class Country < ActiveRecord::Base
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
22
|
+
col :iso_3166_code
|
23
|
+
col :name
|
24
|
+
col :automobile_urbanity, :type => :float
|
25
|
+
col :automobile_fuel_efficiency, :type => :float
|
26
|
+
col :automobile_fuel_efficiency_units
|
27
|
+
col :automobile_city_speed, :type => :float
|
28
|
+
col :automobile_city_speed_units
|
29
|
+
col :automobile_highway_speed, :type => :float
|
30
|
+
col :automobile_highway_speed_units
|
31
|
+
col :automobile_trip_distance, :type => :float
|
32
|
+
col :automobile_trip_distance_units
|
33
|
+
col :flight_route_inefficiency_factor, :type => :float
|
34
|
+
end
|
@@ -7,8 +7,17 @@ class EgridRegion < ActiveRecord::Base
|
|
7
7
|
falls_back_on :name => 'fallback',
|
8
8
|
:loss_factor => 0.061879 # calculated using above formula 2/21/2011
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
col :name
|
11
|
+
col :loss_factor, :type => :float
|
12
|
+
|
13
|
+
# verify "Loss factor should be greater than zero and less than one" do
|
14
|
+
# EgridRegion.all.each do |region|
|
15
|
+
# unless region.loss_factor > 0 and region.loss_factor < 1
|
16
|
+
# raise "Invalid loss factor for EgridRegion #{region.name}: #{region.loss_factor} (should be > 0 and < 1)"
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# FIXME TODO verify fallback loss factor
|
22
|
+
|
23
|
+
end
|
@@ -19,15 +19,5 @@ EgridRegion.class_eval do
|
|
19
19
|
key 'name', :static => 'US'
|
20
20
|
store 'loss_factor', :synthesize => lambda { |row| (row['USTNGN05'].to_f + row['USTNFI05'].to_f - row['USTCON05'].to_f) / row['USTNGN05'].to_f }
|
21
21
|
end
|
22
|
-
|
23
|
-
verify "Loss factor should be greater than zero and less than one" do
|
24
|
-
EgridRegion.all.each do |region|
|
25
|
-
unless region.loss_factor > 0 and region.loss_factor < 1
|
26
|
-
raise "Invalid loss factor for EgridRegion #{region.name}: #{region.loss_factor} (should be > 0 and < 1)"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# FIXME TODO verify fallback loss factor
|
32
22
|
end
|
33
23
|
end
|
@@ -23,22 +23,75 @@ class EgridSubregion < ActiveRecord::Base
|
|
23
23
|
:electricity_emission_factor => lambda { weighted_average(:electricity_emission_factor, :weighted_by => :net_generation) }, # DEPRECATED
|
24
24
|
:electricity_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour' # DEPRECATED
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
26
|
+
col :abbreviation
|
27
|
+
col :name
|
28
|
+
col :nerc_abbreviation
|
29
|
+
col :egrid_region_name
|
30
|
+
col :net_generation, :type => :float
|
31
|
+
col :net_generation_units
|
32
|
+
col :electricity_co2_emission_factor, :type => :float
|
33
|
+
col :electricity_co2_emission_factor_units
|
34
|
+
col :electricity_co2_biogenic_emission_factor, :type => :float
|
35
|
+
col :electricity_co2_biogenic_emission_factor_units
|
36
|
+
col :electricity_ch4_emission_factor, :type => :float
|
37
|
+
col :electricity_ch4_emission_factor_units
|
38
|
+
col :electricity_n2o_emission_factor, :type => :float
|
39
|
+
col :electricity_n2o_emission_factor_units
|
40
|
+
col :electricity_emission_factor, :type => :float
|
41
|
+
col :electricity_emission_factor_units
|
42
|
+
|
43
|
+
# FIXME TODO verify egrid_region_name is found in EgridRegions
|
44
|
+
# %w{ egrid_region_name }.each do |attribute|
|
45
|
+
# verify "#{attribute.humanize} should never be missing" do
|
46
|
+
# EgridSubregion.all.each do |subregion|
|
47
|
+
# unless subregion.send("#{attribute}").present?
|
48
|
+
# raise "Missing #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}"
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# ["net_generation",
|
55
|
+
# "electricity_co2_emission_factor",
|
56
|
+
# "electricity_ch4_emission_factor",
|
57
|
+
# "electricity_n2o_emission_factor",
|
58
|
+
# "electricity_emission_factor" ].each do |attribute|
|
59
|
+
# verify "#{attribute.humanize} should be > 0" do
|
60
|
+
# EgridSubregion.all.each do |subregion|
|
61
|
+
# value = subregion.send(:"#{attribute}")
|
62
|
+
# unless value > 0
|
63
|
+
# raise "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{value} (should be > 0)"
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# verify "Electricity co2 biogenic emission factor should be 0" do
|
70
|
+
# EgridSubregion.all.each do |subregion|
|
71
|
+
# value = subregion.electricity_co2_biogenic_emission_factor
|
72
|
+
# unless value == 0
|
73
|
+
# raise "Invalid electricity co2 biogenic emission factor for EgridSubregion #{subregion.name}: #{value} (should be 0)"
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# [["net_generation_units","megawatt_hours"],
|
79
|
+
# ["electricity_co2_emission_factor_units","kilograms_per_kilowatt_hour"],
|
80
|
+
# ["electricity_co2_biogenic_emission_factor_units","kilograms_per_kilowatt_hour"],
|
81
|
+
# ["electricity_ch4_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
|
82
|
+
# ["electricity_n2o_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
|
83
|
+
# ["electricity_emission_factor_units","kilograms_co2e_per_kilowatt_hour"]].each do |pair|
|
84
|
+
# attribute = pair[0]
|
85
|
+
# proper_units = pair[1]
|
86
|
+
# verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
|
87
|
+
# EgridSubregion.all.each do |subregion|
|
88
|
+
# units = subregion.send(:"#{attribute}")
|
89
|
+
# unless units == proper_units
|
90
|
+
# raise "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{units} (should be #{proper_units})"
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
|
96
|
+
# FIXME TODO verify fallbacks
|
44
97
|
end
|
@@ -61,64 +61,5 @@ EgridSubregion.class_eval do
|
|
61
61
|
update_all %{ electricity_emission_factor = electricity_co2_emission_factor + electricity_ch4_emission_factor + electricity_n2o_emission_factor,
|
62
62
|
electricity_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour' }
|
63
63
|
end
|
64
|
-
|
65
|
-
# FIXME TODO verify egrid_region_name is found in EgridRegions
|
66
|
-
%w{ egrid_region_name }.each do |attribute|
|
67
|
-
verify "#{attribute.humanize} should never be missing" do
|
68
|
-
EgridSubregion.all.each do |subregion|
|
69
|
-
unless subregion.send("#{attribute}").present?
|
70
|
-
puts "Missing #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}"
|
71
|
-
fail
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
["net_generation",
|
78
|
-
"electricity_co2_emission_factor",
|
79
|
-
"electricity_ch4_emission_factor",
|
80
|
-
"electricity_n2o_emission_factor",
|
81
|
-
"electricity_emission_factor" ].each do |attribute|
|
82
|
-
verify "#{attribute.humanize} should be > 0" do
|
83
|
-
EgridSubregion.all.each do |subregion|
|
84
|
-
value = subregion.send(:"#{attribute}")
|
85
|
-
unless value > 0
|
86
|
-
puts "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{value} (should be > 0)"
|
87
|
-
fail
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
verify "Electricity co2 biogenic emission factor should be 0" do
|
94
|
-
EgridSubregion.all.each do |subregion|
|
95
|
-
value = subregion.electricity_co2_biogenic_emission_factor
|
96
|
-
unless value == 0
|
97
|
-
puts "Invalid electricity co2 biogenic emission factor for EgridSubregion #{subregion.name}: #{value} (should be 0)"
|
98
|
-
fail
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
[["net_generation_units","megawatt_hours"],
|
104
|
-
["electricity_co2_emission_factor_units","kilograms_per_kilowatt_hour"],
|
105
|
-
["electricity_co2_biogenic_emission_factor_units","kilograms_per_kilowatt_hour"],
|
106
|
-
["electricity_ch4_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
|
107
|
-
["electricity_n2o_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
|
108
|
-
["electricity_emission_factor_units","kilograms_co2e_per_kilowatt_hour"]].each do |pair|
|
109
|
-
attribute = pair[0]
|
110
|
-
proper_units = pair[1]
|
111
|
-
verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
|
112
|
-
EgridSubregion.all.each do |subregion|
|
113
|
-
units = subregion.send(:"#{attribute}")
|
114
|
-
unless units == proper_units
|
115
|
-
puts "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{units} (should be #{proper_units})"
|
116
|
-
fail
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# FIXME TODO verify fallbacks
|
123
64
|
end
|
124
65
|
end
|
@@ -8,11 +8,9 @@ class PetroleumAdministrationForDefenseDistrict < ActiveRecord::Base
|
|
8
8
|
str
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
11
|
+
col :code
|
12
|
+
col :district_code
|
13
|
+
col :district_name
|
14
|
+
col :subdistrict_code
|
15
|
+
col :subdistrict_name
|
16
|
+
end
|
data/lib/earth/locality/state.rb
CHANGED
@@ -11,11 +11,9 @@ class State < ActiveRecord::Base
|
|
11
11
|
Country.united_states
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
14
|
+
col :postal_abbreviation
|
15
|
+
col :fips_code, :type => :integer
|
16
|
+
col :name
|
17
|
+
col :census_division_number
|
18
|
+
col :petroleum_administration_for_defense_district_code
|
19
|
+
end
|