Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Interpret blank energy uses in CBECS as 0

  • Loading branch information...
commit c0a00454a71ec11eaf26f694175bd706d665b0d6 1 parent 8fd3c58
@ihough ihough authored
View
14 lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb
@@ -51,7 +51,7 @@
store 'heating_degree_days', :field_name => 'HDD658', :from_units => :degrees_fahrenheit, :to_units => :degrees_celsius
store 'cooling_degree_days', :field_name => 'CDD658', :from_units => :degrees_fahrenheit, :to_units => :degrees_celsius
store 'electricity_use', :synthesize => proc { |row| row['ELCNS8'].to_i }, :units => :kilowatt_hours
- store 'electricity_energy', :field_name => 'ELBTU8', :from_units => :kbtus, :to_units => :megajoules
+ store 'electricity_energy', :synthesize => proc { |row| row['ELBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
end
import 'fuel use characteristics from the 2003 EIA CBECS',
@@ -59,12 +59,12 @@
:skip => 1,
: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
key 'id', :field_name => 'PUBID8'
- store 'natural_gas_use', :field_name => 'NGCNS8', :from_units => :hundred_cubic_feet, :to_units => :cubic_metres
- store 'natural_gas_energy', :field_name => 'NGBTU8', :from_units => :kbtus, :to_units => :megajoules
- store 'fuel_oil_use', :field_name => 'FKCNS8', :from_units => :gallons, :to_units => :litres
- store 'fuel_oil_energy', :field_name => 'FKBTU8', :from_units => :kbtus, :to_units => :megajoules
- store 'district_heat_use', :field_name => 'DHBTU8', :from_units => :kbtus, :to_units => :megajoules
- store 'district_heat_energy', :field_name => 'DHBTU8', :from_units => :kbtus, :to_units => :megajoules
+ store 'natural_gas_use', :synthesize => proc { |row| row['NGCNS8'].to_i.hundred_cubic_feet.to(:cubic_metres) }, :units => :cubic_metres
+ store 'fuel_oil_use', :synthesize => proc { |row| row['FKCNS8'].to_i.gallons.to(:litres) }, :units => :litres
+ store 'district_heat_use', :synthesize => proc { |row| row['DHBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
+ store 'natural_gas_energy', :synthesize => proc { |row| row['NGBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
+ store 'fuel_oil_energy', :synthesize => proc { |row| row['FKBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
+ store 'district_heat_energy', :synthesize => proc { |row| row['DHBTU8'].to_i.kbtus.to(:megajoules) }, :units => :megajoules
end
process "Derive room nights for lodging records" do
View
14 spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb
@@ -13,9 +13,17 @@
end
describe "verify imported data", :sanity => true do
- it "should have all the data" do
- CommercialBuildingEnergyConsumptionSurveyResponse.count.should == 5215
- end
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.count.should == 5215 }
+
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:electricity_use => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:electricity_energy => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:natural_gas_use => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:natural_gas_energy => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:fuel_oil_use => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:fuel_oil_energy => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:district_heat_use => nil).count.should == 0 }
+ it { CommercialBuildingEnergyConsumptionSurveyResponse.where(:district_heat_energy => nil).count.should == 0 }
+
it "should have room nights and fuel intensities per room night for lodging_records" do
spot_check = CommercialBuildingEnergyConsumptionSurveyResponse.lodging_records.first
spot_check.room_nights.should == 6205

1 comment on commit c0a0045

@seamusabshere

i can tell earth test coverage is getting better

Please sign in to comment.
Something went wrong with that request. Please try again.