Skip to content

Commit d10efea

Browse files
authored
Merge pull request #1952 from NREL/unknown_columns
Let through unknown columns with a warning
2 parents eadf702 + 6244d97 commit d10efea

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ __New Features__
1414
- Output updates:
1515
- **Breaking change**: Adds generator electricity produced to *total* fuel/energy use; previously it was only included in *net* values.
1616
- Adds new outputs for *net* peak electricity (summer/winter/annual); same as *total* peak electricity outputs but subtracts power produced by PV.
17+
- Allows arbitrary columns to be present in a detailed schedule csv file with warning.
1718

1819
__Bugfixes__
1920
- Fixes zero occupants specified for one unit in a whole MF building from being treated like zero occupants for every unit.

HPXMLtoOpenStudio/measure.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<schema_version>3.1</schema_version>
44
<name>hpxm_lto_openstudio</name>
55
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
6-
<version_id>66547fd4-aed2-4018-b62c-b42f1be47c6f</version_id>
7-
<version_modified>2025-03-12T01:36:17Z</version_modified>
6+
<version_id>32de2cef-2381-4f59-83d6-68aa71e42a49</version_id>
7+
<version_modified>2025-03-13T00:04:23Z</version_modified>
88
<xml_checksum>D8922A73</xml_checksum>
99
<class_name>HPXMLtoOpenStudio</class_name>
1010
<display_name>HPXML to OpenStudio Translator</display_name>
@@ -633,7 +633,7 @@
633633
<filename>schedules.rb</filename>
634634
<filetype>rb</filetype>
635635
<usage_type>resource</usage_type>
636-
<checksum>D2EF0FF6</checksum>
636+
<checksum>BA4E17C6</checksum>
637637
</file>
638638
<file>
639639
<filename>simcontrols.rb</filename>
@@ -783,7 +783,7 @@
783783
<filename>test_validation.rb</filename>
784784
<filetype>rb</filetype>
785785
<usage_type>test</usage_type>
786-
<checksum>06CA5017</checksum>
786+
<checksum>F43A4E45</checksum>
787787
</file>
788788
<file>
789789
<filename>test_vehicle.rb</filename>

HPXMLtoOpenStudio/resources/schedules.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ def initialize(runner: nil,
10451045
return if schedules_paths.empty?
10461046

10471047
@year = year
1048-
import(schedules_paths)
1048+
import(runner, schedules_paths)
10491049
create_battery_charging_discharging_schedules
10501050
expand_schedules
10511051
@tmp_schedules = Marshal.load(Marshal.dump(@schedules)) # make a deep copy because we use unmodified schedules downstream
@@ -1080,11 +1080,13 @@ def includes_col_name(col_name)
10801080
return false
10811081
end
10821082

1083-
# Assemble schedules from all detailed schedule CSVs into a hash.
1083+
# Assemble schedules from all detailed schedule CSVs into a hash and perform various
1084+
# error-checks and data validation.
10841085
#
1086+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
10851087
# @param schedules_paths [Array<String>] array of file paths pointing to detailed schedule CSVs
10861088
# @return [nil]
1087-
def import(schedules_paths)
1089+
def import(runner, schedules_paths)
10881090
num_hrs_in_year = Calendar.num_hours_in_year(@year)
10891091
@schedules = {}
10901092
schedules_paths.each do |schedules_path|
@@ -1093,7 +1095,11 @@ def import(schedules_paths)
10931095
columns.each do |col|
10941096
col_name = col[0]
10951097
column = Columns.values.find { |c| c.name == col_name }
1096-
1098+
if column.nil?
1099+
@schedules[col_name] = col[1..-1]
1100+
runner.registerWarning("Unknown column found in schedule file: #{col_name}. [context: #{schedules_path}]")
1101+
next
1102+
end
10971103
values = col[1..-1].reject { |v| v.nil? }
10981104

10991105
begin

HPXMLtoOpenStudio/tests/test_validation.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,8 @@ def test_ruby_warning_messages
18641864
'schedule-file-and-operating-mode' => ["Both 'water_heater_operating_mode' schedule file and operating mode provided; the latter will be ignored."],
18651865
'schedule-file-max-power-ratio-with-single-speed-system' => ['Maximum power ratio schedule is only supported for variable speed systems.'],
18661866
'schedule-file-max-power-ratio-with-two-speed-system' => ['Maximum power ratio schedule is only supported for variable speed systems.'],
1867-
'schedule-file-max-power-ratio-with-separate-backup-system' => ['Maximum power ratio schedule is only supported for integrated backup system. Schedule is ignored for heating.'] }
1867+
'schedule-file-max-power-ratio-with-separate-backup-system' => ['Maximum power ratio schedule is only supported for integrated backup system. Schedule is ignored for heating.'],
1868+
'schedule-file-unknown-columns' => ['Unknown column found in schedule file: unknown_column'] }
18681869

18691870
all_expected_warnings.each_with_index do |(warning_case, expected_warnings), i|
18701871
puts "[#{i + 1}/#{all_expected_warnings.size}] Testing #{warning_case}..."
@@ -2016,6 +2017,12 @@ def test_ruby_warning_messages
20162017
when 'schedule-file-max-power-ratio-with-separate-backup-system'
20172018
hpxml, hpxml_bldg = _create_hpxml('base-hvac-air-to-air-heat-pump-var-speed-backup-boiler.xml')
20182019
hpxml_bldg.header.schedules_filepaths << File.join(File.dirname(__FILE__), '../resources/schedule_files/hvac-variable-system-maximum-power-ratios-varied.csv')
2020+
when 'schedule-file-unknown-columns'
2021+
hpxml, hpxml_bldg = _create_hpxml('base-schedules-detailed-occupancy-stochastic.xml')
2022+
csv_data = CSV.read(File.join(File.dirname(hpxml.hpxml_path), hpxml_bldg.header.schedules_filepaths[0]))
2023+
csv_data[0][csv_data[0].find_index('lighting_interior')] = 'unknown_column'
2024+
File.write(@tmp_csv_path, csv_data.map(&:to_csv).join)
2025+
hpxml_bldg.header.schedules_filepaths = [@tmp_csv_path]
20192026
else
20202027
fail "Unhandled case: #{warning_case}."
20212028
end

0 commit comments

Comments
 (0)