casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SingleDishMSFiller.h
Go to the documentation of this file.
1 /*
2  * Scantable2MSFiller.h
3  *
4  * Created on: Jan 5, 2016
5  * Author: nakazato
6  */
7 
8 #ifndef SINGLEDISH_FILLER_SINGLEDISHMSFILLER_H_
9 #define SINGLEDISH_FILLER_SINGLEDISHMSFILLER_H_
10 
11 #include <string>
12 #include <memory>
13 #include <map>
14 
15 #include <casacore/casa/OS/File.h>
16 #include <casacore/casa/OS/Path.h>
39 
40 namespace casa { //# NAMESPACE CASA - BEGIN
41 namespace sdfiller {
42 class DataAccumulator;
43 }
44 
45 template<typename Reader>
46 class SingleDishMSFiller {
47 public:
48  // static methods for parallel processing
49  inline static void create_context();
50  inline static void destroy_context();
51  static void *consume(void *arg);
52  static void *produce(void *arg);
53  inline static void fillMainMT(SingleDishMSFiller<Reader> *filler);
54 
55  // constructor
56  SingleDishMSFiller(std::string const &name, bool parallel=false);
57 
58  // destructor
60 
61  // access to reader object
62  Reader const &getReader() const {
63  return *reader_;
64  }
65 
66  std::string const &getDataName() const {
67  return reader_->getName();
68  }
69 
70  // top level method to fill casacore::MS by reading input data
71  void fill();
72 
73  // save
74  void save(std::string const &name);
75 
76 private:
77  // initialization
78  void initialize();
79 
80  // finalization
81  void finalize();
82 
83  // setup casacore::MS as Scratch table
84  // The table will be non-Scratch when it is saved
85  void setupMS();
86 
87  // fill tables that can be processed prior to main loop
88  void fillPreProcessTables();
89 
90  // fill tables that must be processed after main loop
91  void fillPostProcessTables();
92 
93  // fill MAIN table
94  void fillMain();
95 
96  // flush accumulated data
97  inline void flush(sdfiller::DataAccumulator &accumulator);
98 
99  void sortPointing();
100 
101  // Fill subtables
102  // fill ANTENNA table
103  void fillAntenna();
104 
105  // fill OBSERVATION table
106  void fillObservation();
107 
108  // fill PROCESSOR table
109  void fillProcessor();
110 
111  // fill SOURCE table
112  void fillSource();
113 
114  // fill SOURCE table
115  void fillField();
116 
117  // fill SPECTRAL_WINDOW table
118  void fillSpectralWindow();
119 
120  // fill HISTORY table
121  void fillHistory();
122 
123  // update POLARIZATION table
124  // @param[in] corr_type polarization type list
125  // @param[in] num_pol number of polarization components
126  // @return polarization id
128  casacore::Int const &num_pol);
129 
130  // update DATA_DESCRIPTION table
131  // @param[in] polarization_id polarization id
132  // @param[in] spw_id spectral window id
133  // @return data description id
134  inline casacore::Int updateDataDescription(casacore::Int const &polarization_id,
135  casacore::Int const &spw_id);
136 
137  // update STATE table
138  // @param[in] subscan subscan number
139  // @param[in] obs_mode observing mode string
140  // @return state id
141  inline casacore::Int updateState(casacore::Int const &subscan, casacore::String const &obs_mode);
142 
143  // update FEED table
144  // @param[in] feed_id feed ID
145  // @param[in] spw_id spectral window ID
146  // @param[in] pol_type polarization type
147  // @return feed row number
148  inline casacore::Int updateFeed(casacore::Int const &feed_id, casacore::Int const &spw_id,
149  casacore::String const &pol_type);
150 
151  // update POINTING table
152  // @param[in] antenna_id antenna id
153  // @param[in] time time stamp
154  // @param[in] direction pointing direction
155  inline casacore::Int updatePointing(casacore::Int const &antenna_id, casacore::Int const &feed_id,
156  casacore::Double const &time, casacore::Double const &interval,
157  casacore::Matrix<casacore::Double> const &direction);
158 
159  inline void updateWeather(casacore::Int const &antenna_id, casacore::Double const &time,
160  casacore::Double const &interval, sdfiller::MSDataRecord const &data_record);
161 
162  inline void updateWeather(casacore::MSWeatherColumns &columns, casacore::uInt irow,
163  sdfiller::WeatherRecord const &record);
164 
165  inline void updateSysCal(casacore::Int const &antenna_id, casacore::Int const &feed_id,
166  casacore::Int const &spw_id, casacore::Double const &time, casacore::Double const &interval,
167  sdfiller::MSDataRecord const &data_record);
168 
169  inline void updateSysCal(casacore::MSSysCalColumns &columns, casacore::uInt irow,
170  sdfiller::SysCalRecord const &record);
171 
172  // update MAIN table
173  // @param[in] fieldId field id
174  // @param[in] feedId feed id
175  // @param[in] dataDescriptionId data description id
176  // @param[in] stateId state id
177  // @param[in] mainSpec main table row specification except id
178  inline void updateMain(casacore::Int const &antenna_id, casacore::Int field_id, casacore::Int feedId,
179  casacore::Int dataDescriptionId, casacore::Int stateId, casacore::Int const &scan_number,
180  casacore::Double const &time, sdfiller::MSDataRecord const &dataRecord);
181 
182  std::unique_ptr<casacore::MeasurementSet> ms_;
183  std::unique_ptr<casacore::MSMainColumns> ms_columns_;
184  std::unique_ptr<casacore::MSDataDescColumns> data_description_columns_;
185  std::unique_ptr<casacore::MSFeedColumns> feed_columns_;
186  std::unique_ptr<casacore::MSPointingColumns> pointing_columns_;
187  std::unique_ptr<casacore::MSPolarizationColumns> polarization_columns_;
188  std::unique_ptr<casacore::MSSysCalColumns> syscal_columns_;
189  std::unique_ptr<casacore::MSStateColumns> state_columns_;
190  std::unique_ptr<casacore::MSWeatherColumns> weather_columns_;
191  std::unique_ptr<Reader> reader_;
192  bool is_float_;
194 
195  // for POINTING table
197  std::map<casacore::Int, casacore::Vector<casacore::Double>> pointing_time_;
198  std::map<casacore::Int, casacore::Double> pointing_time_max_;
199  std::map<casacore::Int, casacore::Double> pointing_time_min_;
201 
202  // for SYSCAL table
203  std::vector<sdfiller::SysCalTableRecord> syscal_list_;
204 
205  // for STATE table
206  std::vector<casacore::Int> subscan_list_;
207 
208  // for FEED table
209  std::vector<casacore::Vector<casacore::String> *> polarization_type_pool_;
210 
211  // for WEATHER table
212  std::vector<sdfiller::WeatherRecord> weather_list_;
213 
214  // casacore::Data storage to interact with DataAccumulator
216 
217  // for parallel processing
219 }
220 ;
221 
222 } //# NAMESPACE CASA - END
223 
224 #include <singledishfiller/Filler/SingleDishMSFiller.tcc>
225 
226 #endif /* SINGLEDISH_FILLER_SINGLEDISHMSFILLER_H_ */
std::unique_ptr< casacore::MSMainColumns > ms_columns_
casacore::Int updateDataDescription(casacore::Int const &polarization_id, casacore::Int const &spw_id)
update DATA_DESCRIPTION table
sdfiller::MSDataRecord record_
casacore::Data storage to interact with DataAccumulator
int Int
Definition: aipstype.h:50
std::unique_ptr< casacore::MSFeedColumns > feed_columns_
LatticeExprNode arg(const LatticeExprNode &expr)
casacore::Vector< casacore::uInt > num_pointing_time_
SingleDishMSFiller(std::string const &name, bool parallel=false)
constructor
std::vector< casacore::Vector< casacore::String > * > polarization_type_pool_
for FEED table
casacore::Bool const parallel_
for parallel processing
std::unique_ptr< casacore::MSWeatherColumns > weather_columns_
void updateMain(casacore::Int const &antenna_id, casacore::Int field_id, casacore::Int feedId, casacore::Int dataDescriptionId, casacore::Int stateId, casacore::Int const &scan_number, casacore::Double const &time, sdfiller::MSDataRecord const &dataRecord)
update MAIN table
static void create_context()
static methods for parallel processing
static void fillMainMT(SingleDishMSFiller< Reader > *filler)
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
void save(std::string const &name)
save
std::map< casacore::Int, casacore::Double > pointing_time_max_
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
casacore::Int reference_feed_
for POINTING table
void fillSpectralWindow()
fill SPECTRAL_WINDOW table
void updateSysCal(casacore::Int const &antenna_id, casacore::Int const &feed_id, casacore::Int const &spw_id, casacore::Double const &time, casacore::Double const &interval, sdfiller::MSDataRecord const &data_record)
static void destroy_context()
std::map< casacore::Int, casacore::Double > pointing_time_min_
std::map< casacore::Int, casacore::Vector< casacore::Double > > pointing_time_
std::vector< sdfiller::SysCalTableRecord > syscal_list_
for SYSCAL table
void fill()
top level method to fill casacore::MS by reading input data
void setupMS()
setup casacore::MS as Scratch table The table will be non-Scratch when it is saved ...
void fillMain()
fill MAIN table
void fillField()
fill SOURCE table
void fillProcessor()
fill PROCESSOR table
double Double
Definition: aipstype.h:55
void fillObservation()
fill OBSERVATION table
std::string const & getDataName() const
std::unique_ptr< Reader > reader_
A class to provide easy read-write access to MSSysCal columns.
casacore::Int updateState(casacore::Int const &subscan, casacore::String const &obs_mode)
update STATE table
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
~SingleDishMSFiller()
destructor
std::unique_ptr< casacore::MSStateColumns > state_columns_
Reader const & getReader() const
access to reader object
std::unique_ptr< casacore::MeasurementSet > ms_
void initialize()
initialization
std::unique_ptr< casacore::MSPointingColumns > pointing_columns_
std::vector< sdfiller::WeatherRecord > weather_list_
for WEATHER table
void finalize()
finalization
void fillHistory()
fill HISTORY table
void fillPostProcessTables()
fill tables that must be processed after main loop
casacore::Int updatePolarization(casacore::Vector< casacore::Int > const &corr_type, casacore::Int const &num_pol)
update POLARIZATION table
void fillSource()
fill SOURCE table
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static void * produce(void *arg)
void fillPreProcessTables()
fill tables that can be processed prior to main loop
void updateWeather(casacore::Int const &antenna_id, casacore::Double const &time, casacore::Double const &interval, sdfiller::MSDataRecord const &data_record)
void flush(sdfiller::DataAccumulator &accumulator)
flush accumulated data
static void * consume(void *arg)
casacore::Int updatePointing(casacore::Int const &antenna_id, casacore::Int const &feed_id, casacore::Double const &time, casacore::Double const &interval, casacore::Matrix< casacore::Double > const &direction)
update POINTING table
void fillAntenna()
Fill subtables fill ANTENNA table.
std::unique_ptr< casacore::MSPolarizationColumns > polarization_columns_
casacore::Int updateFeed(casacore::Int const &feed_id, casacore::Int const &spw_id, casacore::String const &pol_type)
update FEED table
unsigned int uInt
Definition: aipstype.h:51
std::vector< casacore::Int > subscan_list_
for STATE table
std::unique_ptr< casacore::MSDataDescColumns > data_description_columns_
A class to provide easy read-write access to MSWeather columns.
std::unique_ptr< casacore::MSSysCalColumns > syscal_columns_