Skip to content

Commit

Permalink
Merge pull request #1056 from NREL/sample-weight
Browse files Browse the repository at this point in the history
Support sample_weight in buildstock.csv
  • Loading branch information
joseph-robertson committed Mar 21, 2023
2 parents 4407140 + 9dc24bb commit 746eea1
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Features
- Include battery modeling capabilities for project_testing ([#1009](https://github.com/NREL/resstock/pull/1009))
- Ability to check buildstock csv against an options lookup as a command line utility ([#1042](https://github.com/NREL/resstock/pull/1042))
- Demonstrate new power outage modeling feature using upgrades specified in example project yml files ([#1054](https://github.com/NREL/resstock/pull/1054))
- Ability to specify a "sample_weight" column in the precomputed buildstock.csv ([#1056](https://github.com/NREL/resstock/pull/1056))

Fixes
- Pulls in upstream OS-HPXML fix related to [avoiding possible OpenStudio temporary directory collision](https://github.com/NREL/OpenStudio-HPXML/pull/1316) causing random errors ([#1054](https://github.com/NREL/resstock/pull/1054))
Expand Down
32 changes: 4 additions & 28 deletions measures/BuildExistingModel/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
arg.setDescription('The building unit number (between 1 and the number of samples).')
args << arg

arg = OpenStudio::Ruleset::OSArgument.makeIntegerArgument('number_of_buildings_represented', false)
arg.setDisplayName('Number of Buildings Represented')
arg.setDescription('The total number of buildings represented by the existing building models.')
args << arg

arg = OpenStudio::Ruleset::OSArgument.makeDoubleArgument('sample_weight', false)
arg.setDisplayName('Sample Weight of Simulation')
arg.setDescription('Number of buildings this simulation represents.')
Expand Down Expand Up @@ -271,7 +266,7 @@ def run(model, runner, user_arguments)
end

# Check buildstock.csv doesn't have extra parameters
extras = bldg_data.keys - parameters_ordered - ['Building']
extras = bldg_data.keys - parameters_ordered - ['Building', 'sample_weight']
if !extras.empty?
runner.registerError("Mismatch between buildstock.csv and options_lookup.tsv. Extra parameters: #{extras.join(', ')}.")
return false
Expand Down Expand Up @@ -580,28 +575,9 @@ def run(model, runner, user_arguments)
register_value(runner, 'weather_file_latitude', epw_file.latitude)
register_value(runner, 'weather_file_longitude', epw_file.longitude)

# Determine weight
if args['number_of_buildings_represented'].is_initialized
total_samples = nil
runner.analysis[:analysis][:problem][:workflow].each do |wf|
next if wf[:name] != 'build_existing_model'

wf[:variables].each do |v|
next if v[:argument][:name] != 'building_id'

total_samples = v[:maximum].to_f
end
end
if total_samples.nil?
runner.registerError('Could not retrieve value for number_of_buildings_represented.')
return false
end
weight = args['number_of_buildings_represented'].get / total_samples
register_value(runner, 'weight', weight.to_s)
end

if args['sample_weight'].is_initialized
register_value(runner, 'weight', args['sample_weight'].get.to_s)
if bldg_data.keys.include?('sample_weight')
sample_weight = bldg_data['sample_weight']
register_value(runner, 'sample_weight', sample_weight.to_s)
end

return true
Expand Down
14 changes: 3 additions & 11 deletions measures/BuildExistingModel/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>build_existing_model</name>
<uid>dedf59bb-3b88-4f16-8755-2c1ff5519cbf</uid>
<version_id>d24f574d-ebfc-43b9-8730-c179bd1b976f</version_id>
<version_modified>20230310T232750Z</version_modified>
<version_id>7d0e7725-6762-49c0-a850-c92f1224538d</version_id>
<version_modified>20230321T150352Z</version_modified>
<xml_checksum>2C38F48B</xml_checksum>
<class_name>BuildExistingModel</class_name>
<display_name>Build Existing Model</display_name>
Expand All @@ -19,14 +19,6 @@
<required>true</required>
<model_dependent>false</model_dependent>
</argument>
<argument>
<name>number_of_buildings_represented</name>
<display_name>Number of Buildings Represented</display_name>
<description>The total number of buildings represented by the existing building models.</description>
<type>Integer</type>
<required>false</required>
<model_dependent>false</model_dependent>
</argument>
<argument>
<name>sample_weight</name>
<display_name>Sample Weight of Simulation</display_name>
Expand Down Expand Up @@ -320,7 +312,7 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>22DEFC84</checksum>
<checksum>5160D7EF</checksum>
</file>
</files>
</measure>
4 changes: 2 additions & 2 deletions measures/ServerDirectoryCleanup/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.0</schema_version>
<name>server_directory_cleanup</name>
<uid>ec7d04ad-0b7b-495b-825a-e1b6d28d1d3f</uid>
<version_id>bc53c731-88c9-42f6-8a17-d46c890b2d49</version_id>
<version_modified>20230315T145357Z</version_modified>
<version_id>0d932187-f72e-444b-a2d2-783fd0c85634</version_id>
<version_modified>20230321T150352Z</version_modified>
<xml_checksum>5F1EDF75</xml_checksum>
<class_name>ServerDirectoryCleanup</class_name>
<display_name>Server Directory Cleanup</display_name>
Expand Down
2 changes: 2 additions & 0 deletions test/integrity_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def check_buildstock(output_file, lookup_file, lookup_csv_data = nil)
csv.each do |row|
row.each do |parameter_name, option_name|
next if parameter_name == 'Building'
next if parameter_name == 'sample_weight'

unless parameters_options.keys.include? parameter_name
parameters_options[parameter_name] = []
Expand Down Expand Up @@ -325,6 +326,7 @@ def check_buildstock(output_file, lookup_file, lookup_csv_data = nil)
args_map = {}
row.each do |parameter_name, option_name|
next if parameter_name == 'Building'
next if parameter_name == 'sample_weight'

parameters_options_measure_args[parameter_name][option_name].each do |measure_name, args|
args.keys.each do |arg|
Expand Down
26 changes: 26 additions & 0 deletions test/test_run_analysis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,32 @@ def test_precomputed
assert(File.exist?(File.join(@testing_baseline, 'run1')))
assert(File.exist?(File.join(@testing_baseline, 'run2')))
assert(!File.exist?(File.join(@testing_baseline, 'run3')))

results_baseline = File.join(@testing_baseline, 'results-Baseline.csv')
assert(File.exist?(results_baseline))
results = CSV.read(results_baseline, headers: true)
assert(results.headers.include?('build_existing_model.sample_weight'))
assert_in_delta(results['build_existing_model.sample_weight'][0].to_f, 110000000 / 2, 0.001)
assert_in_delta(results['build_existing_model.sample_weight'][1].to_f, 110000000 / 2, 0.001)
end

def test_precomputed_sample_weight
yml = ' -y test/tests_yml_files/yml_precomputed_weight/testing_baseline.yml'
@command += yml

system(@command)

_test_measure_order(File.join(@testing_baseline, 'testing_baseline-Baseline.osw'))
assert(File.exist?(File.join(@testing_baseline, 'run1')))
assert(File.exist?(File.join(@testing_baseline, 'run2')))
assert(!File.exist?(File.join(@testing_baseline, 'run3')))

results_baseline = File.join(@testing_baseline, 'results-Baseline.csv')
assert(File.exist?(results_baseline))
results = CSV.read(results_baseline, headers: true)
assert(results.headers.include?('build_existing_model.sample_weight'))
assert_in_delta(results['build_existing_model.sample_weight'][0].to_f, 226.2342, 0.001)
assert_in_delta(results['build_existing_model.sample_weight'][1].to_f, 1.000009, 0.001)
end

def test_testing_baseline
Expand Down
6 changes: 3 additions & 3 deletions test/tests_yml_files/yml_precomputed/buildstock.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Building,Schedules,Heating Fuel,Geometry Building Type ACS,Geometry Building Type RECS,Geometry Building Number Units MF,Geometry Building Number Units SFA,Geometry Building Horizontal Location SFA,Geometry Foundation Type,Geometry Wall Type,Geometry Wall Exterior Finish,Geometry Stories,Geometry Building Type Height,Geometry Building Horizontal Location MF,Geometry Building Level MF,Geometry Stories Low Rise,Geometry Attic Type,Geometry Story Bin,Geometry Floor Area,Geometry Floor Area Bin,Geometry Garage,Bedrooms,Corridor,Vacancy Status,Occupants,Orientation,Eaves,Door Area,Window Areas,Overhangs,Neighbors,Insulation Ceiling,Insulation Roof,Radiant Barrier,Roof Material,Insulation Slab,Insulation Floor,Insulation Foundation Wall,Insulation Rim Joist,Insulation Wall,Interior Shading,Windows,Doors,Water Heater Efficiency,Hot Water Fixtures,Hot Water Distribution,Solar Hot Water,HVAC Heating Type,HVAC Cooling Type,HVAC Has Shared System,HVAC Shared Efficiencies,HVAC Heating Efficiency,HVAC Heating Type And Fuel,HVAC Secondary Heating Type And Fuel,HVAC Secondary Heating Efficiency,HVAC Cooling Efficiency,HVAC Cooling Partial Space Conditioning,HVAC System Is Faulted,HVAC System Single Speed AC Airflow,HVAC System Single Speed ASHP Airflow,HVAC System Single Speed AC Charge,HVAC System Single Speed ASHP Charge,Heating Setpoint,Cooling Setpoint,Heating Setpoint Has Offset,Cooling Setpoint Has Offset,Heating Setpoint Offset Magnitude,Cooling Setpoint Offset Magnitude,Heating Setpoint Offset Period,Cooling Setpoint Offset Period,Ceiling Fan,Dehumidifier,Refrigerator,Cooking Range,Dishwasher,Clothes Washer Presence,Clothes Washer,Clothes Dryer,Lighting,Lighting Interior Use,Lighting Other Use,Holiday Lighting,Plug Loads,Plug Load Diversity,Electric Vehicle,Misc Extra Refrigerator,Misc Freezer,Misc Gas Fireplace,Misc Gas Grill,Misc Gas Lighting,Misc Hot Tub Spa,Misc Pool,Misc Pool Heater,Misc Pool Pump,Misc Well Pump,HVAC Has Ducts,Ducts,Infiltration,Natural Ventilation,Mechanical Ventilation,Bathroom Spot Vent Hour,Range Spot Vent Hour,Has PV,PV System Size,PV Orientation,County,ASHRAE IECC Climate Zone 2004,State,Census Region,REEDS Balancing Area,Generation And Emissions Assessment Region
1,Default,Other Fuel,Single-Family Attached,Single-Family Attached,None,144,Right,Unheated Basement,Wood Frame,"Wood, Medium/Dark",3,Single-Family Attached,None,None,3,Finished Attic or Cathedral Ceilings,<8,4000+,4000+,None,5,Not Applicable,Occupied,9,NNW,3 ft,40 ft^2,F30 B30 L30 R30,"2ft, Right Windows",27,None,"Finished, R-38",None,Wood Shingles,None,Ceiling R-38,"Wall R-15, Exterior","R-15, Exterior","Wood Stud, R-19","Summer = 0.5, Winter = 0.95","Single, Clear, Non-metal, Exterior Clear Storm",Fiberglass,Propane Tankless,"100% Usage, Low Flow","R-5, Timer","40 sqft, West, Latitude + 15 degrees",Non-Ducted Heating,None,None,None,Other,None,None,None,None,None,Yes,700.2 cfm/ton,700.2 cfm/ton,1.405 Charge Frac,1.405 Charge Frac,78F,78F,No,No,0F,0F,None,None,"Premium Efficiency, 0.5F Offset","65 pints/day, 50% RH, 2.0 EF","EF 21.9, 105% Usage","Electric, Induction, 120% Usage",None,Yes,"CEE Advanced Tier, 120% Usage",None,None,None,None,None,144%,25%,"EV, 5000 miles, 0.3 kWh/mi",EF 19.9,"EF 20, 2008 Energy Star Most Efficient",National Average,National Average,Gas Lighting,None,None,None,None,Typical Efficiency,Yes,"0% Leakage, Uninsulated",40 ACH50,None,"ERV, 72%",Hour22,Hour18,Yes,13.0 kWDC,West,"NY, New York County",4A,NY,Northeast,127,NYSTc
2,Stochastic,Propane,Single-Family Detached,Single-Family Detached,None,None,None,Unheated Basement,Wood Frame,"Vinyl, Light",3,Single-Family Detached,None,None,3,Finished Attic or Cathedral Ceilings,<8,3000-3999,2500-3999,None,5,Not Applicable,Vacant,10+,Northwest,2 ft,40 ft^2,None,"2ft, Left Windows",None,None,"Finished, R-49",None,"Tile, Concrete",None,Ceiling R-30,"Wall R-13, Interior","R-13, Interior","Wood Stud, R-15","Summer = 0.7, Winter = 0.95","Triple, Low-E, Non-metal, Air, L-Gain",Steel,Propane Standard,"200% Usage, Low Flow","R-2, Demand","40 sqft, West, Latitude + 15 degrees",Non-Ducted Heating,Room AC,None,None,"Fuel Wall/Floor Furnace, 68% AFUE",Propane Fuel Wall/Floor Furnace,None,None,"Room AC, EER 12.0",100% Conditioned,No,None,None,None,None,80F,80F,Yes,Yes,12F,9F,Night -5h,Night Setup -5h,"Standard Efficiency, 0.5F Offset","65 pints/day, 60% RH",None,None,"318 Rated kWh, 120% Usage",None,None,None,20% LED,95% Usage,95% Usage,No Exterior Use,166%,50%,"EV, 4000 miles, 0.3 kWh/mi",None,None,Gas Fireplace,Gas Grill,National Average,None,None,None,None,High Efficiency,No,"30% Leakage, R-8",50 ACH50,"Cooling Season, 7 days/wk","HRV, 60%",Hour23,Hour17,No,None,None,"TX, Harris County",2A,TX,South,67,ERCTc
Building,Heating Fuel,Geometry Building Type ACS,Geometry Building Type RECS,Geometry Building Number Units MF,Geometry Building Number Units SFA,Geometry Building Horizontal Location SFA,Geometry Foundation Type,Geometry Wall Type,Geometry Wall Exterior Finish,Geometry Stories,Geometry Building Type Height,Geometry Building Horizontal Location MF,Geometry Building Level MF,Geometry Stories Low Rise,Geometry Attic Type,Geometry Story Bin,Geometry Floor Area,Geometry Floor Area Bin,Geometry Garage,Bedrooms,Corridor,Vacancy Status,Occupants,Orientation,Eaves,Door Area,Window Areas,Overhangs,Neighbors,Insulation Ceiling,Insulation Roof,Radiant Barrier,Roof Material,Insulation Slab,Insulation Floor,Insulation Foundation Wall,Insulation Rim Joist,Insulation Wall,Interior Shading,Windows,Doors,Water Heater Efficiency,Hot Water Fixtures,Hot Water Distribution,Solar Hot Water,HVAC Heating Type,HVAC Cooling Type,HVAC Has Shared System,HVAC Shared Efficiencies,HVAC Heating Efficiency,HVAC Heating Type And Fuel,HVAC Secondary Heating Type And Fuel,HVAC Secondary Heating Efficiency,HVAC Cooling Efficiency,HVAC Cooling Partial Space Conditioning,HVAC System Is Faulted,HVAC System Single Speed AC Airflow,HVAC System Single Speed ASHP Airflow,HVAC System Single Speed AC Charge,HVAC System Single Speed ASHP Charge,Heating Setpoint,Cooling Setpoint,Heating Setpoint Has Offset,Cooling Setpoint Has Offset,Heating Setpoint Offset Magnitude,Cooling Setpoint Offset Magnitude,Heating Setpoint Offset Period,Cooling Setpoint Offset Period,Ceiling Fan,Dehumidifier,Refrigerator,Cooking Range,Dishwasher,Clothes Washer Presence,Clothes Washer,Clothes Dryer,Lighting,Lighting Interior Use,Lighting Other Use,Holiday Lighting,Plug Loads,Plug Load Diversity,Electric Vehicle,Misc Extra Refrigerator,Misc Freezer,Misc Gas Fireplace,Misc Gas Grill,Misc Gas Lighting,Misc Hot Tub Spa,Misc Pool,Misc Pool Heater,Misc Pool Pump,Misc Well Pump,HVAC Has Ducts,Ducts,Infiltration,Natural Ventilation,Mechanical Ventilation,Bathroom Spot Vent Hour,Range Spot Vent Hour,Has PV,PV System Size,PV Orientation,Battery,County,ASHRAE IECC Climate Zone 2004,State,Census Region,REEDS Balancing Area,Generation And Emissions Assessment Region
1,Other Fuel,Single-Family Attached,Single-Family Attached,None,144,Right,Unheated Basement,Wood Frame,"Vinyl, Light",3,Single-Family Attached,None,None,3,Finished Attic or Cathedral Ceilings,<8,4000+,4000+,None,5,Not Applicable,Vacant,9,Northwest,3 ft,40 ft^2,None,"2ft, Right Windows",27,None,"Finished, R-38",None,Wood Shingles,None,Ceiling R-38,"Wall R-15, Exterior","R-15, Exterior","Wood Stud, R-19","Summer = 0.5, Winter = 0.95","Single, Clear, Non-metal, Exterior Clear Storm",Fiberglass,Propane Tankless,"100% Usage, Low Flow","R-5, Timer","40 sqft, West, Latitude + 15 degrees",Non-Ducted Heating,None,None,None,Other,None,None,None,None,None,Yes,700.2 cfm/ton,700.2 cfm/ton,1.405 Charge Frac,1.405 Charge Frac,80F,80F,No,No,0F,0F,None,None,"Premium Efficiency, 0.5F Offset","65 pints/day, 50% RH, 2.0 EF","EF 21.9, 105% Usage","Electric, Induction, 120% Usage",None,Yes,"CEE Advanced Tier, 120% Usage",None,None,None,None,None,144%,25%,"EV, 5000 miles, 0.3 kWh/mi",EF 19.9,"EF 20, 2008 Energy Star Most Efficient",National Average,National Average,Gas Lighting,None,None,None,None,Typical Efficiency,Yes,"0% Leakage, Uninsulated",40 ACH50,None,"ERV, 72%",Hour22,Hour18,Yes,13.0 kWDC,West,"20 kWh, Outside","TX, Harris County",2A,TX,South,67,ERCTc
2,Propane,Single-Family Detached,Single-Family Detached,None,None,None,Unheated Basement,Wood Frame,"Wood, Medium/Dark",3,Single-Family Detached,None,None,3,Finished Attic or Cathedral Ceilings,<8,3000-3999,2500-3999,None,5,Not Applicable,Occupied,10+,NNW,2 ft,40 ft^2,None,"2ft, Left Windows",None,None,"Finished, R-49",None,"Tile, Concrete",None,Ceiling R-30,"Wall R-13, Interior","R-13, Interior","Wood Stud, R-15","Summer = 0.7, Winter = 0.95","Triple, Low-E, Non-metal, Air, L-Gain",Steel,Propane Standard,"200% Usage, Low Flow","R-2, Demand","40 sqft, West, Latitude + 15 degrees",Non-Ducted Heating,Room AC,None,None,"Fuel Wall/Floor Furnace, 68% AFUE",Propane Fuel Wall/Floor Furnace,None,None,"Room AC, EER 12.0",100% Conditioned,No,None,None,None,None,71F w/ Building America season,76F w/ Building America season,Yes,Yes,12F,9F,Night -5h,Night Setup -5h,"Standard Efficiency, 0.5F Offset","65 pints/day, 60% RH",None,None,"318 Rated kWh, 120% Usage",None,None,None,20% LED,95% Usage,95% Usage,No Exterior Use,166%,50%,"EV, 4000 miles, 0.3 kWh/mi",None,None,Gas Fireplace,Gas Grill,National Average,None,None,None,None,High Efficiency,No,"30% Leakage, R-8",50 ACH50,"Cooling Season, 7 days/wk","HRV, 60%",Hour23,Hour17,No,None,None,"20 kWh, 80% Round Trip Efficiency","NY, New York County",4A,NY,Northeast,127,NYSTc

0 comments on commit 746eea1

Please sign in to comment.