DP3
MSUpdater.h
Go to the documentation of this file.
1 // MSUpdater.h: DPPP step writing to an MS
2 // Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 
5 #ifndef DP3_STEPS_MSUPDATER_H_
6 #define DP3_STEPS_MSUPDATER_H_
7 
8 #include <casacore/tables/Tables/ColumnDesc.h>
9 #include <casacore/tables/Tables/RefRows.h>
10 #include <casacore/tables/Tables/Table.h>
11 
12 #include "base/StManParsetKeys.h"
13 #include "common/ParameterSet.h"
14 #include "common/Timer.h"
15 
16 #include "OutputStep.h"
17 
18 namespace dp3 {
19 namespace steps {
20 
22 
26 //
29 
30 class MSUpdater : public OutputStep {
31  public:
32  explicit MSUpdater(std::string msName, const common::ParameterSet& parset,
33  const std::string& prefix, bool writeHistory = true);
34 
36 
37  void SetFieldsToWrite(const common::Fields& fields) override;
38 
41  bool process(std::unique_ptr<base::DPBuffer> buffer) override;
42 
44  void finish() override;
45 
47  void updateInfo(const base::DPInfo&) override;
48 
50  void show(std::ostream&) const override;
51 
53  void showTimings(std::ostream&, double duration) const override;
54 
58  static bool updateAllowed(const base::DPInfo& info, casacore::String msName,
59  bool throwError = true);
60 
61  private:
63  void putFlags(const casacore::RefRows& rowNrs,
64  const casacore::Cube<bool>& flags);
65 
67  void putWeights(const casacore::RefRows& rowNrs,
68  const casacore::Cube<float>& weights);
69 
71  void putData(const casacore::RefRows& rowNrs,
72  const casacore::Cube<casacore::Complex>& data);
73 
77  bool addColumn(const std::string& colname, const casacore::DataType dataType,
78  const casacore::ColumnDesc& cd);
79 
80  std::string itsName;
81  std::string itsMSName;
82  casacore::Table itsMS;
83  const common::ParameterSet& itsParset;
84  base::DPBuffer itsBuffer;
85  std::string itsDataColName;
86  std::string itsFlagColName;
87  std::string itsWeightColName;
88  unsigned int itsNrTimesFlush;
89  unsigned int itsNrDone;
90  bool itsDataColAdded;
91  bool itsFlagColAdded;
92  bool itsWeightColAdded;
93  bool itsWriteHistory;
94  common::NSTimer itsTimer;
95  unsigned int itsTileSize;
96  base::StManParsetKeys itsStManKeys;
97 };
98 
99 } // namespace steps
100 } // namespace dp3
101 
102 #endif
Buffer holding the data of a timeslot/band.
Definition: DPBuffer.h:92
General info about DP3 data processing attributes like averaging.
Definition: DPInfo.h:35
Definition: Fields.h:16
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
DP3 step writing to an MS.
Definition: MSUpdater.h:30
void showTimings(std::ostream &, double duration) const override
Show the timings.
bool process(std::unique_ptr< base::DPBuffer > buffer) override
void finish() override
Finish the processing of this step and subsequent steps.
void show(std::ostream &) const override
Show the step parameters.
static bool updateAllowed(const base::DPInfo &info, casacore::String msName, bool throwError=true)
MSUpdater(std::string msName, const common::ParameterSet &parset, const std::string &prefix, bool writeHistory=true)
common::Fields getRequiredFields() const override
Get the fields required by the current step.
void updateInfo(const base::DPInfo &) override
Update the general info.
void SetFieldsToWrite(const common::Fields &fields) override
Base class for output steps.
Definition: OutputStep.h:15
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53
Definition: StManParsetKeys.h:46