Skip to content
Snippets Groups Projects
Commit 60eabd5b authored by Maik Nijhuis's avatar Maik Nijhuis
Browse files

AST-1090 Remove get* functions from InputStep

parent b2310c31
Branches
Tags
1 merge request!822AST-1090 Remove get* functions from InputStep
...@@ -34,18 +34,6 @@ InputStep::~InputStep() {} ...@@ -34,18 +34,6 @@ InputStep::~InputStep() {}
std::string InputStep::msName() const { return std::string(); } std::string InputStep::msName() const { return std::string(); }
void InputStep::getUVW(const RefRows&, double, DPBuffer&) {
throw std::runtime_error("InputStep::getUVW not implemented");
}
void InputStep::getWeights(const RefRows&, DPBuffer&) {
throw std::runtime_error("InputStep::getWeights not implemented");
}
bool InputStep::getFullResFlags(const RefRows&, DPBuffer&) {
throw std::runtime_error("InputStep::getFullResFlags not implemented");
}
const casacore::Table& InputStep::table() const { const casacore::Table& InputStep::table() const {
throw std::runtime_error("InputStep::table not implemented"); throw std::runtime_error("InputStep::table not implemented");
} }
......
...@@ -42,22 +42,6 @@ class InputStep : public Step { ...@@ -42,22 +42,6 @@ class InputStep : public Step {
common::Fields getProvidedFields() const override { return fields_to_read_; } common::Fields getProvidedFields() const override { return fields_to_read_; }
/// Read the UVW at the given row numbers into the buffer.
/// The default implementation throws an exception.
virtual void getUVW(const casacore::RefRows& rowNrs, double time,
base::DPBuffer&);
/// Read the weights at the given row numbers into the buffer.
/// The default implementation throws an exception.
virtual void getWeights(const casacore::RefRows& rowNrs, base::DPBuffer&);
/// Read the fullRes flags (LOFAR_FULL_RES_FLAG) at the given row numbers
/// into the buffer.
/// If undefined, false is returned.
/// The default implementation throws an exception.
virtual bool getFullResFlags(const casacore::RefRows& rowNrs,
base::DPBuffer&);
/// Get the MS name. /// Get the MS name.
/// The default implementation returns an empty string. /// The default implementation returns an empty string.
virtual std::string msName() const; virtual std::string msName() const;
......
...@@ -143,19 +143,17 @@ class MSReader : public InputStep { ...@@ -143,19 +143,17 @@ class MSReader : public InputStep {
void showTimings(std::ostream&, double duration) const override; void showTimings(std::ostream&, double duration) const override;
/// Read the UVW at the given row numbers into the buffer. /// Read the UVW at the given row numbers into the buffer.
void getUVW(const casacore::RefRows& rowNrs, double time, void getUVW(const casacore::RefRows& rowNrs, double time, base::DPBuffer&);
base::DPBuffer&) override;
/// Read the weights at the given row numbers into the buffer. /// Read the weights at the given row numbers into the buffer.
/// Note: the buffer must contain DATA if autoweighting is in effect. /// Note: the buffer must contain DATA if autoweighting is in effect.
void getWeights(const casacore::RefRows& rowNrs, base::DPBuffer&) override; void getWeights(const casacore::RefRows& rowNrs, base::DPBuffer&);
/// Read the fullRes flags (LOFAR_FULL_RES_FLAG) at the given row numbers /// Read the fullRes flags (LOFAR_FULL_RES_FLAG) at the given row numbers
/// into the buffer. /// into the buffer.
/// If there is no such column, the flags are set to false and false is /// If there is no such column, the flags are set to false and false is
/// returned. /// returned.
bool getFullResFlags(const casacore::RefRows& rowNrs, bool getFullResFlags(const casacore::RefRows& rowNrs, base::DPBuffer&);
base::DPBuffer&) override;
/// Fill the fullResFlags field in the DPBuffer. /// Fill the fullResFlags field in the DPBuffer.
/// If the LOFAR_FULL_RES_FLAG column is present in the MS /// If the LOFAR_FULL_RES_FLAG column is present in the MS
......
...@@ -263,11 +263,13 @@ bool MultiMSReader::process(const DPBuffer& buf) { ...@@ -263,11 +263,13 @@ bool MultiMSReader::process(const DPBuffer& buf) {
s[1] = e[1] + 1; s[1] = e[1] + 1;
} }
if (getFieldsToRead().Uvw()) if (getFieldsToRead().Uvw()) {
getUVW(itsBuffer.getRowNrs(), itsBuffer.getTime(), itsBuffer); // All Measurement Sets have the same UVWs, so use the first one.
if (getFieldsToRead().Weights()) getWeights(itsBuffer.getRowNrs(), itsBuffer); itsReaders[itsFirst]->getUVW(itsBuffer.getRowNrs(), itsBuffer.getTime(),
if (getFieldsToRead().FullResFlags()) itsBuffer);
getFullResFlags(itsBuffer.getRowNrs(), itsBuffer); }
if (getFieldsToRead().Weights()) getWeights();
if (getFieldsToRead().FullResFlags()) getFullResolutionFlags();
getNextStep()->process(itsBuffer); getNextStep()->process(itsBuffer);
return true; return true;
...@@ -407,13 +409,9 @@ void MultiMSReader::showTimings(std::ostream& os, double duration) const { ...@@ -407,13 +409,9 @@ void MultiMSReader::showTimings(std::ostream& os, double duration) const {
} }
} }
void MultiMSReader::getUVW(const RefRows& rowNrs, double time, DPBuffer& buf) { void MultiMSReader::getWeights() {
// All MSs have the same UVWs, so use first one. const RefRows& rowNrs = itsBuffer.getRowNrs();
itsReaders[itsFirst]->getUVW(rowNrs, time, buf); Cube<float>& weights = itsBuffer.getWeights();
}
void MultiMSReader::getWeights(const RefRows& rowNrs, DPBuffer& buf) {
Cube<float>& weights = buf.getWeights();
// Resize if needed (probably when called for first time). // Resize if needed (probably when called for first time).
if (weights.empty()) { if (weights.empty()) {
weights.resize(itsNrCorr, itsNrChan, itsNrBl); weights.resize(itsNrCorr, itsNrChan, itsNrBl);
...@@ -434,22 +432,23 @@ void MultiMSReader::getWeights(const RefRows& rowNrs, DPBuffer& buf) { ...@@ -434,22 +432,23 @@ void MultiMSReader::getWeights(const RefRows& rowNrs, DPBuffer& buf) {
} }
} }
bool MultiMSReader::getFullResFlags(const RefRows& rowNrs, DPBuffer& buf) { void MultiMSReader::getFullResolutionFlags() {
Cube<bool>& flags = buf.getFullResFlags(); const RefRows& rowNrs = itsBuffer.getRowNrs();
Cube<bool>& flags = itsBuffer.getFullResFlags();
// Resize if needed (probably when called for first time). // Resize if needed (probably when called for first time).
if (flags.empty()) { if (flags.empty()) {
int norigchan = itsNrChan * getInfo().nAveragedFullResolutionChannels(); int norigchan = itsNrChan * getInfo().nAveragedFullResolutionChannels();
flags.resize(norigchan, getInfo().nAveragedFullResolutionTimes(), itsNrBl); flags.resize(norigchan, getInfo().nAveragedFullResolutionTimes(), itsNrBl);
} }
// Return false if no fullRes flags available. // Return if no fullRes flags available.
if (!itsHasFullResFlags) { if (!itsHasFullResFlags) {
flags = false; flags = false;
return false; return;
} }
// Flag everything if data rows are missing. // Flag everything if data rows are missing.
if (rowNrs.rowVector().empty()) { if (rowNrs.rowVector().empty()) {
flags = true; flags = true;
return true; return;
} }
// Get the flags from all MSs and combine them. // Get the flags from all MSs and combine them.
IPosition s(3, 0); IPosition s(3, 0);
...@@ -465,7 +464,6 @@ bool MultiMSReader::getFullResFlags(const RefRows& rowNrs, DPBuffer& buf) { ...@@ -465,7 +464,6 @@ bool MultiMSReader::getFullResFlags(const RefRows& rowNrs, DPBuffer& buf) {
} }
s[0] = e[0] + 1; s[0] = e[0] + 1;
} }
return true;
} }
} // namespace steps } // namespace steps
......
...@@ -137,20 +137,6 @@ class MultiMSReader final : public MSReader { ...@@ -137,20 +137,6 @@ class MultiMSReader final : public MSReader {
/// Show the timings. /// Show the timings.
void showTimings(std::ostream&, double duration) const override; void showTimings(std::ostream&, double duration) const override;
/// Read the UVW at the given row numbers.
void getUVW(const casacore::RefRows& rowNrs, double time,
base::DPBuffer& buf) override;
/// Read the weights at the given row numbers.
void getWeights(const casacore::RefRows& rowNrs,
base::DPBuffer& buf) override;
/// Read the FullRes flags (LOFAR_FULL_RES_FLAG) at the given row numbers.
/// It returns a 3-dim array [norigchan, ntimeavg, nbaseline].
/// If undefined, false is returned.
bool getFullResFlags(const casacore::RefRows& rowNrs,
base::DPBuffer& buf) override;
/// Set which fields must be read. /// Set which fields must be read.
void setFieldsToRead(const dp3::common::Fields& fields) override; void setFieldsToRead(const dp3::common::Fields& fields) override;
...@@ -167,6 +153,13 @@ class MultiMSReader final : public MSReader { ...@@ -167,6 +153,13 @@ class MultiMSReader final : public MSReader {
/// Fill the band info where some MSs are missing. /// Fill the band info where some MSs are missing.
void fillBands(); void fillBands();
/// Reads the weights into 'itsBuffer'
void getWeights();
/// Reads the FullRes flags (LOFAR_FULL_RES_FLAG) into 'itsBuffer'.
/// Sets the flags to false if they are undefined.
void getFullResolutionFlags();
bool itsOrderMS; ///< sort multi MS in order of freq? bool itsOrderMS; ///< sort multi MS in order of freq?
int itsFirst; ///< first valid MSReader (<0 = none) int itsFirst; ///< first valid MSReader (<0 = none)
int itsNMissing; ///< nr of missing MSs int itsNMissing; ///< nr of missing MSs
......
...@@ -17,18 +17,6 @@ common::Fields MockInput::getProvidedFields() const { ...@@ -17,18 +17,6 @@ common::Fields MockInput::getProvidedFields() const {
throw std::runtime_error("Unexpected getProvidedFields call"); throw std::runtime_error("Unexpected getProvidedFields call");
} }
void MockInput::getUVW(const casacore::RefRows&, double,
base::DPBuffer& buffer) {
BOOST_TEST(!buffer.getUVW().empty());
}
void MockInput::getWeights(const casacore::RefRows&, base::DPBuffer& buffer) {
BOOST_TEST(!buffer.getWeights().empty());
}
bool MockInput::getFullResFlags(const casacore::RefRows&,
base::DPBuffer& buffer) {
BOOST_TEST(!buffer.getFullResFlags().empty());
return true;
}
void MockInput::finish() { BOOST_ERROR("Unexpected finish() call"); } void MockInput::finish() { BOOST_ERROR("Unexpected finish() call"); }
void MockInput::show(std::ostream&) const { void MockInput::show(std::ostream&) const {
BOOST_ERROR("Unexpected show() call"); BOOST_ERROR("Unexpected show() call");
......
...@@ -18,11 +18,6 @@ class MockInput : public InputStep { ...@@ -18,11 +18,6 @@ class MockInput : public InputStep {
common::Fields getRequiredFields() const override; common::Fields getRequiredFields() const override;
common::Fields getProvidedFields() const override; common::Fields getProvidedFields() const override;
void getUVW(const casacore::RefRows&, double,
base::DPBuffer& buffer) override;
void getWeights(const casacore::RefRows&, base::DPBuffer& buffer) override;
bool getFullResFlags(const casacore::RefRows& rowNrs,
base::DPBuffer&) override;
void finish() override; void finish() override;
void show(std::ostream&) const override; void show(std::ostream&) const override;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment