Files OpenStudioPostProcessJob::outputFilesImpl() const { // Dan: what's the output files generated? if (!boost::filesystem::exists(outdir() / toPath("report.xml"))) { // no output file has been generated yet return Files(); } Files f; f.append(FileInfo(outdir() / toPath("report.xml"), "xml")); return f; }
void NullJob::startImpl(const std::shared_ptr<ProcessCreator> &) { LOG(Info, "Null starting"); { QMutexLocker l(&m_mutex); } emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); openstudio::path outpath; try { outpath = outdir(true); boost::filesystem::create_directories(outpath); setErrors(JobErrors(ruleset::OSResultValue::Success, std::vector<std::pair<runmanager::ErrorType, std::string> >() )); } catch (const std::exception &e) { LOG(Error, "NullJob error starting job: " << e.what() << ". Job path is: " << toString(outpath)); std::vector<std::pair<runmanager::ErrorType, std::string> > err; err.push_back(std::make_pair(runmanager::ErrorType::Error, e.what())); setErrors(JobErrors(ruleset::OSResultValue::Fail, err)); } }
void PreviewIESJob::startHandlerImpl() { LOG(Debug, "Starting job"); getFiles(allInputFiles()); openstudio::path theoutdir = boost::filesystem::complete(outdir(true)); boost::filesystem::create_directories(theoutdir); addParameter("ies2rad", "-o"); addParameter("ies2rad", "ov"); addParameter("ies2rad", toString(theoutdir/toPath("in.ies"))); addParameter("rad", toString(theoutdir/toPath("ov.rif"))); addParameter("ra_image", "-z"); addParameter("ra_image", "-b"); addParameter("ra_image", "ov_y.hdr"); #ifdef Q_OS_WIN addParameter("ra_image", "out.bmp"); #else addParameter("ra_image", "out.tiff"); #endif // copy ies to "in.ies" addRequiredFile(*m_ies, toPath("in.ies")); writeSurfFile(theoutdir/toPath("surf.rad"), 24); writeRifFile(theoutdir/toPath("ov.rif"), theoutdir/toPath("ov.rad"), theoutdir/toPath("surf.rad"), "Z", "y", theoutdir/toPath("ov.oct"), "-ab 1 -ds .15"); }
Files ModelToRadPreProcessJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.osm")) || !m_osm) { // no output file has been generated yet return Files(); } Files f; FileInfo fi(outpath / toPath("out.osm"), "osm"); fi.requiredFiles = m_osm->requiredFiles; if (!fi.hasRequiredFile(openstudio::toPath("in.epw"))) { /// \todo we need better handling of OSM files and their attachments // epw wasn't found, look for parent one openstudio::path possibleepw = m_osm->fullPath.parent_path() / openstudio::toPath("in.epw"); if (boost::filesystem::exists(possibleepw)) { LOG(Info, "Fixing up EPW file for incoming OSM attachment to " << openstudio::toString(possibleepw)); fi.addRequiredFile(possibleepw, openstudio::toPath("in.epw")); } } f.append(fi); return f; }
void SlabJob::endHandlerImpl() { openstudio::path outpath = outdir(); openstudio::path epobjects(outpath / openstudio::toPath("SLABSurfaceTemps.TXT")); openstudio::path outfile = outpath / openstudio::toPath("slabmerged.idf"); LOG(Debug, "Copying file: " << openstudio::toString(m_expandedidf->fullPath) << " to " << openstudio::toString(outfile)); boost::filesystem::remove(outfile); boost::filesystem::copy_file(m_expandedidf->fullPath, outfile, boost::filesystem::copy_option::overwrite_if_exists); std::fstream f(openstudio::toString(epobjects).c_str(), std::fstream::in|std::fstream::binary); f << std::noskipws; std::istream_iterator<unsigned char> begin(f); std::istream_iterator<unsigned char> end; std::fstream f2(openstudio::toString(outfile).c_str(), std::fstream::out|std::fstream::app|std::fstream::binary); std::ostream_iterator<char> begin2(f2); LOG(Debug, "Appending file: " << openstudio::toString(epobjects) << " to " << openstudio::toString(outfile)); std::copy(begin, end, begin2); }
Files BasementJob::outputFilesHandlerImpl() const { FileInfo fi(outdir() / openstudio::toPath("basementmerged.idf"), "idf"); fi.requiredFiles = m_expandedidf->requiredFiles; Files f; f.append(fi); return f; }
int main(int argc, char *argv[]) { if (argc < 2 || argc > 4) { std::cout << "PCTC version " << CONVERTERVERSION << "\n" << "Usage: pctc name inputfile\n\n" << "Converts a Jazz Jackrabbit 2 tileset file (.j2t) to the native, multiple file\n" << "based format recognized by Project Carrot.\n\n" << "Parameters:\n" << " name Optional. The unique identifying name of this tileset. Use only\n" << " Latin letters, numbers and underscores. For the purposes of\n" << " being cross platform compliant, identifiers are case\n" << " insensitive.\n" << " If omitted, the name of the input file is used.\n" << " inputfile Required. Complete or relative path to a J2T format file to be\n" << " converted.\n"; return EXIT_FAILURE; } QString uniqueID; QString filename; if (argc == 3) { uniqueID = argv[1]; filename = argv[2]; } else { filename = argv[1]; uniqueID = QFileInfo(filename).baseName(); } QDir outdir(QDir::current()); if (!outdir.mkdir(uniqueID)) { int idx = 0; while (!outdir.mkdir(uniqueID + "_" + QString::number(idx))) { idx++; } outdir.cd(uniqueID + "_" + QString::number(idx)); } else { outdir.cd(uniqueID); } try { std::cout << "Converting \"" << filename.toStdString() << "\" to Project Carrot tileset \"" << uniqueID.toStdString() << "\"...\n"; PCTilesetConverter::convert(filename, uniqueID, outdir); std::cout << "\nTileset converted successfully.\n" << "Press Enter to continue...\n"; } catch (Jazz2FormatParseException e) { std::cout << "ERROR: " << e.friendlyText().toStdString() << "\n"; getchar(); return EXIT_FAILURE; } catch (...) { std::cout << "Aborting conversion...\n"; getchar(); return EXIT_FAILURE; } getchar(); return EXIT_SUCCESS; }
void BasementJob::endHandlerImpl() { openstudio::path epobjects(outdir() / openstudio::toPath("EPObjects.TXT")); openstudio::path outfile = outdir() / openstudio::toPath("basementmerged.idf"); boost::filesystem::remove(outfile); boost::filesystem::copy_file(m_expandedidf->fullPath, outfile, boost::filesystem::copy_option::overwrite_if_exists); std::fstream f(openstudio::toString(epobjects).c_str(), std::fstream::in|std::fstream::binary); f << std::noskipws; std::istream_iterator<unsigned char> begin(f); std::istream_iterator<unsigned char> end; std::fstream f2(openstudio::toString(outfile).c_str(), std::fstream::out|std::fstream::app|std::fstream::binary); std::ostream_iterator<char> begin2(f2); std::copy(begin, end, begin2); }
/** -------------------------------------------------------- process_output_dir * Removing trailing '/' if nessary. Also, replace empty string with "." * It is okay to pass NULL to this function. */ SmartArray<char> process_output_dir(const char* output_dir) { // Work out the output directory -- make sure there is no trailing '/' SmartArray<char> outdir((output_dir ? (strlen(output_dir) + 2) : 0)); if(output_dir) { char* ptr = outdir.ptr(); char* end = outdir.ptr() + outdir.size(); ptr += snprintf(ptr, ptr - end, "%s", output_dir); if(strcmp("", output_dir) == 0) ptr += snprintf(ptr, ptr - end, "."); if(ptr[-1] == '/') ptr[-1] = '\0'; } return outdir; }
void RunPP(const char *jobid="test") { Int_t nev=99999999; //TString input0("/star/u/russcher/gamma/analysis/data/pp05/ppProduction.root"); TString input0("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_0.root"); TString input1("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_1.root"); TString input2("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_2.root"); TString input3("/star/u/russcher/gamma/analysis/data/pp05/ppProduction_rcf_3.root"); TString input4("/star/u/russcher/gamma/analysis/data/pp05/ppProductionMinBias.root"); TString outdir("/star/u/russcher/gamma/analysis/output/pp05/"); TString psout("pi0_pp05.ps"); TString psout2("eta_pp05.ps"); TString rootout("pi0_pp05.root"); psout.Prepend(jobid); rootout.Prepend(jobid); TString command("mkdir "); command.Append(outdir.Data()); command.Append(jobid); gSystem->Exec(command.Data()); cout<<endl<<"storing results in: "<<command.Data()<<endl<<endl; outdir.Append(jobid); outdir.Append("/"); psout.Prepend(outdir.Data()); psout2.Prepend(outdir.Data()); rootout.Prepend(outdir.Data()); gSystem->Load("$HOME/MyEvent/MyEvent.so"); gSystem->Load("$HOME/gamma/analysis/lib/AnaCuts.so"); gSystem->Load("$HOME/gamma/analysis/lib/EventMixer.so"); gSystem->Load("$HOME/gamma/analysis/lib/Pi0Analysis.so"); Pi0Analysis *pi0=new Pi0Analysis(psout.Data(),psout2.Data(),"pp05"); pi0->setMC(kFALSE); pi0->init(rootout.Data()); pi0->make(nev,input0.Data()); pi0->make(nev,input1.Data()); pi0->make(nev,input2.Data()); pi0->make(nev,input3.Data()); pi0->printPrescales(); cout<<"****** starting with minbias *********"<<endl; pi0->make(nev,input4.Data()); pi0->printPrescales(); pi0->getYield(); pi0->finish(); }
Files ModelInModelOutJob::outputFilesImpl() const { Files outfiles; try { FileInfo osm(outdir() / toPath("out.osm"), "osm"); osm.requiredFiles = modelFile().requiredFiles; outfiles.append(osm); } catch (const std::exception &) { //output file cannot be generated yet } return outfiles; }
Files ModelToRadPreProcessJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.osm")) || !m_osm) { // no output file has been generated yet return Files(); } Files f; FileInfo fi(outpath / toPath("out.osm"), "osm"); fi.requiredFiles = m_osm->requiredFiles; f.append(fi); return f; }
Files ModelToRadJob::outputFilesImpl() const { openstudio::path outpath = outdir(); QReadLocker l(&m_mutex); if (!boost::filesystem::exists(outpath / toPath("model.rad")) || !m_outputfiles) { // no output file has been generated yet return Files(); } return *m_outputfiles; }
Files IdfToModelJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.osm"))) { // no output file has been generated yet return Files(); } QWriteLocker l(&m_mutex); if (!m_outputfiles) { // check if model has a weather file object boost::optional<QUrl> weatherFilePath; try { FileInfo idfFile = this->idfFile(); try { std::pair<QUrl, openstudio::path> f = idfFile.getRequiredFile(toPath("in.epw")); LOG(Debug, "Setting user defined epw: " << toString(f.first.toString())); weatherFilePath = f.first; } catch (const std::exception &) { } // Specify the set of files we created so that the next Job in the chain (if there is one) // is able to pick them up Files outfiles; FileInfo osm(outpath / toPath("out.osm"), "osm"); if (weatherFilePath){ osm.addRequiredFile(*weatherFilePath, toPath("in.epw")); }else{ LOG(Warn, "No weather file specified"); } outfiles.append(osm); m_outputfiles = outfiles; } catch (const std::exception &) { LOG(Warn, "OSM file not yet available, outputfiles not known"); return Files(); } } return *m_outputfiles; }
void ParallelEnergyPlusSplitJob::startImpl(const std::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(); QWriteLocker l(&m_mutex); if (!m_input) { m_input = inputFile(); resetFiles(m_files, m_input); } LOG(Info, "ParallelEnergyPlusSplit starting, filename: " << toString(m_input->fullPath)); LOG(Info, "ParallelEnergyPlusSplit starting, outdir: " << toString(outpath)); JobErrors errors; errors.result = ruleset::OSResultValue::Success; l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); try { boost::filesystem::create_directories(outpath); FileInfo inputfile = inputFile(); openstudio::path input = inputfile.fullPath; LOG(Debug, "Splitting inputfile: " << toString(input) << " into " << m_numSplits << " parts"); std::vector<openstudio::path> outfilepaths = generateFileNames(outpath, m_numSplits); ParallelEnergyPlus p(input, m_numSplits, m_offset); for (int i = 0; i < m_numSplits; ++i) { p.writePartition(i, outfilepaths[i]); emitOutputFileChanged(RunManager_Util::dirFile(outfilepaths[i])); } } catch (const std::exception &e) { LOG(Debug, "Error executing split job: " << e.what()); errors.addError(ErrorType::Error, "Error with execution: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } setErrors(errors); }
Files EnergyPlusPreProcessJob::outputFilesImpl() const { openstudio::path outpath = outdir(); if (!boost::filesystem::exists(outpath / toPath("out.idf"))) { // no output file has been generated yet return Files(); } Files f; FileInfo fi(outpath / toPath("out.idf"), "idf"); if (m_idf) { fi.requiredFiles = m_idf->requiredFiles; } f.append(fi); return f; }
int main(int argc, const char* argv[]) { mutl::ArgumentParser parser; if ( false == parser.Initialize(argc, argv, descs, sizeof(descs)/sizeof(Desc)) ) { usage(); return 0; } if ( parser.IsEnabled("h") || parser.GetArgumentCount() < 2 ) { usage(); return 0; } const std::string input = parser.GetArgument(0); const std::string reference = parser.GetArgument(1); std::string outfile; std::string outdir("./"); if ( parser.IsEnabled("d") ) { outdir = parser.GetOption("d"); outdir += std::string("/"); } if ( parser.IsEnabled("o") ) { outfile = parser.GetOption("o"); } // Display messages real-time setvbuf(stdout, NULL, _IONBF, 0); LOG("Input: %s\n", input.c_str()); LOG("Impluse: %s\n", reference.c_str()); LOG("\n"); ConvoluteTwoWaveforms(input.c_str(), reference.c_str(), outdir, outfile); return 0; }
Files ParallelEnergyPlusSplitJob::outputFilesImpl() const { // Save off the set of requiredfiles, see below std::vector<std::pair<QUrl, openstudio::path> > requiredFiles = inputFile().requiredFiles; std::vector<openstudio::path> files = generateFileNames(outdir(), m_numSplits); Files retval; for (std::vector<openstudio::path>::const_iterator itr = files.begin(); itr != files.end(); ++itr) { if (boost::filesystem::exists(*itr)) { FileInfo fi = RunManager_Util::dirFile(*itr); // we want to carry along the set of required files used in the original IDF to the children // (ie, the epw file) fi.requiredFiles = requiredFiles; retval.append(fi); } } return retval; }
void EnergyPlusPreProcessJob::startImpl(const boost::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(); QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { m_idf = idfFile(); resetFiles(m_files, m_idf); } catch (const std::runtime_error &e) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, e.what()); } LOG(Info, "EnergyPlusPreProcess starting, outdir: " << toString(outpath)); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } try { boost::filesystem::create_directories(outdir(true)); bool needssqlobj = false; bool needsmonthlyoutput = false; { boost::optional<openstudio::Workspace> ws = openstudio::Workspace::load(m_idf->fullPath); if (!ws){ LOG_AND_THROW("Unable to load idf into workspace"); } std::vector<openstudio::WorkspaceObject> sqliteobjs = ws->getObjectsByType(IddObjectType::Output_SQLite); if (sqliteobjs.empty()) { // ws->addObject(IdfObject(IddObjectType::Output_SQLite)); needssqlobj = true; // sqliteobjs = ws->getObjectsByType(IddObjectType::Output_SQLite); } if (ws->getObjectsByName("Building Energy Performance - Natural Gas").empty() || ws->getObjectsByName("Building Energy Performance - Electricity").empty() || ws->getObjectsByName("Building Energy Performance - District Heating").empty() || ws->getObjectsByName("Building Energy Performance - District Cooling").empty() ) { needsmonthlyoutput = true; } } if (needssqlobj || needsmonthlyoutput) { openstudio::path outfile = outdir(true)/openstudio::toPath("out.idf"); if (boost::filesystem::exists(outfile)) { try { boost::filesystem::remove(outfile); } catch (const boost::filesystem::basic_filesystem_error<openstudio::path> &e) { LOG(Error, "Error removing existing out.idf file: " + std::string(e.what()) + " continuing with run, if copy_file errors, the process will fail"); } } boost::filesystem::copy_file(m_idf->fullPath, outfile, boost::filesystem::copy_option::overwrite_if_exists); std::ofstream ofs(openstudio::toString(outfile).c_str(), std::ios::app); if (needssqlobj) { ofs << "Output:SQLite," << std::endl; ofs << " SimpleAndTabular; ! Option Type" << std::endl; } if (needsmonthlyoutput) { //energy consumption ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - Electricity, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " InteriorLights:Electricity, !- Variable or Meter 1 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorLights:Electricity, !- Variable or Meter 2 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " InteriorEquipment:Electricity, !- Variable or Meter 3 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " ExteriorEquipment:Electricity, !- Variable or Meter 4 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " Fans:Electricity, !- Variable or Meter 5 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Pumps:Electricity, !- Variable or Meter 6 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << " Heating:Electricity, !- Variable or Meter 7 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 7" << std::endl; ofs << " Cooling:Electricity, !- Variable or Meter 8 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 8" << std::endl; ofs << " HeatRejection:Electricity, !- Variable or Meter 9 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 9" << std::endl; ofs << " Humidifier:Electricity, !- Variable or Meter 10 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 10" << std::endl; ofs << " HeatRecovery:Electricity,!- Variable or Meter 11 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 11" << std::endl; ofs << " WaterSystems:Electricity,!- Variable or Meter 12 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 12" << std::endl; ofs << " Cogeneration:Electricity,!- Variable or Meter 13 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 13" << std::endl; ofs << " Refrigeration:Electricity,!- Variable or Meter 14 Name" << std::endl; ofs << " SumOrAverage; !- Aggregation Type for Variable or Meter 14" << std::endl; ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - Natural Gas, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " InteriorEquipment:Gas, !- Variable or Meter 1 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorEquipment:Gas, !- Variable or Meter 2 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " Heating:Gas, !- Variable or Meter 3 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " Cooling:Gas, !- Variable or Meter 4 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " WaterSystems:Gas, !- Variable or Meter 5 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Cogeneration:Gas, !- Variable or Meter 6 Name" << std::endl; ofs << " SumOrAverage; !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - District Heating, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " InteriorLights:DistrictHeating, !- Variable or Meter 1 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorLights:DistrictHeating, !- Variable or Meter 2 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " InteriorEquipment:DistrictHeating, !- Variable or Meter 3 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " ExteriorEquipment:DistrictHeating, !- Variable or Meter 4 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " Fans:DistrictHeating, !- Variable or Meter 5 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Pumps:DistrictHeating, !- Variable or Meter 6 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << " Heating:DistrictHeating, !- Variable or Meter 7 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 7" << std::endl; ofs << " Cooling:DistrictHeating, !- Variable or Meter 8 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 8" << std::endl; ofs << " HeatRejection:DistrictHeating, !- Variable or Meter 9 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 9" << std::endl; ofs << " Humidifier:DistrictHeating, !- Variable or Meter 10 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 10" << std::endl; ofs << " HeatRecovery:DistrictHeating,!- Variable or Meter 11 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 11" << std::endl; ofs << " WaterSystems:DistrictHeating,!- Variable or Meter 12 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 12" << std::endl; ofs << " Cogeneration:DistrictHeating,!- Variable or Meter 13 Name" << std::endl; ofs << " SumOrAverage; !- Aggregation Type for Variable or Meter 13" << std::endl; ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - District Cooling, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " InteriorLights:DistrictCooling, !- Variable or Meter 1 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorLights:DistrictCooling, !- Variable or Meter 2 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " InteriorEquipment:DistrictCooling, !- Variable or Meter 3 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " ExteriorEquipment:DistrictCooling, !- Variable or Meter 4 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " Fans:DistrictCooling, !- Variable or Meter 5 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Pumps:DistrictCooling, !- Variable or Meter 6 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << " Heating:DistrictCooling, !- Variable or Meter 7 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 7" << std::endl; ofs << " Cooling:DistrictCooling, !- Variable or Meter 8 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 8" << std::endl; ofs << " HeatRejection:DistrictCooling, !- Variable or Meter 9 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 9" << std::endl; ofs << " Humidifier:DistrictCooling, !- Variable or Meter 10 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 10" << std::endl; ofs << " HeatRecovery:DistrictCooling,!- Variable or Meter 11 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 11" << std::endl; ofs << " WaterSystems:DistrictCooling,!- Variable or Meter 12 Name" << std::endl; ofs << " SumOrAverage, !- Aggregation Type for Variable or Meter 12" << std::endl; ofs << " Cogeneration:DistrictCooling,!- Variable or Meter 13 Name" << std::endl; ofs << " SumOrAverage; !- Aggregation Type for Variable or Meter 13" << std::endl; //energy demand ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - Electricity Peak Demand, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " Electricity:Facility, !- Variable or Meter 1 Name" << std::endl; ofs << " Maximum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " InteriorLights:Electricity, !- Variable or Meter 1 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorLights:Electricity, !- Variable or Meter 2 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " InteriorEquipment:Electricity, !- Variable or Meter 3 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " ExteriorEquipment:Electricity, !- Variable or Meter 4 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " Fans:Electricity, !- Variable or Meter 5 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Pumps:Electricity, !- Variable or Meter 6 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << " Heating:Electricity, !- Variable or Meter 7 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 7" << std::endl; ofs << " Cooling:Electricity, !- Variable or Meter 8 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 8" << std::endl; ofs << " HeatRejection:Electricity, !- Variable or Meter 9 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 9" << std::endl; ofs << " Humidifier:Electricity, !- Variable or Meter 10 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 10" << std::endl; ofs << " HeatRecovery:Electricity,!- Variable or Meter 11 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 11" << std::endl; ofs << " WaterSystems:Electricity,!- Variable or Meter 12 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 12" << std::endl; ofs << " Cogeneration:Electricity,!- Variable or Meter 13 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum; !- Aggregation Type for Variable or Meter 13" << std::endl; ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - Natural Gas Peak Demand, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " Gas:Facility, !- Variable or Meter 1 Name" << std::endl; ofs << " Maximum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " InteriorEquipment:Gas, !- Variable or Meter 1 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorEquipment:Gas, !- Variable or Meter 2 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " Heating:Gas, !- Variable or Meter 3 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " Cooling:Gas, !- Variable or Meter 4 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " WaterSystems:Gas, !- Variable or Meter 5 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Cogeneration:Gas, !- Variable or Meter 6 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum; !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - District Heating Peak Demand, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " DistrictHeating:Facility, !- Variable or Meter 1 Name" << std::endl; ofs << " Maximum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " InteriorLights:DistrictHeating, !- Variable or Meter 1 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorLights:DistrictHeating, !- Variable or Meter 2 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " InteriorEquipment:DistrictHeating, !- Variable or Meter 3 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " ExteriorEquipment:DistrictHeating, !- Variable or Meter 4 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " Fans:DistrictHeating, !- Variable or Meter 5 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Pumps:DistrictHeating, !- Variable or Meter 6 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << " Heating:DistrictHeating, !- Variable or Meter 7 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 7" << std::endl; ofs << " Cooling:DistrictHeating, !- Variable or Meter 8 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 8" << std::endl; ofs << " HeatRejection:DistrictHeating, !- Variable or Meter 9 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 9" << std::endl; ofs << " Humidifier:DistrictHeating, !- Variable or Meter 10 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 10" << std::endl; ofs << " HeatRecovery:DistrictHeating,!- Variable or Meter 11 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 11" << std::endl; ofs << " WaterSystems:DistrictHeating,!- Variable or Meter 12 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 12" << std::endl; ofs << " Cogeneration:DistrictHeating,!- Variable or Meter 13 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum; !- Aggregation Type for Variable or Meter 13" << std::endl; ofs << "Output:Table:Monthly," << std::endl; ofs << " Building Energy Performance - District Cooling Peak Demand, !- Name" << std::endl; ofs << " 2, !- Digits After Decimal" << std::endl; ofs << " DistrictCooling:Facility, !- Variable or Meter 1 Name" << std::endl; ofs << " Maximum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " InteriorLights:DistrictCooling, !- Variable or Meter 1 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 1" << std::endl; ofs << " ExteriorLights:DistrictCooling, !- Variable or Meter 2 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 2" << std::endl; ofs << " InteriorEquipment:DistrictCooling, !- Variable or Meter 3 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 3" << std::endl; ofs << " ExteriorEquipment:DistrictCooling, !- Variable or Meter 4 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 4" << std::endl; ofs << " Fans:DistrictCooling, !- Variable or Meter 5 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 5" << std::endl; ofs << " Pumps:DistrictCooling, !- Variable or Meter 6 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 6" << std::endl; ofs << " Heating:DistrictCooling, !- Variable or Meter 7 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 7" << std::endl; ofs << " Cooling:DistrictCooling, !- Variable or Meter 8 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 8" << std::endl; ofs << " HeatRejection:DistrictCooling, !- Variable or Meter 9 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 9" << std::endl; ofs << " Humidifier:DistrictCooling, !- Variable or Meter 10 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 10" << std::endl; ofs << " HeatRecovery:DistrictCooling,!- Variable or Meter 11 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 11" << std::endl; ofs << " WaterSystems:DistrictCooling,!- Variable or Meter 12 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum, !- Aggregation Type for Variable or Meter 12" << std::endl; ofs << " Cogeneration:DistrictCooling,!- Variable or Meter 13 Name" << std::endl; ofs << " ValueWhenMaximumOrMinimum; !- Aggregation Type for Variable or Meter 13" << std::endl; } //timestep-level utility demand by fuel type to calculate demand ofs << " Output:Meter,Electricity:Facility,Timestep; !- [J]" << std::endl; ofs << " Output:Meter,Gas:Facility,Timestep; !- [J]" << std::endl; ofs << " Output:Meter,DistrictCooling:Facility,Timestep; !- [J]" << std::endl; ofs << " Output:Meter,DistrictHeating:Facility,Timestep; !- [J]" << std::endl; ofs.flush(); ofs.close(); } } catch (const std::exception &e) { LOG(Error, "Error with EnergyPlusPreProcessJob: " + std::string(e.what())); errors.addError(ErrorType::Error, "Error with EnergyPlusPreProcessJob: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } emitOutputFileChanged(RunManager_Util::dirFile(outpath / openstudio::toPath("out.idf"))); setErrors(errors); }
void ModelInModelOutJob::startImpl(const std::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(true); QWriteLocker l(&m_mutex); if (!m_model) { m_model = modelFile(); resetFiles(m_files, m_model); } std::vector<std::shared_ptr<ModelInModelOutJob> > mergedJobs = m_mergedJobs; boost::optional<FileInfo> model = m_model; LOG(Info, "ModelInModelOut starting, filename: " << toString(m_model->fullPath)); LOG(Info, "ModelInModelOut starting, outdir: " << toString(outpath)); LOG(Info, "ModelInModelOut starting, num merged jobs: " << m_mergedJobs.size()); m_lastrun = QDateTime::currentDateTime(); JobErrors errors; errors.result = ruleset::OSResultValue::Success; l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); try { boost::filesystem::create_directories(outpath); model::OptionalModel m = model::Model::load(model->fullPath); if (!m) { errors.addError(ErrorType::Error, "Unable to load model: " + toString(model->fullPath)); errors.result = ruleset::OSResultValue::Fail; } else { LOG(Info, "ModelInModelOut executing primary job"); model::Model outmodel = modelToModelRun(*m); for (const auto & mergedJob : mergedJobs) { LOG(Info, "ModelInModelOut executing merged job"); outmodel = mergedJob->modelToModelRun(outmodel); } openstudio::path outFile = outpath / toPath("out.osm"); if (!outmodel.save(outFile,true)) { errors.addError(ErrorType::Error, "Error while writing final output file"); errors.result = ruleset::OSResultValue::Fail; } } } catch (const std::exception &e) { errors.addError(ErrorType::Error, "Error with processing: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } emitOutputFileChanged(RunManager_Util::dirFile(outpath / openstudio::toPath("out.osm"))); setErrors(errors); }
void ModelToRadJob::startImpl(const boost::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(); QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { if (!m_model) { m_model = modelFile(); } if (!m_sql) { m_sql = sqlFile(); } resetFiles(m_files, m_model); } catch (const std::runtime_error &e) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, e.what()); } if (!m_sql || !m_model) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "Unable to find required model or sql file"); } LOG(Info, "ModelToRad starting, filename: " << toString(m_model->fullPath)); LOG(Info, "ModelToRad starting, outdir: " << toString(outpath)); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } try { boost::filesystem::create_directories(outpath); // // setup // LOG(Debug, "Working Directory: " + openstudio::toString(outpath)); // get model boost::optional<openstudio::IdfFile> idf = openstudio::IdfFile::load(m_model->fullPath); openstudio::model::Model model = openstudio::model::Model(idf.get()); // load the sql file openstudio::SqlFile sqlFile(m_sql->fullPath); if (!sqlFile.connectionOpen()) { LOG(Error, "SqlFile connection is not open"); errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "SqlFile collection is not open"); setErrors(errors); return; } // set the sql file model.setSqlFile(sqlFile); if (!model.sqlFile()) { LOG(Error, "SqlFile is not set on model"); errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "SqlFile is not set on model"); setErrors(errors); return; } openstudio::radiance::ForwardTranslator ft; std::vector<openstudio::path> outfiles = ft.translateModel(outpath, model); // capture translator errors and warnings? //ft.errors(); //ft.warnings(); Files outfileinfos; for (std::vector<openstudio::path>::const_iterator itr = outfiles.begin(); itr != outfiles.end(); ++itr) { FileInfo fi = RunManager_Util::dirFile(*itr); LOG(Info, "Output file generated: " << openstudio::toString(fi.fullPath)); emitOutputFileChanged(fi); outfileinfos.append(fi); } l.relock(); m_outputfiles = outfileinfos; /// Do work here - and be sure to set output files too } catch (const std::runtime_error &e) { errors.addError(ErrorType::Error, "Error with conversion (runtime_error): " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } catch (const std::exception &e) { errors.addError(ErrorType::Error, "Error with conversion: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } setErrors(errors); }
void EnergyPlusPostProcessJob::startImpl(const boost::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(); QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { m_sql = sqlFile(); resetFiles(m_files, m_sql); } catch (const std::exception &e) { std::vector<std::pair<ErrorType, std::string> > err; err.push_back(std::make_pair(ErrorType::Error, e.what())); errors = JobErrors(ruleset::OSResultValue::Fail, err); } if (m_sql) { LOG(Info, "EnergyPlusPostProcess starting, filename: " << toString(m_sql->fullPath)); } LOG(Info, "EnergyPlusPostProcess starting, outdir: " << toString(outpath)); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } SqlFile sqlFile(m_sql->fullPath); try { boost::filesystem::create_directories(outpath); std::vector<Attribute> attributes = PostProcessReporting::go(sqlFile); if (attributes.empty()) { LOG(Warn, "No attributes loaded for report"); } Attribute report("Report", attributes); bool result = report.saveToXml(outpath / openstudio::toPath("report.xml")); if (!result){ LOG_AND_THROW("Failed to write report.xml"); } } catch (const std::exception &e) { LOG(Error, "Error with EnergyPlusPostProcessJob: " + std::string(e.what())); errors.addError(ErrorType::Error, "Error with EnergyPlusPostProcessJob: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } // Change this to whatever output files you generate emitOutputFileChanged(RunManager_Util::dirFile(outpath / openstudio::toPath("report.xml"))); setErrors(errors); }
int main(int argc, const char* argv[]) { mutl::ArgumentParser parser; if( false == parser.Initialize(argc, argv, descs, sizeof(descs)/sizeof(Desc)) || parser.IsEnabled("h") || parser.GetArgumentCount() < 2 ) { usage(param); return 0; } param.upperValue = 32767.0; param.optimize = false; param.optimizeSeparately = false; param.outputLog = false; param.inputLength = -1; param.inputFilepath = parser.GetArgument(0); param.referenceFilepath = parser.GetArgument(1); size_t& tapps = param.tapps; tapps = 256; if (parser.IsEnabled("m")) { tapps = atoi( parser.GetOption("m").c_str() ); } if ( tapps < 1 ) { ERROR_LOG("tapps (an argument of \"-m\" swtich) must be larger than 0: %d\n", static_cast<int>(tapps) ); return 0; } if (parser.IsEnabled("c")) { param.upperValue = atof( parser.GetOption("c").c_str() ); if (param.upperValue <= 0.0) { ERROR_LOG("The specified value with -c (%f) must be positive.\n", param.upperValue); return 0; } } if (parser.IsEnabled("l")) { param.inputLength = atoi( parser.GetOption("l").c_str() ); if (param.inputLength < 1) { ERROR_LOG("The specified value with -l (%d) must be positive.\n", static_cast<int>(param.inputLength) ); return 0; } } if (parser.IsEnabled("opt")) { param.optimize = true; } if (parser.IsEnabled("sep")) { param.optimizeSeparately = true; } if (parser.IsEnabled("log")) { param.outputLog = true; } std::string outputPrefix; if (parser.IsEnabled("o")) { outputPrefix = parser.GetOption("o"); } else { mutl::NodePath _inputPath(param.inputFilepath); mutl::NodePath _referencePath(param.referenceFilepath); char tappsString[11]; sprintf(tappsString, "%d", static_cast<int>(tapps)); outputPrefix = std::string("./Af_") + std::string(tappsString) + std::string("tapps_") + _inputPath.GetBasename() + std::string("_") + _referencePath.GetBasename(); } std::string outdir("./"); if ( parser.IsEnabled("d") ) { outdir = parser.GetOption("d"); outdir += std::string("/"); } param.outputBase = outdir + outputPrefix; // Display messages real-time setvbuf(stdout, NULL, _IONBF, 0); LOG("Input: %s\n", param.inputFilepath.c_str()); LOG("Reference: %s\n", param.referenceFilepath.c_str()); LOG("Tapps: %d\n", static_cast<int>(tapps) ); LOG("Clamped Value: %g\n", param.upperValue); LOG("\n"); status_t status; status = Setup(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in Startup(): %d\n", status); return 0; } LOG("[Input]\n"); LOG(" File : %s\n", param.inputFilepath.c_str()); LOG(" SamplingRate: %d\n", static_cast<int>(param.samplingRate) ); LOG(" Length : %d\n", static_cast<int>(param.inputSignal.GetColumnLength()) ); LOG("\n"); LOG("[Reference]\n"); LOG(" File : %s\n", param.referenceFilepath.c_str()); LOG(" Length: %d\n", static_cast<int>(param.referenceSignal.GetLength())); LOG("\n"); status = PreProcess(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in PreProcess(): %d\n", status); return 0; } status = Process(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in Estimater(): %d\n", status); return 0; } status = PostProcess(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in PostProcess(): %d\n", status); return 0; } status = Cleanup(¶m); if ( NO_ERROR != status ) { ERROR_LOG("Failed in Cleanup(): %d\n", status); return 0; } return 0; }
int main( int argc, char* argv[] ) { if( argc<2 ) { std::cout << "USAGE: ./fitSignalShapes [configFileName]" << std::endl; std::cout << "Exiting." << std::endl; exit(11); } std::string configFileName(argv[1]); ZGConfig cfg(configFileName); ZGDrawTools::setStyle(); std::vector<float> masses; //masses.push_back( 350. ); masses.push_back( 400. ); masses.push_back( 450. ); masses.push_back( 500. ); masses.push_back( 750. ); masses.push_back( 1000. ); masses.push_back( 1250. ); masses.push_back( 1500. ); masses.push_back( 1750. ); masses.push_back( 2000. ); //masses.push_back( 300. ); //masses.push_back( 400. ); //masses.push_back( 500. ); //masses.push_back( 750. ); //masses.push_back( 1000. ); //masses.push_back( 1500. ); //masses.push_back( 2000. ); //masses.push_back( 2500. ); //masses.push_back( 3000. ); //masses.push_back( 5000. ); std::vector<std::string> widths; widths.push_back( "5p6" ); widths.push_back( "0p014" ); for( unsigned iw =0; iw<widths.size(); ++iw ) { std::string outdir(Form("%s/signalShapes_w%s", cfg.getEventYieldDir().c_str(), widths[iw].c_str())); system( Form("mkdir -p %s", outdir.c_str() ) ); TFile* outfile = TFile::Open(Form("%s/signalShapeParameters_w%s.root", outdir.c_str(), widths[iw].c_str()), "recreate"); outfile->cd(); //fitGraphs( cfg, masses, widths[iw], outdir, outfile, "all" ); fitGraphs( cfg, masses, widths[iw], outdir, outfile, "ee", "leptType==11" ); fitGraphs( cfg, masses, widths[iw], outdir, outfile, "mm", "leptType==13" ); drawCompare( cfg, outdir, outfile, widths[iw], "mean" , "Gaussian Mean [GeV]" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); drawCompare( cfg, outdir, outfile, widths[iw], "sigma" , "Gaussian #sigma [GeV]" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); drawCompare( cfg, outdir, outfile, widths[iw], "width" , "Gaussian #sigma/#mu" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); drawCompare( cfg, outdir, outfile, widths[iw], "alpha1", "CB left #alpha" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); drawCompare( cfg, outdir, outfile, widths[iw], "alpha2", "CB right #alpha" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); drawCompare( cfg, outdir, outfile, widths[iw], "n1" , "CB left N" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); drawCompare( cfg, outdir, outfile, widths[iw], "n2" , "CB right N" , "ee", "ee#gamma", "mm", "#mu#mu#gamma" ); outfile->Close(); } // for widths return 0; }
void StaticAnalyze(const char * set) { Line outdir("bigdat/s/%s", set); printf("[staticAnalyze] %s\n", outdir()); staticAnalyze(outdir()); }
void ModelToRadPreProcessJob::startImpl(const std::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(true); QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { m_osm = osmFile(); resetFiles(m_files, m_osm); } catch (const std::exception &e) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, e.what()); } LOG(Info, "ModelToRadPreProcess starting, loading model file: " << toString(m_osm->fullPath)); openstudio::model::OptionalModel model = openstudio::model::Model::load(m_osm->fullPath); if (!model) { errors.result = ruleset::OSResultValue::Fail; errors.addError(ErrorType::Error, "Unable to load model file"); } LOG(Info, "ModelToRadPreProcess starting, outdir: " << toString(outpath)); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } try { boost::filesystem::create_directories(outpath); openstudio::path path = outpath / openstudio::toPath("out.osm"); openstudio::model::Model outmodel; outmodel.getUniqueModelObject<openstudio::model::Building>(); // implicitly create building object outmodel.getUniqueModelObject<openstudio::model::Timestep>(); // implicitly create timestep object outmodel.getUniqueModelObject<openstudio::model::RunPeriod>(); // implicitly create runperiod object if (model->getOptionalUniqueModelObject<openstudio::model::WeatherFile>()) { outmodel.addObject(model->getUniqueModelObject<openstudio::model::WeatherFile>()); } std::map<std::string, openstudio::model::ThermalZone> thermalZones; std::vector<openstudio::model::Space> spaces = model->getConcreteModelObjects<openstudio::model::Space>(); for (auto & space : spaces) { space.hardApplyConstructions(); space.hardApplySpaceType(true); space.hardApplySpaceLoadSchedules(); // make all surfaces with surface boundary condition adiabatic std::vector<openstudio::model::Surface> surfaces = space.surfaces(); for (auto & surf_it : surfaces){ boost::optional<openstudio::model::Surface> adjacentSurface = surf_it.adjacentSurface(); if (adjacentSurface){ // make sure to hard apply constructions in other space before messing with surface in other space boost::optional<openstudio::model::Space> adjacentSpace = adjacentSurface->space(); if (adjacentSpace){ adjacentSpace->hardApplyConstructions(); } // resets both surfaces surf_it.resetAdjacentSurface(); // set both to adiabatic surf_it.setOutsideBoundaryCondition("Adiabatic"); adjacentSurface->setOutsideBoundaryCondition("Adiabatic"); // remove interior windows for (openstudio::model::SubSurface subSurface : surf_it.subSurfaces()){ subSurface.remove(); } for (openstudio::model::SubSurface subSurface : adjacentSurface->subSurfaces()){ subSurface.remove(); } } } openstudio::model::Space new_space = space.clone(outmodel).optionalCast<openstudio::model::Space>().get(); boost::optional<openstudio::model::ThermalZone> thermalZone = space.thermalZone(); if (thermalZone && thermalZone->name()) { if (thermalZones.find(*thermalZone->name()) == thermalZones.end()) { openstudio::model::ThermalZone newThermalZone(outmodel); newThermalZone.setName(*thermalZone->name()); newThermalZone.setUseIdealAirLoads(true); thermalZones.insert(std::make_pair(*thermalZone->name(), newThermalZone)); } auto itr = thermalZones.find(*thermalZone->name()); OS_ASSERT(itr != thermalZones.end()); // We just added it above if we needed it new_space.setThermalZone(itr->second); } else if (thermalZone && !thermalZone->name()) { errors.addError(ErrorType::Warning, "Space discovered in un-named thermalZone, not translating"); } } std::vector<openstudio::model::ShadingSurfaceGroup> shadingsurfacegroups = outmodel.getConcreteModelObjects<openstudio::model::ShadingSurfaceGroup>(); for (auto & shadingSurfaceGroup : shadingsurfacegroups) { shadingSurfaceGroup.remove(); } std::vector<openstudio::model::SpaceItem> spaceitems = outmodel.getModelObjects<openstudio::model::SpaceItem>(); for (auto & spaceItem : spaceitems) { if (spaceItem.optionalCast<openstudio::model::People>()){ // keep people }else if (spaceItem.optionalCast<openstudio::model::Lights>()){ // keep lights }else if (spaceItem.optionalCast<openstudio::model::Luminaire>()){ // keep luminaires }else{ spaceItem.remove(); } } std::vector<openstudio::model::OutputVariable> outputVariables = outmodel.getConcreteModelObjects<openstudio::model::OutputVariable>(); for (auto & outputVariable : outputVariables) { outputVariable.remove(); } openstudio::model::OutputVariable outputVariable("Site Exterior Horizontal Sky Illuminance", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Site Exterior Beam Normal Illuminance", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Site Solar Altitude Angle", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Site Solar Azimuth Angle", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Site Sky Diffuse Solar Radiation Luminous Efficacy", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Site Beam Solar Radiation Luminous Efficacy", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Zone People Occupant Count", outmodel); outputVariable.setReportingFrequency("Hourly"); outputVariable = openstudio::model::OutputVariable("Zone Lights Electric Power", outmodel); outputVariable.setReportingFrequency("Hourly"); // only report weather periods openstudio::model::SimulationControl simulation_control = outmodel.getUniqueModelObject<openstudio::model::SimulationControl>(); simulation_control.setRunSimulationforSizingPeriods(false); simulation_control.setRunSimulationforWeatherFileRunPeriods(true); simulation_control.setSolarDistribution("MinimalShadowing"); outmodel.save(path, true); } catch (const std::exception &e) { LOG(Error, "Error with ModelToRadPreProcessJob: " + std::string(e.what())); errors.addError(ErrorType::Error, "Error with ModelToRadPreProcessJob: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } // Change this to whatever output files you generate emitOutputFileChanged(RunManager_Util::dirFile(outpath / openstudio::toPath("out.osm"))); setErrors(errors); }
void OpenStudioPostProcessJob::startImpl(const boost::shared_ptr<ProcessCreator> &) { QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { m_sql = sqlFile(); m_osm = osmFile(); resetFiles(m_files, m_sql, m_osm); } catch (const std::exception &e) { JobErrors error; error.result = ruleset::OSResultValue::Fail; error.addError(ErrorType::Error, e.what()); errors = error; } if (m_sql) { LOG(Info, "OpenStudioPostProcess starting, filename: " << toString(m_sql->fullPath)); } LOG(Info, "OpenStudioPostProcess starting, outdir: " << toString(outdir())); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } try { SqlFile sqlFile(m_sql->fullPath); boost::optional<openstudio::model::Model> model = model::Model::load(m_osm->fullPath); if (!model) { throw std::runtime_error("Unable to load model file from " + openstudio::toString(m_osm->fullPath)); } model->setSqlFile(sqlFile); boost::filesystem::create_directories(outdir(true)); std::vector<Attribute> attributes = PostProcessReporting::go(sqlFile); // ETH@20140219 - Not great to add an object here either, but needed for // Facility, and Building is really the same case. (If get this far with // simulation, no harm in accessing data through Building, which has // smart defaults for all fields.) model::Building building = model->getUniqueModelObject<model::Building>(); LOG(Debug,"Extracting attributes from model::Building."); boost::optional<Attribute> attribute; boost::optional<double> value = building.floorArea(); if (value){ attribute = Attribute("floorArea", *value, "m^2"); attribute->setDisplayName("Floor Area"); attributes.push_back(*attribute); } value = building.conditionedFloorArea(); if (value){ attribute = Attribute("conditionedFloorArea", *value, "m^2"); attribute->setDisplayName("Conditioned Floor Area"); attributes.push_back(*attribute); } // ETH@20140218 - Not great to add an object here, but otherwise, do not get // calibration results table in PAT. model::Facility facility = model->getUniqueModelObject<model::Facility>(); LOG(Debug,"Extracting attributes from model::Facility."); value = facility.economicsCapitalCost(); if (value){ attribute = Attribute("economicsCapitalCost", *value, "$"); attribute->setDisplayName("Capital Cost"); attributes.push_back(*attribute); } value = facility.economicsTLCC(); if (value){ attribute = Attribute("economicsTLCC", *value, "$"); attribute->setDisplayName("Total Life Cycle Cost"); attributes.push_back(*attribute); } value = facility.annualWaterTotalCost(); if (value){ attribute = Attribute("annualWaterTotalCost", *value, "$"); attribute->setDisplayName("Annual Water Total Cost"); attributes.push_back(*attribute); } attribute = facility.endUsesAttribute(); if (attribute){ attributes.push_back(*attribute); } attribute = facility.calibrationResultAttribute(); if (attribute){ attributes.push_back(*attribute); } boost::optional<model::TimeDependentValuation> timeDependentValuation = model->getOptionalUniqueModelObject<model::TimeDependentValuation>(); if (timeDependentValuation){ LOG(Debug,"Extracting attributes from model::TimeDependentValuation."); boost::optional<Attribute> attribute; boost::optional<double> value = timeDependentValuation->energyTimeDependentValuation(); if (value){ attribute = Attribute("energyTimeDependentValuation", *value, "J"); attribute->setDisplayName("Energy Time Dependent Valuation"); attributes.push_back(*attribute); } value = timeDependentValuation->costTimeDependentValuation(); if (value){ attribute = Attribute("costTimeDependentValuation", *value, "$"); attribute->setDisplayName("Cost Time Dependent Valuation"); attributes.push_back(*attribute); } } if (attributes.empty()) { LOG(Warn, "No attributes loaded for report"); } Attribute report("Report", attributes); bool result = report.saveToXml(outdir() / openstudio::toPath("report.xml")); if (!result){ LOG_AND_THROW("Failed to write report.xml"); } } catch (const std::exception &e) { LOG(Error, "Error with OpenStudioPostProcessJob: " + std::string(e.what())); errors.addError(ErrorType::Error, "Error with OpenStudioPostProcessJob: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } // Change this to whatever output files you generate emitOutputFileChanged(RunManager_Util::dirFile(outdir() / openstudio::toPath("report.xml"))); setErrors(errors); }
void IdfToModelJob::startImpl(const std::shared_ptr<ProcessCreator> &) { openstudio::path outpath = outdir(true); QWriteLocker l(&m_mutex); if (!m_idf) { m_idf = idfFile(); resetFiles(m_files, m_idf); } LOG(Info, "IdfToModel starting, filename: " << toString(m_idf->fullPath)); LOG(Info, "IdfToModel starting, outdir: " << toString(outpath)); JobErrors errors; errors.result = ruleset::OSResultValue::Success; l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); openstudio::energyplus::ReverseTranslator rt; try { boost::filesystem::create_directories(outpath); LOG(Debug, "Loading input file: " + toString(m_idf->fullPath)); boost::optional<openstudio::model::Model> model; boost::optional<openstudio::Workspace> workspace = openstudio::Workspace::load(m_idf->fullPath); if (workspace){ model = rt.translateWorkspace(*workspace); } OS_ASSERT(model); openstudio::path outfile = outpath / openstudio::toPath("out.osm"); LOG(Debug, "Saving to path: " + toString(outfile)); model->save(outfile, true); emitOutputFileChanged(RunManager_Util::dirFile(outfile)); } catch (const std::exception &e) { LOG(Error, std::string("Error with IdfToModel translation: ") + e.what()); errors.addError(ErrorType::Error, "Error with conversion: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } std::vector<openstudio::LogMessage> logwarnings = rt.warnings(); std::vector<openstudio::LogMessage> logerrors = rt.errors(); for (std::vector<openstudio::LogMessage>::const_iterator itr = logwarnings.begin(); itr != logwarnings.end(); ++itr) { errors.addError(ErrorType::Warning, itr->logMessage()); } for (std::vector<openstudio::LogMessage>::const_iterator itr = logerrors.begin(); itr != logerrors.end(); ++itr) { errors.addError(ErrorType::Error, itr->logMessage()); } setErrors(errors); }
void OpenStudioPostProcessJob::startImpl(const boost::shared_ptr<ProcessCreator> &) { QWriteLocker l(&m_mutex); JobErrors errors; errors.result = ruleset::OSResultValue::Success; try { m_sql = sqlFile(); m_osm = osmFile(); resetFiles(m_files, m_sql, m_osm); } catch (const std::exception &e) { JobErrors error; error.result = ruleset::OSResultValue::Fail; error.addError(ErrorType::Error, e.what()); errors = error; } if (m_sql) { LOG(Info, "OpenStudioPostProcess starting, filename: " << toString(m_sql->fullPath)); } LOG(Info, "OpenStudioPostProcess starting, outdir: " << toString(outdir())); l.unlock(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Starting)); emitStarted(); emitStatusChanged(AdvancedStatus(AdvancedStatusEnum::Processing)); if (errors.result == ruleset::OSResultValue::Fail) { setErrors(errors); return; } try { SqlFile sqlFile(m_sql->fullPath); boost::optional<openstudio::model::Model> model = model::Model::load(m_osm->fullPath); if (!model) { throw std::runtime_error("Unable to load model file from " + openstudio::toString(m_osm->fullPath)); } model->setSqlFile(sqlFile); boost::filesystem::create_directories(outdir(true)); std::vector<Attribute> attributes = PostProcessReporting::go(sqlFile); boost::optional<model::Building> building = model->getOptionalUniqueModelObject<model::Building>(); if (building) { LOG(Debug,"Extracting attributes from model::Building."); boost::optional<Attribute> attribute = building->getAttribute("floorArea"); if (attribute){ attribute->setDisplayName("Floor Area"); attribute->setUnits("m^2"); attributes.push_back(*attribute); } attribute = building->getAttribute("conditionedFloorArea"); if (attribute){ attribute->setDisplayName("Conditioned Floor Area"); attribute->setUnits("m^2"); attributes.push_back(*attribute); } } boost::optional<model::Facility> facility = model->getOptionalUniqueModelObject<model::Facility>(); if (facility){ LOG(Debug,"Extracting attributes from model::Facility."); boost::optional<Attribute> attribute = facility->getAttribute("economicsCapitalCost"); if (attribute){ attribute->setDisplayName("Capital Cost"); attribute->setUnits("$"); attributes.push_back(*attribute); } attribute = facility->getAttribute("economicsTLCC"); if (attribute){ attribute->setDisplayName("Total Life Cycle Cost"); attribute->setUnits("$"); attributes.push_back(*attribute); } attribute = facility->getAttribute("annualWaterTotalCost"); if (attribute){ attribute->setDisplayName("Annual Water Total Cost"); attribute->setUnits("$"); attributes.push_back(*attribute); } attribute = facility->getAttribute("endUsesAttribute"); if (attribute){ attributes.push_back(*attribute); } } boost::optional<model::TimeDependentValuation> timeDependentValuation = model->getOptionalUniqueModelObject<model::TimeDependentValuation>(); if (timeDependentValuation){ LOG(Debug,"Extracting attributes from model::TimeDependentValuation."); boost::optional<Attribute> attribute = timeDependentValuation->getAttribute("energyTimeDependentValuation"); if (attribute){ attribute->setDisplayName("Energy Time Dependent Valuation"); attribute->setUnits("J"); attributes.push_back(*attribute); } attribute = timeDependentValuation->getAttribute("costTimeDependentValuation"); if (attribute){ attribute->setDisplayName("Cost Time Dependent Valuation"); attribute->setUnits("$"); attributes.push_back(*attribute); } } if (attributes.empty()) { LOG(Warn, "No attributes loaded for report"); } Attribute report("Report", attributes); bool result = report.saveToXml(outdir() / openstudio::toPath("report.xml")); if (!result){ LOG_AND_THROW("Failed to write report.xml"); } } catch (const std::exception &e) { LOG(Error, "Error with OpenStudioPostProcessJob: " + std::string(e.what())); errors.addError(ErrorType::Error, "Error with OpenStudioPostProcessJob: " + std::string(e.what())); errors.result = ruleset::OSResultValue::Fail; } // Change this to whatever output files you generate emitOutputFileChanged(RunManager_Util::dirFile(outdir() / openstudio::toPath("report.xml"))); setErrors(errors); }