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
51// <summary>
52// FITSIDItoMS converts a FITS-IDI file to a CASA Measurement Set
53// </summary>
54
55// <use visibility=export>
56
57// <reviewed reviewer="" date="" tests="">
58
59// <prerequisite>
60//# Classes you should understand before using this one.
61// <li> FitsInput
62// <li> HeaderDataUnit
63// <li> BinaryTableExtension
64// <li> Tables module
65// </prerequisite>
66
67// <etymology>
68
69// FITSIDItoMS inherits from the FITS BinaryTableExtension class and
70// its primary use is to convert such an object to a CASA Table.
71// This explains it's use but not its name. A better name should be
72// found.
73
74// </etymology>
75
76// <synopsis>
77// The class starts with an already existing FitsInput object, which
78// should be set at a BinaryTableExtension HDU. Member functions
79// provide a TableDesc appropriate for the FITS data (to help in
80// constructing a CASA Table compatible with the
81// BinaryTableExtension), a Table containing the current row of FITS
82// data and a Table containing the next row of FITS data (which can be
83// used to step through the FitsInput, copying each row using the
84// RowCopier class), and a Table containin the entire FITS binary
85// table from the current row to the end of the table.
86// </synopsis>
87
88// <motivation>
89// We need a way to get FITS-IDI data (typically from VLBI observations) into CASA.
90// </motivation>
91
92// <example>
93// Open a FitsInput from a disk file, if the HDU is a
94// BinaryTableExtension, then instantiate a MSBinaryTable object and
95// get the entire table. A fair amount of error checking has been
96// eliminated from this example.
97// <srcblock>
98// FitsInput infits("myFITSFile", FITS::Disk);
99// switch (infits.hdutype()) {
100// case FITS::BinaryTableHDU:
101// MSBinaryTable bintab(infits);
102// Table tab = bintab.fullTable("myTable");
103// break;
104// }
105// </srcblock>
106// There would obviously be other cases to the switch to deal with any
107// other HDUs (e.g. skip them via infits.skip_hdu()). The Table
108// destructor would write "myTable" to disk.
109// </example>
110
111// <todo>
112//
113// </todo>
114
116{
117public:
118
119 //
120 // The only constructor is from a FitsInput. The correlat string
121 // should be set to the correlator name/type as contained in the
122 // CORRELAT keyword from the FITS-IDI primary header. If it is set
123 // to "DIFX" (case-sensitive) additional digital corrections
124 // appropriate for the DiFX software correlator will be applied.
125 // Other valid values include "VLBA" (for the original VLBA hardware
126 // correlator; currently unsupported) and "SFXC" (for the SFXC
127 // software correlator used by the EVN).
128 //
129
130 FITSIDItoMS1(FitsInput& in, const String& correlat,
131 const Int& obsType=0, const Bool& initFirstMain=True,
132 const Float& vanVleck=0.0, const Float& corVer=0.0);
133
135
136 //
137 // Get the full table, using the supplied arguments to construct
138 // the table. The table will contain all data from the current
139 // row to the end of the BinaryTableExtension.
140 //
141
142 Table oldfullTable(const String& tabName);
143
144
145 // Fill the Observation and ObsLog tables
147
148 // Read a binary table extension of type ANTENNA and create an antenna table
149 //void fillAntennaTable(BinaryTable& bt);
151
152 // fill the Feed table with minimal info needed for synthesis processing
154
155 //fill the Field table
156 //void fillFieldTable(Int nField);
158
159 //fill the Spectral Window table with the content of FREQUENCY
161
162 //fill the optional Correlator Model table with the content of INTERFEROMETER_MODEL
164
165 //fill the optional SysCal table with the content of SYSTEM_TEMPERATURE
167
168 //fill the optional FlagCmd table with the content of FLAG
170
171 //fill the optional Weather table with the content of WEATHER
173
174 //store the information from the GAIN_CURVE table in a calibration table
176
177 //store the information from the PHASE-CAL table in a calibration table
179
180 //store the information from the CALC table in a calibration table
182
183 //store the information from the MODEL_COMPS table
185
186 // fix up the EPOCH MEASURE_REFERENCE keywords
188
189 //update the Polarization table
190 void updateTables(const String& tabName);
191
192
193 //
194 // Get an appropriate TableDesc (this is the same TableDesc used
195 // to construct any Table objects returned by this class.
196 //
198
199 //
200 // Return the Table keywords (this is the same TableRecord used in
201 // any Table objects returned by this class.
202 //
204
205 //
206 // Get a Table with a single row, the current row of the FITS
207 // table. The returned Table is a Scratch table. The standard
208 // BinaryTableExtension manipulation functions are available to
209 // position the FITS input at the desired location.
210 //
211 const Table &thisRow();
212
213 //
214 // Get a Table with a single row, the next row of the FITS table.
215 // The returned Table is a Scratch table. The FITS input is
216 // positioned to the next row and the values translated and
217 // returned in a Table object.
218 //
219 const Table &nextRow();
220
221 // Get the version of the archived MS.
223 { return itsVersion; }
224
225 // Read all the data from the FITS file and create the MeasurementSet. Throws
226 // an exception when it has severe trouble interpreting the FITS file.
227 // Returns False if it encounters an unsupported extension.
228 Bool readFitsFile(const String& msFile);
229
230 //is this the first UV_DATA extension
232
233protected:
234 // Read the axis info, throws an exception if required axes are missing.
236
237 // Set up the MeasurementSet, including StorageManagers and fixed columns.
238 // If useTSM is True, the Tiled Storage Manager will be used to store
239 // DATA, FLAG and WEIGHT_SPECTRUM
240 void setupMeasurementSet(const String& MSFileName, Bool useTSM=True,
241 Bool mainTbl=False, Bool addCorrMod=False,
242 Bool addSyscal=False, Bool addWeather=False,
243 Bool addGainCurve=False, Bool addPhaseCal=False,
244 Bool addEOP=False);
245
246 // Fill the main table from the Primary group data
247 void fillMSMainTable(const String& MSFileName, Int& nField, Int& nSpW);
248
249 private:
250 //
251 //# Data Members
252 //
253
254 // The scratch table containing the current row
256
257 // The number of elements for each column of the
258 // BinaryTableExtension
260
261 // For each column: is it an array?
263
264 // Table keyword set
266
267 // Table descriptor for construction
269
270 // Table info
272
273 // The MS version.
275
276 //
277 // Buffer for storing the MSK's, MS-specific FITS keywords.
278 //
284
285
286 //# FitsInput &infile_p;
296 static Double rdate;
302 //# Int nIF_p;
325 static std::map<Int,Int> antIdFromNo;
326 static std::map<Int,Int> digiLevels;
329
330 //
331 //# Member Functions
332 //
333
334 // Fill in each row as needed
335 void fillRow();
336
337 // Build part of the keywords of the itsCurRowTab
339
340 // Convert FITS field descriptions to TableColumn descriptions.
342
343 // Convert the MS-specific keywords in the FITS binary table.
345};
346
347
348} //# NAMESPACE CASACORE - END
349
350#endif
351
352
BINTABLE extension
Definition hdu.h:1033
simple 1-D array
Definition Block.h:198
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
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.
static std::map< Int, Int > digiLevels
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
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
static std::map< Int, Int > antIdFromNo
fixed-length sequential blocked FITS input
Definition fitsio.h:154
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition MFrequency.h:173
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
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