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

AST-1257 MSUpdater: Use XTensor interface of DPBuffer

parent 84405da4
No related branches found
No related tags found
1 merge request!1034AST-1257 MSUpdater: Use XTensor interface of DPBuffer
...@@ -34,7 +34,6 @@ using casacore::Cube; ...@@ -34,7 +34,6 @@ using casacore::Cube;
using casacore::DataManager; using casacore::DataManager;
using casacore::DataManagerCtor; using casacore::DataManagerCtor;
using casacore::IPosition; using casacore::IPosition;
using casacore::MeasurementSet;
using casacore::Record; using casacore::Record;
using casacore::RefRows; using casacore::RefRows;
using casacore::ScalarColumn; using casacore::ScalarColumn;
...@@ -153,44 +152,53 @@ bool MSUpdater::addColumn(const string& colName, ...@@ -153,44 +152,53 @@ bool MSUpdater::addColumn(const string& colName,
} }
bool MSUpdater::process(std::unique_ptr<DPBuffer> buffer) { bool MSUpdater::process(std::unique_ptr<DPBuffer> buffer) {
{
common::NSTimer::StartStop sstime(itsTimer); common::NSTimer::StartStop sstime(itsTimer);
const casacore::IPosition casacore_shape(
3, getInfo().ncorr(), getInfo().nchan(), getInfo().nbaselines());
if (GetFieldsToWrite().Flags()) { if (GetFieldsToWrite().Flags()) {
putFlags(buffer->getRowNrs(), buffer->GetCasacoreFlags()); const Cube<bool> flags(casacore_shape, buffer->GetFlags().data(),
casacore::SHARE);
putFlags(buffer->getRowNrs(), flags);
} }
if (GetFieldsToWrite().Data()) { if (GetFieldsToWrite().Data()) {
const Cube<casacore::Complex> data(
casacore_shape, buffer->GetData().data(), casacore::SHARE);
// If compressing, flagged values need to be set to NaN to decrease the // If compressing, flagged values need to be set to NaN to decrease the
// dynamic range // dynamic range
if (itsStManKeys.stManName == "dysco") { if (itsStManKeys.stManName == "dysco") {
Cube<casacore::Complex> dataCopy = buffer->GetCasacoreData().copy(); Cube<casacore::Complex> data_copy = data.copy();
Cube<casacore::Complex>::iterator dataIter = dataCopy.begin(); Cube<casacore::Complex>::iterator data_iterator = data_copy.begin();
for (const bool flag : buffer->GetFlags()) { for (const bool flag : buffer->GetFlags()) {
if (flag) { if (flag) {
*dataIter = *data_iterator =
casacore::Complex(std::numeric_limits<float>::quiet_NaN(), casacore::Complex(std::numeric_limits<float>::quiet_NaN(),
std::numeric_limits<float>::quiet_NaN()); std::numeric_limits<float>::quiet_NaN());
} }
++dataIter; ++data_iterator;
} }
putData(buffer->getRowNrs(), dataCopy); putData(buffer->getRowNrs(), data_copy);
} else { } else {
putData(buffer->getRowNrs(), buffer->GetCasacoreData()); putData(buffer->getRowNrs(), data);
} }
} }
if (GetFieldsToWrite().Weights()) { if (GetFieldsToWrite().Weights()) {
const Cube<float>& weights = buffer->GetCasacoreWeights(); const Cube<float> weights(casacore_shape, buffer->GetWeights().data(),
casacore::SHARE);
// If compressing, set weights of flagged points to zero to decrease the // If compressing, set weights of flagged points to zero to decrease the
// dynamic range // dynamic range
if (itsStManKeys.stManName == "dysco") { if (itsStManKeys.stManName == "dysco") {
Cube<float> weightsCopy = weights.copy(); Cube<float> weights_copy = weights.copy();
Cube<float>::iterator weightsIter = weightsCopy.begin(); Cube<float>::iterator weights_iterator = weights_copy.begin();
for (const bool flag : buffer->GetFlags()) { for (const bool flag : buffer->GetFlags()) {
if (flag) { if (flag) {
*weightsIter = 0.; *weights_iterator = 0.0f;
} }
++weightsIter; ++weights_iterator;
} }
putWeights(buffer->getRowNrs(), weightsCopy); putWeights(buffer->getRowNrs(), weights_copy);
} else { } else {
putWeights(buffer->getRowNrs(), weights); putWeights(buffer->getRowNrs(), weights);
} }
...@@ -199,6 +207,7 @@ bool MSUpdater::process(std::unique_ptr<DPBuffer> buffer) { ...@@ -199,6 +207,7 @@ bool MSUpdater::process(std::unique_ptr<DPBuffer> buffer) {
if (itsNrTimesFlush > 0 && itsNrDone % itsNrTimesFlush == 0) { if (itsNrTimesFlush > 0 && itsNrDone % itsNrTimesFlush == 0) {
itsMS.flush(); itsMS.flush();
} }
}
getNextStep()->process(std::move(buffer)); getNextStep()->process(std::move(buffer));
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment