Class: RunReportingMeasures
- Inherits:
-
OpenStudio::Workflow::Job
- Object
- OpenStudio::Workflow::Job
- RunReportingMeasures
- Includes:
- OpenStudio::Workflow::Util::Measure, OpenStudio::Workflow::Util::Model, OpenStudio::Workflow::Util::PostProcess
- Defined in:
- lib/openstudio/workflow/jobs/run_reporting_measures.rb
Overview
Run reporting measures and execute scripts to post-process objective functions and results on the filesystem
Instance Method Summary collapse
-
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunReportingMeasures
constructor
A new instance of RunReportingMeasures.
- #perform ⇒ Object
Methods included from OpenStudio::Workflow::Util::PostProcess
#cleanup, #gather_reports, #load_sql_file, #rename_hash_keys, #run_extract_inputs_and_outputs
Methods included from OpenStudio::Workflow::Util::Measure
#add_result_measure_info, #apply_arguments, #apply_arguments_2, #apply_measure, #apply_measures, #validate_measures
Methods included from OpenStudio::Workflow::Util::Model
#load_idf, #load_osm, #save_idf, #save_osm, #translate_to_energyplus
Constructor Details
#initialize(input_adapter, output_adapter, registry, options = {}) ⇒ RunReportingMeasures
Returns a new instance of RunReportingMeasures.
47 48 49 50 51 52 53 54 55 |
# File 'lib/openstudio/workflow/jobs/run_reporting_measures.rb', line 47 def initialize(input_adapter, output_adapter, registry, = {}) defaults = { load_simulation_osm: false, load_simulation_idf: false, load_simulation_sql: false } = defaults.merge() super end |
Instance Method Details
#perform ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/openstudio/workflow/jobs/run_reporting_measures.rb', line 57 def perform @logger.debug "Calling #{__method__} in the #{self.class} class" @logger.debug 'RunPostProcess Retrieving datapoint and problem' # halted workflow is handled in apply_measures # Ensure output_attributes is initialized in the registry @registry.register(:output_attributes) { {} } unless @registry[:output_attributes] # get OSA[:urbanopt] #BLB should prob be sent in as cli arg and used in options but for now just do this @registry.register(:urbanopt) { false } if @registry[:osw_path] workflow = nil if File.exist? @registry[:osw_path] workflow = ::JSON.parse(File.read(@registry[:osw_path]), symbolize_names: true) if !workflow.nil? && !workflow[:urbanopt].nil? @registry.register(:urbanopt) { workflow[:urbanopt] } end end end # Load simulation files as required unless @registry[:runner].halted || @registry[:urbanopt] if @registry[:model].nil? osm_path = File.absolute_path(File.join(@registry[:run_dir], 'in.osm')) @logger.debug "Attempting to load #{osm_path}" @registry.register(:model) { load_osm('.', osm_path) } raise "Unable to load #{osm_path}" unless @registry[:model] @logger.debug "Successfully loaded #{osm_path}" end if @registry[:model_idf].nil? idf_path = File.absolute_path(File.join(@registry[:run_dir], 'in.idf')) @logger.debug "Attempting to load #{idf_path}" @registry.register(:model_idf) { load_idf(idf_path, @logger) } raise "Unable to load #{idf_path}" unless @registry[:model_idf] @logger.debug "Successfully loaded #{idf_path}" end if @registry[:sql].nil? sql_path = File.absolute_path(File.join(@registry[:run_dir], 'eplusout.sql')) if File.exist?(sql_path) @registry.register(:sql) { sql_path } @logger.debug "Registered the sql filepath as #{@registry[:sql]}" end # raise "Unable to load #{sql_path}" unless @registry[:sql] end if @registry[:wf].nil? epw_path = File.absolute_path(File.join(@registry[:run_dir], 'in.epw')) if File.exist?(epw_path) @registry.register(:wf) { epw_path } @logger.debug "Registered the wf filepath as #{@registry[:wf]}" end # raise "Unable to load #{epw_path}" unless @registry[:wf] end end # Apply reporting measures @options[:output_adapter] = @output_adapter @logger.info 'Beginning to execute Reporting measures.' apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options) @logger.info('Finished applying Reporting measures.') # Send the updated measure_attributes to the output adapter @logger.debug 'Communicating measures output attributes to the output adapter' @output_adapter.communicate_measure_attributes @registry[:output_attributes] # Parse the files generated by the local output adapter results, objective_functions = run_extract_inputs_and_outputs @registry[:run_dir], @logger @registry.register(:results) { results } # Send the objective function results to the output adapter @logger.debug "Objective Function JSON is #{objective_functions}" @output_adapter.communicate_objective_function objective_functions nil end |