Skip to content

Commit

Permalink
Resstock connecction (#472)
Browse files Browse the repository at this point in the history
* bump dependency versions

* bump to version 0.13.0

* copy files from example-repo to enable resstock usage!

* update path formatting and paths for new files

* match test expectation to updated error message

* remove hpxml-measures if present when updating to v0.13.0

* use released gems in CI, and run CI when review is requested

* fix repo link in baseline mapper license text
  • Loading branch information
vtnate authored Jun 27, 2024
1 parent cf3285d commit 399485a
Show file tree
Hide file tree
Showing 1,037 changed files with 1,977,596 additions and 748 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightly_ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:
# # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# # 5:24 am UTC (11:24pm MDT the day before) every weekday night in MDT
- cron: '24 5 * * 2-6'
# pull_request:
# types: [review_requested]
pull_request:
types: [review_requested]

env:
# Favor_Local_Gems enforces develop branch of all Ruby dependencies
# This is our canary in the coal mine! If any simulation tests fail, comment this and retry.
# If CI is then successful, we have a breaking change in a dependency somewhere.
FAVOR_LOCAL_GEMS: true
# FAVOR_LOCAL_GEMS: true
GEM_DEVELOPER_KEY: ${{ secrets.GEM_DEVELOPER_KEY }}
# RUBYLIB: /usr/local/openstudio-3.7.0/Ruby
UO_NUM_PARALLEL: 4
Expand Down
4 changes: 2 additions & 2 deletions example_files/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if allow_local && File.exist?('../urbanopt-geojson-gem')
elsif allow_local
gem 'urbanopt-geojson', github: 'URBANopt/urbanopt-geojson-gem', branch: 'develop'
else
gem 'urbanopt-geojson', '~> 0.11.1'
gem 'urbanopt-geojson', '~> 0.11.2'
end

# NEVER put SCENARIO-GEM in this file...it will make all simulations fail due to the sqlite dependency
Expand All @@ -94,5 +94,5 @@ if allow_local && File.exist?('../urbanopt-reporting-gem')
elsif allow_local
gem 'urbanopt-reporting', github: 'URBANopt/urbanopt-reporting-gem', branch: 'develop'
else
gem 'urbanopt-reporting', '~> 0.10.0'
gem 'urbanopt-reporting', '~> 0.10.1'
end
20 changes: 11 additions & 9 deletions example_files/example_project_combined.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"end_date": "2017-12-31T07:00:00.000Z",
"timesteps_per_hour": 1,
"default_template": "90.1-2013",
"emissions": true,
"emissions": true,
"electricity_emissions_future_subregion": "NYSTc",
"electricity_emissions_hourly_historical_subregion": "New York",
"electricity_emissions_annual_historical_subregion": "NYCW",
Expand Down Expand Up @@ -652,8 +652,7 @@
"onsite_parking_fraction": 1,
"template": "Residential IECC 2015 - Customizable Template Sep 2020",
"geometry_unit_orientation": 90.0,
"geometry_unit_aspect_ratio" : 1.0

"geometry_unit_aspect_ratio": 1.0
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -700,7 +699,9 @@
"roof_type": "Hip",
"system_type": "Residential - boiler and room air conditioner",
"heating_system_fuel_type": "propane",
"template": "Residential IECC 2015 - Customizable Template Sep 2020"
"year_built": 1986,
"characterize_residential_buildings_from_buildstock_csv": true,
"uo_buildstock_mapping_csv_path": "resources/uo_buildstock_mapping.csv"
},
"geometry": {
"type": "Polygon",
Expand Down Expand Up @@ -834,17 +835,18 @@
"name": "Residential 5",
"type": "Building",
"building_type": "Multifamily",
"floor_area": 28636,
"footprint_area": 14318,
"floor_area": 10000,
"footprint_area": 5000,
"number_of_stories_above_ground": 2,
"number_of_stories": 2,
"number_of_bedrooms": 16,
"foundation_type": "slab",
"attic_type": "flat roof",
"system_type": "Residential - furnace and room air conditioner",
"heating_system_fuel_type": "wood",
"system_type": "Residential - furnace and central air conditioner",
"heating_system_fuel_type": "electricity",
"number_of_residential_units": 8,
"template": "Residential IECC 2015 - Customizable Template Sep 2020"
"characterize_residential_buildings_from_buildstock_csv": true,
"resstock_buildstock_csv_path": "resources/residential-measures/test/base_results/baseline/annual/buildstock.csv"
},
"geometry": {
"type": "Polygon",
Expand Down
66 changes: 59 additions & 7 deletions example_files/mappers/Baseline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initialize

# add any paths local to the project
@@osw[:measure_paths] << File.join(File.dirname(__FILE__), '../measures/')
@@osw[:measure_paths] << File.join(File.dirname(__FILE__), '../resources/hpxml-measures')
@@osw[:measure_paths] << File.join(File.dirname(__FILE__), '../resources/residential-measures/resources/hpxml-measures')
@@osw[:file_paths] << File.join(File.dirname(__FILE__), '../weather/')

# configures OSW with extension gem paths for measures and files, all extension gems must be
Expand Down Expand Up @@ -264,7 +264,7 @@ def commercial_building_types
def get_climate_zone_iecc(epw)
headers = CSV.open(epw, 'r', &:first)
wmo = headers[5]
zones_csv = Pathname(__FILE__).dirname.parent / 'resources' / 'hpxml-measures' / 'HPXMLtoOpenStudio' / 'resources' / 'data' / 'climate_zones.csv'
zones_csv = Pathname(__FILE__).dirname.parent / 'resources' / 'residential-measures' / 'resources' / 'hpxml-measures' / 'HPXMLtoOpenStudio' / 'resources' / 'data' / 'climate_zones.csv'

# Check if the CSV file is empty
if File.empty?(epw)
Expand Down Expand Up @@ -549,12 +549,13 @@ def create_osw(scenario, features, feature_names)
end

# Start general residential mapping
# mappers/residential/util.rb
args = {}
require File.join(File.dirname(__FILE__), 'residential/util')
residential(scenario, feature, args, building_type)

# Then onto optional "template" mapping
# mappers/residential/template
# mappers/residential/template/util.rb
template = nil
begin
template = feature.template
Expand All @@ -566,9 +567,60 @@ def create_osw(scenario, features, feature_names)
residential_template(args, template, climate_zone)
end

# Parse BuildResidentialModel measure xml so we can override defaults
# Then onto optional "samples" mapping
# mappers/residential/samples/util.rb
uo_resstock_connection = false
begin
uo_resstock_connection = feature.characterize_residential_buildings_from_buildstock_csv
rescue StandardError
end

# Run workflows if UO-ResStock connection is established
if uo_resstock_connection

buildstock_csv_path = nil
begin
csv_path = feature.resstock_buildstock_csv_path
buildstock_csv_path = File.absolute_path(File.join(File.dirname(__FILE__), '..', csv_path))
rescue StandardError
@@logger.error("\n resstock_buildstock_csv_path was not assigned by the user.")
end

uo_buildstock_mapping_csv_path = nil
begin
mapping_csv_path = feature.uo_buildstock_mapping_csv_path
uo_buildstock_mapping_csv_path = File.absolute_path(File.join(File.dirname(__FILE__), '..', mapping_csv_path))
rescue StandardError
@@logger.error("\n uo_buildstock_mapping_csv_path was not assigned by the user")
end

require File.join(File.dirname(__FILE__), 'residential/samples/util')
if !buildstock_csv_path.nil? # If resstock_buildstock_csv_path is provided
@@logger.info("Processing with BuildStock CSV path.")

start_time = Time.now # To document the time of finding the resstock building id
resstock_building_id = find_resstock_building_id(buildstock_csv_path, feature, building_type, @@logger)
puts "Processing time for finding a building match (resstock_building_id = #{resstock_building_id}) from the buildstock CSV: #{Time.now - start_time} seconds."

residential_samples(args, resstock_building_id, buildstock_csv_path)

elsif !uo_buildstock_mapping_csv_path.nil? # If uo_buildstock_mapping_csv_path is provided
@@logger.info("Processing with UO-BuildStock mapping CSV path.")

start_time = Time.now # To document the time of getting the resstock building id
resstock_building_id = find_building_for_uo_id(uo_buildstock_mapping_csv_path, feature.id)
puts "Processing time for finding the building match (resstock_building_id = #{resstock_building_id}) from the buildstock CSV: #{Time.now - start_time} seconds."

residential_samples(args, resstock_building_id, uo_buildstock_mapping_csv_path) # uo_buildstock_mapping_csv_path may contain a subset of all parameters

else
@@logger.error("The user did not specify either the uo_buildstock_mapping_csv_path or the resstock_buildstock_csv_path. At least one of these is required for UO - ResStock connection.")
end
end

# Parse BuildResidentialHPXML measure xml so we can fill "args" in with default values where keys aren't already assigned
default_args = {}
measures_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../resources/hpxml-measures'))
measures_dir = File.absolute_path(File.join(File.dirname(__FILE__), '../resources/residential-measures/resources/hpxml-measures'))
measure_xml = File.read(File.join(measures_dir, 'BuildResidentialHPXML', 'measure.xml'))
measure = REXML::Document.new(measure_xml).root
measure.elements.each('arguments/argument') do |arg|
Expand All @@ -581,7 +633,7 @@ def create_osw(scenario, features, feature_names)
end
end

build_res_model_args = [:feature_id, :schedules_type, :schedules_random_seed, :schedules_variation, :geometry_num_floors_above_grade, :hpxml_dir, :output_dir]
build_res_model_args = [:urbanopt_feature_id, :resstock_buildstock_csv_path, :resstock_building_id, :schedules_type, :schedules_random_seed, :schedules_variation, :geometry_num_floors_above_grade, :hpxml_dir, :output_dir]
args.each_key do |arg_name|
unless default_args.key?(arg_name)
next if build_res_model_args.include?(arg_name)
Expand Down Expand Up @@ -1105,6 +1157,6 @@ def time_mapping(time)

return osw
end
end
end # end class
end
end
Loading

0 comments on commit 399485a

Please sign in to comment.