Skip to content

Commit

Permalink
Merge pull request #90 from NREL/rakefile_updates
Browse files Browse the repository at this point in the history
Remove non-linux binaries from sam sdk zip on copy_beopt_files rake t…
  • Loading branch information
joseph-robertson committed Sep 22, 2017
2 parents ae4aa93 + 7ce6616 commit e75003d
Show file tree
Hide file tree
Showing 22 changed files with 297 additions and 8,957 deletions.
20 changes: 20 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Bundler.setup
desc 'Copy measures/osms from OpenStudio-BEopt repo'
task :copy_beopt_files do
require 'fileutils'
require 'openstudio'

# TODO: Should really grab latest from https://github.com/NREL/OpenStudio-BEopt/archive/master.zip
beopt_measures_dir = File.join(File.dirname(__FILE__), "..", "OpenStudio-BEopt", "measures")
Expand Down Expand Up @@ -77,6 +78,20 @@ task :copy_beopt_files do
FileUtils.rm_rf("#{buildstock_measure_subdir}/.", secure: true)
end
end
if other_measure == "UtilityBillCalculations"
["resources"].each do |subdir|
buildstock_measure_subdir = File.join(buildstock_measures_dir, other_measure, subdir)
unzip_file = OpenStudio::UnzipFile.new(File.join(buildstock_measure_subdir, "sam-sdk-2017-1-17-r1.zip"))
unzip_file.extractAllFiles(OpenStudio::toPath(File.join(buildstock_measure_subdir, "sam-sdk-2017-1-17-r1")))
["osx64", "win32", "win64"].each do |platform|
FileUtils.rm_rf(File.join(buildstock_measure_subdir, "sam-sdk-2017-1-17-r1", platform))
end
sam_sdk_zip = OpenStudio::toPath(File.join(buildstock_measure_subdir, "sam-sdk-2017-1-17-r1.zip"))
zip_file = OpenStudio::ZipFile.new(sam_sdk_zip, false)
zip_file.addDirectory(File.join(buildstock_measure_subdir, "sam-sdk-2017-1-17-r1"), OpenStudio::toPath("/"))
FileUtils.rm_rf(File.join(buildstock_measure_subdir, "sam-sdk-2017-1-17-r1"))
end
end
end
end

Expand Down Expand Up @@ -122,6 +137,11 @@ task :integrity_check_resstock_comed do
integrity_check(['project_resstock_comed'])
end # rake task

desc 'Perform integrity check on inputs for project_resstock_efs'
task :integrity_check_resstock_efs do
integrity_check(['project_resstock_efs'])
end # rake task

def integrity_check(project_dir_names=nil)
require 'openstudio'

Expand Down
101 changes: 95 additions & 6 deletions measures/TimeseriesCSVExport/measure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ def end_uses
]

return end_uses
end
end

def output_vars
output_vars = [
'Zone Mean Air Temperature',
'Zone Mean Air Humidity Ratio',
'Fan Runtime Fraction'
]

return output_vars
end

# define the arguments that the user will input
def arguments()
Expand All @@ -77,6 +87,12 @@ def arguments()

# TODO: argument for subset of output meters

#make an argument for including optional output variables
inc_output_variables = OpenStudio::Measure::OSArgument::makeBoolArgument("inc_output_variables", true)
inc_output_variables.setDisplayName("Include Output Variables")
inc_output_variables.setDefaultValue(false)
args << inc_output_variables

return args
end

Expand All @@ -87,6 +103,7 @@ def energyPlusOutputRequests(runner, user_arguments)
result = OpenStudio::IdfObjectVector.new

reporting_frequency = runner.getStringArgumentValue("reporting_frequency",user_arguments)
inc_output_variables = runner.getBoolArgumentValue("inc_output_variables",user_arguments)

# Request the output for each end use/fuel type combination
end_uses.each do |end_use|
Expand All @@ -100,6 +117,13 @@ def energyPlusOutputRequests(runner, user_arguments)
end
end

# Request the output for each variable
if inc_output_variables
output_vars.each do |output_var|
result << OpenStudio::IdfObject.load("Output:Variable,#{output_var},#{reporting_frequency},*;").get
end
end

return result
end

Expand All @@ -114,6 +138,7 @@ def run(runner, user_arguments)

