| 105 | } |
| 106 | |
| 107 | void OSWorkflow::initializeWeatherFileFromOSW() { |
| 108 | LOG(Debug, "Initialize the weather file from osw"); |
| 109 | auto epwPath_ = workflowJSON.weatherFile(); |
| 110 | |
| 111 | if (epwPath_) { |
| 112 | LOG(Debug, "Search for weather file defined by osw " << epwPath_.get()); |
| 113 | auto epwFullPath_ = workflowJSON.findFile(epwPath_.get()); |
| 114 | if (!epwFullPath_) { |
| 115 | auto epwFullPath_ = workflowJSON.findFile(epwPath_->filename()); |
| 116 | } |
| 117 | if (!epwFullPath_) { |
| 118 | throw std::runtime_error(fmt::format("Weather file {} specified but cannot be found", epwPath_->string())); |
| 119 | } |
| 120 | |
| 121 | epwPath = epwFullPath_.get(); |
| 122 | |
| 123 | if (auto epwFile_ = openstudio::EpwFile::load(epwPath)) { |
| 124 | model::WeatherFile::setWeatherFile(model, epwFile_.get()); |
| 125 | runner.setLastEpwFilePath(epwPath); |
| 126 | } else { |
| 127 | LOG(Warn, "Could not load weather file from " << epwPath_.get()); |
| 128 | } |
| 129 | } else { |
| 130 | LOG(Debug, "No weather file specified in OSW, looking in model"); |
| 131 | updateLastWeatherFileFromModel(); |
| 132 | if (epwPath.empty()) { |
| 133 | LOG(Warn, "No valid weather file defined in either the osm or osw."); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | void OSWorkflow::updateLastWeatherFileFromModel() { |
| 139 | LOG(Debug, "Find model's weather file and update LastEpwFilePath"); |
nothing calls this directly
no test coverage detected