00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025 #if !defined(ALMA_ASDM2MSFILLER_H)
00026 #define ALMA_ASDM2MSFILLER_H
00027
00028
00029 #include <casa/aips.h>
00030 #include <casa/Utilities/Assert.h>
00031 #include <tables/Tables.h>
00032 #include <ms/MeasurementSets/MeasurementSet.h>
00033 #include <ms/MeasurementSets/MSAntennaColumns.h>
00034 #include <ms/MeasurementSets/MSDataDescColumns.h>
00035 #include <ms/MeasurementSets/MSFeedColumns.h>
00036 #include <ms/MeasurementSets/MSFieldColumns.h>
00037 #include <ms/MeasurementSets/MSFlagCmdColumns.h>
00038 #include <ms/MeasurementSets/MSHistoryColumns.h>
00039 #include <ms/MeasurementSets/MSMainColumns.h>
00040
00041 #include <ms/MeasurementSets/MSObsColumns.h>
00042 #include <ms/MeasurementSets/MSPointingColumns.h>
00043 #include <ms/MeasurementSets/MSPolColumns.h>
00044 #include <ms/MeasurementSets/MSProcessorColumns.h>
00045 #include <ms/MeasurementSets/MSSourceColumns.h>
00046 #include <ms/MeasurementSets/MSStateColumns.h>
00047 #include <ms/MeasurementSets/MSSpWindowColumns.h>
00048
00049 #include <ms/MeasurementSets/MSWeatherColumns.h>
00050
00051 #include <tables/Tables/StandardStMan.h>
00052 #include <tables/Tables/TiledShapeStMan.h>
00053 #include <tables/Tables/SetupNewTab.h>
00054 #include <tables/Tables/TableDesc.h>
00055 #include <tables/Tables/TableRecord.h>
00056 #include <casa/Arrays/Vector.h>
00057 #include <casa/Arrays/Cube.h>
00058 #include <casa/Arrays/Matrix.h>
00059 #include <casa/Arrays/ArrayMath.h>
00060 #include <casa/Arrays/ArrayUtil.h>
00061 #include <casa/Arrays/ArrayLogical.h>
00062 #include <casa/Containers/Block.h>
00063 #include <casa/Containers/OrderedMap.h>
00064 #include <measures/Measures/MCuvw.h>
00065 #include <measures/Measures/MPosition.h>
00066 #include <measures/Measures/MBaseline.h>
00067 #include <measures/Measures/Muvw.h>
00068 #include <measures/Measures/MeasTable.h>
00069 #include <measures/Measures/Stokes.h>
00070 #include <measures/Measures/MeasConvert.h>
00071 #include "measures/Measures/Stokes.h"
00072 #include <casa/BasicSL/Constants.h>
00073 #include <casa/OS/File.h>
00074 #include <casa/OS/Path.h>
00075 #include <complex>
00076
00077 #include <vector>
00078
00079
00080 using namespace casa;
00081 using namespace std;
00082
00083
00084
00085 class TimeRange;
00086 class MPosition;
00087 class MeasFrame;
00088 class MeasurementSet;
00089 class MSMainColumns;
00090
00091
00092
00093 class timeMgr {
00094 private:
00095 int index;
00096 double startTime;
00097
00098 public:
00099 timeMgr();
00100 timeMgr(int i, double t);
00101 void setIndex(int i);
00102 void setStartTime(double t);
00103 int getIndex();
00104 double getStartTime();
00105 };
00106
00107
00108
00109
00110
00111
00112
00113 class ddMgr {
00114 private:
00115 int numCorr[100];
00116 int numChan[100];
00117 struct {
00118 int polId;
00119 int swId;
00120 } dd[100];
00121
00122 public:
00123
00124 ddMgr();
00125
00126 int setNumCorr(int i, int numChan);
00127 int setNumChan(int i, int numCorr);
00128
00129 int getNumCorr(int i);
00130 int getNumChan(int i);
00131
00132 int setDD(int i, int polId, int swId);
00133
00134 int getPolId(int i);
00135 int getSwId(int i);
00136 };
00137
00138
00139
00140
00141 class ASDM2MSFiller
00142 {
00143 private:
00144 double itsCreationTime;
00145 const char* itsName;
00146 int itsNumAntenna;
00147 int itsNumChan;
00148 int itsNumCorr;
00149 casa::MeasurementSet *itsMS;
00150 casa::MSMainColumns *itsMSCol;
00151
00152
00153
00154
00155
00156
00157
00158
00159 String itsMSPath;
00160 timeMgr* itsFeedTimeMgr;
00161 timeMgr* itsFieldTimeMgr;
00162 timeMgr* itsObservationTimeMgr;
00163 timeMgr* itsPointingTimeMgr;
00164
00165 timeMgr* itsSourceTimeMgr;
00166 timeMgr* itsSyscalTimeMgr;
00167 timeMgr* itsWeatherTimeMgr;
00168
00169 Bool itsWithRadioMeters;
00170 Bool itsFirstScan;
00171 uInt itsMSMainRow;
00172
00173 Block<IPosition> itsDataShapes;
00174
00175 int itsScanNumber;
00176 int itsNCat;
00177
00178 ddMgr itsDDMgr;
00179
00180
00181 int createMS(const char* msName, Bool complexData, Bool withCompression);
00182
00183 const char** getPolCombinations(int numCorr);
00184
00185
00186 public:
00187 ASDM2MSFiller (const char* name_,
00188 double creation_time_,
00189 Bool withRadioMeters,
00190 Bool complexData,
00191 Bool withCompression);
00192
00193
00194 ~ASDM2MSFiller();
00195
00196 const casa::MeasurementSet* ms();
00197
00198 int addAntenna(
00199 const char *name_,
00200 const char *station_,
00201 double lx_,
00202 double ly_,
00203 double lz_,
00204 double offset_x_,
00205 double offset_y_,
00206 double offset_z_,
00207 float dish_diam_);
00208
00209 void addData(double time_,
00210 double interval_,
00211 double exposure_,
00212 double time_centroid_,
00213 int nb_antenna_feed_,
00214 int antenna_id_[],
00215 int feed_id_[],
00216 int data_desc_id_,
00217 int field_id_,
00218 double uvw_[],
00219 float vis_r_[],
00220 float vis_i_[],
00221 float sigma_[],
00222 float weight_[],
00223 const char flag_[]);
00224
00225 void addData (bool complexData,
00226 double time_,
00227 vector<int> &antennaId1_,
00228 vector<int> &antennaId2_,
00229 vector<int> &feed1_,
00230 vector<int> &feed2_,
00231 vector<int> &dataDescId_,
00232 int processorId_,
00233 int fieldId_,
00234 double interval_,
00235 vector<double> &exposure_,
00236 vector<double> &timeCentroid_,
00237 int scanNumber_,
00238 int arrayId_,
00239 int observationId_,
00240 vector<int> &stateId_,
00241 vector <double*> &uvw_,
00242 vector<vector<int> > &dataShape_,
00243 vector<float *> &data_,
00244 vector<unsigned int> &flag_);
00245
00246 void addData (bool complexData,
00247 vector<double> &time_,
00248 vector<int> &antennaId1_,
00249 vector<int> &antennaId2_,
00250 vector<int> &feedId1_,
00251 vector<int> &feedId2_,
00252 vector<int> &dataDescId_,
00253 int processorId_,
00254 vector<int> &fieldId_,
00255 vector<double> &interval_,
00256 vector<double> &exposure_,
00257 vector<double> &timeCentroid_,
00258 int scanNumber_,
00259 int arrayId_,
00260 int observationId_,
00261 vector<int> &stateId_,
00262 vector<double> &uvw_,
00263 vector<vector<unsigned int> > &dataShape_,
00264 vector<float *> &uncorrectedData_,
00265 vector<float *> &correctedData_,
00266 vector<unsigned int> &flag_);
00267
00268 void addRCData(double time_,
00269 double interval_,
00270 double exposure_,
00271 double time_centroid_,
00272 int nb_antenna_feed_,
00273 int antenna_id_[],
00274 int feed_id_[],
00275 int data_desc_id_,
00276 int field_id_,
00277 double uvw_[],
00278 float rvis_r_[],
00279 float rvis_i_[],
00280 float cvis_r_[],
00281 float cvis_i_[],
00282 float sigma_[],
00283 float weight_[],
00284 const char flag_[]);
00285
00286 int addDataDescription(int spectral_window_id_,
00287 int polarizarion_id_);
00288
00289 int addUniqueDataDescription(int spectral_window_id_,
00290 int polarizarion_id_);
00291
00292 int exists(char *path);
00293 String msPath();
00294
00295
00296 void addFeed(int antenna_id_,
00297 int feed_id_,
00298 int spectral_window_id_,
00299 double time_,
00300 double interval_,
00301 int num_receptors_,
00302 int beam_id_,
00303 double beam_offset_[],
00304 const vector<string>& pol_type_,
00305 double polarization_responseR_[],
00306 double polarization_responseI_[],
00307 double position_[3],
00308 double receptor_angle_[]);
00309
00310 void addField( const char *name_,
00311 const char *code_,
00312 double time_,
00313 double delay_dir_[2],
00314 double phase_dir_[2],
00315 double reference_dir_[2],
00316 int source_id_);
00317
00318 void addFlagCmd(double time_,
00319 double interval_,
00320 const char *type_,
00321 const char *reason_,
00322 int level_,
00323 int severity_,
00324 int applied_,
00325 const char *command_);
00326
00327 void addHistory( double time_,
00328 int observation_id_,
00329 const char *message_,
00330 const char *priority_,
00331 const char *origin_,
00332 int object_id_,
00333 const char *application_,
00334 const char *cli_command_,
00335 const char *app_parms_ );
00336
00337 void addObservation(const char *telescopeName_,
00338 double startTime_,
00339 double endTime_,
00340 const char *observer_,
00341 const char **log_,
00342 const char *schedule_type_,
00343 const char **schedule_,
00344 const char *project_,
00345 double release_date_);
00346
00347
00348 void addPointing(int antenna_id_,
00349 double time_,
00350 double interval_,
00351 const char *name_,
00352 double direction_[2],
00353 double target_[2],
00354 double pointing_offset_[2],
00355 double encoder_[2],
00356 int tracking_);
00357
00358 void addPointingSlice(unsigned int n_row_,
00359 int *antenna_id,
00360 double *time_,
00361 double *interval_,
00362 char **name_,
00363 double *direction_,
00364 double *target_,
00365 double *pointing_offset_,
00366 double *encoder_,
00367 bool *tracking_);
00368
00369 int addPolarization(int num_corr_,
00370 int corr_type_[],
00371 int corr_product_[]);
00372
00373 int addUniquePolarization(int num_corr_,
00374 Stokes::StokesTypes corr_type_[],
00375 int corr_product_[]);
00376
00377 void addProcessor(const char *type_,
00378 const char*sub_type_,
00379 int type_id_,
00380 int mode_id_);
00381
00382 void addSource(int source_id_,
00383 double time_,
00384 double interval_,
00385 int spectral_window_id_,
00386 int num_lines_,
00387 const char *name_,
00388 int calibration_group_,
00389 const char *code_,
00390 double direction_[2],
00391 double position_[2],
00392 double proper_motion_[2],
00393 const char *transition_[],
00394 double rest_frequency_[],
00395 double sysvel_[]);
00396
00397
00398 int addSpectralWindow(int num_chan_,
00399 const char *name_,
00400 double ref_frequency_,
00401 double chan_freq_[],
00402 double chan_width_[],
00403 int meas_freq_ref_,
00404 double effective_bw_[],
00405 double resolution_[],
00406 double total_bandwidth_,
00407 int net_sideband_,
00408 int bbc_no_,
00409 int if_conv_chain_,
00410 int freq_group_,
00411 const char *freq_group_name_,
00412 int num_assoc_,
00413 int assoc_spectral_window_[],
00414 char** assoc_nature_);
00415
00416 int addUniqueState(Bool sig_,
00417 Bool ref_,
00418 double cal_,
00419 double load_,
00420 unsigned int sub_scan_,
00421 const char* obs_mode_,
00422 Bool flag_row_);
00423
00424
00425 void addState(Bool sig_,
00426 Bool ref_,
00427 double cal_,
00428 double load_,
00429 int sub_scan_,
00430 const char *obs_mode_);
00431
00432 void addWeather(int antennaId_,
00433 double time_,
00434 double interval_,
00435 float h2o_,
00436 float rms_h2o_,
00437 float rms_h2o_flag_,
00438 float pressure_,
00439 float rel_humidity_,
00440 float temperature_,
00441 float dew_point_,
00442 float wind_direction_,
00443 float wind_speed_);
00444
00445 void end(double time_);
00446 };
00447 #endif
00448