# Assign the user inputs to variables
reporting_frequency = runner.getStringArgumentValue("reporting_frequency",user_arguments)
inc_output_variables = runner.getBoolArgumentValue("inc_output_variables",user_arguments)

# get the last model and sql file
model = runner.lastOpenStudioModel
Expand All @@ -122,6 +147,7 @@ def run(runner, user_arguments)
return false
end
model = model.get
epw_file = OpenStudio::EpwFile.new(File.expand_path(model.getWeatherFile.path.get.to_s))

sql = runner.lastEnergyPlusSqlFile
if sql.empty?
Expand Down Expand Up @@ -153,7 +179,7 @@ def run(runner, user_arguments)
# 2009-May-14 00:10:00 Raw string
# Javascript time
# 2009/07/12 12:34:56
def to_JSTime(os_time)
def to_JSTime(os_time, year_description)
js_time = os_time.to_s
# Replace the '-' with '/'
js_time = js_time.gsub('-','/')
Expand All @@ -170,7 +196,57 @@ def to_JSTime(os_time)
js_time = js_time.gsub('Oct','10')
js_time = js_time.gsub('Nov','11')
js_time = js_time.gsub('Dec','12')


# manually shift timestamps for leap years
if year_description.isLeapYear
date, time = js_time.split(" ")
year, month, day = date.split("/")
year = year.to_f
month = month.to_f
day = day.to_f
if not ( month == 1 and year == 2009 ) and not ( month == 2 and year == 2009 )
day -= 1
if day == 0
month -= 1
if month == 0
month = 12
day = 31
elsif month == 1
day = 31
elsif month == 2
day = 29
elsif month == 3
day = 31
elsif month == 4
day = 28
elsif month == 5
day = 31
elsif month == 6
day = 30
elsif month == 7
day = 31
elsif month == 8
day = 31
elsif month == 9
day = 30
elsif month == 10
day = 31
elsif month == 11
day = 30
end
end
end
js_time = "#{year.to_i}/#{month.to_i.to_s.rjust(2, "0")}/#{day.to_i.to_s.rjust(2, "0")} #{time}"
offset = 0
if month == 1 and year == 2010
offset = 1
end
end

unless year_description.calendarYear.empty?
js_time[0..3] = (year_description.calendarYear.get + offset).to_i.to_s
end

return js_time

end
Expand All @@ -188,6 +264,14 @@ def to_JSTime(os_time)
runner.registerInfo("Exporting #{variable_name}")
end
end
if inc_output_variables
output_vars.each do |output_var|
sql.availableKeyValues(ann_env_pd, reporting_frequency, output_var).each do |key_value|
variables_to_graph << [output_var, reporting_frequency, key_value]
runner.registerInfo("Exporting #{key_value} #{output_var}")
end
end
end

# Create a new series like this
# for each condition series we want to plot
Expand Down Expand Up @@ -227,11 +311,16 @@ def to_JSTime(os_time)
y_timeseries = y_timeseries.get
end
y_vals = y_timeseries.values

# Convert time stamp format to be more readable

# Convert time stamp format to be more readable
year_description = model.getYearDescription
unless epw_file.startDateActualYear.empty?
year_description.setCalendarYear(epw_file.startDateActualYear.get)
end

js_date_times = []
y_timeseries.dateTimes.each do |date_time|
js_date_times << to_JSTime(date_time)
js_date_times << to_JSTime(date_time, year_description)
end

