lib/residence/carbon_model.rb in residence-0.0.11 vs lib/residence/carbon_model.rb in residence-0.0.12
- old
+ new
@@ -30,56 +30,56 @@
committee :fuel_oil_consumed do # returns litres
quorum 'from reports', :needs => :reported_annual_fuel_oil_consumption do |characteristics, timeframe|
characteristics[:reported_annual_fuel_oil_consumption] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_fuel_oil_consumption, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_fuel_oil_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:fuel_oil]).joules.to(:litres_of_fuel_oil) ) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_fuel_oil_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:fuel_oil]).joules.to(:litres_of_fuel_oil) ) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :natural_gas_consumed do # returns joules
quorum 'from reports', :needs => :reported_annual_natural_gas_consumption do |characteristics, timeframe|
characteristics[:reported_annual_natural_gas_consumption] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_natural_gas_consumption, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_natural_gas_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:natural_gas])) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_natural_gas_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:natural_gas])) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :propane_consumed do # returns litres
quorum 'from reports', :needs => :reported_annual_propane_consumption do |characteristics, timeframe|
characteristics[:reported_annual_propane_consumption] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_propane_consumption, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_propane_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:propane]).joules.to(:litres_of_propane)) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_propane_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:propane]).joules.to(:litres_of_propane)) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :biomass_consumed do # returns joules
quorum 'from reports', :needs => :reported_annual_biomass_consumption do |characteristics, timeframe|
characteristics[:reported_annual_biomass_consumption] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_biomass_consumption, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_biomass_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:biomass])) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_biomass_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:biomass])) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :kerosene_consumed do # returns litres
quorum 'from reports', :needs => :reported_annual_kerosene_consumption do |characteristics, timeframe|
characteristics[:reported_annual_kerosene_consumption] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_kerosene_consumption, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_kerosene_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:kerosene]).joules.to(:litres_of_kerosene)) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_kerosene_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:kerosene]).joules.to(:litres_of_kerosene)) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :coal_consumed do # returns kg
quorum 'from reports', :needs => :reported_annual_coal_consumption do |characteristics, timeframe|
characteristics[:reported_annual_coal_consumption] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_coal_consumption, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_coal_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:coal]).joules.to(:kilograms_of_coal)) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_coal_consumption] + (characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:coal]).joules.to(:kilograms_of_coal)) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :dirty_electricity_generated do
quorum 'from electricity generated and green electricity', :needs => [:electricity_generated, :green_electricity] do |characteristics|
@@ -87,11 +87,11 @@
end
end
committee :green_electricity do
quorum 'default' do
- Residence.residence_model.fallback.green_electricity
+ base.fallback.green_electricity
end
end
committee :electricity_generated do # returns kWh
quorum 'from electricity used and loss rate', :needs => [:electricity_used, :electricity_loss_rate] do |characteristics|
@@ -103,11 +103,11 @@
quorum 'from reports', :needs => :reported_annual_electricity_use do |characteristics, timeframe|
characteristics[:reported_annual_electricity_use] * (timeframe / timeframe.year)
end
quorum 'from research', :needs => [:predicted_annual_electricity_use, :predicted_fuel_shares, :missing_annual_energy, :occupation] do |characteristics, timeframe|
- (characteristics[:predicted_annual_electricity_use] + ((characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:electricity]).joules.to(:kilowatt_hours))) * (timeframe / timeframe.year) * characteristics[:occupation] / Residence.residence_model.fallback.occupation
+ (characteristics[:predicted_annual_electricity_use] + ((characteristics[:missing_annual_energy] * characteristics[:predicted_fuel_shares][:electricity]).joules.to(:kilowatt_hours))) * (timeframe / timeframe.year) * characteristics[:occupation] / base.fallback.occupation
end
end
committee :missing_annual_energy do # returns joules
quorum 'from fuel reports', :needs => [:predicted_annual_fuel_oil_consumption, :predicted_annual_natural_gas_consumption, :predicted_annual_propane_consumption, :predicted_annual_kerosene_consumption, :predicted_annual_biomass_consumption, :predicted_annual_coal_consumption, :predicted_annual_electricity_use], :appreciates => [:reported_annual_fuel_oil_consumption, :reported_annual_natural_gas_consumption, :reported_annual_propane_consumption, :reported_annual_kerosene_consumption, :reported_annual_biomass_consumption, :reported_annual_coal_consumption, :reported_annual_electricity_use] do |characteristics|
@@ -169,21 +169,21 @@
end
end
committee :occupation do
quorum 'default' do
- Residence.residence_model.fallback.occupation
+ base.fallback.occupation
end
end
committee :residents do
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average :residents
end
quorum 'default' do
- Residence.residence_model.fallback.residents_before_type_cast
+ base.fallback.residents_before_type_cast
end
end
committee :air_conditioner_use do
quorum 'default' do
@@ -241,11 +241,11 @@
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average(%w(heating_space heating_water appliances).map { |purpose| "annual_energy_from_fuel_oil_for_#{purpose}".to_sym }).to_f.joules.to(:litres_of_fuel_oil)
end
quorum 'default' do
- Residence.residence_model.fallback.annual_fuel_oil_volume_estimate
+ base.fallback.annual_fuel_oil_volume_estimate
end
end
committee :reported_annual_natural_gas_consumption do # returns joules
quorum 'from volume estimate', :needs => :monthly_natural_gas_volume_estimate do |characteristics|
@@ -270,11 +270,11 @@
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average(%w(heating_space heating_water appliances).map { |purpose| "annual_energy_from_natural_gas_for_#{purpose}".to_sym }).to_f
end
quorum 'default' do
- Residence.residence_model.fallback.monthly_natural_gas_volume_estimate * 12
+ base.fallback.monthly_natural_gas_volume_estimate * 12
end
end
committee :reported_annual_propane_consumption do # returns litres
quorum 'from volume estimate', :needs => :annual_propane_volume_estimate do |characteristics|
@@ -299,11 +299,11 @@
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average(%w(heating_space heating_water appliances).map { |purpose| "annual_energy_from_propane_for_#{purpose}".to_sym }).to_f.joules.to(:litres_of_propane)
end
quorum 'default' do
- Residence.residence_model.fallback.annual_propane_volume_estimate
+ base.fallback.annual_propane_volume_estimate
end
end
committee :reported_annual_kerosene_consumption do # returns litres
quorum 'from volume estimate', :needs => :annual_kerosene_volume_estimate do |characteristics|
@@ -315,11 +315,11 @@
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average(:annual_energy_from_kerosene).to_f.joules.to(:litres_of_kerosene)
end
quorum 'default' do
- Residence.residence_model.fallback.annual_kerosene_volume_estimate
+ base.fallback.annual_kerosene_volume_estimate
end
end
committee :reported_annual_biomass_consumption do # returns joules
quorum 'from volume estimate', :needs => :annual_wood_volume_estimate do |characteristics|
@@ -331,11 +331,11 @@
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average(:annual_energy_from_wood)
end
quorum 'default' do
- Residence.residence_model.fallback.annual_wood_volume_estimate
+ base.fallback.annual_wood_volume_estimate
end
end
committee :reported_annual_coal_consumption do # returns kg
quorum 'from volume estimate', :needs => :annual_coal_volume_estimate do |characteristics|
@@ -343,11 +343,11 @@
end
end
committee :predicted_annual_coal_consumption do # returns kg
quorum 'default' do
- Residence.residence_model.fallback.annual_coal_volume_estimate
+ base.fallback.annual_coal_volume_estimate
end
end
committee :reported_annual_electricity_use do # returns kWh
quorum 'from use estimate', :needs => :monthly_electricity_use_estimate do |characteristics|
@@ -441,11 +441,11 @@
energy.joules.to(:kilowatt_hours)
end
quorum 'default' do
- Residence.residence_model.fallback.monthly_electricity_use_estimate * 12
+ base.fallback.monthly_electricity_use_estimate * 12
end
end
committee :active_subtimeframe do
quorum 'from acquisition and retirement', :needs => [:acquisition, :retirement] do |characteristics, timeframe|
@@ -469,17 +469,17 @@
end
end
# This is kindof "hacky"
# As implemented, this needs to be above floorspace committee or else cohort will always
- # use the Residence.residence_model.fallback
+ # use the base.fallback
committee :floorspace_estimate do
quorum 'from cohort', :needs => :cohort do |characteristics|
characteristics[:cohort].weighted_average :floorspace
end
quorum 'default' do
- Residence.residence_model.fallback.floorspace_estimate
+ base.fallback.floorspace_estimate
end
end
committee :cohort do
quorum 'from residential energy consumption survey', :appreciates => ResidentialEnergyConsumptionSurveyResponse::INPUT_CHARACTERISTICS do |characteristics|