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.
29 30 31 32 33 34 35 36 37 |
# File 'lib/openstudio/workflow/jobs/run_reporting_measures.rb', line 29 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
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 |
# File 'lib/openstudio/workflow/jobs/run_reporting_measures.rb', line 39 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] # Load simulation files as required unless @registry[:runner].halted 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.exists?(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.exists?(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 |