Skip to content
Snippets Groups Projects
Commit 525933e5 authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

BugID: 687

Final(?) version of the DelayCompensation package.
parent b894383a
No related branches found
No related tags found
No related merge requests found
...@@ -180,7 +180,7 @@ namespace LOFAR ...@@ -180,7 +180,7 @@ namespace LOFAR
// Number of delays that will be calculated per epoch. This number is a // Number of delays that will be calculated per epoch. This number is a
// run-time constant, because it is equal to the number of beams per // run-time constant, because it is equal to the number of beams per
// station times the number of stations. // station times the number of stations.
const uint itsNrDelaysPerEpoch; const uint itsNrDelays;
// The sample rate in a subband, in samples per second.. // The sample rate in a subband, in samples per second..
const double itsSampleRate; const double itsSampleRate;
......
...@@ -45,6 +45,8 @@ namespace LOFAR ...@@ -45,6 +45,8 @@ namespace LOFAR
INIT_TRACER_CONTEXT(WH_DelayCompensation, LOFARLOGGER_PACKAGE); INIT_TRACER_CONTEXT(WH_DelayCompensation, LOFARLOGGER_PACKAGE);
//##---------------- Public methods ----------------##//
WH_DelayCompensation::WH_DelayCompensation(const string& name, WH_DelayCompensation::WH_DelayCompensation(const string& name,
const ParameterSet& ps) : const ParameterSet& ps) :
WorkHolder (0, // inputs WorkHolder (0, // inputs
...@@ -54,7 +56,7 @@ namespace LOFAR ...@@ -54,7 +56,7 @@ namespace LOFAR
itsParamSet (ps), itsParamSet (ps),
itsNrBeams (ps.getUint32("Observation.NBeams")), itsNrBeams (ps.getUint32("Observation.NBeams")),
itsNrStations(ps.getUint32("Observation.NStations")), itsNrStations(ps.getUint32("Observation.NStations")),
itsNrDelaysPerEpoch(itsNrBeams*itsNrStations), itsNrDelays (itsNrBeams*itsNrStations),
itsSampleRate(ps.getDouble("Observation.SampleRate")), itsSampleRate(ps.getDouble("Observation.SampleRate")),
itsLoopCount (0), itsLoopCount (0),
itsConverter (0) itsConverter (0)
...@@ -73,7 +75,7 @@ namespace LOFAR ...@@ -73,7 +75,7 @@ namespace LOFAR
for (int i = 0; i < itsNoutputs; ++i) { for (int i = 0; i < itsNoutputs; ++i) {
string str = "DH_Delay_out_" + formatString("%02d", i); string str = "DH_Delay_out_" + formatString("%02d", i);
LOG_TRACE_LOOP_STR("Creating " << str); LOG_TRACE_LOOP_STR("Creating " << str);
getDataManager().addOutDataHolder(i, new DH_Delay(str, itsNoutputs)); getDataManager().addOutDataHolder(i, new DH_Delay(str, itsNrDelays));
} }
} }
...@@ -97,8 +99,8 @@ namespace LOFAR ...@@ -97,8 +99,8 @@ namespace LOFAR
ASSERT(itsConverter); ASSERT(itsConverter);
// Pre-allocate and initialize storage for the delay vectors. // Pre-allocate and initialize storage for the delay vectors.
itsDelaysAtBegin.resize(itsNrDelaysPerEpoch); itsDelaysAtBegin.resize(itsNrDelays);
itsDelaysAfterEnd.resize(itsNrDelaysPerEpoch); itsDelaysAfterEnd.resize(itsNrDelays);
// Initialize \c itsDelaysAfterEnd with the conversion results for the // Initialize \c itsDelaysAfterEnd with the conversion results for the
// epoch after the end of the first time interval. // epoch after the end of the first time interval.
...@@ -114,48 +116,47 @@ namespace LOFAR ...@@ -114,48 +116,47 @@ namespace LOFAR
LOG_TRACE_LIFETIME_STR(TRACE_LEVEL_FLOW, "count = " << itsLoopCount); LOG_TRACE_LIFETIME_STR(TRACE_LEVEL_FLOW, "count = " << itsLoopCount);
// Calculate the delays for the epoch after the end of the current time // Calculate the delays for the epoch after the end of the current time
// interval. // interval. Put the results in itsDelaysAtBegin and itsDelaysAfterEnd.
calculateDelays(); calculateDelays();
// The time differences need to be split into a coarse (sample) delay // The delays -- split into a coarse (sample) delay and a fine
// and a fine (subsample) delay. // (subsample) delay -- need to be put into a DelayInfo struct.
vector<int> coarseDelay(itsNrDelaysPerEpoch); vector<DH_Delay::DelayInfo> delayInfo(itsNrDelays);
vector<float> fineDelayAtBegin(itsNrDelaysPerEpoch); for (uint i = 0; i < itsNrDelays; ++i) {
vector<float> fineDelayAfterEnd(itsNrDelaysPerEpoch);
for (uint i = 0; i < itsNrDelaysPerEpoch; ++i) {
// Get delays "at begin" and "after end". // Get delays "at begin" and "after end".
double db = itsDelaysAtBegin[i]; double db = itsDelaysAtBegin[i];
double de = itsDelaysAfterEnd[i]; double de = itsDelaysAfterEnd[i];
LOG_TRACE_VAR_STR("Beamlet #" << i << ":");
// LOG_TRACE_VAR_STR("itsDelaysAtBegin[" << i << "] = " <<
// itsDelaysAtBegin[i]);
// LOG_TRACE_VAR_STR("itsDelaysAfterEnd[" << i << "] = " <<
// itsDelaysAfterEnd[i]);
// The coarse delay will be determined for the center of the current // The coarse delay will be determined for the center of the current
// time interval and will be expressed in \e samples. // time interval and will be expressed in \e samples.
coarseDelay[i] = (int)floor(0.5 * (db + de) * itsSampleRate + 0.5); delayInfo[i].coarseDelay =
double d = coarseDelay[i] / itsSampleRate; (int32)floor(0.5 * (db + de) * itsSampleRate + 0.5);
// The fine delay will be determined for the boundaries of the current // The fine delay will be determined for the boundaries of the current
// time interval and will be expressed in seconds. // time interval and will be expressed in seconds.
fineDelayAtBegin[i] = (float)(db - d); double d = delayInfo[i].coarseDelay / itsSampleRate;
fineDelayAfterEnd[i] = (float)(de - d); delayInfo[i].fineDelayAtBegin = (float)(db - d);
delayInfo[i].fineDelayAfterEnd = (float)(de - d);
LOG_TRACE_CALC_STR(" coarseDelay = " << coarseDelay[i]);
LOG_TRACE_CALC_STR(" fineDelayAtBegin = " << fineDelayAtBegin[i]); LOG_TRACE_CALC_STR("Beamlet #" << i << ":");
LOG_TRACE_CALC_STR(" fineDelayAfterEnd = " << fineDelayAfterEnd[i]); LOG_TRACE_CALC_STR(" coarseDelay = " <<
delayInfo[i].coarseDelay);
LOG_TRACE_CALC_STR(" fineDelayAtBegin = " <<
delayInfo[i].fineDelayAtBegin);
LOG_TRACE_CALC_STR(" fineDelayAfterEnd = " <<
delayInfo[i].fineDelayAfterEnd);
} }
// We need to send the coarse and fine delay info to all RSP boards. // We need to send the coarse and fine delay info to all RSP boards.
for (int rsp = 0; rsp < itsNoutputs; ++rsp) { for (int rsp = 0; rsp < itsNoutputs; ++rsp) {
DH_Delay* dh = (DH_Delay*)getDataManager().getOutHolder(rsp); DH_Delay& dh =
dh; dynamic_cast<DH_Delay&>(*getDataManager().getOutHolder(rsp));
for (uint i = 0; i < itsNrDelays; ++i) {
dh[i] = delayInfo[i];
}
} }
} }
...@@ -177,6 +178,8 @@ namespace LOFAR ...@@ -177,6 +178,8 @@ namespace LOFAR
} }
//##---------------- Private methods ----------------##//
void WH_DelayCompensation::getConverterConfig(const ParameterSet& ps) void WH_DelayCompensation::getConverterConfig(const ParameterSet& ps)
{ {
LOG_TRACE_FLOW(AUTO_FUNCTION_NAME); LOG_TRACE_FLOW(AUTO_FUNCTION_NAME);
...@@ -345,8 +348,8 @@ namespace LOFAR ...@@ -345,8 +348,8 @@ namespace LOFAR
// Since we've calculated the coordinates for only one epoch, the number // Since we've calculated the coordinates for only one epoch, the number
// of directions in the result vector must be equal to the number of // of directions in the result vector must be equal to the number of
// delays per epoch. // delays per epoch.
ASSERTSTR(result.direction.size() == itsNrDelaysPerEpoch, ASSERTSTR(result.direction.size() == itsNrDelays,
result.direction.size() << " == " << itsNrDelaysPerEpoch); result.direction.size() << " == " << itsNrDelays);
LOG_TRACE_CALC("Beamlet directions:"); LOG_TRACE_CALC("Beamlet directions:");
for (uint i = 0; i < result.direction.size(); ++i) { for (uint i = 0; i < result.direction.size(); ++i) {
...@@ -362,8 +365,8 @@ namespace LOFAR ...@@ -362,8 +365,8 @@ namespace LOFAR
// itsBeamDirections.size() elements contain the converted directions // itsBeamDirections.size() elements contain the converted directions
// for itsStationPositions[0], the second for itsStationPositions[1], // for itsStationPositions[0], the second for itsStationPositions[1],
// etc. // etc.
LOG_TRACE_CALC_STR("Beamlet geometrical delays:"); LOG_TRACE_CALC("Beamlet geometrical delays:");
for (uint i = 0; i < itsNrDelaysPerEpoch; ++i) { for (uint i = 0; i < itsNrDelays; ++i) {
uint j = i / itsBeamDirections.size(); uint j = i / itsBeamDirections.size();
itsDelaysAfterEnd[i] = itsDelaysAfterEnd[i] =
(result.direction[i] * itsPositionDiffs[j]) / speedOfLight; (result.direction[i] * itsPositionDiffs[j]) / speedOfLight;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment