You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently discovered that if you run an OpenStudio Workflow using the CLI and that workflow contains the create_DOE_prototype_building, an error will occur within OpenstudioStandards.Weather.get_standards_weather_file_path on this line of code.
The issue is that the code is attempting to create a new directory with a leading : in the path, because __dir__, which is the root of the path is an embedded file in this case.
I believe the desired behavior is for the path root to be Dir.pwd.
I implemented a work around by including the following code at the top of my Measure.
module OpenstudioStandards
module Weather
def self.get_standards_weather_file_path(weather_file_name)
# Define where the weather files lives
weather_dir = nil
# load weather file from embedded files
epw_string = File.read(":/ruby/3.2.0/gems/openstudio-standards-0.7.0/data/weather/#{weather_file_name}")
ddy_string = File.read(":/ruby/3.2.0/gems/openstudio-standards-0.7.0/data/weather/#{weather_file_name.gsub('.epw', '.ddy')}")
stat_string = File.read(":/ruby/3.2.0/gems/openstudio-standards-0.7.0/data/weather/#{weather_file_name.gsub('.epw', '.stat')}")
# extract to local weather dir
weather_dir = File.expand_path(File.join(Dir.pwd, 'extracted_files/weather/'))
OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Weather.information', "Extracting weather files from OpenStudio CLI to #{weather_dir}")
FileUtils.mkdir_p(weather_dir)
path_length = "#{weather_dir}/#{weather_file_name}".length
if path_length > 260
OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Weather.information', "Weather file path length #{path_length} is >260 characters and may cause issues in Windows environments.")
end
File.open("#{weather_dir}/#{weather_file_name}", 'wb') do |f|
f.write(epw_string)
#f.flush
end
File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.ddy')}", 'wb') do |f|
f.write(ddy_string)
#f.flush
end
File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.stat')}", 'wb') do |f|
f.write(stat_string)
#f.flush
end
# Add Weather File
unless (Pathname.new weather_dir).absolute?
weather_dir = File.expand_path(File.join(File.dirname(__FILE__), weather_dir))
end
weather_file_path = File.join(weather_dir, weather_file_name)
return weather_file_path
end
end
end
The text was updated successfully, but these errors were encountered:
I recently discovered that if you run an OpenStudio Workflow using the CLI and that workflow contains the
create_DOE_prototype_building
, an error will occur withinOpenstudioStandards.Weather.get_standards_weather_file_path
on this line of code.The issue is that the code is attempting to create a new directory with a leading
:
in the path, because__dir__
, which is the root of the path is an embedded file in this case.I believe the desired behavior is for the path root to be Dir.pwd.
I implemented a work around by including the following code at the top of my Measure.
The text was updated successfully, but these errors were encountered: