diff --git a/CMakeLists.txt b/CMakeLists.txt index b7495bbbda3da7bd38ce8383a4494557782d744c..866de5b0d9b62b33a29888c9bbec36eb8b2ff90a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ endif() # Set version number and project name. # Please keep CPack/CMakeLists.txt and setup.py in sync with this. -set(DP3_VERSION 6.1.0) +set(DP3_VERSION 6.2.0) if(DP3_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") set(DP3_VERSION_MAJOR "${CMAKE_MATCH_1}") set(DP3_VERSION_MINOR "${CMAKE_MATCH_2}") diff --git a/base/DPInfo.cc b/base/DPInfo.cc index 30a361aae83a35ce596f661b4d3870d5d43841cb..ec2e5b0b58a03349790e7265599a4e9821948654 100644 --- a/base/DPInfo.cc +++ b/base/DPInfo.cc @@ -31,7 +31,7 @@ namespace dp3 { namespace base { DPInfo::DPInfo(unsigned int n_correlations, unsigned int original_n_channels, - unsigned int start_channel, std::string antenna_set) + std::string antenna_set) : meta_changed_(false), ms_name_(), data_column_name_(MS::columnName(MS::DATA)), @@ -39,7 +39,7 @@ DPInfo::DPInfo(unsigned int n_correlations, unsigned int original_n_channels, weight_column_name_(MS::columnName(MS::WEIGHT_SPECTRUM)), antenna_set_(std::move(antenna_set)), n_correlations_(n_correlations), - start_channel_(start_channel), + start_channel_(0), original_n_channels_(original_n_channels), n_channels_(original_n_channels), channel_averaging_factor_(1), @@ -355,9 +355,10 @@ void DPInfo::update(std::vector<unsigned int>&& timeAvg) { time_averaging_factors_ = std::move(timeAvg); } -void DPInfo::update(unsigned int startChan, unsigned int nchan, - const std::vector<unsigned int>& baselines, - bool removeAnt) { +void DPInfo::SelectChannels(unsigned int start_channel, + unsigned int n_channels) { + if (start_channel == 0 && n_channels == n_channels_) return; + if (channel_frequencies_.size() != 1) { throw std::runtime_error("Channel selection does not support BDA"); } @@ -373,45 +374,46 @@ void DPInfo::update(unsigned int startChan, unsigned int nchan, effective_bandwidth_.front().size() && "The number of elements of the channel frequencies and effective " "bandwidths should be equal."); - if (startChan + nchan > channel_frequencies_.front().size()) { + if (start_channel + n_channels > channel_frequencies_.front().size()) { throw std::invalid_argument("Channel range is out of bounds."); } - start_channel_ = startChan; - auto freqs_begin = channel_frequencies_.front().begin() + startChan; - auto widths_begin = channel_widths_.front().begin() + startChan; - auto resol_begin = resolutions_.front().begin() + startChan; - auto effbw_begin = effective_bandwidth_.front().begin() + startChan; + auto freqs_begin = channel_frequencies_.front().begin() + start_channel; + auto widths_begin = channel_widths_.front().begin() + start_channel; + auto resol_begin = resolutions_.front().begin() + start_channel; + auto effbw_begin = effective_bandwidth_.front().begin() + start_channel; channel_frequencies_.front() = - std::vector<double>(freqs_begin, freqs_begin + nchan); + std::vector<double>(freqs_begin, freqs_begin + n_channels); channel_widths_.front() = - std::vector<double>(widths_begin, widths_begin + nchan); - resolutions_.front() = std::vector<double>(resol_begin, resol_begin + nchan); + std::vector<double>(widths_begin, widths_begin + n_channels); + resolutions_.front() = + std::vector<double>(resol_begin, resol_begin + n_channels); effective_bandwidth_.front() = - std::vector<double>(effbw_begin, effbw_begin + nchan); - n_channels_ = nchan; - // Keep only selected baselines. - if (!baselines.empty()) { - std::vector<int> ant1(baselines.size()); - std::vector<int> ant2(baselines.size()); - for (unsigned int i = 0; i < baselines.size(); ++i) { - ant1[i] = antenna1_[baselines[i]]; - ant2[i] = antenna2_[baselines[i]]; - } - antenna1_ = std::move(ant1); - antenna2_ = std::move(ant2); - // Clear; they'll be recalculated if needed. - baseline_lengths_.clear(); - auto_correlation_indices_.clear(); + std::vector<double>(effbw_begin, effbw_begin + n_channels); + + // Add the new start channel to an existing start_channel, so MSUpdater can + // still update the correct channel(s) in the original input MS. + start_channel_ += start_channel; + n_channels_ = n_channels; +} + +void DPInfo::SelectBaselines(const std::vector<unsigned int>& baselines) { + std::vector<int> ant1(baselines.size()); + std::vector<int> ant2(baselines.size()); + for (unsigned int i = 0; i < baselines.size(); ++i) { + ant1[i] = antenna1_[baselines[i]]; + ant2[i] = antenna2_[baselines[i]]; } + antenna1_ = std::move(ant1); + antenna2_ = std::move(ant2); + // Clear; they'll be recalculated if needed. + baseline_lengths_.clear(); + auto_correlation_indices_.clear(); + setAntUsed(); - // If needed, remove the stations and renumber the baselines. - if (removeAnt) { - removeUnusedAnt(); - } } -void DPInfo::removeUnusedAnt() { +void DPInfo::RemoveUnusedAntennas() { if (antennas_used_.size() < antenna_map_.size()) { // First remove stations. std::vector<std::string> names(antennas_used_.size()); @@ -432,6 +434,9 @@ void DPInfo::removeUnusedAnt() { antenna1_[i] = antenna_map_[antenna1_[i]]; antenna2_[i] = antenna_map_[antenna2_[i]]; } + + setMetaChanged(); + // Now fill the antennas_used_ and antenna_map_ vectors again. setAntUsed(); // Clear; they'll be recalculated if needed. diff --git a/base/test/unit/tDP3.cc b/base/test/unit/tDP3.cc index 4f0dfcc3617f6279491a40dee6c093010f320957..bb221b8f3a874d65506aa750367945c3ea6e21b8 100644 --- a/base/test/unit/tDP3.cc +++ b/base/test/unit/tDP3.cc @@ -735,6 +735,97 @@ BOOST_FIXTURE_TEST_CASE(test_update_scale, FixtureCopyInput) { BOOST_CHECK(allEQ(flags_input.getColumn(), flags_output.getColumn())); } +// Test updating a subset of the channels, using startchan and nchan. +BOOST_FIXTURE_TEST_CASE(test_update_channel_subset, FixtureCopyInput) { + { + std::ofstream ostr(kParsetFile); + ostr << "checkparset=1\n"; + ostr << "msin=" << kCopyMs << '\n'; + ostr << "msin.startchan=1\n"; + ostr << "msin.nchan=2\n"; + ostr << "msout=" << kCopyMs << '\n'; // same name means update + ostr << "steps=[scaledata]\n"; + ostr << "scaledata.coeffs=2\n"; + ostr << "scaledata.stations=*\n"; + ostr << "scaledata.scalesize=false\n"; + } + dp3::base::Execute(kParsetFile); + + const casacore::Array<Complex> data_input = + ArrayColumn<Complex>(Table(kInputMs), "DATA").getColumn(); + const casacore::Array<Complex> data_output = + ArrayColumn<Complex>(Table(kCopyMs), "DATA").getColumn(); + + IPosition start = IPosition(3, 0, 0, 0); + IPosition end = data_input.shape(); + const int n_channels = end[1]; + // casacore::Array includes the last element. + --end[0]; + --end[2]; + + // First channel should be unchanged. + end[1] = 0; + BOOST_CHECK(allNear(data_input(start, end), data_output(start, end), 1.0e-6)); + + // Channels 1 and 2 should be scaled by a factor of 2. + start[1] = 1; + end[1] = 2; + BOOST_CHECK(allNear(data_input(start, end) * Complex(2, 0), + data_output(start, end), 1.0e-6)); + + // All remaining channels should be unchanged. + start[1] = 3; + end[1] = n_channels - 1; + BOOST_CHECK(allNear(data_input(start, end), data_output(start, end), 1.0e-6)); +} + +// Test using msin.startchan/nchan together with filter.startchan/nchan, and +// then updating the input ms. +BOOST_FIXTURE_TEST_CASE(test_filter_update_channel_subset, FixtureCopyInput) { + { + std::ofstream ostr(kParsetFile); + ostr << "checkparset=1\n"; + ostr << "msin=" << kCopyMs << '\n'; + ostr << "msin.startchan=4\n"; + ostr << "msin.nchan=4\n"; + ostr << "msout=" << kCopyMs << '\n'; // same name means update + ostr << "steps=[filter,scaledata]\n"; + ostr << "filter.startchan=1\n"; + ostr << "filter.nchan=2\n"; + ostr << "scaledata.coeffs=2\n"; + ostr << "scaledata.stations=*\n"; + ostr << "scaledata.scalesize=false\n"; + } + dp3::base::Execute(kParsetFile); + + const casacore::Array<Complex> data_input = + ArrayColumn<Complex>(Table(kInputMs), "DATA").getColumn(); + const casacore::Array<Complex> data_output = + ArrayColumn<Complex>(Table(kCopyMs), "DATA").getColumn(); + + IPosition start = IPosition(3, 0, 0, 0); + IPosition end = data_input.shape(); + const int n_channels = end[1]; + // casacore::Array includes the last element. + --end[0]; + --end[2]; + + // First 5 channels (indices 0-4) should be unchanged. + end[1] = 4; + BOOST_CHECK(allNear(data_input(start, end), data_output(start, end), 1.0e-6)); + + // Channels 5 and 6 should be scaled by a factor of 2. + start[1] = 5; + end[1] = 6; + BOOST_CHECK(allNear(data_input(start, end) * Complex(2, 0), + data_output(start, end), 1.0e-6)); + + // All remaining channels should be unchanged. + start[1] = 7; + end[1] = n_channels - 1; + BOOST_CHECK(allNear(data_input(start, end), data_output(start, end), 1.0e-6)); +} + namespace { casacore::Array<bool> GetFlags(const std::string& out_ms) { diff --git a/base/test/unit/tDPInfo.cc b/base/test/unit/tDPInfo.cc index 5b5b2647c0446038d578e39d250c4df21f8f5aef..69dcc8a34c7f9970c39cff46200e495dc206f77c 100644 --- a/base/test/unit/tDPInfo.cc +++ b/base/test/unit/tDPInfo.cc @@ -21,19 +21,15 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_TEST(default_values.ncorr() == 0); BOOST_TEST(default_values.origNChan() == 0); BOOST_TEST(default_values.nchan() == 0); - BOOST_TEST(default_values.startchan() == 0); BOOST_TEST(default_values.antennaSet().empty()); const unsigned int kNCorrelations = 4; const unsigned int kNChannels = 42; - const unsigned int kStartChannel = 10; const std::string kAntennaSet = "test_antenna_set"; - const DPInfo custom_values(kNCorrelations, kNChannels, kStartChannel, - kAntennaSet); + const DPInfo custom_values(kNCorrelations, kNChannels, kAntennaSet); BOOST_TEST(custom_values.ncorr() == kNCorrelations); BOOST_TEST(custom_values.origNChan() == kNChannels); BOOST_TEST(custom_values.nchan() == kNChannels); - BOOST_TEST(custom_values.startchan() == kStartChannel); BOOST_TEST(custom_values.antennaSet() == kAntennaSet); } @@ -152,23 +148,28 @@ BOOST_AUTO_TEST_CASE(set_channels) { BOOST_TEST(kTotalWidth == info.totalBW()); } -BOOST_AUTO_TEST_CASE(update) { +BOOST_AUTO_TEST_CASE(select_channels) { + DPInfo info; + BOOST_CHECK(info.startchan() == 0); + BOOST_CHECK(info.nchan() == 0); + + // Create two channels. const std::vector<double> kFreqs{10.0, 20.0}; const std::vector<double> kWidths{5.0, 6.0}; - - DPInfo info; info.setChannels(std::vector<double>(kFreqs), std::vector<double>(kWidths)); + BOOST_CHECK(info.startchan() == 0); + BOOST_CHECK(info.nchan() == kFreqs.size()); + // Select only the second channel. const unsigned int kStartChannel = 1; const unsigned int kNChannel = 1; - const std::vector<unsigned int> kBaselines; - const bool kRemove = false; - // Select only the second channel - BOOST_CHECK_NO_THROW( - info.update(kStartChannel, kNChannel, kBaselines, kRemove)); - // Try to select only the second channel again - // This should fail because only one channel is left - BOOST_CHECK_THROW(info.update(kStartChannel, kNChannel, kBaselines, kRemove), + BOOST_CHECK_NO_THROW(info.SelectChannels(kStartChannel, kNChannel)); + BOOST_CHECK(info.startchan() == kStartChannel); + BOOST_CHECK(info.nchan() == kNChannel); + + // Try to select only the second channel again. + // This should fail because only one channel is left. + BOOST_CHECK_THROW(info.SelectChannels(kStartChannel, kNChannel), std::invalid_argument); } diff --git a/include/dp3/base/DPInfo.h b/include/dp3/base/DPInfo.h index aebcb3f5e99954b51e1eaa62f07e24d55cffc024..1a4fe276d5989cc795457f4911bbab8fda77adbf 100644 --- a/include/dp3/base/DPInfo.h +++ b/include/dp3/base/DPInfo.h @@ -36,7 +36,6 @@ class DPInfo { public: explicit DPInfo(unsigned int n_correlations = 0, unsigned int n_original_channels = 0, - unsigned int start_channel = 0, std::string antenna_set = std::string()); /// Set time information and derive the number of time slots. @@ -106,28 +105,27 @@ class DPInfo { const std::vector<casacore::MPosition>& antPos, const std::vector<int>& ant1, const std::vector<int>& ant2); + /// Select a subset of the channels. + /// @param start_channel Start channel, relative to the current first channel. + /// @param n_channels Number of channels to select. + void SelectChannels(unsigned int start_channel, unsigned int n_channels); + + /// Select a subset of the baselines. + /// @param baselines A list with the indices of the baselines that must + /// remain. All other baselines are removed. + void SelectBaselines(const std::vector<unsigned int>& baselines); + /// Update the info for the given average factors. /// If chanAvg is higher than the actual nr of channels, it is reset. /// The same is true for timeAvg. /// It returns the possibly reset nr of channels to average. unsigned int update(unsigned int chanAvg, unsigned int timeAvg); - /// Update the info from the given selection parameters. - /// Optionally unused stations are really removed from the antenna lists. - /// - /// @pre The range [startChan, startChan + nchan) does not exceed the ranges - /// of the interal vector of the class. - /// - /// @param startChan The first channal to use. - /// @param nchan The number of channels to use. - void update(unsigned int startChan, unsigned int nchan, - const std::vector<unsigned int>& baselines, bool remove); - /// Update the info for the given average factors. void update(std::vector<unsigned int>&& timeAvg); /// Remove unused stations from the antenna lists. - void removeUnusedAnt(); + void RemoveUnusedAntennas(); void setPhaseCenter(const casacore::MDirection& phase_center) { phase_center_ = phase_center; diff --git a/pythondp3/PyDpInfo.cc b/pythondp3/PyDpInfo.cc index 5436951012356686e1cd63a35cf81b5743a4c845..f060a5ca7be7a9b217695de141cc5d57ecf177d1 100644 --- a/pythondp3/PyDpInfo.cc +++ b/pythondp3/PyDpInfo.cc @@ -20,9 +20,9 @@ namespace pythondp3 { void WrapDpInfo(py::module& m) { py::class_<DPInfo>(m, "DPInfo") - .def(py::init<unsigned int, unsigned int, unsigned int, std::string>(), + .def(py::init<unsigned int, unsigned int, std::string>(), py::arg("n_correlations") = 0, py::arg("n_original_channels") = 0, - py::arg("start_channel") = 0, py::arg("antenna_set") = "") + py::arg("antenna_set") = "") /* Antenna properties */ .def( "set_antennas", diff --git a/pythondp3/test/unit/tPyDpInfo.py b/pythondp3/test/unit/tPyDpInfo.py index 622069b7721cdf190fdae95a4e5befbea382b899..7fbe8cd518d45b3729f1a4995279384a2698e99b 100644 --- a/pythondp3/test/unit/tPyDpInfo.py +++ b/pythondp3/test/unit/tPyDpInfo.py @@ -36,21 +36,16 @@ def test_constructor(): # Check whether the default values for the constructor arguments have been used assert info0.n_correlations == 0 assert info0.original_n_channels == 0 - assert info0.start_channel == 0 assert info0.antenna_set == "" # Constructor using specific values for the arguments n_correlations = 4 original_n_channels = 8 - start_channel = 1 antenna_set = "LBA" - info1 = dp3.DPInfo( - n_correlations, original_n_channels, start_channel, antenna_set - ) + info1 = dp3.DPInfo(n_correlations, original_n_channels, antenna_set) assert info1.n_correlations == n_correlations assert info1.original_n_channels == original_n_channels - assert info1.start_channel == start_channel assert info1.antenna_set == antenna_set diff --git a/setup.py b/setup.py index 0b3a1588b4ee84d84f26e97af01f8a91cd92fef8..971a3e9bdf7110c4ee160aee3c90d31a8dad0922 100755 --- a/setup.py +++ b/setup.py @@ -111,7 +111,7 @@ class CMakeBuild(build_ext): # logic and declaration, and simpler if you include description/version in a file. setup( name="DP3", - version="6.1.0", + version="6.2.0", author="Astron", author_email="dijkema@astron.nl", description="DP3", diff --git a/steps/BdaDdeCal.cc b/steps/BdaDdeCal.cc index 1b01f84c323ca26f2354aa5c68f6dfd8ed68ffea..515ac27d55429525a29171ef442ed04d09495f27 100644 --- a/steps/BdaDdeCal.cc +++ b/steps/BdaDdeCal.cc @@ -173,7 +173,7 @@ void BdaDdeCal::updateInfo(const DPInfo& _info) { DetermineChannelBlocks(); // Create lists with used antenna indices, similarly to - // DPInfo::removeUnusedAnt. + // DPInfo::RemoveUnusedAntennas. antennas1_.resize(info().getAnt1().size()); antennas2_.resize(info().getAnt2().size()); for (size_t i = 0; i < antennas1_.size(); ++i) { diff --git a/steps/DDECal.cc b/steps/DDECal.cc index a71fd99d773bda0764630641e9f5f4b521d38912..ba1d095967a5d7078405a6c9c0b94e8e96dfbf2d 100644 --- a/steps/DDECal.cc +++ b/steps/DDECal.cc @@ -249,7 +249,7 @@ void DDECal::updateInfo(const DPInfo& infoIn) { } // Create lists with used antenna indices, similarly to - // DPInfo::removeUnusedAnt. + // DPInfo::RemoveUnusedAntennas. itsAntennas1.resize(info().getAnt1().size()); itsAntennas2.resize(info().getAnt2().size()); for (size_t i = 0; i < itsAntennas1.size(); ++i) { diff --git a/steps/Filter.cc b/steps/Filter.cc index 8c8be39feb243a66674c8f2534581cb00d404a02..23e96ac8495bb4a8ee5005adc24e4f25abcffc8a 100644 --- a/steps/Filter.cc +++ b/steps/Filter.cc @@ -73,9 +73,6 @@ common::Fields Filter::getProvidedFields() const { void Filter::updateInfo(const base::DPInfo& infoIn) { Step::updateInfo(infoIn); - if (itsRemoveAnt) { - info().setMetaChanged(); - } // Parse the chan expressions. // Nr of channels can be used as 'nchan' in the expressions. Record rec; @@ -99,6 +96,7 @@ void Filter::updateInfo(const base::DPInfo& infoIn) { } else { nrChan = std::min(nrChan, maxNrChan); } + itsDoSelect = itsStartChan > 0 || nrChan < maxNrChan; // Handle possible baseline selection. if (itsBaselines.hasSelection()) { @@ -115,10 +113,11 @@ void Filter::updateInfo(const base::DPInfo& infoIn) { itsDoSelect = true; } } - if (itsDoSelect || itsRemoveAnt) { - // Update the DPInfo object. - info().update(itsStartChan, nrChan, itsSelBL, itsRemoveAnt); - } + + // Update the DPInfo object. + infoOut().SelectChannels(itsStartChan, nrChan); + if (!itsSelBL.empty()) infoOut().SelectBaselines(itsSelBL); + if (itsRemoveAnt) infoOut().RemoveUnusedAntennas(); } void Filter::show(std::ostream& os) const { diff --git a/steps/MSBDAReader.cc b/steps/MSBDAReader.cc index 5f9a1efa2d1f7160d21de5a1c91b9cfb39695ed4..f6a981a2522fc8417db79fcc21585333410f4a70 100644 --- a/steps/MSBDAReader.cc +++ b/steps/MSBDAReader.cc @@ -195,7 +195,7 @@ bool MSBDAReader::process(std::unique_ptr<base::BDABuffer>) { void MSBDAReader::finish() { getNextStep()->finish(); } -void MSBDAReader::updateInfo(const DPInfo& info_in) { +void MSBDAReader::updateInfo(const DPInfo&) { using MS_Ant = casacore::MSAntenna; using MS_SPW = casacore::MSSpectralWindow; using MS_Field = casacore::MSField; @@ -246,9 +246,7 @@ void MSBDAReader::updateInfo(const DPInfo& info_in) { antPos.push_back(ant_col(i)); } - const unsigned int start_channel = 0; - const std::string antenna_set = base::ReadAntennaSet(ms_); - info() = DPInfo(ncorr, max_n_channels, start_channel, antenna_set); + infoOut() = DPInfo(ncorr, max_n_channels, base::ReadAntennaSet(ms_)); // Set time info. diff --git a/steps/MSReader.cc b/steps/MSReader.cc index 56dfc9e918a3cba6b51ac76461d52d9680883c81..90868e095a6c1804df9e21e6bc55168745ea9e67 100644 --- a/steps/MSReader.cc +++ b/steps/MSReader.cc @@ -250,7 +250,7 @@ MSReader::MSReader(const casacore::MeasurementSet& ms, // Are all channels used? itsUseAllChan = itsStartChan == 0 && n_channels == nAllChan; // Do the rest of the preparation. - prepare2(spectralWindow, n_channels); + prepare2(spectralWindow, itsStartChan, n_channels); // Take subset of channel frequencies if needed. // Make sure to copy the subset to get a proper Vector. // Form the slicer to get channels and correlations from column. @@ -522,9 +522,7 @@ void MSReader::prepare(double& firstTime, double& lastTime, double& interval) { IPosition shape(ArrayColumn<casacore::Complex>(itsSelMS, "DATA").shape(0)); const unsigned int n_correlations = shape[0]; const unsigned int n_channels = shape[1]; - - const std::string antenna_set = base::ReadAntennaSet(itsMS); - info() = DPInfo(n_correlations, n_channels, itsStartChan, antenna_set); + info() = DPInfo(n_correlations, n_channels, base::ReadAntennaSet(itsMS)); if (itsSelMS.nrow() == 0) { aocommon::Logger::Warn << "The selected input does not contain any data.\n"; @@ -703,9 +701,11 @@ void MSReader::prepare(double& firstTime, double& lastTime, double& interval) { std::make_unique<base::UVWCalculator>(phaseCenter, arrayPos, antPos); } -void MSReader::prepare2(int spectralWindow, unsigned int n_channels) { - info().setTimes(itsFirstTime, itsMaximumTime, itsTimeInterval); - info().setMsNames(msName(), itsDataColName, itsFlagColName, itsWeightColName); +void MSReader::prepare2(int spectralWindow, unsigned int start_channel, + unsigned int n_channels) { + infoOut().setTimes(itsFirstTime, itsMaximumTime, itsTimeInterval); + infoOut().setMsNames(msName(), itsDataColName, itsFlagColName, + itsWeightColName); // Read the center frequencies of all channels. Table spwtab(itsMS.keywordSet().asTable("SPECTRAL_WINDOW")); ArrayColumn<double> freqCol(spwtab, "CHAN_FREQ"); @@ -718,21 +718,10 @@ void MSReader::prepare2(int spectralWindow, unsigned int n_channels) { std::vector<double> resolutions = resolCol(spectralWindow).tovector(); std::vector<double> effectiveBW = effBWCol(spectralWindow).tovector(); const double refFreq = refCol(spectralWindow); - if (itsUseAllChan) { - info().setChannels(std::move(chanFreqs), std::move(chanWidths), - std::move(resolutions), std::move(effectiveBW), refFreq, - spectralWindow); - } else { - auto freqBegin = chanFreqs.begin() + itsStartChan; - auto widthBegin = chanWidths.begin() + itsStartChan; - auto resolBegin = resolutions.begin() + itsStartChan; - auto effbwBegin = effectiveBW.begin() + itsStartChan; - info().setChannels(std::vector<double>(freqBegin, freqBegin + n_channels), - std::vector<double>(widthBegin, widthBegin + n_channels), - std::vector<double>(resolBegin, resolBegin + n_channels), - std::vector<double>(effbwBegin, effbwBegin + n_channels), - refFreq, spectralWindow); - } + infoOut().setChannels(std::move(chanFreqs), std::move(chanWidths), + std::move(resolutions), std::move(effectiveBW), refFreq, + spectralWindow); + infoOut().SelectChannels(start_channel, n_channels); std::set<aocommon::PolarizationEnum> polarizations; casacore::MSDataDescription data_description_table = itsMS.dataDescription(); diff --git a/steps/MSReader.h b/steps/MSReader.h index 56161492b83d9aa93393668c4986914c17bf2ac4..d36b80c1b80c72de62d13e4c5f907482390544c6 100644 --- a/steps/MSReader.h +++ b/steps/MSReader.h @@ -182,7 +182,8 @@ class MSReader : public InputStep { void prepare(double& firstTime, double& lastTime, double& interval); /// Do the rest of the preparation. - void prepare2(int spectralWindow, unsigned int n_channels); + void prepare2(int spectralWindow, unsigned int start_channel, + unsigned int n_channels); /// Skip the first times in the MS in case a start time was given. /// If needed, it sets itsFirstTime properly. diff --git a/steps/test/unit/tApplyBeam.cc b/steps/test/unit/tApplyBeam.cc index c636f76531792388f64cf478e17720b545b05b1f..705b509e4f1f9c80e8df3b548833c9e3d1b9c1c6 100644 --- a/steps/test/unit/tApplyBeam.cc +++ b/steps/test/unit/tApplyBeam.cc @@ -38,7 +38,7 @@ std::unique_ptr<dp3::base::DPBuffer> CreateBuffer( // Create and populate an info object with the bare minimum values required to // run ApplyBeam successfully dp3::base::DPInfo MakeInfo() { - dp3::base::DPInfo info(4, 8, 0, "HBA_DUAL_INNER"); + dp3::base::DPInfo info(4, 8, "HBA_DUAL_INNER"); info.setMsName("tNDPPP-generic.MS"); info.setChannels({1.34288e+08, 1.34312e+08}, {24414.1, 24414.1}, {24414.1, 24414.1}, {24414.1, 24414.1}, 1.34375e+08, 0); diff --git a/steps/test/unit/tDemixer.cc b/steps/test/unit/tDemixer.cc index 58f88769a940e76f7812066333f08b984c56b8dd..1c2aa58fe99c285ec16b0ef90509bbd4280c6190 100644 --- a/steps/test/unit/tDemixer.cc +++ b/steps/test/unit/tDemixer.cc @@ -114,7 +114,6 @@ class TestInput : public dp3::steps::MockInput { casacore::MVPosition{0, 0, 0}, casacore::MVPosition{1, 1, 1}}; std::vector<int> antenna1 = {0, 0, 1}; std::vector<int> antenna2 = {0, 1, 1}; - std::vector<unsigned int> baselines = {0, 1, 2}; info().setAntennas(ant_names, ant_diameter, ant_position, antenna1, antenna2); @@ -125,8 +124,8 @@ class TestInput : public dp3::steps::MockInput { for (size_t i = 0; i < kNOrigChannels; i++) { chan_freqs.push_back(start_frequency + i * 100000.); } - info().setChannels(std::move(chan_freqs), std::move(chan_width)); - info().update(start_channel, n_channels_, baselines, false); + infoOut().setChannels(std::move(chan_freqs), std::move(chan_width)); + infoOut().SelectChannels(start_channel, n_channels_); } private: