DP3
SVPInput.h
Go to the documentation of this file.
1 // Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
6 
7 #ifndef DP3_STEPS_SVPINPUT_H_
8 #define DP3_STEPS_SVPINPUT_H_
9 
10 #include <steps/InputStep.h>
11 
12 #include "steps/Step.h"
13 #include "base/DPBuffer.h"
14 #include <base/SubtableWriter.h>
15 #include <casacore/measures/Measures.h>
16 #include <casacore/measures/Measures/MEpoch.h>
17 #include <casacore/measures/Measures/MCEpoch.h>
18 #include <common/ParameterSet.h>
19 #include <common/Timer.h>
20 
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 namespace dp3 {
26 namespace steps {
27 
28 class SVPInput : public InputStep {
29  class MetaData {
30  public:
31  enum Telescope { kLOFAR, kALMA, kAARTFAAC };
32  MetaData(){};
33  size_t nr_channels_;
34  int nr_polarizations_;
35  size_t nr_antennas_;
36 
37  double start_time_;
38  double end_time_;
39  double integration_time_;
40  size_t nr_times_;
41 
42  std::vector<casacore::MPosition> antenna_positions_;
43  std::array<double, 9> axes_;
44  std::vector<std::string> antenna_names_;
45  std::vector<double> antenna_diameters_;
46  double scale_factor_{1.0};
47 
48  double ra_, dec_;
49  std::string source_name_;
50  std::string frame_name_;
51  std::string telescope_name_;
52  Telescope telescope_;
53 
54  std::vector<double> chan_freqs_;
55  std::vector<double> chan_widths_;
56 
57  private:
58  };
59 
60  public:
61  SVPInput(const common::ParameterSet&, const std::string& prefix);
62 
63  void finish() override;
64  bool process(std::unique_ptr<dp3::base::DPBuffer> buffer) override;
65  // The following should be explicitly defined
66  void updateInfo(const base::DPInfo&) override{};
67  void show(std::ostream&) const override;
68 
69  std::string msName() const override;
70 
71  private:
72  std::string name_;
73  std::string temp_out_ms_;
74  std::string receiver_socket_;
75  const std::string kSocketName{"/tmp/svpsock0"};
76 
77  const std::string kDataColumnName{"DATA"};
78  const std::string kWeightColumnName{"WEIGHT"};
79  const std::string kFlagColumnName{"FLAG"};
80 
81  casacore::MDirection phase_direction_;
82  std::unique_ptr<base::UVWCalculator> uvw_calculator_;
83 
84  MetaData metadata_;
85  size_t process_counter_{0};
86  void InitializeInfo();
87  void CreateInitialSubtables();
88  void CreateAntennaTable(double time, base::SubtableWriter& writer);
89 
90  void CreateSpectralWindowTable(int nchannels,
91  std::vector<double> const& chan_freqs,
92  std::vector<double> const& chan_widths,
93  base::SubtableWriter& writer);
94 
95  void CreateSourceTable(std::string& name, double start_time, double end_time,
96  base::SubtableWriter& writer);
97 
98  void CreateFieldTable(std::string& name, double time,
99  base::SubtableWriter& writer);
100 
101  void CreateObservationTable(double start_time, double end_time,
102  base::SubtableWriter& writer);
103 
104  void CreatePolarizationTable(base::SubtableWriter& writer,
105  const int nr_polarizations);
106 
107  int sock_fd_{-1};
108  void ConnectServer(const char* path);
109  void DisconnectServer() {
110  if (sock_fd_ != -1) {
111  close(sock_fd_);
112  }
113  }
114 
115  template <typename T>
116  int ReceiveItem(T& message);
117  int ReceiveBytes(char* message, const int message_size);
118 };
119 
120 } // namespace steps
121 } // namespace dp3
122 
123 #endif /* DP3_STEPS_SVPINPUT_H_ */
Buffer holding the data of a timeslot/band.
Abstract base class for a Step generating input.
Class to hold code for virtual base class for Flaggers in DP3.
General info about DP3 data processing attributes like averaging.
Definition: DPInfo.h:35
Implements a map of Key-Value pairs.
Definition: ParameterSet.h:31
Abstract base class for a Step generating input.
Definition: InputStep.h:37
Definition: SVPInput.h:28
std::string msName() const override
bool process(std::unique_ptr< dp3::base::DPBuffer > buffer) override
void finish() override
Finish the processing of this step and subsequent steps.
void updateInfo(const base::DPInfo &) override
Definition: SVPInput.h:66
SVPInput(const common::ParameterSet &, const std::string &prefix)
void show(std::ostream &) const override
Show the step parameters.
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53