# Store the timeseries data to hash for later
Expand Down
48 changes: 45 additions & 3 deletions measures/TimeseriesCSVExport/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>timeseries_csv_export</name>
<uid>2a3442c1-944d-4e91-9e11-11e0cf368c64</uid>
<version_id>c4c38900-8772-4e53-8683-df6d49a3794e</version_id>
<version_modified>20170913T174723Z</version_modified>
<version_id>00b4e8f5-340c-491c-a123-0b161179b50d</version_id>
<version_modified>20170914T175619Z</version_modified>
<xml_checksum>15BF4E57</xml_checksum>
<class_name>TimeseriesCSVExport</class_name>
<display_name>Timeseries CSV Export</display_name>
Expand Down Expand Up @@ -44,6 +44,24 @@
</choice>
</choices>
</argument>
<argument>
<name>inc_output_variables</name>
<display_name>Include Output Variables</display_name>
<type>Boolean</type>
<required>true</required>
<model_dependent>false</model_dependent>
<default_value>false</default_value>
<choices>
<choice>
<value>true</value>
<display_name>true</display_name>
</choice>
<choice>
<value>false</value>
<display_name>false</display_name>
</choice>
</choices>
</argument>
</arguments>
<outputs/>
<provenances/>
Expand All @@ -67,7 +85,31 @@
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>00D3F7C6</checksum>
<checksum>74F2FACB</checksum>
</file>
<file>
<filename>DuPage_17043_725300_880860.epw</filename>
<filetype>epw</filetype>
<usage_type>resource</usage_type>
<checksum>AD5BB8D6</checksum>
</file>
<file>
<filename>timeseries_csv_export_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>85934CF9</checksum>
</file>
<file>
<filename>SFD_Successful_EnergyPlus_Run.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>2EA0987A</checksum>
</file>
<file>
<filename>USA_CO_Denver_Intl_AP_725650_TMY3.epw</filename>
<filetype>epw</filetype>
<usage_type>resource</usage_type>
<checksum>E23378AA</checksum>
</file>
</files>
</measure>
Binary file not shown.
38 changes: 19 additions & 19 deletions resources/measures/ResidentialAirflow/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>residential_airflow</name>
<uid>7d2adf5c-9995-49be-b662-a23d2452bb36</uid>
<version_id>aaa5759e-457d-475e-b439-c78479a848b9</version_id>
<version_modified>20170906T152559Z</version_modified>
<version_id>9d6cb0e0-d49c-47d0-a9bc-bf18e6b37614</version_id>
<version_modified>20170914T174000Z</version_modified>
<xml_checksum>19EEDBBB</xml_checksum>
<class_name>ResidentialAirflow</class_name>
<display_name>Set Residential Airflow</display_name>
Expand Down Expand Up @@ -683,12 +683,6 @@
<usage_type>resource</usage_type>
<checksum>20190C86</checksum>
</file>
<file>
<filename>residential_airflow_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>16BEB73E</checksum>
</file>
<file>
<filename>util.rb</filename>
<filetype>rb</filetype>
Expand All @@ -701,17 +695,6 @@
<usage_type>resource</usage_type>
<checksum>B34275B6</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>1.13.1</identifier>
<min_compatible>2.0.4</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>DA9FA8E6</checksum>
</file>
<file>
<filename>airflow.rb</filename>
<filetype>rb</filetype>
Expand Down Expand Up @@ -814,5 +797,22 @@
<usage_type>resource</usage_type>
<checksum>8F96C373</checksum>
</file>
<file>
<filename>residential_airflow_test.rb</filename>
<filetype>rb</filetype>
<usage_type>test</usage_type>
<checksum>2C665EA0</checksum>
</file>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>1.13.1</identifier>
<min_compatible>2.0.4</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>F9977BB0</checksum>
</file>
</files>
</measure>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<schema_version>3.0</schema_version>
<name>process_single_speed_air_source_heat_pump</name>
<uid>9f709cf6-cf55-4bb3-8087-7a5c5a98aa7c</uid>
<version_id>b75719cf-90d2-4c18-a0fb-5d64bcae11f1</version_id>
<version_modified>20170731T151915Z</version_modified>
<version_id>e0936530-1493-4335-a24a-a27161226175</version_id>
<version_modified>20170914T175612Z</version_modified>
<xml_checksum>0DA5C9E6</xml_checksum>
<class_name>ProcessSingleSpeedAirSourceHeatPump</class_name>
<display_name>Set Residential Single-Speed Air Source Heat Pump</display_name>
Expand Down Expand Up @@ -337,12 +337,6 @@
<usage_type>test</usage_type>
<checksum>CDE07A35</checksum>
</file>
<file>
<filename>SFD_2000sqft_2story_FB_UA_Denver_Furnace.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>133820CF</checksum>
</file>
<file>
<filename>SFD_2000sqft_2story_FB_UA_Denver_Furnace_CentralAC.osm</filename>
<filetype>osm</filetype>
Expand Down Expand Up @@ -433,5 +427,11 @@
<usage_type>test</usage_type>
<checksum>AB27EEFB</checksum>
</file>
<file>
<filename>SFD_2000sqft_2story_FB_UA_Denver_Furnace.osm</filename>
<filetype>osm</filetype>
<usage_type>test</usage_type>
<checksum>CC349A6D</checksum>
</file>
</files>
</measure>

0 comments on commit e75003d

Please sign in to comment.