casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Scantable2MSReader.h
Go to the documentation of this file.
1 /*
2  * ScantableReader.h
3  *
4  * Created on: Jan 5, 2016
5  * Author: nakazato
6  */
7 
8 #ifndef SINGLEDISH_FILLER_SCANTABLE2MSREADER_H_
9 #define SINGLEDISH_FILLER_SCANTABLE2MSREADER_H_
10 
11 #include <string>
12 #include <memory>
13 
14 // casacore includes
21 
22 namespace casa { //# NAMESPACE CASA - BEGIN
23 
25 public:
26  Scantable2MSReader(std::string const &scantable_name);
27  virtual ~Scantable2MSReader();
28 
29  // get number of rows for MAIN table
30  virtual size_t getNumberOfRows() {
31  if (!main_table_) {
32  return 0;
33  }
34  return main_table_->nrow();
35  }
36 
37  virtual casacore::Bool isFloatData() const {
38  casacore::Bool is_float = true;
39  if (!main_table_) {
40  is_float = false;
41  } else {
42  casacore::String pol_type = main_table_->keywordSet().asString("POLTYPE");
44  casacore::uInt max_pol = max(polno_column.getColumn());
45 // std::cout << "pol_type=" << pol_type << " max_pol=" << max_pol << std::endl;
46  if ((max_pol == 3) && (pol_type == "linear" || pol_type == "circular")) {
47  is_float = false;
48  }
49  }
50 // std::cout << "is_float = " << is_float << std::endl;
51  return is_float;
52  }
53 
54  virtual casacore::String getDataUnit() const {
55  return main_table_->keywordSet().asString("FluxUnit");
56  }
57 
58  // to get OBSERVATION table
60  POST_START;
61 
62  casacore::Bool return_value = (*this.*get_observation_row_)(record);
63 
64  POST_END;
65  return return_value;
66  }
67 
68  // to get ANTENNA table
70  POST_START;
71 
72  casacore::Bool return_value = (*this.*get_antenna_row_)(record);
73 
74  POST_END;
75  return return_value;
76  }
77 
78  // to get PROCESSOR table
80  POST_START;
81 
82  casacore::Bool return_value = (*this.*get_processor_row_)(record);
83 
84  POST_END;
85  return return_value;
86  }
87 
88  // to get SOURCE table
90  POST_START;
91 
92  casacore::Bool return_value = (*this.*get_source_row_)(record);
93 
94  POST_END;
95  return return_value;
96  }
97 
98  // to get FIELD table
100  POST_START;
101 
102  casacore::Bool return_value = (*this.*get_field_row_)(record);
103 
104  POST_END;
105  return return_value;
106  }
107 
108  // to get SOURCE table
110  POST_START;
111 
112  casacore::Bool return_value = (*this.*get_spw_row_)(record);
113 
114  POST_END;
115  return return_value;
116  }
117 
118  // for DataAccumulator
119  virtual casacore::Bool getData(size_t irow, sdfiller::DataRecord &record);
120 
121 protected:
122  void initializeSpecific();
123  void finalizeSpecific();
124 
125 private:
126  std::unique_ptr<casacore::Table> main_table_;
129 
146  std::map<casacore::uInt, casacore::uInt> tcal_id_map_;
147  std::map<casacore::uInt, casacore::uInt> weather_id_map_;
149 
157 
158  std::unique_ptr<ScantableFieldIterator> field_iter_;
159  std::unique_ptr<ScantableFrequenciesIterator> freq_iter_;
160  std::unique_ptr<ScantableSourceIterator> source_iter_;
161 
168 
169  template<class _Record>
172  return false;
173  }
174 
175  template<class _Iterator, class _Record, class _Func>
176  casacore::Bool getRowImplTemplate(std::unique_ptr<_Iterator> &iter, _Record &record,
177  _Func &func, typename _Iterator::Product *product = nullptr) {
178  POST_START;
179 
180  if (!iter) {
181  iter.reset(new _Iterator(*main_table_));
182  }
183 
184  casacore::Bool more_data = iter->moreData();
185  if (more_data) {
186  iter->getEntry(record);
187  iter->next();
188  } else {
189  // seems to be passed through all the table, deallocate iterator
190  iter->getProduct(product);
191  iter.reset(nullptr);
192  // and then redirect function pointer to noMoreRowImpl
193  func = &Scantable2MSReader::noMoreRowImpl<_Record>;
194  }
195 
196  POST_END;
197 
198  return more_data;
199  }
200 };
201 
202 } //# NAMESPACE CASA - END
203 
204 #endif /* SINGLEDISH_FILLER_SCANTABLE2MSREADER_H_ */
casacore::ScalarColumn< casacore::uInt > weather_id_column_
casacore::ArrayColumn< casacore::Float > data_column_
casacore::Bool getAntennaRowImpl(sdfiller::AntennaRecord &record)
std::unique_ptr< ScantableSourceIterator > source_iter_
#define POST_END
Definition: FillerUtil.h:18
casacore::ArrayColumn< casacore::Double > direction_column_
casacore::Bool noMoreRowImpl(_Record &)
virtual casacore::Bool getObservationRow(sdfiller::ObservationRecord &record)
to get OBSERVATION table
casacore::ScalarColumn< casacore::Float > wind_direction_column_
Main interface class to a read/write table.
Definition: Table.h:153
#define max(a, b)
Definition: hio.h:44
casacore::Bool getObservationRowImpl(sdfiller::ObservationRecord &record)
virtual casacore::Bool getSourceRow(sdfiller::SourceRecord &record)
to get SOURCE table
std::unique_ptr< ScantableFrequenciesIterator > freq_iter_
virtual casacore::Bool getFieldRow(sdfiller::FieldRecord &record)
to get FIELD table
casacore::ScalarColumn< casacore::String > fieldname_column_
casacore::ScalarColumn< casacore::uInt > flagrow_column_
virtual size_t getNumberOfRows()
get number of rows for MAIN table
casacore::ArrayColumn< casacore::uChar > flag_column_
casacore::ScalarColumn< casacore::Float > wind_speed_column_
casacore::ScalarColumn< casacore::Int > srctype_column_
virtual casacore::Bool getAntennaRow(sdfiller::AntennaRecord &record)
to get ANTENNA table
virtual casacore::Bool getSpectralWindowRow(sdfiller::SpectralWindowRecord &record)
to get SOURCE table
casacore::ArrayColumn< casacore::Float > tcal_column_
casacore::ScalarColumn< casacore::uInt > cycle_column_
casacore::Bool getSourceRowImpl(sdfiller::SourceRecord &record)
casacore::Bool(Scantable2MSReader::* get_spw_row_)(sdfiller::SpectralWindowRecord &)
std::unique_ptr< ScantableFieldIterator > field_iter_
virtual casacore::String getDataUnit() const
casacore::ScalarColumn< casacore::Double > time_column_
casacore::Bool getSpectralWindowRowImpl(sdfiller::SpectralWindowRecord &record)
double Double
Definition: aipstype.h:55
std::unique_ptr< casacore::Table > main_table_
casacore::ScalarColumn< casacore::uInt > polno_column_
casacore::Matrix< T > product(const casacore::Vector< T > &x, const casacore::Matrix< T > &yT)
The matrix/outer product of a vector and a transposed vector.
Scantable2MSReader(std::string const &scantable_name)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Vector< casacore::uInt > sorted_rows_
casacore::Bool getRowImplTemplate(std::unique_ptr< _Iterator > &iter, _Record &record, _Func &func, typename _Iterator::Product *product=nullptr)
casacore::Bool getFieldRowImpl(sdfiller::FieldRecord &record)
casacore::Bool(Scantable2MSReader::* get_observation_row_)(sdfiller::ObservationRecord &)
float Float
Definition: aipstype.h:54
casacore::ScalarColumn< casacore::uInt > beam_column_
casacore::ScalarColumn< casacore::Float > temperature_column_
casacore::ScalarColumn< casacore::uInt > scan_column_
casacore::Bool(Scantable2MSReader::* get_source_row_)(sdfiller::SourceRecord &)
virtual casacore::Bool isFloatData() const
ScantableFrequenciesIterator::Product num_chan_map_
casacore::Bool(Scantable2MSReader::* get_processor_row_)(sdfiller::ProcessorRecord &)
casacore::ArrayColumn< casacore::Double > scanrate_column_
virtual casacore::Bool getData(size_t irow, sdfiller::DataRecord &record)
for DataAccumulator
casacore::ScalarColumn< casacore::uInt > tcal_id_column_
casacore::ScalarColumn< casacore::Double > interval_column_
std::map< casacore::Int, casacore::Int > Product
casacore::Bool getProcessorRowImpl(sdfiller::ProcessorRecord &record)
std::map< casacore::uInt, casacore::uInt > tcal_id_map_
String: the storage and methods of handling collections of characters.
Definition: String.h:223
std::map< casacore::uInt, casacore::uInt > weather_id_map_
casacore::ArrayColumn< casacore::Float > tsys_column_
virtual casacore::Bool getProcessorRow(sdfiller::ProcessorRecord &record)
to get PROCESSOR table
casacore::ScalarColumn< casacore::Float > humidity_column_
#define POST_START
Definition: FillerUtil.h:17
casacore::Bool(Scantable2MSReader::* get_field_row_)(sdfiller::FieldRecord &)
casacore::ScalarColumn< casacore::Float > pressure_column_
ScantableFieldIterator::Product field_map_
std::map< casacore::String, casacore::Int > Product
unsigned int uInt
Definition: aipstype.h:51
casacore::ScalarColumn< casacore::uInt > ifno_column_
void getColumn(Vector< T > &vec, Bool resize=False) const
Get the vector of all values in the column.
casacore::Bool(Scantable2MSReader::* get_antenna_row_)(sdfiller::AntennaRecord &)