diff --git a/.gitattributes b/.gitattributes index d4b037c819218e4fab80647f6d453878d88ea685..5f085c42ae4c47b6a05703af3b066d3a5f72a667 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,7 +20,6 @@ CEP/Calibration/BBSControl/include/BBSControl/CalSession.h -text CEP/Calibration/BBSControl/include/BBSControl/CalSessionTransactors.h -text CEP/Calibration/BBSControl/include/BBSControl/GlobalSolveController.h -text CEP/Calibration/BBSControl/include/BBSControl/LocalSolveController.h -text -CEP/Calibration/BBSControl/include/BBSControl/NoiseStep.h -text CEP/Calibration/BBSControl/scripts/example_solflag.py -text CEP/Calibration/BBSControl/scripts/example_solplot.py -text CEP/Calibration/BBSControl/scripts/solflag.py -text @@ -30,7 +29,6 @@ CEP/Calibration/BBSControl/src/CalSession.cc -text CEP/Calibration/BBSControl/src/CalSessionTransactors.cc -text CEP/Calibration/BBSControl/src/GlobalSolveController.cc -text CEP/Calibration/BBSControl/src/LocalSolveController.cc -text -CEP/Calibration/BBSControl/src/NoiseStep.cc -text CEP/Calibration/BBSControl/src/calibrate -text CEP/Calibration/BBSControl/src/calibrate-part -text CEP/Calibration/BBSKernel/include/BBSKernel/Equator.h -text diff --git a/CEP/Calibration/BBSControl/include/BBSControl/CommandVisitor.h b/CEP/Calibration/BBSControl/include/BBSControl/CommandVisitor.h index 89f276ab15e668071a6b3efc2457860f71aef96a..d71ae195c7a533736472c39c77d75c8ebb25772e 100644 --- a/CEP/Calibration/BBSControl/include/BBSControl/CommandVisitor.h +++ b/CEP/Calibration/BBSControl/include/BBSControl/CommandVisitor.h @@ -23,7 +23,7 @@ #ifndef LOFAR_BBSCONTROL_COMMANDVISITOR_H #define LOFAR_BBSCONTROL_COMMANDVISITOR_H -// \file +// \file // Abstract visitor class for the Command class #include <BBSControl/CommandResult.h> @@ -46,7 +46,6 @@ namespace LOFAR class SolveStep; class ShiftStep; class RefitStep; - class NoiseStep; // \addtogroup BBSControl // @{ @@ -78,7 +77,6 @@ namespace LOFAR virtual CommandResult visit(const SolveStep &command) = 0; virtual CommandResult visit(const ShiftStep &command) = 0; virtual CommandResult visit(const RefitStep &command) = 0; - virtual CommandResult visit(const NoiseStep &command) = 0; }; //# Pure virtual destructor has to be defined... diff --git a/CEP/Calibration/BBSControl/include/BBSControl/KernelProcessControl.h b/CEP/Calibration/BBSControl/include/BBSControl/KernelProcessControl.h index be58292e7d1be689c8dc9e691418e976c9106ec2..2e3349c6a83a7e79bbf0b2e5256d3dc177281b5b 100644 --- a/CEP/Calibration/BBSControl/include/BBSControl/KernelProcessControl.h +++ b/CEP/Calibration/BBSControl/include/BBSControl/KernelProcessControl.h @@ -97,7 +97,6 @@ public: virtual CommandResult visit(const SolveStep &command); virtual CommandResult visit(const ShiftStep &command); virtual CommandResult visit(const RefitStep &command); - virtual CommandResult visit(const NoiseStep &command); // @} private: @@ -128,17 +127,17 @@ private: // Calibration session information. scoped_ptr<CalSession> itsCalSession; - + // 0-based index of this kernel process. KernelIndex itsKernelIndex; - + // Measurement. Measurement::Pointer itsMeasurement; string itsInputColumn; - + // Global time axis. Axis::ShPtr itsGlobalTimeAxis; - + // Chunk. Box itsDomain; VisSelection itsChunkSelection; diff --git a/CEP/Calibration/BBSControl/include/BBSControl/Makefile.am b/CEP/Calibration/BBSControl/include/BBSControl/Makefile.am index 4c097d1e376f1d42783ace062e67e37a344ddbdf..90267d7be1603a32716bd9fe488f22245ed594b4 100644 --- a/CEP/Calibration/BBSControl/include/BBSControl/Makefile.am +++ b/CEP/Calibration/BBSControl/include/BBSControl/Makefile.am @@ -18,7 +18,6 @@ pkginclude_HEADERS = Package__Version.h \ MessageHandlers.h \ MultiStep.h \ NextChunkCommand.h \ - NoiseStep.h \ PredictStep.h \ RecoverCommand.h \ RefitStep.h \ diff --git a/CEP/Calibration/BBSControl/include/BBSControl/NoiseStep.h b/CEP/Calibration/BBSControl/include/BBSControl/NoiseStep.h deleted file mode 100644 index c8917123c228418358a26c1763d9e427350376d3..0000000000000000000000000000000000000000 --- a/CEP/Calibration/BBSControl/include/BBSControl/NoiseStep.h +++ /dev/null @@ -1,96 +0,0 @@ -//# NoiseStep.h: Options for noise operation. -//# -//# Copyright (C) 2008 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -#ifndef LOFAR_BBSCONTROL_BBSNOISESTEP_H -#define LOFAR_BBSCONTROL_BBSNOISESTEP_H - -// \file -// Options for noise operation. - -#include <BBSControl/SingleStep.h> -#include <Common/LofarTypes.h> - -namespace LOFAR -{ -namespace BBS -{ - -// \addtogroup BBSControl -// @{ - -class NoiseStep: public SingleStep -{ -public: - // Default constructor. Construct an empty NoiseStep object and make - // it a child of the Step object \a parent. - NoiseStep(const Step* parent = 0); - - // Construct a NoiseStep having the name \a name. Configuration - // information for this step can be retrieved from the parameter set \a - // parset, by searching for keys <tt>Step.\a name</tt>. \a parent - // is a pointer to the Step object that is the parent of \c *this. - NoiseStep(const string& name, - const ParameterSet& parset, - const Step* parent); - - virtual ~NoiseStep(); - - // Accept a CommandVisitor that wants to process \c *this. - virtual CommandResult accept(CommandVisitor &visitor) const; - - // Return the operation type of \c *this as a string. - virtual const string& operation() const; - - // Print the contents of \c *this in human readable form into the output - // stream \a os. - virtual void print(ostream& os) const; - - // @name Accessor methods - // @{ - double mean() const - { return itsMean; } - double sigma() const - { return itsSigma; } -// unsigned int seed() const -// { return itsSeed; } - // @} - - // Return the command type of \c *this as a string. - virtual const string& type() const; - -private: - // Write the contents of \c *this into the ParameterSet \a ps. - virtual void write(ParameterSet& ps) const; - - // Read the contents from the ParameterSet \a ps into \c *this. - virtual void read(const ParameterSet& ps); - - double itsMean, itsSigma; -// uint32 itsSeed; -}; - -// @} - -} //# namespace BBS -} //# namespace LOFAR - -#endif diff --git a/CEP/Calibration/BBSControl/include/BBSControl/SolverProcessControl.h b/CEP/Calibration/BBSControl/include/BBSControl/SolverProcessControl.h index 374a20439efcc8d3b8a5c22b5c53e20669c7c771..b88d2bf338549d9fc2fe1b8bc250103111cd7083 100644 --- a/CEP/Calibration/BBSControl/include/BBSControl/SolverProcessControl.h +++ b/CEP/Calibration/BBSControl/include/BBSControl/SolverProcessControl.h @@ -88,9 +88,8 @@ namespace LOFAR virtual CommandResult visit(const SolveStep &command); virtual CommandResult visit(const ShiftStep &command); virtual CommandResult visit(const RefitStep &command); - virtual CommandResult visit(const NoiseStep &command); // @} - + private: enum State { @@ -103,7 +102,7 @@ namespace LOFAR // Returns a CommandResult with a descriptive message. CommandResult unsupported(const Command &command) const; - + // Set run state to \a state void setState(State state); @@ -129,7 +128,7 @@ namespace LOFAR // Vector of kernels. vector<KernelConnection> itsKernels; - + // Container of solve tasks. Each task is executed by a different kernel // group. vector<SolveTask> itsSolveTasks; diff --git a/CEP/Calibration/BBSControl/src/CalSessionTransactors.cc b/CEP/Calibration/BBSControl/src/CalSessionTransactors.cc index b2b65f1dbb19a6ebddfd0f7cd45de846bc388051..719a88d2440ff3ca574067fac57ee88cbd60a91a 100644 --- a/CEP/Calibration/BBSControl/src/CalSessionTransactors.cc +++ b/CEP/Calibration/BBSControl/src/CalSessionTransactors.cc @@ -33,7 +33,7 @@ namespace LOFAR { -namespace BBS +namespace BBS { PQInitSession::PQInitSession(const string &key, int32 &id) @@ -42,7 +42,7 @@ PQInitSession::PQInitSession(const string &key, int32 &id) itsId(id) { } - + void PQInitSession::operator()(argument_type &transaction) { ostringstream query; @@ -68,7 +68,7 @@ PQSetState::PQSetState(int32 id, const ProcessId &pid, CalSession::State state, itsStatus(status) { } - + void PQSetState::operator()(argument_type &transaction) { ostringstream query; @@ -108,7 +108,7 @@ void PQGetState::operator()(argument_type &transaction) void PQGetState::on_commit() { itsStatus = itsQueryResult[0]["_status"].as<int32>(); - + if(itsStatus == 0) { int32 state = itsQueryResult[0]["_state"].as<int32>(); @@ -117,7 +117,6 @@ void PQGetState::on_commit() { THROW(TranslationException, "Invalid session state: " << state); } - LOG_DEBUG_STR("RUN STATE: " << state); itsState = static_cast<CalSession::State>(state); } } @@ -131,12 +130,12 @@ PQInitWorkerRegister::PQInitWorkerRegister(int32 id, const ProcessId &pid, itsVdsDesc(vds), itsUseSolver(useSolver) { -} +} void PQInitWorkerRegister::operator()(argument_type &transaction) { ostringstream query; - + const vector<CEP::VdsPartDesc> &parts = itsVdsDesc.getParts(); for(size_t i = 0; i < parts.size(); ++i) { @@ -150,7 +149,7 @@ void PQInitWorkerRegister::operator()(argument_type &transaction) LOG_DEBUG_STR("Query: " << query.str()); transaction.exec(query.str()); } - + if(itsUseSolver) { query.str(""); @@ -200,7 +199,7 @@ PQRegisterAsKernel::PQRegisterAsKernel(int32 id, const ProcessId &pid, itsGrid(grid), itsStatus(status) { -} +} void PQRegisterAsKernel::operator()(argument_type &transaction) { @@ -221,7 +220,7 @@ void PQRegisterAsKernel::operator()(argument_type &transaction) << pack_vector(transaction, itsGrid[0]->uppers()) << "',E'" << pack_vector(transaction, itsGrid[1]->lowers()) << "',E'" << pack_vector(transaction, itsGrid[1]->uppers()) << "')"; - LOG_DEBUG_STR("Query: " << query.str()); +// LOG_DEBUG_STR("Query: " << query.str()); itsQueryResult = transaction.exec(query.str()); } @@ -239,7 +238,7 @@ PQRegisterAsSolver::PQRegisterAsSolver(int32 id, const ProcessId &pid, itsPort(port), itsStatus(status) { -} +} void PQRegisterAsSolver::operator()(argument_type &transaction) { @@ -269,7 +268,7 @@ PQGetWorkerRegister::PQGetWorkerRegister(int32 id, vector<size_t> &count, { ASSERT(itsCount.size() == CalSession::N_WorkerType); } - + void PQGetWorkerRegister::operator()(argument_type &transaction) { ostringstream query; @@ -282,7 +281,7 @@ void PQGetWorkerRegister::operator()(argument_type &transaction) void PQGetWorkerRegister::on_commit() { fill(itsCount.begin(), itsCount.end(), 0); - + pqxx::result::const_iterator rowIt = itsQueryResult.begin(); const pqxx::result::const_iterator rowItEnd = itsQueryResult.end(); while(rowIt != rowItEnd) @@ -293,7 +292,7 @@ void PQGetWorkerRegister::on_commit() { THROW(TranslationException, "Invalid worker type: " << type); } - CalSession::WorkerType workerType = + CalSession::WorkerType workerType = static_cast<CalSession::WorkerType>(type); // Update slot counter. @@ -330,7 +329,7 @@ void PQGetWorkerRegister::on_commit() // Get measurement part. worker.filesys = rowIt["filesys"].as<string>(); worker.path = rowIt["path"].as<string>(); - + // Unpack frequency axis. pqxx::binarystring freqLower(rowIt["axis_freq_lower"]); pqxx::binarystring freqUpper(rowIt["axis_freq_upper"]); @@ -338,7 +337,7 @@ void PQGetWorkerRegister::on_commit() unpack_vector<double>(freqLower), unpack_vector<double>(freqUpper), true)); - + // Unpack time axis. pqxx::binarystring timeLower(rowIt["axis_time_lower"]); pqxx::binarystring timeUpper(rowIt["axis_time_upper"]); @@ -346,7 +345,7 @@ void PQGetWorkerRegister::on_commit() unpack_vector<double>(timeLower), unpack_vector<double>(timeUpper), true)); - + worker.grid = Grid(freqAxis, timeAxis); } else @@ -363,7 +362,7 @@ void PQGetWorkerRegister::on_commit() itsWorkers.push_back(worker); LOG_DEBUG_STR("Found worker... Type: " << type); - + ++rowIt; } } @@ -423,7 +422,7 @@ void PQPostCommand::operator()(argument_type &transaction) << itsId << ",'" << transaction.esc(itsProcessId.hostname) << "'" << "," << itsProcessId.pid; - + if(itsAddressee != CalSession::N_WorkerType) { query << "," << static_cast<int32>(itsAddressee); @@ -476,7 +475,7 @@ PQPostResult::PQPostResult(int32 id, const ProcessId &pid, itsCommandResult(cmdResult), itsStatus(status) { -} +} void PQPostResult::operator()(argument_type &transaction) { @@ -508,7 +507,7 @@ PQGetCommand::PQGetCommand(int32 id, const ProcessId &pid, int32 &status, itsCommand(cmd) { } - + void PQGetCommand::operator()(argument_type &transaction) { ostringstream query; @@ -531,7 +530,7 @@ void PQGetCommand::on_commit() itsCommand = make_pair(CommandId(-1), shared_ptr<Command>()); return; } - + string type = itsQueryResult[0]["_type"].as<string>(); // Get the command-id. @@ -564,7 +563,7 @@ void PQGetCommand::on_commit() THROW(TranslationException, "Failed to create a '" << type << "'" << " command object"); } - + cmd->read(ps); itsCommand = make_pair(id, cmd); } @@ -580,7 +579,7 @@ PQGetCommandStatus::PQGetCommandStatus(const CommandId &id, int32 &status, itsCommandStatus(commandStatus) { } - + void PQGetCommandStatus::operator()(argument_type &transaction) { ostringstream query; @@ -624,7 +623,7 @@ PQGetResults::PQGetResults(const CommandId &id, itsResults(results) { } - + void PQGetResults::operator()(argument_type &transaction) { ostringstream query; @@ -637,7 +636,7 @@ void PQGetResults::operator()(argument_type &transaction) void PQGetResults::on_commit() { itsResults.clear(); - + pqxx::result::const_iterator rowIt = itsQueryResult.begin(); const pqxx::result::const_iterator rowItEnd = itsQueryResult.end(); while(rowIt != rowItEnd) @@ -658,7 +657,7 @@ void PQGetResults::on_commit() itsResults.push_back(res); ++rowIt; - } + } } } //# namespace BBS diff --git a/CEP/Calibration/BBSControl/src/KernelProcessControl.cc b/CEP/Calibration/BBSControl/src/KernelProcessControl.cc index e91d6f87291ffdeaeb247585a6d46b8281c1426d..cce1c19ac72f2a405c28b44ec1f695f4af586e36 100644 --- a/CEP/Calibration/BBSControl/src/KernelProcessControl.cc +++ b/CEP/Calibration/BBSControl/src/KernelProcessControl.cc @@ -1,4 +1,4 @@ -//# KernelProcessControl.cc: +//# KernelProcessControl.cc: //# //# Copyright (C) 2002-2007 //# ASTRON (Netherlands Foundation for Research in Astronomy) @@ -46,7 +46,6 @@ #include <BBSControl/SolveStep.h> #include <BBSControl/ShiftStep.h> #include <BBSControl/RefitStep.h> -#include <BBSControl/NoiseStep.h> #include <Common/ParameterSet.h> #include <Common/Exceptions.h> @@ -73,12 +72,12 @@ #include <BBSKernel/Equator.h> #include <BBSKernel/Solver.h> -namespace LOFAR +namespace LOFAR { - namespace BBS + namespace BBS { using LOFAR::operator<<; - + // Forces registration with Object Factory. namespace { @@ -149,7 +148,7 @@ namespace LOFAR LOG_ERROR_STR("Failed to open sky model parameter database: " << skyDb); return false; - } + } try { // Open instrument model parameter database. @@ -170,7 +169,7 @@ namespace LOFAR ps->getString("BBDB.Password", ""), ps->getString("BBDB.Host", "localhost"), ps->getString("BBDB.Port", "5432"))); - + // Poll until Control is ready to accept workers. while(itsCalSession->getState() == CalSession::WAITING_FOR_CONTROL) { sleep(3); @@ -182,7 +181,7 @@ namespace LOFAR LOG_ERROR("Registration denied."); return false; } - + LOG_INFO_STR("Registration OK."); setState(RUN); } @@ -206,7 +205,7 @@ namespace LOFAR return false; break; } - + case WAIT: { // Wait for a command. Note that this call falls through whenever // a new command is inserted. @@ -220,11 +219,11 @@ namespace LOFAR case RUN: { pair<CommandId, shared_ptr<Command> > command = itsCalSession->getCommand(); - + if(command.second) { LOG_DEBUG_STR("Executing a " << command.second->type() << "command."); - + // Try to execute the command. CommandResult result = command.second->accept(*this); @@ -252,13 +251,13 @@ namespace LOFAR } break; } - } // switch(itsState) + } // switch(itsState) } catch(Exception& e) { LOG_ERROR_STR(e); return false; } - + return true; } @@ -322,10 +321,10 @@ namespace LOFAR CommandResult KernelProcessControl::visit(const InitializeCommand &command) { LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); - + // Get the index of this kernel process. itsKernelIndex = itsCalSession->getIndex(); - + // Construct global time axis. itsGlobalTimeAxis = itsCalSession->getGlobalTimeAxis(); ASSERT(itsGlobalTimeAxis); @@ -336,7 +335,7 @@ namespace LOFAR ProcessId solverId = itsCalSession->getWorkerByIndex(CalSession::SOLVER, 0); const size_t port = itsCalSession->getPort(solverId); - + LOG_DEBUG_STR("Defining connection: solver@" << solverId.hostname << ":" << port); @@ -346,7 +345,7 @@ namespace LOFAR itsSolver.reset(new BlobStreamableConnection(solverId.hostname, tmp.str(), Socket::TCP)); - if(!itsSolver->connect()) { + if(!itsSolver->connect()) { return CommandResult(CommandResult::ERROR, "Unable to connect to" " solver."); } @@ -365,12 +364,12 @@ namespace LOFAR if(!command.getStations().empty()) { itsChunkSelection.setStations(command.getStations()); } - + Correlation correlation = command.getCorrelation(); if(!correlation.type.empty()) { itsChunkSelection.setPolarizations(correlation.type); } - + if(correlation.selection == "AUTO") { itsChunkSelection.setBaselineFilter(VisSelection::AUTO); } @@ -411,7 +410,7 @@ namespace LOFAR // (even though locally visibility data is available for only a small part // of this domain). ParmManager::instance().setDomain(itsDomain); - + // Update chunk selection. itsChunkSelection.clear(VisSelection::TIME_START); itsChunkSelection.clear(VisSelection::TIME_END); @@ -467,19 +466,19 @@ namespace LOFAR // Parse visibility selection. vector<baseline_t> baselines; vector<string> products; - + if(!(parseBaselineSelection(baselines, command) && parseProductSelection(products, command))) { return CommandResult(CommandResult::ERROR, "Unable to parse visibility" " selection."); - } - + } + // Initialize model. if(!itsModel->makeFwdExpressions(command.modelConfig(), baselines)) { return CommandResult(CommandResult::ERROR, "Unable to initialize" " model."); } - + // Compute simulated visibilities. Evaluator evaluator(itsChunk, itsModel); evaluator.setSelection(baselines, products); @@ -507,19 +506,19 @@ namespace LOFAR // Parse visibility selection. vector<baseline_t> baselines; vector<string> products; - + if(!(parseBaselineSelection(baselines, command) && parseProductSelection(products, command))) { return CommandResult(CommandResult::ERROR, "Unable to parse visibility" " selection."); - } - + } + // Initialize model. if(!itsModel->makeFwdExpressions(command.modelConfig(), baselines)) { return CommandResult(CommandResult::ERROR, "Unable to initialize" " model."); } - + // Compute simulated visibilities. Evaluator evaluator(itsChunk, itsModel); evaluator.setSelection(baselines, products); @@ -547,19 +546,19 @@ namespace LOFAR // Parse visibility selection. vector<baseline_t> baselines; vector<string> products; - + if(!(parseBaselineSelection(baselines, command) && parseProductSelection(products, command))) { return CommandResult(CommandResult::ERROR, "Unable to parse visibility" " selection."); - } - + } + // Initialize model. if(!itsModel->makeFwdExpressions(command.modelConfig(), baselines)) { return CommandResult(CommandResult::ERROR, "Unable to initialize" " model."); } - + // Compute simulated visibilities. Evaluator evaluator(itsChunk, itsModel); evaluator.setSelection(baselines, products); @@ -587,20 +586,20 @@ namespace LOFAR // Parse visibility selection. vector<baseline_t> baselines; vector<string> products; - + if(!(parseBaselineSelection(baselines, command) && parseProductSelection(products, command))) { return CommandResult(CommandResult::ERROR, "Unable to parse visibility" " selection."); - } - + } + // Initialize model. if(!itsModel->makeInvExpressions(command.modelConfig(), itsChunk, baselines)) { return CommandResult(CommandResult::ERROR, "Unable to initialize" " model."); } - + // Compute simulated visibilities. Evaluator evaluator(itsChunk, itsModel); evaluator.setSelection(baselines, products); @@ -621,26 +620,26 @@ namespace LOFAR CommandResult KernelProcessControl::visit(const SolveStep &command) { LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); - + ASSERTSTR(itsChunk, "No visibility data available."); ASSERTSTR(itsModel, "No model available."); // Parse visibility selection. vector<baseline_t> baselines; vector<string> products; - + if(!(parseBaselineSelection(baselines, command) && parseProductSelection(products, command))) { return CommandResult(CommandResult::ERROR, "Unable to parse" " visibility selection."); } - + // Initialize model. if(!itsModel->makeFwdExpressions(command.modelConfig(), baselines)) { return CommandResult(CommandResult::ERROR, "Unable to initialize" " model."); } - + try { if(command.calibrationGroups().empty()) @@ -705,7 +704,7 @@ namespace LOFAR // calibration group that this kernel is part of. const size_t first = groupId > 0 ? groupIndex[groupId - 1] : 0; const size_t last = groupIndex[groupId] - 1; - + // Get frequency range of the calibration group. ProcessId firstKernel = itsCalSession->getWorkerByIndex(CalSession::KERNEL, first); @@ -715,7 +714,7 @@ namespace LOFAR itsCalSession->getWorkerByIndex(CalSession::KERNEL, last); const double freqEnd = itsCalSession->getGrid(lastKernel)[0]->range().second; - + LOG_DEBUG_STR("Group freq range: [" << setprecision(15) << freqBegin << "," << freqEnd << "]"); Axis::ShPtr freqAxis(new RegularAxis(freqBegin, freqEnd - freqBegin, @@ -779,13 +778,6 @@ namespace LOFAR return unsupported(command); } - CommandResult KernelProcessControl::visit(const NoiseStep &command) - { - LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); - return unsupported(command); - } - - //##-------- P r i v a t e m e t h o d s --------##// CommandResult KernelProcessControl::unsupported(const Command &command) const @@ -834,17 +826,17 @@ namespace LOFAR " the same length."); return false; } - + // Filter available baselines. set<baseline_t> selection; - + if(station1.empty()) { // If no station groups are speficied, select all the baselines // available in the chunk that match the baseline filter. const VisDimensions &dims = itsChunk->getDimensions(); const vector<baseline_t> &baselines = dims.getBaselines(); - + vector<baseline_t>::const_iterator baselIt = baselines.begin(); vector<baseline_t>::const_iterator baselItEnd = baselines.end(); while(baselIt != baselItEnd) @@ -935,7 +927,7 @@ namespace LOFAR " observation."); return false; } - + result.resize(selection.size()); copy(selection.begin(), selection.end(), result.begin()); return true; diff --git a/CEP/Calibration/BBSControl/src/Makefile.am b/CEP/Calibration/BBSControl/src/Makefile.am index c81b818b198eebb025b6008603db175111f09969..1cbd76fbc7de536a00266e1fc55889a3ee2cbbb2 100644 --- a/CEP/Calibration/BBSControl/src/Makefile.am +++ b/CEP/Calibration/BBSControl/src/Makefile.am @@ -18,7 +18,6 @@ libbbscontrol_la_SOURCES = Package__Version.cc \ Messages.cc \ MultiStep.cc \ NextChunkCommand.cc \ - NoiseStep.cc \ PredictStep.cc \ RecoverCommand.cc \ RefitStep.cc \ diff --git a/CEP/Calibration/BBSControl/src/NoiseStep.cc b/CEP/Calibration/BBSControl/src/NoiseStep.cc deleted file mode 100644 index fce0ab91b76efbdc618d9750b40ded0ed8b4bcdd..0000000000000000000000000000000000000000 --- a/CEP/Calibration/BBSControl/src/NoiseStep.cc +++ /dev/null @@ -1,116 +0,0 @@ -//# NoiseStep.cc: Options for noise operation. -//# -//# Copyright (C) 2008 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ - -#include <lofar_config.h> -#include <BBSControl/NoiseStep.h> -#include <BBSControl/CommandVisitor.h> -#include <BBSControl/StreamUtil.h> -#include <Common/LofarLogger.h> -#include <Common/ParameterSet.h> - -namespace LOFAR -{ -namespace BBS -{ -using LOFAR::operator<<; - -NoiseStep::NoiseStep(const Step* parent) - : SingleStep(parent) -{ - LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); -} - -NoiseStep::NoiseStep(const string& name, - const ParameterSet& parset, - const Step* parent) - : SingleStep(name, parent) -{ - LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); - - // Get the relevant parameters from the Parameter Set \a parset. - read(parset.makeSubset("Step." + name + ".")); -} - -NoiseStep::~NoiseStep() -{ - LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); -} - -CommandResult NoiseStep::accept(CommandVisitor &visitor) const -{ - return visitor.visit(*this); -} - -const string& NoiseStep::operation() const -{ - static const string theType("Noise"); - return theType; -} - -void NoiseStep::print(ostream& os) const -{ - LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); - SingleStep::print(os); - Indent id; - os << endl << indent << "Additive Gaussian noise:"; - { - Indent id; - os << endl << indent << "Mean: " << itsMean - << endl << indent << "Sigma: " << itsSigma; -// << endl << indent << "Seed: " << itsSeed; - } -} - -const string& NoiseStep::type() const -{ - static const string theOperation("Noise"); - return theOperation; -} - -//##-------- P r i v a t e m e t h o d s --------##// - -void NoiseStep::write(ParameterSet& ps) const -{ - LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); - SingleStep::write(ps); - - const string prefix = "Step." + name() + ".Noise."; - ps.replace(prefix + "Mean", toString(itsMean)); - ps.replace(prefix + "Sigma", toString(itsSigma)); -// ps.replace(prefix + "Seed", toString(itsSeed)); - - LOG_TRACE_VAR_STR("\nContents of ParameterSet ps:\n" << ps); -} - -void NoiseStep::read(const ParameterSet& ps) -{ - LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); - SingleStep::read(ps); - ParameterSet pss(ps.makeSubset("Noise.")); - itsMean = pss.getDouble("Mean", 0.0); - itsSigma = pss.getDouble("Sigma", 1.0); - // Default seed used in boost::random::mersenne_twister. -// itsSeed = pss.getUint32("Seed", 5489u); -} - -} //# namespace BBS -} //# namespace LOFAR diff --git a/CEP/Calibration/BBSControl/src/SolverProcessControl.cc b/CEP/Calibration/BBSControl/src/SolverProcessControl.cc index fbd6962219e3128d7e23ece06e5da45b6601fbe5..9d65e035b4004409fa22cac0259328391c8c8ca6 100644 --- a/CEP/Calibration/BBSControl/src/SolverProcessControl.cc +++ b/CEP/Calibration/BBSControl/src/SolverProcessControl.cc @@ -47,7 +47,6 @@ #include <BBSControl/SolveStep.h> #include <BBSControl/ShiftStep.h> #include <BBSControl/RefitStep.h> -#include <BBSControl/NoiseStep.h> #include <Common/ParameterSet.h> @@ -103,7 +102,7 @@ namespace LOFAR try { const ParameterSet *ps = globalParameterSet(); ASSERT(ps); - + // Initialize the calibration session. string key = ps->getString("BBDB.Key", "default"); itsCalSession.reset(new CalSession(key, @@ -112,14 +111,14 @@ namespace LOFAR ps->getString("BBDB.Password", ""), ps->getString("BBDB.Host", "localhost"), ps->getString("BBDB.Port", "5432"))); - + // Initialize a TCP listen socket that will accept incoming kernel // connections. int32 backlog = ps->getInt32("ConnectionBacklog", 10); // Set socket name. itsSocket.setName("Solver"); - + // Get range of ports to test from parset, or default to [6500, 6599]. vector<uint> range = ps->getUintVector("PortRange", vector<uint>()); uint portLow = range.size() > 0 ? range[0] : 6500; @@ -145,9 +144,9 @@ namespace LOFAR " the range [" << portLow << "," << portHigh << "]"); return false; } - + LOG_INFO_STR("Listening on port: " << port); - + // Poll until Control is ready to accept workers. LOG_INFO_STR("Waiting for Control..."); while(itsCalSession->getState() == CalSession::WAITING_FOR_CONTROL) { @@ -159,7 +158,7 @@ namespace LOFAR LOG_ERROR("Registration denied."); return false; } - + LOG_INFO_STR("Registration OK."); setState(RUN); } @@ -184,7 +183,7 @@ namespace LOFAR return false; break; } - + case WAIT: { // Wait for a command. Note that this call falls through whenever // a new command is inserted. @@ -209,7 +208,7 @@ namespace LOFAR // Report the result to the global controller. itsCalSession->postResult(command.first, result); - + // If an error occurred, log a descriptive message and exit. if(result.is(CommandResult::ERROR)) { LOG_ERROR_STR("Error executing " << command.second->type() @@ -231,7 +230,7 @@ namespace LOFAR } break; } - } // switch(itsState) + } // switch(itsState) } catch(Exception& e) { LOG_ERROR_STR(e); @@ -326,13 +325,13 @@ namespace LOFAR THROW(SolverControlException, "Protocol error. Expected a" " ProcessIdMsg"); } - + if(!itsCalSession->isKernel(msg->getProcessId())) { connection.reset(); THROW(SolverControlException, "Process " << msg->getProcessId() << "is not a registered kernel process; disconnected"); } - + KernelIndex index = itsCalSession->getIndex(msg->getProcessId()); try { @@ -407,7 +406,7 @@ namespace LOFAR CommandResult SolverProcessControl::visit(const SolveStep &command) { LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); - + // Initialize a solve task for each calibration group. setSolveTasks(command.calibrationGroups(), command.solverOptions()); @@ -430,7 +429,7 @@ namespace LOFAR done = itsSolveTasks[i].run() && done; } } - + return CommandResult(CommandResult::OK, "Ok."); } @@ -446,13 +445,6 @@ namespace LOFAR return unsupported(command); } - CommandResult SolverProcessControl::visit(const NoiseStep &command) - { - LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); - return unsupported(command); - } - - //##-------- P r i v a t e m e t h o d s --------##// CommandResult SolverProcessControl::unsupported(const Command &command) @@ -491,7 +483,7 @@ namespace LOFAR // Sanity check if (itsKernels.size() < accumulate(groups.begin(), groups.end(), 0U)) { - THROW (SolverControlException, + THROW (SolverControlException, "Sum of kernels in subgroups exceeds total number of kernels"); } diff --git a/CEP/Calibration/BBSControl/src/Step.cc b/CEP/Calibration/BBSControl/src/Step.cc index 86e4a98e5cbc364e3ab0702b895169437cc3fba3..175eef91f72dc2fd5234e7ef224f08af091895e1 100644 --- a/CEP/Calibration/BBSControl/src/Step.cc +++ b/CEP/Calibration/BBSControl/src/Step.cc @@ -1,4 +1,4 @@ -//# Step.cc: +//# Step.cc: //# //# Copyright (C) 2002-2007 //# ASTRON (Netherlands Foundation for Research in Astronomy) @@ -24,7 +24,6 @@ #include <BBSControl/Step.h> #include <BBSControl/CorrectStep.h> -#include <BBSControl/NoiseStep.h> #include <BBSControl/PredictStep.h> #include <BBSControl/RefitStep.h> #include <BBSControl/ShiftStep.h> @@ -80,7 +79,7 @@ namespace LOFAR // We'll have to figure out what kind of SingleStep we must // create. The key "Operation" contains this information. try { - string oper = + string oper = toUpper(parset.getString("Step." + name + ".Operation")); LOG_TRACE_COND_STR("Creating a " << oper << " step ..."); if (oper == "SOLVE") @@ -97,9 +96,7 @@ namespace LOFAR step.reset(new ShiftStep(name, parset, parent)); else if (oper == "REFIT") step.reset(new RefitStep(name, parset, parent)); - else if (oper == "NOISE") - step.reset(new NoiseStep(name, parset, parent)); - else THROW (BBSControlException, "Operation \"" << oper << + else THROW (BBSControlException, "Operation \"" << oper << "\" is not a valid Step operation"); } catch (APSException& e) { THROW (BBSControlException, e.what()); @@ -165,7 +162,7 @@ namespace LOFAR dynamic_pointer_cast<const HamakerDipoleConfig> (itsModelConfig.beamConfig); ASSERT(config); - + ps.replace(prefix + "Model.Beam.HamakerDipole.CoeffFile", config->coeffFile); } @@ -192,16 +189,16 @@ namespace LOFAR LOG_TRACE_LIFETIME(TRACE_LEVEL_COND, ""); // Get the baseline selection for this step. - itsBaselines.station1 = + itsBaselines.station1 = ps.getStringVector("Baselines.Station1", itsBaselines.station1); itsBaselines.station2 = ps.getStringVector("Baselines.Station2", itsBaselines.station2); // Get the correlation selection (ALL, AUTO, or CROSS), and type // (e.g., ["XX", "XY", "YX", "YY"]). - itsCorrelation.selection = + itsCorrelation.selection = ps.getString("Correlation.Selection", itsCorrelation.selection); - itsCorrelation.type = + itsCorrelation.type = ps.getStringVector("Correlation.Type", itsCorrelation.type); // Get the model configuration. @@ -211,13 +208,13 @@ namespace LOFAR ps.getStringVector("Model.Sources", itsModelConfig.sources); itsModelConfig.components = ps.getStringVector("Model.Components", itsModelConfig.components); - + if(ps.isDefined("Model.Ionosphere.Rank")) { IonoConfig::Pointer config(new IonoConfig()); config->rank = ps.getUint32("Model.Ionosphere.Rank"); itsModelConfig.ionoConfig = config; } - + if(ps.isDefined("Model.Beam.Type")) { string beamType(ps.getString("Model.Beam.Type")); @@ -228,7 +225,7 @@ namespace LOFAR HamakerDipoleConfig::ConstPointer parentConfig = dynamic_pointer_cast<const HamakerDipoleConfig> (itsModelConfig.beamConfig); - + HamakerDipoleConfig::Pointer config(new HamakerDipoleConfig()); config->coeffFile = ps.getString("Model.Beam.HamakerDipole.CoeffFile", @@ -237,14 +234,14 @@ namespace LOFAR THROW(BBSControlException, "Model.Beam.HamakerDipole.CoeffFile" " expected but not found."); } - + itsModelConfig.beamConfig = config; } else if(beamType == "YatawattaDipole") { YatawattaDipoleConfig::ConstPointer parentConfig = dynamic_pointer_cast<const YatawattaDipoleConfig> (itsModelConfig.beamConfig); - + YatawattaDipoleConfig::Pointer config(new YatawattaDipoleConfig()); config->moduleTheta = @@ -269,7 +266,7 @@ namespace LOFAR THROW(BBSControlException, "Unknown beam model type " << beamType << " encountered."); } - } + } }