/** * @file LeadtimeThreadDataForField.cc */ #include "LeadtimeThreadDataForField.hh" #include #include #include "PbarVector.hh" #include #include //---------------------------------------------------------------------- LeadtimeThreadDataForField:: LeadtimeThreadDataForField(const ParmsThreshFromObarPbar ¶ms, int which, const time_t &genTime, int leadTime) : _params(params), _genTime(genTime), _leadTime(leadTime), _threshInfo(params._tileInfo.numTiles()), _currentThresh(0) { if (which == 1) { _spdb = params._thresholdsSpdb1; _coldstartThresh = params._thresholdedFieldColdstartThresh1; _greaterOrEqual = true; for (size_t i=0; i &thresholds, int &belowTile, int &threshIndex) { TileThreshInfoGenBased info; if (_params._tileInfo.outOfBoundsY(tileIndex, belowTile)) { // try to use the tile below if (_threshInfo.useTileBelow(tileIndex, belowTile, info)) { _threshInfo[tileIndex] = info; vector::const_iterator i; i = find(thresholds.begin(), thresholds.end(), info.getThresh()); if (i != thresholds.end()) { threshIndex = (int)(i - thresholds.begin()); return true; } } LOG(ERROR) << "Tile order not as expected index=" << tileIndex << " belowIndex=" << belowTile; threshIndex = setToMotherOrColdstart(tileIndex, isMotherTile); return true; } else { return false; } } //----------------------------------------------------------------------- int LeadtimeThreadDataForField::setToMotherOrColdstart(int tileIndex, bool isMotherTile) { if (isMotherTile) { // this means setting the mother tile has failed _motherFail = true; _motherSet = false; _motherPbarIndex = -1; _threshInfo[tileIndex] = TileThreshInfoGenBased(_coldstartThresh, _genTime, _leadTime, tileIndex, true, true); return -1; } else { if (_motherSet) { TileThreshInfoGenBased ret(_motherInfo); ret.setTileIndex(tileIndex); _threshInfo[tileIndex] = ret; return _motherPbarIndex; } else { _threshInfo[tileIndex] = TileThreshInfoGenBased(_coldstartThresh, _genTime, _leadTime, tileIndex, false, true); return -1; } } } //---------------------------------------------------------------------- void LeadtimeThreadDataForField::handleMotherResults(int motherIndex, int pbarIndex) { if (!_motherFail) { _motherSet = true; _motherInfo = _threshInfo[motherIndex]; _motherPbarIndex = pbarIndex; } } //------------------------------------------------------------------------ // use max threshold (or min threshold that gives 0), unless all thresolds // give 0, in which case use default or mothertile threshold int LeadtimeThreadDataForField::setupAndRunObsZero(int tileIndex, const std::vector &pbar, const std::vector &thresh, bool isMotherTile, int obsThreshIndex) { _currentThresh = _bestOld[tileIndex]; double tb; if (obsThreshIndex < 0 || obsThreshIndex >= (int)_targetBias.size()) { LOG(ERROR) << "logic error in accessing target bias values, use targetbias 0"; LOG(ERROR) << " obsThreshIndex=" << obsThreshIndex << " bias array size = " << _targetBias.size(); tb = _targetBias[0]; } else { tb = _targetBias[obsThreshIndex]; } PbarVector pbarV(tb, thresh); for (size_t i=0; i &pbar, const std::vector &thresh, bool isMotherTile, int obsThreshIndex) { _currentThresh = _bestOld[tileIndex]; double tb; if (obsThreshIndex < 0 || obsThreshIndex >= (int)_targetBias.size()) { LOG(ERROR) << "logic error in accessing target bias values, use targetbias 0"; LOG(ERROR) << " obsThreshIndex=" << obsThreshIndex << " bias array size = " << _targetBias.size(); tb = _targetBias[0]; } else { tb = _targetBias[obsThreshIndex]; } PbarVector pbarV(tb, thresh); for (size_t i=0; i