lib/openstudio/analysis.rb in openstudio-analysis-0.4.4 vs lib/openstudio/analysis.rb in openstudio-analysis-0.4.5

- old
+ new

@@ -18,7 +18,41 @@ def self.from_excel(filename) excel = OpenStudio::Analysis::Translator::Excel.new(filename) excel.process excel.analyses end + + # Load an set of batch datapoints from a csv. This will create a analysis + # of type 'batch_datapoints' which requires 'batch_run' + def self.from_csv(filename) + csv = OpenStudio::Analysis::Translator::Datapoints.new(filename) + csv.process + csv.analysis + end + + # Retrieve aws instance options from a project. This will return a hash + def self.aws_instance_options(filename) + if File.extname(filename) == '.xlsx' + excel = OpenStudio::Analysis::Translator::Excel.new(filename) + excel.process + options = { + os_server_version: excel.settings['openstudio_server_version'], + server_instance_type: excel.settings['server_instance_type'], + worker_instance_type: excel.settings['worker_instance_type'], + worker_node_number: excel.settings['worker_nodes'].to_i, + user_id: excel.settings['user_id'], + aws_tags: excel.aws_tags, + analysis_type: excel.analyses.first.analysis_type, + cluster_name: excel.cluster_name + } + elsif File.extname(filename) == '.csv' + csv = OpenStudio::Analysis::Translator::Datapoints.new(filename) + csv.process + options = csv.settings + else + fail 'Invalid file extension' + end + + return options + end end end