MSFitsInput.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef MS_MSFITSINPUT_H
00029 #define MS_MSFITSINPUT_H
00030
00031 #include <casacore/casa/aips.h>
00032 #include <casacore/casa/Arrays/Matrix.h>
00033 #include <casacore/casa/Arrays/Vector.h>
00034 #include <casacore/casa/Containers/Block.h>
00035 #include <casacore/casa/Containers/Record.h>
00036 #include <casacore/fits/FITS/fits.h>
00037 #include <casacore/fits/FITS/hdu.h>
00038 #include <casacore/casa/Logging/LogIO.h>
00039 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
00040 #include <casacore/measures/Measures/MDirection.h>
00041 #include <casacore/measures/Measures/MFrequency.h>
00042 #include <casacore/casa/BasicSL/String.h>
00043 #include <casacore/ms/MeasurementSets/MSTileLayout.h>
00044 #include <casacore/tables/Tables/BaseTable.h>
00045
00046 namespace casacore {
00047
00048 class FitsInput;
00049 class BinaryTable;
00050 class MSColumns;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class MSPrimaryTableHolder
00065 {
00066
00067
00068
00069 public:
00070
00071 MSPrimaryTableHolder();
00072
00073
00074
00075 MSPrimaryTableHolder(FitsInput& infile);
00076
00077 ~MSPrimaryTableHolder();
00078
00079
00080
00081 void attach(FitsInput& infile);
00082
00083
00084 void detach();
00085
00086
00087
00088
00089 Int dims()
00090 {return hdu_p->dims();}
00091
00092
00093 Int dim(Int i)
00094 {return hdu_p->dim(i);}
00095
00096
00097 Char* ctype(Int i)
00098 { return pf ? pf->ctype(i) : (pl ? pl->ctype(i) : ps->ctype(i));}
00099
00100
00101 Double crval(Int i)
00102 { return pf ? pf->crval(i) : (pl ? pl->crval(i) : ps->crval(i));}
00103
00104
00105 Double crpix(Int i)
00106 { return pf ? pf->crpix(i) : (pl ? pl->crpix(i) : ps->crpix(i));}
00107
00108
00109 Double cdelt(Int i)
00110 { return pf ? pf->cdelt(i) : (pl ? pl->cdelt(i) : ps->cdelt(i));}
00111
00112
00113 const FitsKeyword* kw(const FITS::ReservedName& n)
00114 { return hdu_p->kw(n);}
00115
00116
00117 ConstFitsKeywordList& kwlist()
00118 { return hdu_p->kwlist();}
00119
00120
00121 const FitsKeyword* nextkw()
00122 { return hdu_p->nextkw();}
00123
00124
00125 Int read() {
00126 if (pf) return pf->read();
00127 else if (pl) return pl->read();
00128 else if (ps) return ps->read();
00129 else if (pb) return pb->read();
00130 else cout << "can not read the table" << endl;
00131 return 0;
00132 }
00133
00134 private:
00135 HeaderDataUnit* hdu_p;
00136 PrimaryTable<Short>* ps;
00137 PrimaryTable<FitsLong>* pl;
00138 PrimaryTable<Float>* pf;
00139 PrimaryTable<uChar>* pb;
00140 };
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 class MSPrimaryGroupHolder
00155 {
00156
00157
00158
00159 public:
00160
00161 MSPrimaryGroupHolder();
00162
00163
00164
00165 MSPrimaryGroupHolder(FitsInput& infile);
00166
00167 ~MSPrimaryGroupHolder();
00168
00169
00170
00171 void attach(FitsInput& infile);
00172
00173
00174 void detach();
00175
00176
00177
00178
00179 Int dims()
00180 {return hdu_p->dims();}
00181
00182
00183 Int dim(Int i)
00184 {return hdu_p->dim(i);}
00185
00186
00187 Char* ctype(Int i)
00188 { return pf ? pf->ctype(i) : (pl ? pl->ctype(i) : ps->ctype(i));}
00189
00190
00191 Double crval(Int i)
00192 { return pf ? pf->crval(i) : (pl ? pl->crval(i) : ps->crval(i));}
00193
00194
00195 Double crpix(Int i)
00196 { return pf ? pf->crpix(i) : (pl ? pl->crpix(i) : ps->crpix(i));}
00197
00198
00199 Double cdelt(Int i)
00200 { return pf ? pf->cdelt(i) : (pl ? pl->cdelt(i) : ps->cdelt(i));}
00201
00202
00203 const FitsKeyword* kw(const FITS::ReservedName& n)
00204 { return hdu_p->kw(n);}
00205
00206
00207 ConstFitsKeywordList& kwlist()
00208 { return hdu_p->kwlist();}
00209
00210
00211 const FitsKeyword* nextkw()
00212 { return hdu_p->nextkw();}
00213
00214
00215 Int gcount() const
00216 { return pf ? pf->gcount() : ( pl ? pl->gcount() : ps->gcount());}
00217
00218
00219 Int pcount() const
00220 { return pf ? pf->pcount() : ( pl ? pl->pcount() : ps->pcount());}
00221
00222
00223 Char* ptype(Int i) const
00224 { return pf ? pf->ptype(i) : ( pl ? pl->ptype(i) : ps->ptype(i));}
00225
00226
00227 Int read()
00228 { return pf ? pf->read() : ( pl ? pl->read() : ps->read());}
00229
00230
00231 Double parm(Int i)
00232 { return pf ? pf->parm(i) : ( pl ? pl->parm(i) : ps->parm(i));}
00233
00234
00235 Double operator () (Int i) const
00236 { return pf ? (*pf)(i) : ( pl ? (*pl)(i) : (*ps)(i));}
00237
00238 private:
00239 HeaderDataUnit* hdu_p;
00240 PrimaryGroup<Short>* ps;
00241 PrimaryGroup<FitsLong>* pl;
00242 PrimaryGroup<Float>* pf;
00243 };
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 class MSFitsInput
00268 {
00269
00270
00271 public:
00272
00273
00274 MSFitsInput(const String& msFile, const String& fitsFile, const Bool NewNameStyle=False);
00275
00276
00277 ~MSFitsInput();
00278
00279
00280
00281
00282 void readFitsFile(Int obsType = MSTileLayout::Standard);
00283
00284
00285
00286
00287
00288
00289
00290 void rotateAntennaPositions(Bool b) {
00291 _rotateAnts = b;
00292 }
00293
00294 protected:
00295
00296
00297
00298 Bool checkInput(FitsInput& infile);
00299
00300
00301
00302 void getPrimaryGroupAxisInfo();
00303
00304
00305
00306
00307
00308 void setupMeasurementSet(const String& MSFileName, Bool useTSM=True,
00309 Int obsType = MSTileLayout::Standard);
00310
00312
00313 void fillAntennaTable(BinaryTable& bt);
00314
00315
00316 void fillHistoryTable(ConstFitsKeywordList& kwl);
00317
00318
00319 void fillObservationTable(ConstFitsKeywordList& kwl);
00320
00321
00322 void getAxisInfo(ConstFitsKeywordList&);
00323
00324
00325 void sortPolarizations();
00326
00327 void fillPolarizationTable();
00328
00329
00330 void checkRequiredAxis();
00331
00332 void fillSpectralWindowTable(BinaryTable& bt);
00333
00334
00335 void fillFieldTable(BinaryTable& bt);
00336 void fillFieldTable(double, double, String);
00337
00338 void fillMSMainTable(BinaryTable& bt);
00339
00340 void fillPointingTable();
00341
00342 void fillSourceTable();
00343
00344
00345 void fillFeedTable();
00346
00348
00349 void fillObsTables();
00350
00351
00352
00353 void fillMSMainTableColWise(Int& nField, Int& nSpW);
00354
00355 void fillMSMainTable(Int& nField, Int& nSpW);
00356
00357
00358 void fillSpectralWindowTable(BinaryTable& bt, Int nSpW);
00359
00360
00361 void fillSpectralWindowTable();
00362
00363
00364 void fillFieldTable(BinaryTable& bt, Int nField);
00365
00366
00367 void fillFieldTable(Int nField);
00368
00369
00370
00371 void fillExtraTables();
00372
00373
00374
00375 void fixEpochReferences();
00376
00377
00378
00379 MDirection::Types getDirectionFrame(Double epoch);
00380
00381
00382 void setFreqFrameVar(BinaryTable& binTab);
00383
00384 void updateSpectralWindowTable();
00385
00386 void readRandomGroupUVFits(Int obsType);
00387 void readPrimaryTableUVFits(Int obsType);
00388
00389 private:
00390
00391 MSFitsInput();
00392
00393 MSFitsInput(const MSFitsInput& other);
00394
00395 MSFitsInput& operator=(const MSFitsInput& other);
00396
00397 FitsInput* _infile;
00398 String _msFile;
00399 MSPrimaryGroupHolder _priGroup;
00400 MSPrimaryTableHolder _priTable;
00401 MeasurementSet _ms;
00402 MSColumns* _msc;
00403 Int _nIF;
00404 Vector<Int> _nPixel, _corrType;
00405 Block<Int> _corrIndex;
00406 Matrix<Int> _corrProduct;
00407 Vector<String> _coordType;
00408 Vector<Double> _refVal, _refPix, _delta;
00409 String _array, _object, _timsys;
00410 Double _epoch;
00411 MDirection::Types _epochRef;
00412
00413
00414
00415 std::set<Int> _uniqueAnts;
00416
00417 Int _nAntRow;
00418 Int _nArray;
00419 Vector<Double> _receptorAngle;
00420 MFrequency::Types _freqsys;
00421 Double _restfreq;
00422 Bool _addSourceTable;
00423 LogIO _log;
00424 Record _header;
00425 Double _refFreq;
00426 Bool _useAltrval;
00427 Vector<Double> _chanFreq;
00428 Bool _newNameStyle;
00429 Vector<Double> _obsTime;
00430
00431 Matrix<Double> _restFreq;
00432 Matrix<Double> _sysVel;
00433 Bool _msCreated, _rotateAnts;
00434
00435 std::pair<Int, Int> _extractAntennas(Float baseline);
00436
00437 };
00438
00439
00440 }
00441
00442 #endif