casacore
FitsIDItoMS.h
Go to the documentation of this file.
1 //# FITSIDItoMS.h: Convert a FITS-IDI binary table to an AIPS++ Table.
2 //# Copyright (C) 1995,1996,2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 //# Mod 2010: DP
28 
29 #ifndef MS_FITSIDITOMS_H
30 #define MS_FITSIDITOMS_H
31 
32 #include <casacore/casa/aips.h>
33 #include <casacore/fits/FITS/hdu.h>
34 #include <casacore/tables/Tables/Table.h> //
35 #include <casacore/tables/Tables/TableDesc.h> //
36 #include <casacore/tables/Tables/TableRecord.h> //
37 #include <casacore/tables/Tables/TableColumn.h> //
38 #include <casacore/casa/Containers/SimOrdMap.h> //
39 #include <casacore/casa/Arrays/Vector.h>
40 #include <casacore/casa/Arrays/Matrix.h>
41 #include <casacore/casa/Containers/Block.h>
42 #include <casacore/casa/Logging/LogIO.h>
43 #include <casacore/measures/Measures/MFrequency.h>
44 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
45 #include <casacore/casa/BasicSL/String.h>
46 namespace casacore { //# NAMESPACE CASACORE - BEGIN
47 
48 class MSColumns;
49 class FitsInput;
50 
51 
52 // <summary>
53 // FITSIDItoMS converts a FITS-IDI file to a CASA Measurement Set
54 // </summary>
55 
56 // <use visibility=export>
57 
58 // <reviewed reviewer="" date="" tests="">
59 
60 // <prerequisite>
61 //# Classes you should understand before using this one.
62 // <li> FitsInput
63 // <li> HeaderDataUnit
64 // <li> BinaryTableExtension
65 // <li> Tables module
66 // </prerequisite>
67 
68 // <etymology>
69 
70 // FITSIDItoMS inherits from the FITS BinaryTableExtension class and
71 // its primary use is to convert such an object to a CASA Table.
72 // This explains it's use but not its name. A better name should be
73 // found.
74 
75 // </etymology>
76 
77 // <synopsis>
78 // The class starts with an already existing FitsInput object, which
79 // should be set at a BinaryTableExtension HDU. Member functions
80 // provide a TableDesc appropriate for the FITS data (to help in
81 // constructing a CASA Table compatible with the
82 // BinaryTableExtension), a Table containing the current row of FITS
83 // data and a Table containing the next row of FITS data (which can be
84 // used to step through the FitsInput, copying each row using the
85 // RowCopier class), and a Table containin the entire FITS binary
86 // table from the current row to the end of the table.
87 // </synopsis>
88 
89 // <motivation>
90 // We need a way to get FITS-IDI data (typically from VLBI observations) into CASA.
91 // </motivation>
92 
93 // <example>
94 // Open a FitsInput from a disk file, if the HDU is a
95 // BinaryTableExtension, then instantiate a MSBinaryTable object and
96 // get the entire table. A fair amount of error checking has been
97 // eliminated from this example.
98 // <srcblock>
99 // FitsInput infits("myFITSFile", FITS::Disk);
100 // switch (infits.hdutype()) {
101 // case FITS::BinaryTableHDU:
102 // MSBinaryTable bintab(infits);
103 // Table tab = bintab.fullTable("myTable");
104 // break;
105 // }
106 // </srcblock>
107 // There would obviously be other cases to the switch to deal with any
108 // other HDUs (e.g. skip them via infits.skip_hdu()). The Table
109 // destructor would write "myTable" to disk.
110 // </example>
111 
112 // <todo>
113 //
114 // </todo>
115 
117 {
118 public:
119 
120  //
121  // The only constructor is from a FitsInput.
122  //
123 
124  FITSIDItoMS1(FitsInput& in, const Int& obsType=0, const Bool& initFirstMain=True);
125 
126  ~FITSIDItoMS1();
127 
128  //
129  // Get the full table, using the supplied arguments to construct
130  // the table. The table will contain all data from the current
131  // row to the end of the BinarTableExtension.
132  //
133 
134  Table oldfullTable(const String& tabName);
135 
136 
137  // Fill the Observation and ObsLog tables
138  void fillObsTables();
139 
140  // Read a binary table extension of type ANTENNA and create an antenna table
141  //void fillAntennaTable(BinaryTable& bt);
142  void fillAntennaTable();
143 
144  // fill the Feed table with minimal info needed for synthesis processing
145  void fillFeedTable();
146 
147  //fill the Field table
148  //void fillFieldTable(Int nField);
149  void fillFieldTable();
150 
151  //fill the Spectral Window table with the content of FREQUENCY
153 
154  //fill the optional Correlator Model table with the content of INTERFEROMETER_MODEL
156 
157  //fill the optional SysCal table with the content of SYSTEM_TEMPERATURE
159 
160  //fill the optional FlagCmd table with the content of FLAG
162 
163  //fill the optional Weather table with the content of WEATHER
165 
166  //store the information from the GAIN_CURVE table in a calibration table
168 
169  //store the information from the PHASE-CAL table in a calibration table
171 
172  //store the information from the MODEL_COMPS table
174 
175  // fix up the EPOCH MEASURE_REFERENCE keywords
176  void fixEpochReferences();
177 
178  //update the Polarization table
179  void updateTables(const String& tabName);
180 
181 
182  //
183  // Get an appropriate TableDesc (this is the same TableDesc used
184  // to construct any Table objects returned by this class.
185  //
186  const TableDesc& getDescriptor();
187 
188  //
189  // Return the Table keywords (this is the same TableRecord used in
190  // any Table objects returned by this class.
191  //
193 
194  //
195  // Get a Table with a single row, the current row of the FITS
196  // table. The returned Table is a Scratch table. The standard
197  // BinaryTableExtension manipulation functions are available to
198  // position the FITS input at the desired location.
199  //
200  const Table &thisRow();
201 
202  //
203  // Get a Table with a single row, the next row of the FITS table.
204  // The returned Table is a Scratch table. The FITS input is
205  // positioned to the next row and the values translated and
206  // returned in a Table object.
207  //
208  const Table &nextRow();
209 
210  // Get the version of the archived MS.
211  Float msVersion() const
212  { return itsVersion; }
213 
214  // Read all the data from the FITS file and create the MeasurementSet. Throws
215  // an exception when it has severe trouble interpreting the FITS file.
216  // Returns False if it encounters an unsupported extension.
217  Bool readFitsFile(const String& msFile);
218 
219  //is this the first UV_DATA extension
221 
222 protected:
223  // Read the axis info, throws an exception if required axes are missing.
224  void getAxisInfo();
225 
226  // Set up the MeasurementSet, including StorageManagers and fixed columns.
227  // If useTSM is True, the Tiled Storage Manager will be used to store
228  // DATA, FLAG and WEIGHT_SPECTRUM
229  void setupMeasurementSet(const String& MSFileName, Bool useTSM=True,
230  Bool mainTbl=False,
231  Bool addCorrMod=False, Bool addSyscal=False);
232 
233  // Fill the main table from the Primary group data
234  void fillMSMainTable(const String& MSFileName, Int& nField, Int& nSpW);
235 
236  private:
237  //
238  //# Data Members
239  //
240 
241  // The scratch table containing the current row
243 
244  // The number of elements for each column of the
245  // BinaryTableExtension
247 
248  // For each column: is it an array?
250 
251  // Table keyword set
253 
254  // Table descriptor for construction
256 
257  // Table info
259 
260  // The MS version.
262 
263  //
264  // Buffer for storing the MSK's, MS-specific FITS keywords.
265  //
271 
272 
280  static String array_p;
283  static Double rdate;
295  static Bool firstMain;
302 
303  //
304  //# Member Functions
305  //
306 
307  // Fill in each row as needed
308  void fillRow();
309 
310  // Build part of the keywords of the itsCurRowTab
311  void convertKeywords();
312 
313  // Convert FITS field descriptions to TableColumn descriptions.
314  void describeColumns();
315 
316  // Convert the MS-specific keywords in the FITS binary table.
317  void convertMSKeywords();
318 };
319 
320 
321 } //# NAMESPACE CASACORE - END
322 
323 #endif
324 
325 
MeasurementSet ms_p
Definition: FitsIDItoMS.h:293
FITSIDItoMS converts a FITS-IDI file to a CASA Measurement Set.
Definition: FitsIDItoMS.h:116
int Int
Definition: aipstype.h:47
TableInfo itsTableInfo
Table info.
Definition: FitsIDItoMS.h:258
Vector< String > itsMSKV
Definition: FitsIDItoMS.h:269
void getAxisInfo()
Read the axis info, throws an exception if required axes are missing.
const Table & nextRow()
Get a Table with a single row, the next row of the FITS table.
void describeColumns()
Convert FITS field descriptions to TableColumn descriptions.
Bool readFitsFile(const String &msFile)
Read all the data from the FITS file and create the MeasurementSet.
Main interface class to a read/write table.
Definition: Table.h:149
Matrix< Float > weightsFromKW_p
Definition: FitsIDItoMS.h:300
BINTABLE extension.
Definition: hdu.h:1035
Table itsCurRowTab
The scratch table containing the current row.
Definition: FitsIDItoMS.h:242
Bool fillSysCalTable()
fill the optional SysCal table with the content of SYSTEM_TEMPERATURE
void fillSpectralWindowTable()
fill the Spectral Window table with the content of FREQUENCY
void fillMSMainTable(const String &MSFileName, Int &nField, Int &nSpW)
Fill the main table from the Primary group data.
Vector< Double > refVal_p
Definition: FitsIDItoMS.h:279
void convertKeywords()
Build part of the keywords of the itsCurRowTab.
Vector< Int > corrType_p
Definition: FitsIDItoMS.h:275
TableRecord & getKeywords()
Return the Table keywords (this is the same TableRecord used in any Table objects returned by this cl...
void updateTables(const String &tabName)
update the Polarization table
void fillFeedTable()
fill the Feed table with minimal info needed for synthesis processing
uInt itsNrMSKs
Buffer for storing the MSK&#39;s, MS-specific FITS keywords.
Definition: FitsIDItoMS.h:266
Bool handlePhaseCal()
store the information from the PHASE-CAL table in a calibration table
void fillFieldTable()
fill the Field table void fillFieldTable(Int nField);
static SimpleOrderedMap< Int, Int > antIdFromNo
Definition: FitsIDItoMS.h:301
ostream-like interface to creating log messages.
Definition: LogIO.h:167
FITSIDItoMS1(FitsInput &in, const Int &obsType=0, const Bool &initFirstMain=True)
The only constructor is from a FitsInput.
static String array_p
Definition: FitsIDItoMS.h:280
TableRecord itsKwSet
Table keyword set.
Definition: FitsIDItoMS.h:252
const TableDesc & getDescriptor()
Get an appropriate TableDesc (this is the same TableDesc used to construct any Table objects returned...
MFrequency::Types freqsys_p
Definition: FitsIDItoMS.h:286
Block< Int > corrIndex_p
Definition: FitsIDItoMS.h:276
Table oldfullTable(const String &tabName)
Get the full table, using the supplied arguments to construct the table.
Vector< Double > refPix_p
Definition: FitsIDItoMS.h:279
Vector< Int > itsNelem
The number of elements for each column of the BinaryTableExtension.
Definition: FitsIDItoMS.h:246
Vector< String > itsMSKN
Definition: FitsIDItoMS.h:268
Vector< Int > nPixel_p
Definition: FitsIDItoMS.h:275
TableDesc itsTableDesc
Table descriptor for construction.
Definition: FitsIDItoMS.h:255
void fillRow()
Fill in each row as needed.
double Double
Definition: aipstype.h:52
Bool isfirstMain()
is this the first UV_DATA extension
Definition: FitsIDItoMS.h:220
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
Float itsVersion
The MS version.
Definition: FitsIDItoMS.h:261
Vector< Double > delta_p
Definition: FitsIDItoMS.h:279
void setupMeasurementSet(const String &MSFileName, Bool useTSM=True, Bool mainTbl=False, Bool addCorrMod=False, Bool addSyscal=False)
Set up the MeasurementSet, including StorageManagers and fixed columns.
Vector< String > itsMSKC
Definition: FitsIDItoMS.h:267
float Float
Definition: aipstype.h:51
Table type, subtype and further info.
Definition: TableInfo.h:130
const Table & thisRow()
Get a Table with a single row, the current row of the FITS table.
void fixEpochReferences()
fix up the EPOCH MEASURE_REFERENCE keywords
void convertMSKeywords()
Convert the MS-specific keywords in the FITS binary table.
const Bool False
Definition: aipstype.h:41
Vector< Bool > itsgotMSK
Definition: FitsIDItoMS.h:270
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
A Table intended to hold astronomical data (a set of Measurements).
Float msVersion() const
Get the version of the archived MS.
Definition: FitsIDItoMS.h:211
String msFile_p
FitsInput .
Definition: FitsIDItoMS.h:274
void fillAntennaTable()
Read a binary table extension of type ANTENNA and create an antenna table void fillAntennaTable(Binar...
Bool fillFlagCmdTable()
fill the optional FlagCmd table with the content of FLAG
fixed-length sequential blocked FITS input
Definition: fitsio.h:156
static Double rdate
Definition: FitsIDItoMS.h:283
Bool handleGainCurve()
store the information from the GAIN_CURVE table in a calibration table
Vector< Double > receptorAngle_p
Definition: FitsIDItoMS.h:285
Bool fillCorrelatorModelTable()
fill the optional Correlator Model table with the content of INTERFEROMETER_MODEL ...
A class to provide easy read-write access to MeasurementSet columns.
Definition: MSColumns.h:216
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Vector< Bool > itsIsArray
For each column: is it an array?
Definition: FitsIDItoMS.h:249
Define the structure of a Casacore table.
Definition: TableDesc.h:186
Matrix< Int > corrProduct_p
Definition: FitsIDItoMS.h:277
Bool handleModelComps()
store the information from the MODEL_COMPS table
Double startTime_p
Int nIF_p;.
Definition: FitsIDItoMS.h:290
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition: MFrequency.h:176
void fillObsTables()
Fill the Observation and ObsLog tables.
Bool fillWeatherTable()
fill the optional Weather table with the content of WEATHER
const Bool True
Definition: aipstype.h:40
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:48
Vector< String > coordType_p
Definition: FitsIDItoMS.h:278