-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New ResStockArgumentsPostHPXML measure #929
Open
joseph-robertson
wants to merge
39
commits into
develop
Choose a base branch
from
resstock-args-refactor
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 30 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
172879c
Rename ResstockArguments to ResStockArgumentsPreHPXML.
joseph-robertson fa408c7
Update measure name in other measures and lookup.
joseph-robertson 44347c3
Stub new ResStockArgumentsPostHPXML measure.
joseph-robertson 771042c
Update meta measures for new measure.
joseph-robertson 2abcc64
Get meta measures working properly.
joseph-robertson 1587e5b
Update measure descriptions.
joseph-robertson 7bdf4da
More description updates.
joseph-robertson e111940
Merge branch 'develop' into resstock-args-refactor
joseph-robertson 6fad137
Rename pre hpxml back to original.
joseph-robertson fd288ae
Revert lookup.
joseph-robertson 06133ea
Merge branch 'develop' into resstock-args-refactor
joseph-robertson 87e876b
Measure updates.
joseph-robertson 957b9c9
Temp code in building existing model.
joseph-robertson 3a5effb
Remove project folders before each test.
joseph-robertson be0e390
Squashed 'resources/hpxml-measures/' changes from c015c17d0ee..cdaa49…
joseph-robertson a8bfe43
Merge commit 'be0e390519975d5028881cfb584b5c89bef9f497' into resstock…
joseph-robertson 94c5b04
Ignore new debug argument for resstock arguments.
joseph-robertson e6736f6
Merge branch 'develop' into resstock-args-refactor
joseph-robertson 5c23cf2
Request setpoint output vars.
joseph-robertson 53f3fc0
Latest results.
a8fc8d3
Merge branch 'develop' into resstock-args-refactor
joseph-robertson bfa8478
Merge branch 'develop' into resstock-args-refactor
joseph-robertson 76ef1b6
Latest results.
d2d0ceb
Merge branch 'develop' into resstock-args-refactor
joseph-robertson 55b9fa5
Clean up top level measures.
joseph-robertson c7c7948
Latest results.
4f7106d
Update changelog.
joseph-robertson 87279c6
Update docs.
joseph-robertson 2dac598
Revert output vars request in yml.
joseph-robertson ecd366d
Latest results.
abae054
Merge branch 'develop' into resstock-args-refactor
joseph-robertson b68c82f
Merge branch 'develop' into resstock-args-refactor
joseph-robertson bd316de
Merge branch 'develop' into resstock-args-refactor
rajeee 18f62ab
Cleanup merge conflicts
rajeee dae2310
Reimplment calling ResStockArgumentsPostHPXML
rajeee c454026
Update measures
rajeee e7b642e
Merge branch 'ci_fix' into resstock-args-refactor
rajeee 17e85f5
Update to use runner method
rajeee 95f5936
Merge branch 'develop' into resstock-args-refactor
rajeee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# frozen_string_literal: true | ||
|
||
# see the URL below for information on how to write OpenStudio measures | ||
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/ | ||
|
||
# start the measure | ||
class ResStockArgumentsPostHPXML < OpenStudio::Measure::ModelMeasure | ||
# human readable name | ||
def name | ||
# Measure name should be the title case of the class name. | ||
return 'ResStock Arguments Post-HPXML' | ||
end | ||
|
||
# human readable description | ||
def description | ||
return 'Measure that post-processes the output of the BuildResidentialHPXML and BuildResidentialScheduleFile measures.' | ||
end | ||
|
||
# human readable description of modeling approach | ||
def modeler_description | ||
return 'Passes in all ResStockArgumentsPostHPXML arguments from the options lookup, processes them, and then modifies output of other measures.' | ||
end | ||
|
||
# define the arguments that the user will input | ||
def arguments(model) # rubocop:disable Lint/UnusedMethodArgument | ||
args = OpenStudio::Measure::OSArgumentVector.new | ||
|
||
arg = OpenStudio::Measure::OSArgument.makeStringArgument('hpxml_path', false) | ||
arg.setDisplayName('HPXML File Path') | ||
arg.setDescription('Absolute/relative path of the HPXML file.') | ||
args << arg | ||
|
||
arg = OpenStudio::Measure::OSArgument::makeStringArgument('output_csv_path', false) | ||
arg.setDisplayName('Schedules: Output CSV Path') | ||
arg.setDescription('Absolute/relative path of the csv file containing user-specified occupancy schedules. Relative paths are relative to the HPXML output path.') | ||
args << arg | ||
|
||
return args | ||
end | ||
|
||
# define what happens when the measure is run | ||
def run(model, runner, user_arguments) | ||
super(model, runner, user_arguments) | ||
|
||
# use the built-in error checking | ||
if !runner.validateUserArguments(arguments(model), user_arguments) | ||
return false | ||
end | ||
|
||
# assign the user inputs to variables | ||
args = get_argument_values(runner, arguments(model), user_arguments) | ||
args = Hash[args.collect { |k, v| [k.to_sym, v] }] | ||
|
||
hpxml_path = args[:hpxml_path].get | ||
unless (Pathname.new hpxml_path).absolute? | ||
hpxml_path = File.expand_path(File.join(File.dirname(__FILE__), hpxml_path)) | ||
end | ||
unless File.exist?(hpxml_path) && hpxml_path.downcase.end_with?('.xml') | ||
fail "'#{hpxml_path}' does not exist or is not an .xml file." | ||
end | ||
|
||
_hpxml = HPXML.new(hpxml_path: hpxml_path) | ||
|
||
# init | ||
new_schedules = {} | ||
|
||
# TODO: populate new_schedules | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add the schedules here or is this section just a placeholder for future PRs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a placeholder for future PRs. |
||
|
||
# return if not writing schedules | ||
return true if new_schedules.empty? | ||
|
||
# write schedules | ||
schedules_filepath = File.join(File.dirname(args[:output_csv_path].get), 'schedules2.csv') | ||
write_new_schedules(new_schedules, schedules_filepath) | ||
|
||
# modify the hpxml with the schedules path | ||
doc = XMLHelper.parse_file(hpxml_path) | ||
extension = XMLHelper.create_elements_as_needed(XMLHelper.get_element(doc, '/HPXML'), ['SoftwareInfo', 'extension']) | ||
schedules_filepaths = XMLHelper.get_values(extension, 'SchedulesFilePath', :string) | ||
if !schedules_filepaths.include?(schedules_filepath) | ||
XMLHelper.add_element(extension, 'SchedulesFilePath', schedules_filepath, :string) | ||
|
||
# write out the modified hpxml | ||
XMLHelper.write_file(doc, hpxml_path) | ||
runner.registerInfo("Wrote file: #{hpxml_path}") | ||
end | ||
|
||
return true | ||
end | ||
|
||
def write_new_schedules(schedules, schedules_filepath) | ||
CSV.open(schedules_filepath, 'w') do |csv| | ||
csv << schedules.keys | ||
rows = schedules.values.transpose | ||
rows.each do |row| | ||
csv << row.map { |x| '%.3g' % x } | ||
end | ||
end | ||
end | ||
end | ||
|
||
# register the measure to be used by the application | ||
ResStockArgumentsPostHPXML.new.registerWithApplication |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the workflow makes sense. This allows for ResStock custom edits to the OS-HPXML workflow.