-
Notifications
You must be signed in to change notification settings - Fork 83
New ResStockArgumentsPostHPXML measure #929
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
Merged
Merged
Changes from all commits
Commits
Show all changes
63 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 c010da9
Remove old CHANGELOG [skip ci]
rajeee 1d0b67d
Merge branch 'develop' into resstock-args-refactor
rajeee 05cdc4c
Use python 3.11 for CI
rajeee 8d088c4
Call ResStockArgumentsPostHPXML properly
rajeee d888168
Merge branch 'develop' into resstock-args-refactor
rajeee c4461a3
Merge branch 'latest-os-hpxml' into resstock-args-refactor
rajeee a05e619
Merge branch 'develop' into resstock-args-refactor
rajeee 3ac3388
Update argument
rajeee a289292
Merge branch 'no_lib' into resstock-args-refactor
rajeee e93126a
Correct ApplyUpgrade path
rajeee 543070d
Add warning to skip list
rajeee 6ca2340
Ignore some warnings
rajeee b708160
Merge branch 'no_lib' into resstock-args-refactor
rajeee 12f52ae
Update measures
rajeee 0e03076
Update measure xml files.
joseph-robertson 07af3bf
Update measure xml file.
joseph-robertson b7a6d6c
add test file
rajeee ad5bd14
Merge branch 'latest-os-hpxml' into resstock-args-refactor
rajeee a22fb63
update measures
rajeee 01129bf
Move changelog entry into correct folder.
joseph-robertson 27fe291
Update measure xml files.
joseph-robertson a2564f7
Few more minor changes.
joseph-robertson efed0d0
Add ResStockArgumentsPostHPXML lines back into ApplyUpgrade after bad…
joseph-robertson df0cd90
More cleanup.
joseph-robertson 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3827e629e35c9fbbbc53363b9886e22d | ||
| 357944431a5a88e46e2b12c30da3f703 |
This file contains hidden or 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,106 @@ | ||
| # 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 | ||
| 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('building_id', false) | ||
| arg.setDisplayName('Building Unit ID') | ||
| arg.setDescription('The building unit number (between 1 and the number of samples).') | ||
| 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 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 = runner.getArgumentValues(arguments(model), user_arguments) | ||
|
|
||
| hpxml_path = args[:hpxml_path] | ||
| 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 | ||
|
|
||
| # 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 | ||
This file contains hidden or 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,70 @@ | ||
| <?xml version="1.0"?> | ||
| <measure> | ||
| <schema_version>3.1</schema_version> | ||
| <name>res_stock_arguments_post_hpxml</name> | ||
| <uid>db102ce5-ac96-4ef9-90d3-abbe53478716</uid> | ||
| <version_id>6566f1b1-977e-47da-9d62-b4cd3fae0553</version_id> | ||
| <version_modified>2025-02-04T21:19:03Z</version_modified> | ||
| <xml_checksum>2C38F48B</xml_checksum> | ||
| <class_name>ResStockArgumentsPostHPXML</class_name> | ||
| <display_name>ResStock Arguments Post-HPXML</display_name> | ||
| <description>Measure that post-processes the output of the BuildResidentialHPXML and BuildResidentialScheduleFile measures.</description> | ||
| <modeler_description>Passes in all ResStockArgumentsPostHPXML arguments from the options lookup, processes them, and then modifies output of other measures.</modeler_description> | ||
| <arguments> | ||
| <argument> | ||
| <name>hpxml_path</name> | ||
| <display_name>HPXML File Path</display_name> | ||
| <description>Absolute/relative path of the HPXML file.</description> | ||
| <type>String</type> | ||
| <required>false</required> | ||
| <model_dependent>false</model_dependent> | ||
| </argument> | ||
| <argument> | ||
| <name>building_id</name> | ||
| <display_name>Building Unit ID</display_name> | ||
| <description>The building unit number (between 1 and the number of samples).</description> | ||
| <type>String</type> | ||
| <required>false</required> | ||
| <model_dependent>false</model_dependent> | ||
| </argument> | ||
| <argument> | ||
| <name>output_csv_path</name> | ||
| <display_name>Schedules: Output CSV Path</display_name> | ||
| <description>Absolute/relative path of the csv file containing occupancy schedules. Relative paths are relative to the HPXML output path.</description> | ||
| <type>String</type> | ||
| <required>false</required> | ||
| <model_dependent>false</model_dependent> | ||
| </argument> | ||
| </arguments> | ||
| <outputs /> | ||
| <provenances /> | ||
| <tags> | ||
| <tag>Whole Building.Space Types</tag> | ||
| </tags> | ||
| <attributes> | ||
| <attribute> | ||
| <name>Measure Type</name> | ||
| <value>ModelMeasure</value> | ||
| <datatype>string</datatype> | ||
| </attribute> | ||
| </attributes> | ||
| <files> | ||
| <file> | ||
| <version> | ||
| <software_program>OpenStudio</software_program> | ||
| <identifier>3.3.0</identifier> | ||
| <min_compatible>3.3.0</min_compatible> | ||
| </version> | ||
| <filename>measure.rb</filename> | ||
| <filetype>rb</filetype> | ||
| <usage_type>script</usage_type> | ||
| <checksum>A81E9245</checksum> | ||
| </file> | ||
| <file> | ||
| <filename>test_resstock_arguments_post_hpxml.rb</filename> | ||
| <filetype>rb</filetype> | ||
| <usage_type>test</usage_type> | ||
| <checksum>31C4A0A8</checksum> | ||
| </file> | ||
| </files> | ||
| </measure> |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a placeholder for future PRs.