casacore
Loading...
Searching...
No Matches
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: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25// # Mod 2010: DP
26
27#ifndef MS_FITSIDITOMS_H
28#define MS_FITSIDITOMS_H
29
30#include <casacore/casa/aips.h>
31#include <casacore/fits/FITS/hdu.h>
32#include <casacore/tables/Tables/Table.h> //
33#include <casacore/tables/Tables/TableDesc.h> //
34#include <casacore/tables/Tables/TableRecord.h> //
35#include <casacore/tables/Tables/TableColumn.h> //
36#include <casacore/casa/Arrays/Vector.h>
37#include <casacore/casa/Arrays/Matrix.h>
38#include <casacore/casa/Containers/Block.h>
39#include <casacore/casa/Logging/LogIO.h>
40#include <casacore/measures/Measures/MFrequency.h>
41#include <casacore/ms/MeasurementSets/MeasurementSet.h>
42#include <casacore/casa/BasicSL/String.h>
43#include <map>
44
45namespace casacore { // # NAMESPACE CASACORE - BEGIN
46
47class MSColumns;
48class FitsInput;
49
50// <summary>
51// FITSIDItoMS converts a FITS-IDI file to a CASA Measurement Set
52// </summary>
53
54// <use visibility=export>
55
56// <reviewed reviewer="" date="" tests="">
57
58// <prerequisite>
59// # Classes you should understand before using this one.
60// <li> FitsInput
61// <li> HeaderDataUnit
62// <li> BinaryTableExtension
63// <li> Tables module
64// </prerequisite>
65
66// <etymology>
67
68// FITSIDItoMS inherits from the FITS BinaryTableExtension class and
69// its primary use is to convert such an object to a CASA Table.
70// This explains it's use but not its name. A better name should be
71// found.
72
73// </etymology>
74
75// <synopsis>
76// The class starts with an already existing FitsInput object, which
77// should be set at a BinaryTableExtension HDU. Member functions
78// provide a TableDesc appropriate for the FITS data (to help in
79// constructing a CASA Table compatible with the
80// BinaryTableExtension), a Table containing the current row of FITS
81// data and a Table containing the next row of FITS data (which can be
82// used to step through the FitsInput, copying each row using the
83// RowCopier class), and a Table containin the entire FITS binary
84// table from the current row to the end of the table.
85// </synopsis>
86
87// <motivation>
88// We need a way to get FITS-IDI data (typically from VLBI observations) into CASA.
89// </motivation>
90
91// <example>
92// Open a FitsInput from a disk file, if the HDU is a
93// BinaryTableExtension, then instantiate a MSBinaryTable object and
94// get the entire table. A fair amount of error checking has been
95// eliminated from this example.
96// <srcblock>
97// FitsInput infits("myFITSFile", FITS::Disk);
98// switch (infits.hdutype()) {
99// case FITS::BinaryTableHDU:
100// MSBinaryTable bintab(infits);
101// Table tab = bintab.fullTable("myTable");
102// break;
103// }
104// </srcblock>
105// There would obviously be other cases to the switch to deal with any
106// other HDUs (e.g. skip them via infits.skip_hdu()). The Table
107// destructor would write "myTable" to disk.
108// </example>
109
110// <todo>
111//
112// </todo>
113
115 public:
116 //
117 // The only constructor is from a FitsInput. The correlat string
118 // should be set to the correlator name/type as contained in the
119 // CORRELAT keyword from the FITS-IDI primary header. If it is set
120 // to "DIFX" (case-sensitive) additional digital corrections
121 // appropriate for the DiFX software correlator will be applied.
122 // Other valid values include "VLBA" (for the original VLBA hardware
123 // correlator; currently unsupported) and "SFXC" (for the SFXC
124 // software correlator used by the EVN).
125 //
126
127 FITSIDItoMS1(FitsInput& in, const String& correlat, const Int& obsType = 0,
128 const Bool& initFirstMain = True, const Float& vanVleck = 0.0,
129 const Float& corVer = 0.0);
130
132
133 //
134 // Get the full table, using the supplied arguments to construct
135 // the table. The table will contain all data from the current
136 // row to the end of the BinaryTableExtension.
137 //
138
139 Table oldfullTable(const String& tabName);
140
141 // Fill the Observation and ObsLog tables
143
144 // Read a binary table extension of type ANTENNA and create an antenna table
145 // void fillAntennaTable(BinaryTable& bt);
147
148 // fill the Feed table with minimal info needed for synthesis processing
150
151 // fill the Field table
152 // void fillFieldTable(Int nField);
154
155 // fill the Spectral Window table with the content of FREQUENCY
157
158 // fill the optional Correlator Model table with the content of INTERFEROMETER_MODEL
160
161 // fill the optional SysCal table with the content of SYSTEM_TEMPERATURE
163
164 // fill the optional FlagCmd table with the content of FLAG
166
167 // fill the optional Weather table with the content of WEATHER
169
170 // store the information from the GAIN_CURVE table in a calibration table
172
173 // store the information from the PHASE-CAL table in a calibration table
175
176 // store the information from the CALC table in a calibration table
178
179 // store the information from the MODEL_COMPS table
181
182 // fix up the EPOCH MEASURE_REFERENCE keywords
184
185 // update the Polarization table
186 void updateTables(const String& tabName);
187
188 //
189 // Get an appropriate TableDesc (this is the same TableDesc used
190 // to construct any Table objects returned by this class.
191 //
193
194 //
195 // Return the Table keywords (this is the same TableRecord used in
196 // any Table objects returned by this class.
197 //
199
200 //
201 // Get a Table with a single row, the current row of the FITS
202 // table. The returned Table is a Scratch table. The standard
203 // BinaryTableExtension manipulation functions are available to
204 // position the FITS input at the desired location.
205 //
206 const Table& thisRow();
207
208 //
209 // Get a Table with a single row, the next row of the FITS table.
210 // The returned Table is a Scratch table. The FITS input is
211 // positioned to the next row and the values translated and
212 // returned in a Table object.
213 //
214 const Table& nextRow();
215
216 // Get the version of the archived MS.
217 Float msVersion() const { return itsVersion; }
218
219 // Read all the data from the FITS file and create the MeasurementSet. Throws
220 // an exception when it has severe trouble interpreting the FITS file.
221 // Returns False if it encounters an unsupported extension.
222 Bool readFitsFile(const String& msFile);
223
224 // is this the first UV_DATA extension
226
227 protected:
228 // Read the axis info, throws an exception if required axes are missing.
230
231 // Set up the MeasurementSet, including StorageManagers and fixed columns.
232 // If useTSM is True, the Tiled Storage Manager will be used to store
233 // DATA, FLAG and WEIGHT_SPECTRUM
234 void setupMeasurementSet(const String& MSFileName, Bool useTSM = True, Bool mainTbl = False,
235 Bool addCorrMod = False, Bool addSyscal = False, Bool addWeather = False,
236 Bool addGainCurve = False, Bool addPhaseCal = False,
237 Bool addEOP = False);
238
239 // Fill the main table from the Primary group data
240 void fillMSMainTable(const String& MSFileName, Int& nField, Int& nSpW);
241
242 private:
243 //
244 // # Data Members
245 //
246
247 // The scratch table containing the current row
249
250 // The number of elements for each column of the
251 // BinaryTableExtension
253
254 // For each column: is it an array?
256
257 // Table keyword set
259
260 // Table descriptor for construction
262
263 // Table info
265
266 // The MS version.
268
269 //
270 // Buffer for storing the MSK's, MS-specific FITS keywords.
271 //
277
278 // # FitsInput &infile_p;
288 static Double rdate;
294 // # Int nIF_p;
317 static std::map<Int, Int> antIdFromNo;
318 static std::map<Int, Int> digiLevels;
321
322 //
323 // # Member Functions
324 //
325
326 // Fill in each row as needed
327 void fillRow();
328
329 // Build part of the keywords of the itsCurRowTab
331
332 // Convert FITS field descriptions to TableColumn descriptions.
334
335 // Convert the MS-specific keywords in the FITS binary table.
337};
338
339} // namespace casacore
340
341#endif
BinaryTableExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
void convertKeywords()
Build part of the keywords of the itsCurRowTab.
Float msVersion() const
Get the version of the archived MS.
Bool readFitsFile(const String &msFile)
Read all the data from the FITS file and create the MeasurementSet.
static Bool firstPhaseCal
static std::map< Int, Int > antIdFromNo
Bool fillSysCalTable()
fill the optional SysCal table with the content of SYSTEM_TEMPERATURE
Vector< Double > receptorAngle_p
TableDesc itsTableDesc
Table descriptor for construction.
Vector< String > itsMSKV
MeasurementSet ms_p
const Table & nextRow()
Get a Table with a single row, the next row of the FITS table.
void updateTables(const String &tabName)
update the Polarization table
Bool handlePhaseCal()
store the information from the PHASE-CAL table in a calibration table
TableRecord & getKeywords()
Return the Table keywords (this is the same TableRecord used in any Table objects returned by this cl...
Vector< Int > itsNelem
The number of elements for each column of the BinaryTableExtension.
Block< Int > corrIndex_p
Vector< Double > refPix_p
void fillSpectralWindowTable()
fill the Spectral Window table with the content of FREQUENCY
static Bool firstGainCurve
void fillMSMainTable(const String &MSFileName, Int &nField, Int &nSpW)
Fill the main table from the Primary group data.
uInt itsNrMSKs
Buffer for storing the MSK's, MS-specific FITS keywords.
const Table & thisRow()
Get a Table with a single row, the current row of the FITS table.
Table oldfullTable(const String &tabName)
Get the full table, using the supplied arguments to construct the table.
Vector< String > itsMSKN
Vector< Int > corrType_p
TableRecord itsKwSet
Table keyword set.
void fillObsTables()
Fill the Observation and ObsLog tables.
void setupMeasurementSet(const String &MSFileName, Bool useTSM=True, Bool mainTbl=False, Bool addCorrMod=False, Bool addSyscal=False, Bool addWeather=False, Bool addGainCurve=False, Bool addPhaseCal=False, Bool addEOP=False)
Set up the MeasurementSet, including StorageManagers and fixed columns.
TableInfo itsTableInfo
Table info.
Vector< Double > refVal_p
Bool handleCalc()
store the information from the CALC table in a calibration table
void getAxisInfo()
Read the axis info, throws an exception if required axes are missing.
const TableDesc & getDescriptor()
Get an appropriate TableDesc (this is the same TableDesc used to construct any Table objects returned...
Bool fillFlagCmdTable()
fill the optional FlagCmd table with the content of FLAG
void fixEpochReferences()
fix up the EPOCH MEASURE_REFERENCE keywords
Vector< String > coordType_p
static Vector< Double > effChBw
Matrix< Int > corrProduct_p
FITSIDItoMS1(FitsInput &in, const String &correlat, const Int &obsType=0, const Bool &initFirstMain=True, const Float &vanVleck=0.0, const Float &corVer=0.0)
The only constructor is from a FitsInput.
Bool handleGainCurve()
store the information from the GAIN_CURVE table in a calibration table
Vector< Bool > itsIsArray
For each column: is it an array?
static String array_p
Vector< Int > nPixel_p
Bool fillWeatherTable()
fill the optional Weather table with the content of WEATHER
void describeColumns()
Convert FITS field descriptions to TableColumn descriptions.
Table itsCurRowTab
The scratch table containing the current row.
void fillFieldTable()
fill the Field table void fillFieldTable(Int nField);
MFrequency::Types freqsys_p
Block< Int > corrSwapIndex_p
Bool handleModelComps()
store the information from the MODEL_COMPS table
void fillAntennaTable()
Read a binary table extension of type ANTENNA and create an antenna table void fillAntennaTable(Binar...
Bool fillCorrelatorModelTable()
fill the optional Correlator Model table with the content of INTERFEROMETER_MODEL
static std::map< Int, Int > digiLevels
Bool isfirstMain()
is this the first UV_DATA extension
void convertMSKeywords()
Convert the MS-specific keywords in the FITS binary table.
void fillRow()
Fill in each row as needed.
Float itsVersion
The MS version.
void fillFeedTable()
fill the Feed table with minimal info needed for synthesis processing
Vector< Double > delta_p
Vector< String > itsMSKC
Vector< Bool > itsgotMSK
fixed-length sequential blocked FITS input
Definition fitsio.h:170
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition MFrequency.h:175
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53