// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // © University Corporation for Atmospheric Research (UCAR) 2009-2010. // All rights reserved. The Government's right to use this data and/or // software (the "Work") is restricted, per the terms of Cooperative // Agreement (ATM (AGS)-0753581 10/1/08) between UCAR and the National // Science Foundation, to a "nonexclusive, nontransferable, irrevocable, // royalty-free license to exercise or have exercised for or on behalf of // the U.S. throughout the world all the exclusive rights provided by // copyrights. Such license, however, does not include the right to sell // copies or phonorecords of the copyrighted works to the public." The // Work is provided "AS IS" and without warranty of any kind. UCAR // EXPRESSLY DISCLAIMS ALL OTHER WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE. // // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* /** * @file CmorphAveragerMgr.cc * @brief Source for CmorphAveragerMgr class */ #include "CmorphAveragerMgr.hh" #include #include #include #include #include #include #include #include using std::vector; // using std::string; CmorphAveragerMgr::CmorphAveragerMgr(const ParmsCmorphAverager ¶ms, void cleanExit(int)): pParams(params) { time_t t = time(0); // // Set up real-time or archive data triggering // if (!InterfaceParm::driverInit(pParams.main, cleanExit)) { cleanExit(1); } ILOGF(WARNING, "Restarted at %s", ConvWxTime::stime(t).c_str()); } CmorphAveragerMgr::~CmorphAveragerMgr() { time_t t = time(0); ILOGF(WARNING, "Terminated at %s", ConvWxTime::stime(t).c_str()); } bool CmorphAveragerMgr::run() const { // // Observation data time. // time_t obsTime; int lastYear = -1; int lastMonth = -1; int lastDay = -1; int lastHour = -1; vector hoursForProcessing; // if center averaging, look to do an average of older data // at hour 1, 4, 7, etc, with output time set to 0, 3, 6, etc. // the average will be at 7: 7, 6.5, 6, 5.5, 5, 4.5 output time = 6 // for end time averaging, look to do an average of older data // at hour 0, 3, 6, etc. with output time same (0, 3, 6, etc). // the average at 6: 3.5, 4, 4.5, 5, 5.5, 6 // if (pParams.centerAveraging) // { // hoursForProcessing.push_back(1); // hoursForProcessing.push_back(4); // hoursForProcessing.push_back(7); // hoursForProcessing.push_back(10); // hoursForProcessing.push_back(13); // hoursForProcessing.push_back(16); // hoursForProcessing.push_back(19); // hoursForProcessing.push_back(22); // } // else // { hoursForProcessing.push_back(0); hoursForProcessing.push_back(3); hoursForProcessing.push_back(6); hoursForProcessing.push_back(9); hoursForProcessing.push_back(12); hoursForProcessing.push_back(15); hoursForProcessing.push_back(18); hoursForProcessing.push_back(21); // } while (Trigger::sequenceTrigger(pParams.main, obsTime)) { InterfaceLL::doRegister("Processing observation data"); bool doWrite = false; int y, m, d, h, min, s; ConvWxTime::expandTime(obsTime, y, m, d, h, min, s); if (find(hoursForProcessing.begin(), hoursForProcessing.end(), h) == hoursForProcessing.end()) { InterfaceLL::doRegister("Skipping observation data"); continue; } if (min != 0) { InterfaceLL::doRegister("Skipping observation data"); continue; } time_t t0, t1, outTime; // if (pParams.centerAveraging) // { // t0 = obsTime-3.5*3600; // t1 = obsTime; // outTime = obsTime - 3600; // } // else // { t0 = obsTime - 3.5*3600; t1 = obsTime; outTime = obsTime; // } Grid data; Grid out; Grid counts; vector times = InterfaceIO::availableObsTimesInARange(pParams.obs.pUrl, t0, t1); bool first = true; for (size_t i=0; i