casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ASDM2MSFiller.h
Go to the documentation of this file.
1 // ASDM2MSFiller.h: implementation of a casacore::MeasurementSet's filler
2 // for Francois Viallefond & Frederic Badia ALMA Simulator
3 //
4 // Copyright (C) 2001
5 // OBSERVATOIRE DE PARIS - DEMIRM
6 // Avenue Denfert Rochereau - 75014 - PARIS
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 //
23 //
25 #if !defined(ALMA_ASDM2MSFILLER_H)
26 #define ALMA_ASDM2MSFILLER_H
27 //# Includes
28 
29 #include <casa/aips.h>
30 #include <casa/Utilities/Assert.h>
31 #include <tables/Tables.h>
40 
50 
56 #include <casa/Arrays/Vector.h>
57 #include <casa/Arrays/Cube.h>
58 #include <casa/Arrays/Matrix.h>
59 #include <casa/Arrays/ArrayMath.h>
60 #include <casa/Arrays/ArrayUtil.h>
62 #include <casa/Containers/Block.h>
65 #include <measures/Measures/Muvw.h>
74 #include <casa/BasicSL/Constants.h>
75 #include <casa/OS/File.h>
76 #include <casa/OS/Path.h>
77 #include <complex>
78 
79 #include <vector>
80 
81 
82 namespace casacore{
83  class MPosition;
84  class MeasFrame;
85  class MeasurementSet;
86  class MSMainColumns;
87 }
88 
89 //# Forward Declarations
90 
91 namespace casa {
92  class TimeRange;
93 }
94 
95 //
96 // A structure to define a range of rows in the Pointing table where the attribute overTheTop is defined and with which value.
97 //
98 struct s_overTheTop {
99  unsigned int start; // The index of the first row of the range.
100  unsigned int len; // The number of consecutive rows in the range.
101  bool value; // The value of overTheTop in that range.
102 };
103 
104 // Class ddMgr is a utility to help for the management
105 // of DataDescription, SpectralWindow and Polarization ids.
106 // Here we provide enough space to store 100 values for
107 // each quantity; this is very likeky far beyond the actual
108 // needs.
109 class ddMgr {
110  private:
111  int numCorr[100];
112  int numChan[100];
113  struct {
114  int polId;
115  int swId;
116  } dd[100];
117 
118  public:
119 
120  ddMgr();
121 
122  int setNumCorr(int i, int numChan);
123  int setNumChan(int i, int numCorr);
124 
125  int getNumCorr(int i);
126  int getNumChan(int i);
127 
128  int setDD(int i, int polId, int swId);
129 
130  int getPolId(int i);
131  int getSwId(int i);
132 };
133 
134 
135 
136 // Class ASDM2MSFiller
138  private:
140  const std::string itsName;
148  /*casacore::TiledDataStManAccessor itsImWgtAcc;*/
150 
152  int itsNCat;
153 
155 
158 
159  int createMS(const std::string& msName,
160  bool complexData,
161  bool withCompression,
162  const std::string& telName,
163  int maxNumCorr,
164  int maxNumChan,
165  bool withCorrectedData=false,
166  bool useAsdmStMan4DATA=false);
167 
168  const char** getPolCombinations(int numCorr);
169 
170  static std::map<std::string, casacore::MDirection::Types> string2MDirection;
171  static std::map<std::string, casacore::MDirection::Types> string2MDirectionInit();
172 
173  public:
174  ASDM2MSFiller (const std::string& name_,
175  double creation_time_,
176  bool complexData,
177  bool withCompression,
178  const std::string& telName,
179  int intintmaxNumCorr,
180  int maxNumChan,
181  bool withCorrectedData=false,
182  bool useAsdmStMan4DATA=false);
183 
184  // Destructor
185  ~ASDM2MSFiller();
186 
187  const casacore::MeasurementSet* ms();
188 
189  int addAntenna(const std::string& name_,
190  const std::string& station_,
191  double lx_,
192  double ly_,
193  double lz_,
194  double offset_x_,
195  double offset_y_,
196  double offset_z_,
197  float dish_diam_);
198 
199 
200  void addData (bool complexData,
201  std::vector<double> &time_,
202  std::vector<int> &antennaId1_,
203  std::vector<int> &antennaId2_,
204  std::vector<int> &feedId1_,
205  std::vector<int> &feedId2_,
206  std::vector<int> &dataDescId_,
207  int processorId_,
208  int fieldId_,
209  std::vector<double> &interval_,
210  std::vector<double> &exposure_,
211  std::vector<double> &timeCentroid_,
212  int scanNumber_,
213  int arrayId_,
214  int observationId_,
215  std::vector<int> &stateId_,
216  std::vector<std::pair<int, int> > &nChanNPol_,
217  std::vector<double> &uvw_,
218  std::vector<double> &weight_,
219  std::vector<double> &sigma_);
220 
221  void addData (bool complexData,
222  std::vector<double> &time_,
223  std::vector<int> &antennaId1_,
224  std::vector<int> &antennaId2_,
225  std::vector<int> &feedId1_,
226  std::vector<int> &feedId2_,
227  std::vector<int> &dataDescId_,
228  int processorId_,
229  std::vector<int> &fieldId_,
230  std::vector<double> &interval_,
231  std::vector<double> &exposure_,
232  std::vector<double> &timeCentroid_,
233  int scanNumber_,
234  int arrayId_,
235  int observationId_,
236  std::vector<int> &stateId_,
237  std::vector<double> &uvw_,
238  std::vector<std::vector<unsigned int> > &dataShape_,
239  std::vector<float *> &uncorrectedData_,
240  std::vector<float *> &correctedData_,
241  std::vector<unsigned int> &flag_);
242 
243  void addData (bool complexData,
244  std::vector<double> &time_,
245  std::vector<int> &antennaId1_,
246  std::vector<int> &antennaId2_,
247  std::vector<int> &feedId1_,
248  std::vector<int> &feedId2_,
249  std::vector<int> &dataDescId_,
250  int processorId_,
251  std::vector<int> &fieldId_,
252  std::vector<double> &interval_,
253  std::vector<double> &exposure_,
254  std::vector<double> &timeCentroid_,
255  int scanNumber_,
256  int arrayId_,
257  int observationId_,
258  std::vector<int> &stateId_,
259  std::vector<double> &uvw_,
260  std::vector<std::vector<unsigned int> > &dataShape_,
261  std::vector<float *> &data_,
262  std::vector<unsigned int> &flag_,
263  std::vector<double> &weight_,
264  std::vector<double> &sigma_);
265 
266  int addDataDescription(int spectral_window_id_,
267  int polarizarion_id_);
268 
269  int addUniqueDataDescription(int spectral_window_id_,
270  int polarizarion_id_);
271 
272  int exists(char *path);
274 
275 
276  void addFeed(int antenna_id_,
277  int feed_id_,
278  int spectral_window_id_,
279  double time_,
280  double interval_,
281  int num_receptors_,
282  int beam_id_,
283  std::vector<double> & beam_offset_,
284  std::vector<std::string> & pol_type_,
285  std::vector<std::complex<float> > & polarization_response_,
286  std::vector<double>& position_, // Must be a 3 elements vector !!!
287  std::vector<double>& receptor_angle_);
288 
289  void addField( const std::string& name_,
290  const std::string& code_,
291  double time_,
292  unsigned int num_poly_,
293  std::vector<std::vector<double> >& delay_dir_,
294  std::vector<std::vector<double> >& phase_dir_,
295  std::vector<std::vector<double> >& reference_dir_,
296  const std::string& direction_code_,
297  int source_id_);
298 
299  void updateEphemerisIdInField(std::vector<std::pair<int, int> >& idxEphemerisId_v);
300 
301  void addFlagCmd(double time_,
302  double interval_,
303  const std::string& type_,
304  const std::string& reason_,
305  int level_,
306  int severity_,
307  int applied_,
308  std::string& command_);
309 
310  void addHistory( double time_,
311  int observation_id_,
312  const std::string& message_,
313  const std::string& priority_,
314  const std::string& origin_,
315  int object_id_,
316  const std::string& application_,
317  const std::string& cli_command_,
318  const std::string& app_parms_ );
319 
320  void addObservation(const std::string& telescopeName_,
321  double startTime_,
322  double endTime_,
323  const std::string& observer_,
324  const std::vector<std::string>& log_,
325  const std::string& schedule_type_,
326  const std::vector<std::string>& schedule_,
327  const std::string& project_,
328  double release_date_);
329 
330  void addPointingSlice(unsigned int n_row_,
331  std::vector<int>& antenna_id_,
332  std::vector<double>& time_,
333  std::vector<double>& interval_,
334  std::vector<double>& direction_,
335  std::vector<double>& target_,
336  std::vector<double>& pointing_offset_,
337  std::vector<double>& encoder_,
338  std::vector<bool>& tracking_,
339  bool overTheTopExists4All_,
340  std::vector<bool>& v_overTheTop_,
341  std::vector<s_overTheTop>& v_s_overTheTop_);
342 
343  int addPolarization(int num_corr_,
344  std::vector<int>& corr_type_,
345  std::vector<int>& corr_product_);
346 
347  int addUniquePolarization(int num_corr_,
348  // const std::vector<casacore::Stokes::StokesTypes>& corr_type_,
349  const std::vector<int>& corr_type_,
350  const std::vector<int>& corr_product_);
351 
352  void addProcessor(std::string& type_,
353  std::string& sub_type_,
354  int type_id_,
355  int mode_id_);
356 
357  void addSource(int source_id_,
358  double time_,
359  double interval_,
360  int spectral_window_id_,
361  int num_lines_,
362  std::string& name_,
363  int calibration_group_,
364  std::string& code_,
365  std::vector<double>& direction_,
366  std::string& direction_code_,
367  std::vector<double>& position_,
368  std::vector<double>& proper_motion_,
369  std::vector<std::string>& transition_,
370  std::vector<double>& rest_frequency_,
371  std::vector<double>& sysvel_);
372 
373  int addSpectralWindow(int num_chan_,
374  const std::string& name_,
375  double ref_frequency_,
376  const std::vector<double>& chan_freq_,
377  const std::vector<double>& chan_width_,
378  int meas_freq_ref_,
379  const std::vector<double>& effective_bw_,
380  const std::vector<double>& resolution_,
381  double total_bandwidth_,
382  int net_sideband_,
383  int bbc_no_,
384  int if_conv_chain_,
385  int freq_group_,
386  const std::string& freq_group_name_,
387  int num_assoc_,
388  const std::vector<int>& assoc_sp_id_,
389  const std::vector<std::string>& assoc_nature_,
390  const std::string & windowFunction_,
391  int numBin_);
392 
393  int addUniqueState(bool sig_,
394  bool ref_,
395  double cal_,
396  double load_,
397  unsigned int sub_scan_,
398  std::string& obs_mode_,
399  bool flag_row_);
400 
401 
402  void addState(bool sig_,
403  bool ref_,
404  double cal_,
405  double load_,
406  int sub_scan_,
407  std::string& obs_mode_);
408 
409  void addSysCal(int antenna_id,
410  int feed_id,
411  int spectral_window_id,
412  double time_,
413  double interval_,
414  int numReceptor_,
415  int numChan_,
416  std::pair<bool, std::vector<float> >& tcal_spectrum_pair,
417  std::pair<bool, bool>& tcal_flag_pair,
418  std::pair<bool, std::vector<float> >& trx_spectrum_pair,
419  std::pair<bool, bool>& trx_flag_pair,
420  std::pair<bool, std::vector<float> >& tsky_spectrum_pair,
421  std::pair<bool, bool>& tsky_flag_pair,
422  std::pair<bool, std::vector<float> >& tsys_spectrum_pair,
423  std::pair<bool, bool>& tsys_flag_pair,
424  std::pair<bool, std::vector<float> >& tant_spectrum_pair,
425  std::pair<bool, bool>& tant_flag_pair,
426  std::pair<bool, std::vector<float> >& tant_tsys_spectrum_pair,
427  std::pair<bool, bool>& tant_tsys_flag_pair);
428 
429  void addWeather(int antenna_id_,
430  double time_,
431  double interval_,
432  const std::pair<bool, float>& pressure_opt_,
433  const std::pair<bool, float>& relHumidity_opt_,
434  const std::pair<bool, float>& temperature_opt_,
435  const std::pair<bool, float>& windDirection_opt_,
436  const std::pair<bool, float>& windSpeed_opt_,
437  const std::pair<bool, float>& dewPoint_opt_,
438  int wx_station_id_,
439  std::vector<double>& wx_station_position_);
440 
452  void addCalDevice(int antennaId,
453  int feedId,
454  int spectralWindowId,
455  double time,
456  double interval,
457  unsigned int numCalLoad,
458  std::vector<std::string> calloadNames,
459  unsigned int numReceptor,
460  std::vector<std::vector<float> >& calEff,
461  std::vector<std::vector<float> >& noiseCal,
462  std::vector<double >& temperatureLoad);
463 
486  void addSysPower(int antennaId,
487  int feedId,
488  int spectralWindowId,
489  double time,
490  double interval,
491  unsigned int numReceptor,
492  std::vector<float>& switchedPowerDifference,
493  std::vector<float>& switchedPowerSum,
494  std::vector<float>& requantizerGain);
495 
496  void addSysPowerSlice(unsigned int nRow,
497  std::vector<int>& antennaId,
498  std::vector<int>& spectralWindowId,
499  std::vector<int>& feedId,
500  std::vector<double>& time,
501  std::vector<double>& interval,
502  unsigned int numReceptor,
503  std::vector<float>& switchedPowerDifference,
504  std::vector<float>& switchedPowerSum,
505  std::vector<float>& requantizerGain);
506 
507  void end();
508 };
509 
510 #endif
void addCalDevice(int antennaId, int feedId, int spectralWindowId, double time, double interval, unsigned int numCalLoad, std::vector< std::string > calloadNames, unsigned int numReceptor, std::vector< std::vector< float > > &calEff, std::vector< std::vector< float > > &noiseCal, std::vector< double > &temperatureLoad)
Add one row in the casacore::MS CALDEVICE table.
casacore::MeasurementSet * itsMS
int polId
void addSource(int source_id_, double time_, double interval_, int spectral_window_id_, int num_lines_, std::string &name_, int calibration_group_, std::string &code_, std::vector< double > &direction_, std::string &direction_code_, std::vector< double > &position_, std::vector< double > &proper_motion_, std::vector< std::string > &transition_, std::vector< double > &rest_frequency_, std::vector< double > &sysvel_)
casacore::Block< casacore::IPosition > itsDataShapes
int setNumChan(int i, int numCorr)
Class ASDM2MSFiller.
int getNumCorr(int i)
void addState(bool sig_, bool ref_, double cal_, double load_, int sub_scan_, std::string &obs_mode_)
void addPointingSlice(unsigned int n_row_, std::vector< int > &antenna_id_, std::vector< double > &time_, std::vector< double > &interval_, std::vector< double > &direction_, std::vector< double > &target_, std::vector< double > &pointing_offset_, std::vector< double > &encoder_, std::vector< bool > &tracking_, bool overTheTopExists4All_, std::vector< bool > &v_overTheTop_, std::vector< s_overTheTop > &v_s_overTheTop_)
void addProcessor(std::string &type_, std::string &sub_type_, int type_id_, int mode_id_)
Main interface class to a read/write table.
Definition: Table.h:153
void addSysPower(int antennaId, int feedId, int spectralWindowId, double time, double interval, unsigned int numReceptor, std::vector< float > &switchedPowerDifference, std::vector< float > &switchedPowerSum, std::vector< float > &requantizerGain)
Adds one row in the casacore::MS SYSPOWER table.
unsigned int start
Definition: ASDM2MSFiller.h:99
int numCorr[100]
int addAntenna(const std::string &name_, const std::string &station_, double lx_, double ly_, double lz_, double offset_x_, double offset_y_, double offset_z_, float dish_diam_)
const std::string itsName
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
casacore::MSMainColumns * itsMSCol
A structure to define a range of rows in the Pointing table where the attribute overTheTop is defined...
Definition: ASDM2MSFiller.h:98
int itsCalDeviceNumberOfRows
const char ** getPolCombinations(int numCorr)
~ASDM2MSFiller()
Destructor.
Class ddMgr is a utility to help for the management of DataDescription, SpectralWindow and Polarizati...
int setDD(int i, int polId, int swId)
void updateEphemerisIdInField(std::vector< std::pair< int, int > > &idxEphemerisId_v)
int createMS(const std::string &msName, bool complexData, bool withCompression, const std::string &telName, int maxNumCorr, int maxNumChan, bool withCorrectedData=false, bool useAsdmStMan4DATA=false)
void addSysPowerSlice(unsigned int nRow, std::vector< int > &antennaId, std::vector< int > &spectralWindowId, std::vector< int > &feedId, std::vector< double > &time, std::vector< double > &interval, unsigned int numReceptor, std::vector< float > &switchedPowerDifference, std::vector< float > &switchedPowerSum, std::vector< float > &requantizerGain)
int getNumChan(int i)
int addSpectralWindow(int num_chan_, const std::string &name_, double ref_frequency_, const std::vector< double > &chan_freq_, const std::vector< double > &chan_width_, int meas_freq_ref_, const std::vector< double > &effective_bw_, const std::vector< double > &resolution_, double total_bandwidth_, int net_sideband_, int bbc_no_, int if_conv_chain_, int freq_group_, const std::string &freq_group_name_, int num_assoc_, const std::vector< int > &assoc_sp_id_, const std::vector< std::string > &assoc_nature_, const std::string &windowFunction_, int numBin_)
void addWeather(int antenna_id_, double time_, double interval_, const std::pair< bool, float > &pressure_opt_, const std::pair< bool, float > &relHumidity_opt_, const std::pair< bool, float > &temperature_opt_, const std::pair< bool, float > &windDirection_opt_, const std::pair< bool, float > &windSpeed_opt_, const std::pair< bool, float > &dewPoint_opt_, int wx_station_id_, std::vector< double > &wx_station_position_)
void addField(const std::string &name_, const std::string &code_, double time_, unsigned int num_poly_, std::vector< std::vector< double > > &delay_dir_, std::vector< std::vector< double > > &phase_dir_, std::vector< std::vector< double > > &reference_dir_, const std::string &direction_code_, int source_id_)
int addUniqueDataDescription(int spectral_window_id_, int polarizarion_id_)
std::string path(const std::string &name)
static std::map< std::string, casacore::MDirection::Types > string2MDirectionInit()
void addFeed(int antenna_id_, int feed_id_, int spectral_window_id_, double time_, double interval_, int num_receptors_, int beam_id_, std::vector< double > &beam_offset_, std::vector< std::string > &pol_type_, std::vector< std::complex< float > > &polarization_response_, std::vector< double > &position_, std::vector< double > &receptor_angle_)
int exists(char *path)
int addUniqueState(bool sig_, bool ref_, double cal_, double load_, unsigned int sub_scan_, std::string &obs_mode_, bool flag_row_)
unsigned int len
std::pair< casacore::Double, casacore::Double > TimeRange
int setNumCorr(int i, int numChan)
casacore::String msPath()
casacore::uInt itsMSMainRow
void addSysCal(int antenna_id, int feed_id, int spectral_window_id, double time_, double interval_, int numReceptor_, int numChan_, std::pair< bool, std::vector< float > > &tcal_spectrum_pair, std::pair< bool, bool > &tcal_flag_pair, std::pair< bool, std::vector< float > > &trx_spectrum_pair, std::pair< bool, bool > &trx_flag_pair, std::pair< bool, std::vector< float > > &tsky_spectrum_pair, std::pair< bool, bool > &tsky_flag_pair, std::pair< bool, std::vector< float > > &tsys_spectrum_pair, std::pair< bool, bool > &tsys_flag_pair, std::pair< bool, std::vector< float > > &tant_spectrum_pair, std::pair< bool, bool > &tant_flag_pair, std::pair< bool, std::vector< float > > &tant_tsys_spectrum_pair, std::pair< bool, bool > &tant_tsys_flag_pair)
int getPolId(int i)
const casacore::MeasurementSet * ms()
int addDataDescription(int spectral_window_id_, int polarizarion_id_)
ASDM2MSFiller(const std::string &name_, double creation_time_, bool complexData, bool withCompression, const std::string &telName, int intintmaxNumCorr, int maxNumChan, bool withCorrectedData=false, bool useAsdmStMan4DATA=false)
A Table intended to hold astronomical data (a set of Measurements).
int addPolarization(int num_corr_, std::vector< int > &corr_type_, std::vector< int > &corr_product_)
int numChan[100]
casacore::String itsMSPath
int swId
void addObservation(const std::string &telescopeName_, double startTime_, double endTime_, const std::string &observer_, const std::vector< std::string > &log_, const std::string &schedule_type_, const std::vector< std::string > &schedule_, const std::string &project_, double release_date_)
double itsCreationTime
void addHistory(double time_, int observation_id_, const std::string &message_, const std::string &priority_, const std::string &origin_, int object_id_, const std::string &application_, const std::string &cli_command_, const std::string &app_parms_)
static std::map< std::string, casacore::MDirection::Types > string2MDirection
A class for easy read-write access to MeasurementSet main table columns.
casacore::ScalarColumn< casacore::String > * itsWinFuncCol
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Table itsMSCalDeviceTable
int addUniquePolarization(int num_corr_, const std::vector< int > &corr_type_, const std::vector< int > &corr_product_)
struct ddMgr::@56 dd[100]
int getSwId(int i)
casacore::ScalarColumn< casacore::Int > * itsNumBinCol
void addData(bool complexData, std::vector< double > &time_, std::vector< int > &antennaId1_, std::vector< int > &antennaId2_, std::vector< int > &feedId1_, std::vector< int > &feedId2_, std::vector< int > &dataDescId_, int processorId_, int fieldId_, std::vector< double > &interval_, std::vector< double > &exposure_, std::vector< double > &timeCentroid_, int scanNumber_, int arrayId_, int observationId_, std::vector< int > &stateId_, std::vector< std::pair< int, int > > &nChanNPol_, std::vector< double > &uvw_, std::vector< double > &weight_, std::vector< double > &sigma_)
unsigned int uInt
Definition: aipstype.h:51
void addFlagCmd(double time_, double interval_, const std::string &type_, const std::string &reason_, int level_, int severity_, int applied_, std::string &command_)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42