casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NewCalTable.h
Go to the documentation of this file.
1 //# NewCalTable.h: Calibration table access and creation
2 //# Copyright (C) 2011
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 adressed 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 //#
27 //# $Id$
28 
29 #ifndef CALIBRATION_NEWCALTABLE_H
30 #define CALIBRATION_NEWCALTABLE_H
31 
32 #include <casa/aips.h>
33 #include <tables/Tables/Table.h>
34 #include <tables/TaQL/ExprNode.h>
35 #include <casa/Containers/Record.h>
36 #include <casa/OS/Path.h>
37 #include <casa/Utilities/Sort.h>
53 
54 namespace casa { //# NAMESPACE CASA - BEGIN
55 
56 
57 // <summary>
58 // NewCalTable: New Calibration table access and creation
59 // </summary>
60 
61 // <use visibility=export>
62 
63 // <reviewed reviewer="" date="" tests="" demos="">
64 
65 // <prerequisite>
66 // <li> <linkto class="CalTableDesc">CalTableDesc</linkto> module
67 // </prerequisite>
68 //
69 // <etymology>
70 // From "calibration" and "table".
71 // </etymology>
72 //
73 // <synopsis>
74 // The NewCalTable classes provide basic access to calibration tables. This
75 // includes the creation of calibration tables, sorting and selection
76 // capabilities, and basic data access. Specializations for baseline-based,
77 // time-variable and solvable VisJones types, and sub-types, are provided
78 // through inheritance.
79 // </etymology>
80 //
81 // <example>
82 // <srcblock>
83 // </srcblock>
84 // </example>
85 //
86 // <motivation>
87 // This class is used by other calibration table accessors and iterators.
88 // </motivation>
89 //
90 // <todo asof="11/06/10">
91 // </todo>
92 
93 
94 // Typedefs for subtable objects
110 
112 {
113 
114  friend class SolvableVisCal;
115 
116  public:
117  // Default null constructor, and destructor
118  NewCalTable();
119  virtual ~NewCalTable();
120 
121  // Construct from a specified table name, calibration table descriptor
122  // and table access option. Used for creating new tables.
123  NewCalTable (const casacore::String& tableName, CTDesc& ctableDesc,
126 
127  // Construct from setupNewTable
128  NewCalTable (casacore::SetupNewTable& newTab, casacore::uInt nrow = 0, casacore::Bool initialize = false);
129 
130  // Create an empty NewCalTable conveniently
133 
134  // Construct from a specified table name, and access option. Used
135  // for accessing existing tables.
139  // control locking option
144 
148  casacore::Bool doBackCompat=true);
149 
153  casacore::Bool doBackCompat=true);
154 
155 
156 
157  // Construct from an existing table object
158  NewCalTable (const casacore::Table& table);
159 
160  // Copy constructor
161  NewCalTable (const NewCalTable& other);
162 
163  // Create a vanilla NewCalTable from shapes (for testing purposes)
164  // Default rTime is 2012/01/06/12:00:00
166  casacore::Int nObs=1, casacore::Int nScanPerObs=1,casacore::Int nTimePerScan=1,
168  casacore::Int nFld=1,
169  casacore::Double rTime=0.0, casacore::Double tint=0.0,
170  casacore::Bool disk=false, casacore::Bool verbose=false);
171 
172  // Create an empty NewCalTable from a SimpleSimVi2Parameters object
173  // NB: only for testing, for now
175  const vi::SimpleSimVi2Parameters& ssp,
176  casacore::Bool disk=false,casacore::Bool verbose=false);
177 
178  // Assignment operator
179  NewCalTable& operator= (const NewCalTable& other);
180 
181  // Handle backward compatibility
182  static casacore::Bool CTBackCompat(const casacore::String& caltable);
183 
184  // Set the casacore::TableInfo record
185  void setTableInfo();
186 
187  // initialize reference to subtables
188  void createSubTables();
189  void attachSubTables();
190  void clearSubtables();
191 
192  void copyMemCalSubtables(const NewCalTable& other);
193  void copyMemCalSubtable(const casacore::Table& otherSubtable, casacore::Table& subTable);
194 
195  // casacore::Complex parameters? (else casacore::Float)
197 
198  // Report the polarization basis (from header record)
200 
201  // Report the CASA version at which the NCT was created (from header)
203 
204  // Get a row from cal_main
206 
207  // Put a row to cal_main
208  void putRowMain (const casacore::Int& jrow, CTMainRecord& tableRec);
209 
210  // Get rows of the data from the main table
211  // void fillRowsMain ();
212 
213  // Set Meta data info from a parent casacore::MS
214  void setMetaInfo (const casacore::String& msName);
215 
216  //validate input table desc. over required caltable desc
217  static casacore::Bool conformant(const casacore::TableDesc& tabDesc);
218 
219  // save to disk
220  void writeToDisk(const casacore::String& tableName);
221 
224  CTField& field() {return field_p;}
227  const CTObservation& observation() const {return observation_p;}
228  const CTAntenna& antenna() const {return antenna_p;}
229  const CTField& field() const {return field_p;}
231  const CTHistory& history() const {return history_p;}
232 
233  // Provide RO access to
234  // inline ROCTMainColumns mcols() const {return ROCTMainColumns(*this);};
235 
238 
239  // Fill in antenna-based solutions
240  // (obsId-less version calls obsId-capable version w/ obsId=0)
243  casacore::Int fieldId,casacore::uInt spwId,casacore::Int scanNo,
244  const casacore::Vector<casacore::Int>& ant1list, casacore::Int refant,
245  const casacore::Cube<casacore::Complex>& cparam,
246  const casacore::Cube<casacore::Bool>& flag,
247  const casacore::Cube<casacore::Float>& paramErr,
251  casacore::Int fieldId,casacore::uInt spwId,casacore::Int obsId,casacore::Int scanNo,
252  const casacore::Vector<casacore::Int>& ant1list, casacore::Int refant,
253  const casacore::Cube<casacore::Complex>& cparam,
254  const casacore::Cube<casacore::Bool>& flag,
255  const casacore::Cube<casacore::Float>& paramErr,
257 
258  // Reset spw freq info
261 
262  // Set FLAG_ROW in SPECTRAL_WINDOW subtable for spws absent in MAIN
263  void flagAbsentSpws();
264 
265  // Merge SPW subtable rows from another NewCalTable
266  void mergeSpwMetaInfo(const NewCalTable& other);
267 
268  // Add a line to the HISTORY table
269  void addHistoryMessage(casacore::String app="",casacore::String message="none");
270 
271  private:
272 
273  // Services for generic test table ctor
274  // Default rTime is 2012/01/06/12:00:00
275  void fillGenericContents(casacore::Int nObs=1, casacore::Int nScanPerObs=1, casacore::Int nTimePerScan=1,
277  casacore::Int nFld=1,
278  casacore::Double rTime=0.0, casacore::Double tint=0.0,
279  casacore::Bool verbose=false);
280  void fillGenericObs(casacore::Int nObs);
281  void fillGenericField(casacore::Int nFld);
284 
285  // Init subtables from SimpleSimVi2Parameters
290 
291  // Force Spw subtable to be all nchan=1
292  // (very basic; uses chan n/2 freq)
293  void makeSpwSingleChan();
294 
295  // Handle pre-4.1 caltables that don't have OBS_ID
296  // (by adding a phoney one with a single OBS_ID
297  void addPhoneyObs();
298 
299  // Handle Eph objects...
300  void handleEphObj(const casacore::MSField& msfldtab,const casacore::String& msName);
301 
302 
303  // The subtables
309 
310  };
311 
312 } //# NAMESPACE CASA - END
313 
314 #endif
void copyMemCalSubtable(const casacore::Table &otherSubtable, casacore::Table &subTable)
A Table intended to hold a MeasurementSet OBSERVATIONLOG table.
Definition: MSHistory.h:78
casacore::Record getRowMain(const casacore::Int &jrow)
Get a row from cal_main.
int Int
Definition: aipstype.h:50
CTSpectralWindow spectralWindow_p
Definition: NewCalTable.h:307
void addHistoryMessage(casacore::String app="", casacore::String message="none")
Add a line to the HISTORY table.
Create a new table - define shapes, data managers, etc.
Definition: SetupNewTab.h:346
void fillGenericSpw(casacore::Int nSpw, casacore::Vector< casacore::Int > &nChan)
CTSpectralWindow & spectralWindow()
Definition: NewCalTable.h:225
void setMetaInfo(const casacore::String &msName)
Get rows of the data from the main table void fillRowsMain ();.
A Table intended to hold a MeasurementSet OBSERVATION table.
Definition: MSObservation.h:78
void handleEphObj(const casacore::MSField &msfldtab, const casacore::String &msName)
Handle Eph objects...
A class to provide easy read-write access to MSObservation columns.
Definition: MSObsColumns.h:181
Main interface class to a read/write table.
Definition: Table.h:153
A class to provide easy access to MSField columns.
casacore::MSObservation CTObservation
Definition: NewCalTable.h:96
casacore::MSSpectralWindow CTSpectralWindow
Definition: NewCalTable.h:98
casacore::Bool isComplex()
casacore::Complex parameters? (else casacore::Float)
static casacore::Bool CTBackCompat(const casacore::String &caltable)
Handle backward compatibility.
CTHistory history_p
Definition: NewCalTable.h:308
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
A class to provide easy read-write access to MSHistory columns.
casacore::MSFieldColumns CTFieldColumns
Definition: NewCalTable.h:100
casacore::String CASAvers()
Report the CASA version at which the NCT was created (from header)
casacore::MSObservationColumns CTObservationColumns
Definition: NewCalTable.h:101
static NewCalTable createCT(const casacore::String &tableName, casacore::Table::TableOption access, casacore::Table::TableType ttype, casacore::Bool doBackCompat=true)
A class to provide easy read-only access to MSASpectralWindow columns.
A Table intended to hold a MeasurementSet ANTENNA table.
Definition: MSAntenna.h:79
const String & tableName() const
Get the table name.
Definition: Table.h:1219
virtual casacore::String typeName()
Return type name as string.
A class to provide easy read-write access to MSField columns.
casacore::MSAntennaColumns CTAntennaColumns
Definition: NewCalTable.h:102
CTObservation observation_p
The subtables.
Definition: NewCalTable.h:304
void putRowMain(const casacore::Int &jrow, CTMainRecord &tableRec)
Put a row to cal_main.
casacore::ROMSAntennaColumns ROCTAntennaColumns
Definition: NewCalTable.h:107
void setSpwFreqs(casacore::Int spw, const casacore::Vector< casacore::Double > &freq, const casacore::Vector< casacore::Double > &chanwidth=casacore::Vector< casacore::Double >())
Reset spw freq info.
static casacore::Float NCTtestvalueF(casacore::Int iant, casacore::Int ispw, casacore::Double ich, casacore::Double time, casacore::Double refTime, casacore::Double tint)
void fillGenericContents(casacore::Int nObs=1, casacore::Int nScanPerObs=1, casacore::Int nTimePerScan=1, casacore::Int nAnt=1, casacore::Int nSpw=1, casacore::Vector< casacore::Int > nChan=casacore::Vector< casacore::Int >(1, 1), casacore::Int nFld=1, casacore::Double rTime=0.0, casacore::Double tint=0.0, casacore::Bool verbose=false)
Services for generic test table ctor Default rTime is 2012/01/06/12:00:00.
CTObservation & observation()
Definition: NewCalTable.h:222
existing table
Definition: Table.h:170
casacore::MSAntenna CTAntenna
Definition: NewCalTable.h:97
NewCalTable & operator=(const NewCalTable &other)
Assignment operator.
double Double
Definition: aipstype.h:55
casacore::MSHistory CTHistory
Definition: NewCalTable.h:99
A class to provide easy read-only access to MSHistory columns.
plain table (stored on disk)
Definition: Table.h:186
void setTableInfo()
Set the casacore::TableInfo record.
const CTAntenna & antenna() const
Definition: NewCalTable.h:228
A class to provide easy read-write access to MSSpectralWindow columns.
void copyMemCalSubtables(const NewCalTable &other)
virtual ~NewCalTable()
CTDesc: Define the format of calibration tables.
Definition: CTDesc.h:84
const TableLock & lockOptions() const
Get the locking options.
Definition: Table.h:1140
void makeSpwSingleChan()
Force Spw subtable to be all nchan=1 (very basic; uses chan n/2 freq)
A class to provide easy read-write access to MSAntenna columns.
casacore::ROMSObservationColumns ROCTObservationColumns
Definition: NewCalTable.h:106
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void mergeSpwMetaInfo(const NewCalTable &other)
Merge SPW subtable rows from another NewCalTable.
casacore::ROMSSpWindowColumns ROCTSpWindowColumns
Definition: NewCalTable.h:108
void fillGenericAntenna(casacore::Int nAnt)
uInt nrow() const
Get the number of rows.
Definition: Table.h:1201
casacore::String polBasis()
Report the polarization basis (from header record)
NewCalTable()
Default null constructor, and destructor.
static casacore::Bool conformant(const casacore::TableDesc &tabDesc)
validate input table desc.
float Float
Definition: aipstype.h:54
table held in memory
Definition: Table.h:188
void addPhoneyObs()
Handle pre-4.1 caltables that don&#39;t have OBS_ID (by adding a phoney one with a single OBS_ID...
Class to hold table lock options.
Definition: TableLock.h:65
const CTSpectralWindow & spectralWindow() const
Definition: NewCalTable.h:230
A Table intended to hold a MeasurementSet FIELD table.
Definition: MSField.h:78
casacore::MSHistoryColumns CTHistoryColumns
Definition: NewCalTable.h:104
CTField & field()
Definition: NewCalTable.h:224
casacore::MSField CTField
NewCalTable: New Calibration table access and creation.
Definition: NewCalTable.h:95
casacore::ROMSFieldColumns ROCTFieldColumns
Definition: NewCalTable.h:105
void flagAbsentSpws()
Set FLAG_ROW in SPECTRAL_WINDOW subtable for spws absent in MAIN.
static NewCalTable * createCTptr(const casacore::String &tableName, casacore::Table::TableOption access, casacore::Table::TableType ttype, casacore::Bool doBackCompat=true)
A class to provide easy read-only access to MSObservation columns.
Definition: MSObsColumns.h:80
void fillAntBasedMainRows(casacore::uInt nrows, casacore::Double time, casacore::Double interval, casacore::Int fieldId, casacore::uInt spwId, casacore::Int scanNo, const casacore::Vector< casacore::Int > &ant1list, casacore::Int refant, const casacore::Cube< casacore::Complex > &cparam, const casacore::Cube< casacore::Bool > &flag, const casacore::Cube< casacore::Float > &paramErr, const casacore::Cube< casacore::Float > &snr)
Fill in antenna-based solutions (obsId-less version calls obsId-capable version w/ obsId=0) ...
A class to provide easy read-only access to MSAntenna columns.
const CTObservation & observation() const
Definition: NewCalTable.h:227
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::MSSpWindowColumns CTSpWindowColumns
Definition: NewCalTable.h:103
Define the structure of a Casacore table.
Definition: TableDesc.h:187
TableType
Define the possible table types.
Definition: Table.h:184
create table
Definition: Table.h:172
const CTField & field() const
Definition: NewCalTable.h:229
CTHistory & history()
Definition: NewCalTable.h:226
static casacore::Complex NCTtestvalueC(casacore::Int iant, casacore::Int ispw, casacore::Double ich, casacore::Double time, casacore::Double refTime, casacore::Double tint)
Provide RO access to inline ROCTMainColumns mcols() const {return ROCTMainColumns(*this);};.
void fillGenericField(casacore::Int nFld)
CTAntenna & antenna()
Definition: NewCalTable.h:223
CTAntenna antenna_p
Definition: NewCalTable.h:305
void writeToDisk(const casacore::String &tableName)
save to disk
void createSubTables()
initialize reference to subtables
const CTHistory & history() const
Definition: NewCalTable.h:231
void fillGenericObs(casacore::Int nObs)
unsigned int uInt
Definition: aipstype.h:51
TableOption
Define the possible options how a table can be opened.
Definition: Table.h:168
casacore::ROMSHistoryColumns ROCTHistoryColumns
Definition: NewCalTable.h:109
CTMainRecord: Calibration table record access and creation.
Definition: CTMainRecord.h:74
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.