From 8fff9c5a6b3d6e6fef951be5a6f946adcc7f582f Mon Sep 17 00:00:00 2001 From: Joris van Zwieten <zwieten@astron.nl> Date: Wed, 24 Jan 2007 10:33:50 +0000 Subject: [PATCH] BugID: 1008 - Moved value checking for Strategy.RegionOfInterest to BBSKernelProcessControl. - Fixed RegionOfInterest selection. - Removed work domain iteration as this has to be done for the whole strategy and not for each step. --- .../BBSControl/src/BBSKernelProcessControl.cc | 135 ++++++++++-------- CEP/BB/BBSControl/src/BBSStrategy.cc | 17 +-- CEP/BB/BBSControl/src/KernelProcessControl.cc | 135 ++++++++++-------- 3 files changed, 151 insertions(+), 136 deletions(-) diff --git a/CEP/BB/BBSControl/src/BBSKernelProcessControl.cc b/CEP/BB/BBSControl/src/BBSKernelProcessControl.cc index 84eb338fe4d..1060e11078a 100644 --- a/CEP/BB/BBSControl/src/BBSKernelProcessControl.cc +++ b/CEP/BB/BBSControl/src/BBSKernelProcessControl.cc @@ -276,31 +276,59 @@ namespace BBS itsWorkDomainSize = strategy->domainSize(); itsRegionOfInterest = strategy->regionOfInterest(); - // Time is specified as an offset from the start time of - // the measurement set. const MeqDomain domain = itsPrediffer->getLocalDataDomain(); - LOG_DEBUG_STR("Local data domain: " << domain); - itsRegionOfInterest[2] += domain.startY(); - itsRegionOfInterest[3] += domain.startY(); - if(itsRegionOfInterest[0] > domain.endX() - || itsRegionOfInterest[2] > domain.endY()) + if(itsRegionOfInterest.size() == 4) { - LOG_DEBUG_STR("Region of interest does not intersect the local data domain."); - return false; - } + if(itsRegionOfInterest[0] > itsRegionOfInterest[1]) + { + double tmp = itsRegionOfInterest[0]; + itsRegionOfInterest[0] = itsRegionOfInterest[1]; + itsRegionOfInterest[1] = tmp; + } + + if(itsRegionOfInterest[2] > itsRegionOfInterest[3]) + { + double tmp = itsRegionOfInterest[2]; + itsRegionOfInterest[2] = itsRegionOfInterest[3]; + itsRegionOfInterest[3] = tmp; + } + + // Time is specified as an offset from the start time of + // the measurement set. + itsRegionOfInterest[2] += domain.startY(); + itsRegionOfInterest[3] += domain.startY(); + + if(itsRegionOfInterest[0] > domain.endX() + || itsRegionOfInterest[1] < domain.startX() + || itsRegionOfInterest[2] > domain.endY() + || itsRegionOfInterest[3] < domain.startY()) + { + LOG_DEBUG_STR("Region of interest does not intersect the local data domain."); + return false; + } - // Clip region of interest against local data domain. - if(itsRegionOfInterest[0] < domain.startX()) - itsRegionOfInterest[0] = domain.startX(); - if(itsRegionOfInterest[1] < domain.endX()) - itsRegionOfInterest[1] = domain.endX(); + // Clip region of interest against local data domain. + if(itsRegionOfInterest[0] < domain.startX()) + itsRegionOfInterest[0] = domain.startX(); + if(itsRegionOfInterest[1] > domain.endX()) + itsRegionOfInterest[1] = domain.endX(); - if(itsRegionOfInterest[2] > domain.startY()) - itsRegionOfInterest[2] = domain.startY(); - if(itsRegionOfInterest[3] > domain.endY()) - itsRegionOfInterest[3] = domain.endY(); - + if(itsRegionOfInterest[2] < domain.startY()) + itsRegionOfInterest[2] = domain.startY(); + if(itsRegionOfInterest[3] > domain.endY()) + itsRegionOfInterest[3] = domain.endY(); + } + else + { + LOG_INFO("Strategy.RegionOfInterest not specified or has incorrect format; will use the local data domain instead."); + itsRegionOfInterest.resize(4); + itsRegionOfInterest[0] = domain.startX(); + itsRegionOfInterest[1] = domain.endX(); + itsRegionOfInterest[2] = domain.startY(); + itsRegionOfInterest[3] = domain.endY(); + } + // Select stations and correlations. return itsPrediffer->setSelection(strategy->stations(), strategy->correlation()); } @@ -318,54 +346,41 @@ namespace BBS ASSERT(itsPrediffer); - // Currently only the size in time of the work domain size is honoured. - int timeCount = std::max(1, (int) (0.5 + (itsRegionOfInterest[3] - itsRegionOfInterest[2]) / itsWorkDomainSize.timeInterval)); - - double timeStep = (itsRegionOfInterest[3] - itsRegionOfInterest[2]); - if(timeCount > 1) - timeStep /= timeCount; - - bool result = true; - double time = itsRegionOfInterest[2]; - for(int i = 0; i < timeCount && result; ++i) - { - ASSERT(itsPrediffer->setWorkDomain(itsRegionOfInterest[0], - itsRegionOfInterest[1], - time, - time + timeStep)); + ASSERT(itsPrediffer->setWorkDomain(itsRegionOfInterest[0], + itsRegionOfInterest[1], + itsRegionOfInterest[2], + itsRegionOfInterest[3])); - time = itsPrediffer->getWorkDomain().endY(); - result = false; + bool result = false; + { + const BBSPredictStep* step = dynamic_cast<const BBSPredictStep*>(bs); + if(step) { - const BBSPredictStep* step = dynamic_cast<const BBSPredictStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } - + } + + { + const BBSSubtractStep* step = dynamic_cast<const BBSSubtractStep*>(bs); + if(step) { - const BBSSubtractStep* step = dynamic_cast<const BBSSubtractStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } - + } + + { + const BBSCorrectStep* step = dynamic_cast<const BBSCorrectStep*>(bs); + if(step) { - const BBSCorrectStep* step = dynamic_cast<const BBSCorrectStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } - + } + + { + const BBSSolveStep* step = dynamic_cast<const BBSSolveStep*>(bs); + if(step) { - const BBSSolveStep* step = dynamic_cast<const BBSSolveStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } } diff --git a/CEP/BB/BBSControl/src/BBSStrategy.cc b/CEP/BB/BBSControl/src/BBSStrategy.cc index ebb527465c9..d7f3b0b377d 100644 --- a/CEP/BB/BBSControl/src/BBSStrategy.cc +++ b/CEP/BB/BBSControl/src/BBSStrategy.cc @@ -89,22 +89,7 @@ namespace LOFAR try { itsRegionOfInterest = ps.getDoubleVector("RegionOfInterest"); - if(itsRegionOfInterest.size() != 4 - || itsRegionOfInterest[0] < 0.0 - || itsRegionOfInterest[2] < 0.0 - || itsRegionOfInterest[0] > itsRegionOfInterest[1] - || itsRegionOfInterest[2] > itsRegionOfInterest[3]) - { - THROW(BBSControlException, "Invalid region of interest specified: " - << itsRegionOfInterest); - } - } - catch(APSException&) - { - itsRegionOfInterest.resize(4); - itsRegionOfInterest[0] = itsRegionOfInterest[2] = 0.0; - itsRegionOfInterest[1] = itsRegionOfInterest[3] = 1e50; - } + } catch (APSException&) {} // Get the work domain size for this strategy itsDomainSize.bandWidth = ps.getDouble("WorkDomainSize.Freq"); diff --git a/CEP/BB/BBSControl/src/KernelProcessControl.cc b/CEP/BB/BBSControl/src/KernelProcessControl.cc index 84eb338fe4d..1060e11078a 100644 --- a/CEP/BB/BBSControl/src/KernelProcessControl.cc +++ b/CEP/BB/BBSControl/src/KernelProcessControl.cc @@ -276,31 +276,59 @@ namespace BBS itsWorkDomainSize = strategy->domainSize(); itsRegionOfInterest = strategy->regionOfInterest(); - // Time is specified as an offset from the start time of - // the measurement set. const MeqDomain domain = itsPrediffer->getLocalDataDomain(); - LOG_DEBUG_STR("Local data domain: " << domain); - itsRegionOfInterest[2] += domain.startY(); - itsRegionOfInterest[3] += domain.startY(); - if(itsRegionOfInterest[0] > domain.endX() - || itsRegionOfInterest[2] > domain.endY()) + if(itsRegionOfInterest.size() == 4) { - LOG_DEBUG_STR("Region of interest does not intersect the local data domain."); - return false; - } + if(itsRegionOfInterest[0] > itsRegionOfInterest[1]) + { + double tmp = itsRegionOfInterest[0]; + itsRegionOfInterest[0] = itsRegionOfInterest[1]; + itsRegionOfInterest[1] = tmp; + } + + if(itsRegionOfInterest[2] > itsRegionOfInterest[3]) + { + double tmp = itsRegionOfInterest[2]; + itsRegionOfInterest[2] = itsRegionOfInterest[3]; + itsRegionOfInterest[3] = tmp; + } + + // Time is specified as an offset from the start time of + // the measurement set. + itsRegionOfInterest[2] += domain.startY(); + itsRegionOfInterest[3] += domain.startY(); + + if(itsRegionOfInterest[0] > domain.endX() + || itsRegionOfInterest[1] < domain.startX() + || itsRegionOfInterest[2] > domain.endY() + || itsRegionOfInterest[3] < domain.startY()) + { + LOG_DEBUG_STR("Region of interest does not intersect the local data domain."); + return false; + } - // Clip region of interest against local data domain. - if(itsRegionOfInterest[0] < domain.startX()) - itsRegionOfInterest[0] = domain.startX(); - if(itsRegionOfInterest[1] < domain.endX()) - itsRegionOfInterest[1] = domain.endX(); + // Clip region of interest against local data domain. + if(itsRegionOfInterest[0] < domain.startX()) + itsRegionOfInterest[0] = domain.startX(); + if(itsRegionOfInterest[1] > domain.endX()) + itsRegionOfInterest[1] = domain.endX(); - if(itsRegionOfInterest[2] > domain.startY()) - itsRegionOfInterest[2] = domain.startY(); - if(itsRegionOfInterest[3] > domain.endY()) - itsRegionOfInterest[3] = domain.endY(); - + if(itsRegionOfInterest[2] < domain.startY()) + itsRegionOfInterest[2] = domain.startY(); + if(itsRegionOfInterest[3] > domain.endY()) + itsRegionOfInterest[3] = domain.endY(); + } + else + { + LOG_INFO("Strategy.RegionOfInterest not specified or has incorrect format; will use the local data domain instead."); + itsRegionOfInterest.resize(4); + itsRegionOfInterest[0] = domain.startX(); + itsRegionOfInterest[1] = domain.endX(); + itsRegionOfInterest[2] = domain.startY(); + itsRegionOfInterest[3] = domain.endY(); + } + // Select stations and correlations. return itsPrediffer->setSelection(strategy->stations(), strategy->correlation()); } @@ -318,54 +346,41 @@ namespace BBS ASSERT(itsPrediffer); - // Currently only the size in time of the work domain size is honoured. - int timeCount = std::max(1, (int) (0.5 + (itsRegionOfInterest[3] - itsRegionOfInterest[2]) / itsWorkDomainSize.timeInterval)); - - double timeStep = (itsRegionOfInterest[3] - itsRegionOfInterest[2]); - if(timeCount > 1) - timeStep /= timeCount; - - bool result = true; - double time = itsRegionOfInterest[2]; - for(int i = 0; i < timeCount && result; ++i) - { - ASSERT(itsPrediffer->setWorkDomain(itsRegionOfInterest[0], - itsRegionOfInterest[1], - time, - time + timeStep)); + ASSERT(itsPrediffer->setWorkDomain(itsRegionOfInterest[0], + itsRegionOfInterest[1], + itsRegionOfInterest[2], + itsRegionOfInterest[3])); - time = itsPrediffer->getWorkDomain().endY(); - result = false; + bool result = false; + { + const BBSPredictStep* step = dynamic_cast<const BBSPredictStep*>(bs); + if(step) { - const BBSPredictStep* step = dynamic_cast<const BBSPredictStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } - + } + + { + const BBSSubtractStep* step = dynamic_cast<const BBSSubtractStep*>(bs); + if(step) { - const BBSSubtractStep* step = dynamic_cast<const BBSSubtractStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } - + } + + { + const BBSCorrectStep* step = dynamic_cast<const BBSCorrectStep*>(bs); + if(step) { - const BBSCorrectStep* step = dynamic_cast<const BBSCorrectStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } - + } + + { + const BBSSolveStep* step = dynamic_cast<const BBSSolveStep*>(bs); + if(step) { - const BBSSolveStep* step = dynamic_cast<const BBSSolveStep*>(bs); - if(step) - { - result = handle(step); - } + result = handle(step); } } -- GitLab