earth 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/LICENSE-PREAMBLE +1 -1
- data/Rakefile +3 -0
- data/earth.gemspec +1 -1
- data/lib/earth.rb +7 -7
- data/lib/earth/air/aircraft.rb +15 -0
- data/lib/earth/air/aircraft/data_miner.rb +65 -77
- data/lib/earth/air/aircraft_class.rb +1 -1
- data/lib/earth/air/aircraft_fuel_use_equation.rb +1 -1
- data/lib/earth/air/airline.rb +1 -1
- data/lib/earth/air/airport.rb +1 -1
- data/lib/earth/air/bts_aircraft.rb +1 -1
- data/lib/earth/air/flight_distance_class.rb +1 -1
- data/lib/earth/air/flight_seat_class.rb +1 -1
- data/lib/earth/air/flight_segment.rb +1 -1
- data/lib/earth/air/flight_segment/data_miner.rb +24 -46
- data/lib/earth/automobile/automobile_fuel.rb +1 -1
- data/lib/earth/automobile/automobile_make.rb +1 -1
- data/lib/earth/automobile/automobile_make_fleet_year.rb +1 -1
- data/lib/earth/automobile/automobile_make_model.rb +1 -1
- data/lib/earth/automobile/automobile_make_model_year.rb +1 -1
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +1 -1
- data/lib/earth/automobile/automobile_make_year.rb +1 -1
- data/lib/earth/automobile/automobile_size_class.rb +1 -1
- data/lib/earth/automobile/automobile_size_class_year.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_age.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_control.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_year.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_year_age.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +1 -1
- data/lib/earth/automobile/automobile_type_year.rb +1 -1
- data/lib/earth/bus/bus_class.rb +1 -1
- data/lib/earth/bus/bus_fuel.rb +1 -1
- data/lib/earth/bus/bus_fuel_control.rb +1 -1
- data/lib/earth/bus/bus_fuel_year_control.rb +1 -1
- data/lib/earth/computation/computation_carrier.rb +1 -1
- data/lib/earth/computation/computation_carrier_instance_class.rb +1 -1
- data/lib/earth/computation/computation_carrier_region.rb +1 -1
- data/lib/earth/conversions_ext.rb +1 -0
- data/lib/earth/diet/diet_class.rb +1 -1
- data/lib/earth/diet/food_group.rb +1 -1
- data/lib/earth/fuel/fuel.rb +1 -1
- data/lib/earth/fuel/fuel_price.rb +1 -1
- data/lib/earth/fuel/fuel_type.rb +1 -1
- data/lib/earth/fuel/fuel_year.rb +1 -1
- data/lib/earth/fuel/greenhouse_gas.rb +1 -1
- data/lib/earth/hospitality/lodging_class.rb +1 -1
- data/lib/earth/industry/industry.rb +1 -1
- data/lib/earth/industry/industry_product.rb +1 -1
- data/lib/earth/industry/industry_product_line.rb +1 -1
- data/lib/earth/industry/industry_sector.rb +1 -1
- data/lib/earth/industry/merchant.rb +1 -1
- data/lib/earth/industry/merchant_category.rb +1 -1
- data/lib/earth/industry/merchant_category_industry.rb +1 -1
- data/lib/earth/industry/product_line.rb +1 -1
- data/lib/earth/industry/product_line_industry_product.rb +1 -1
- data/lib/earth/industry/sector.rb +1 -1
- data/lib/earth/locality/census_division.rb +1 -1
- data/lib/earth/locality/census_region.rb +1 -1
- data/lib/earth/locality/climate_division.rb +1 -1
- data/lib/earth/locality/country.rb +1 -1
- data/lib/earth/locality/egrid_region.rb +1 -1
- data/lib/earth/locality/egrid_region/data_miner.rb +10 -0
- data/lib/earth/locality/egrid_subregion.rb +1 -1
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +1 -1
- data/lib/earth/locality/state.rb +1 -1
- data/lib/earth/locality/urbanity.rb +1 -1
- data/lib/earth/locality/zip_code.rb +1 -1
- data/lib/earth/pet/breed.rb +1 -1
- data/lib/earth/pet/breed_gender.rb +1 -1
- data/lib/earth/pet/gender.rb +1 -1
- data/lib/earth/pet/species.rb +1 -1
- data/lib/earth/rail/rail_class.rb +1 -1
- data/lib/earth/residence/air_conditioner_use.rb +1 -1
- data/lib/earth/residence/clothes_machine_use.rb +1 -1
- data/lib/earth/residence/dishwasher_use.rb +1 -1
- data/lib/earth/residence/residence_appliance.rb +1 -1
- data/lib/earth/residence/residence_class.rb +1 -1
- data/lib/earth/residence/residence_fuel_price.rb +1 -1
- data/lib/earth/residence/residence_fuel_type.rb +1 -1
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +1 -1
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +9 -9
- data/lib/earth/shipping/carrier.rb +1 -1
- data/lib/earth/shipping/carrier_mode.rb +1 -1
- data/lib/earth/shipping/shipment_mode.rb +1 -1
- data/lib/earth/version.rb +1 -1
- data/spec/earth/air/aircraft_spec.rb +1 -1
- metadata +42 -44
@@ -6,7 +6,7 @@ class AutomobileMake < ActiveRecord::Base
|
|
6
6
|
has_many :fleet_years, :class_name => 'AutomobileMakeFleetYear', :foreign_key => 'make_name'
|
7
7
|
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_name'
|
8
8
|
|
9
|
-
|
9
|
+
force_schema do
|
10
10
|
string 'name'
|
11
11
|
float 'fuel_efficiency'
|
12
12
|
string 'fuel_efficiency_units'
|
@@ -4,7 +4,7 @@ class AutomobileMakeFleetYear < ActiveRecord::Base
|
|
4
4
|
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
5
|
belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
6
6
|
|
7
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'name'
|
9
9
|
string 'make_year_name'
|
10
10
|
string 'make_name'
|
@@ -4,7 +4,7 @@ class AutomobileMakeModel < ActiveRecord::Base
|
|
4
4
|
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
5
|
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_name'
|
6
6
|
|
7
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'name' # make + model
|
9
9
|
string 'make_name'
|
10
10
|
string 'model_name' # model only
|
@@ -4,7 +4,7 @@ class AutomobileMakeModelYear < ActiveRecord::Base
|
|
4
4
|
belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
5
5
|
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_year_name'
|
6
6
|
|
7
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'name' # make + model + year
|
9
9
|
string 'make_name'
|
10
10
|
string 'model_name'
|
@@ -6,7 +6,7 @@ class AutomobileMakeModelYearVariant < ActiveRecord::Base
|
|
6
6
|
belongs_to :make_model_year, :class_name => 'AutomobileMakeModelYear', :foreign_key => 'make_model_year_name'
|
7
7
|
belongs_to :fuel, :class_name => 'AutomobileFuel', :foreign_key => 'fuel_code', :primary_key => 'code'
|
8
8
|
|
9
|
-
|
9
|
+
force_schema do
|
10
10
|
string 'row_hash'
|
11
11
|
string 'name' # short name!
|
12
12
|
string 'make_name'
|
@@ -4,7 +4,7 @@ class AutomobileMakeYear < ActiveRecord::Base
|
|
4
4
|
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
5
|
has_many :fleet_years, :class_name => 'AutomobileMakeFleetYear', :foreign_key => 'make_year_name'
|
6
6
|
|
7
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'name'
|
9
9
|
string 'make_name'
|
10
10
|
integer 'year'
|
@@ -6,7 +6,7 @@ class AutomobileSizeClass < ActiveRecord::Base
|
|
6
6
|
:conventional_fuel_efficiency_city_multiplier => 0.987,
|
7
7
|
:conventional_fuel_efficiency_highway_multiplier => 0.996
|
8
8
|
|
9
|
-
|
9
|
+
force_schema do
|
10
10
|
string 'name'
|
11
11
|
string 'type_name'
|
12
12
|
float 'annual_distance'
|
@@ -4,7 +4,7 @@ class AutomobileTypeFuelYear < ActiveRecord::Base
|
|
4
4
|
has_many :year_controls, :class_name => 'AutomobileTypeFuelYearControl', :foreign_key => 'type_fuel_year_name'
|
5
5
|
belongs_to :type_year, :class_name => 'AutomobileTypeYear', :foreign_key => 'type_year_name'
|
6
6
|
|
7
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'name'
|
9
9
|
string 'type_name'
|
10
10
|
string 'fuel_common_name'
|
@@ -3,7 +3,7 @@ class AutomobileTypeFuelYearControl < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
belongs_to :control, :class_name => 'AutomobileTypeFuelControl', :foreign_key => 'type_fuel_control_name'
|
5
5
|
|
6
|
-
|
6
|
+
force_schema do
|
7
7
|
string 'name'
|
8
8
|
string 'type_name'
|
9
9
|
string 'fuel_common_name'
|
data/lib/earth/bus/bus_class.rb
CHANGED
@@ -28,7 +28,7 @@ class BusClass < ActiveRecord::Base
|
|
28
28
|
:alternative_fuels_intensity => 0.04632038.gallons_per_mile.to(:litres_per_kilometre), # deprecated
|
29
29
|
:alternative_fuels_intensity_units => 'litres_per_kilometre' # deprecated
|
30
30
|
|
31
|
-
|
31
|
+
force_schema do
|
32
32
|
string 'name'
|
33
33
|
float 'distance'
|
34
34
|
string 'distance_units'
|
data/lib/earth/bus/bus_fuel.rb
CHANGED
@@ -4,7 +4,7 @@ class ComputationCarrier < ActiveRecord::Base
|
|
4
4
|
falls_back_on :name => 'fallback',
|
5
5
|
:power_usage_effectiveness => lambda { ComputationCarrier.maximum('power_usage_effectiveness') }
|
6
6
|
|
7
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'name'
|
9
9
|
float 'power_usage_effectiveness'
|
10
10
|
end
|
@@ -7,7 +7,7 @@ class ComputationCarrierInstanceClass < ActiveRecord::Base
|
|
7
7
|
:electricity_intensity => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity },
|
8
8
|
:electricity_intensity_units => lambda { ComputationCarrierInstanceClass.find_by_name('Amazon m1.small').electricity_intensity_units }
|
9
9
|
|
10
|
-
|
10
|
+
force_schema do
|
11
11
|
string 'name'
|
12
12
|
string 'computation_carrier_name'
|
13
13
|
string 'instance_class'
|
@@ -25,6 +25,7 @@ Conversions.register(:joules, :litres_of_fuel_oil, 1.0 / (138_690.0 * 3.78541178
|
|
25
25
|
Conversions.register(:joules, :kilograms_of_coal, 1.0 / (22_342_000.0 * 0.00110231131 * 1_055.05585)) # should only be used for RECS 2005
|
26
26
|
|
27
27
|
Conversions.register(:kilograms, :lbs, 2.20462262)
|
28
|
+
Conversions.register(:metric_tonnes, :kilograms, 1_000.0)
|
28
29
|
Conversions.register(:kbtus, :btus, 1_000.0)
|
29
30
|
Conversions.register(:square_feet, :square_metres, 0.09290304)
|
30
31
|
Conversions.register(:pounds_per_square_foot, :kilograms_per_square_metre, 4.88242764)
|
data/lib/earth/fuel/fuel.rb
CHANGED
data/lib/earth/fuel/fuel_type.rb
CHANGED
data/lib/earth/fuel/fuel_year.rb
CHANGED
@@ -6,7 +6,7 @@ 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
|
-
|
9
|
+
force_schema do
|
10
10
|
string 'ps_code'
|
11
11
|
string 'description'
|
12
12
|
string 'broadline' # FIXME TODO do we need this?
|
@@ -4,7 +4,7 @@ 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
|
-
|
7
|
+
force_schema do
|
8
8
|
string 'row_hash'
|
9
9
|
string 'ps_code'
|
10
10
|
float 'ratio'
|
@@ -13,7 +13,7 @@ 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
|
-
|
16
|
+
force_schema do
|
17
17
|
integer 'number'
|
18
18
|
string 'name'
|
19
19
|
string 'census_region_name'
|
@@ -7,7 +7,7 @@ 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
|
-
|
10
|
+
force_schema do
|
11
11
|
integer 'number'
|
12
12
|
string 'name'
|
13
13
|
end
|
@@ -10,6 +10,16 @@ EgridRegion.class_eval do
|
|
10
10
|
store 'loss_factor', :field_name => '2005 grid gross loss factor'
|
11
11
|
end
|
12
12
|
|
13
|
+
# resurrected from a7bb363f10d951957dd051ff3cfb81c280f61151
|
14
|
+
import "the US average grid loss factor derived eGRID 2007 data",
|
15
|
+
:url => 'http://www.epa.gov/cleanenergy/documents/egridzips/eGRID2007_Version1-1.zip',
|
16
|
+
:filename => 'eGRID2007_Version1-1/eGRID2007V1_1_year0504_STIE_USGC.xls',
|
17
|
+
:sheet => 'USGC',
|
18
|
+
:skip => 5 do
|
19
|
+
key 'name', :static => 'US'
|
20
|
+
store 'loss_factor', :synthesize => lambda { |row| (row['USTNGN05'].to_f + row['USTNFI05'].to_f - row['USTCON05'].to_f) / row['USTNGN05'].to_f }
|
21
|
+
end
|
22
|
+
|
13
23
|
verify "Loss factor should be greater than zero and less than one" do
|
14
24
|
EgridRegion.all.each do |region|
|
15
25
|
unless region.loss_factor > 0 and region.loss_factor < 1
|