casacore
Loading...
Searching...
No Matches
MeasurementSets.h
Go to the documentation of this file.
1//# MeasurementSets.h: Handle storage and access of the telescope data
2//# Copyright (C) 1996,1997
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
26#ifndef MS_MEASUREMENTSETS_H
27#define MS_MEASUREMENTSETS_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/ms/MeasurementSets/MeasurementSet.h>
31#include <casacore/ms/MeasurementSets/MSColumns.h>
32
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35// <module>
36//
37// <summary>
38// Handle storage and access of telescope data
39// </summary>
40
41// <prerequisite>
42// <li> <linkto module="Tables:description">Tables</linkto> module
43// <li> <a href="../notes/229.html">Note 229</a>
44// </prerequisite>
45//
46//
47// <reviewed reviewer="Bob Garwood" date="1997/02/01" demos="">
48// </reviewed>
49
50// <etymology>
51// The MeasurementSet is where all data are ultimately to be found
52// in Casacore. Since, this is a collection of
53// measurements (either actual or simulated), the term MeasurementSet
54// seems appropriate. Often we use the abbreviation (and typedef) MS for
55// MeasurementSet.
56// </etymology>
57//
58// <synopsis>
59// The MeasurementSets module handles storage of telescope data and access
60// to it. The MeasurementSet is the class that gives access to the data.
61//
62// A <linkto class=MeasurementSet>MeasurementSet</linkto> (MS)
63// is a Table with subtables stored as keywords.
64// For each of these tables there is a separate class: the main table is
65// MeasurementSet, the subtables are MSAntenna,
66// MSArray, MSFeed, MSField, MSObsLog, MSObservation, MSSource,
67// MSSpectralWindow, MSSysCal, MSWeather.
68//
69// <h4> Class hierarchy and Table layout </h4>
70// Each table has a number
71// of predefined columns and keywords, a subset of which is required to be
72// present. The column and keyword layout of each table is described in
73// <a href="../notes/229.html">Note 229</a>
74// and in a separate class which contains two enum definitions.
75// The enum classes, e.g.,
76// <linkto class=MSMainEnums>MSMainEnums</linkto> and
77// <linkto class=MSAntennaEnums>MSAntennaEnums</linkto>, just contain a
78// PredefinedColumn (PDC) enum and a PredefinedKeyword (PDK) enum. These enum
79// definitions are used as template arguments for the generic class
80// <linkto class=MSTable><src>MSTable<PDC,PDK></src></linkto> from which MeasurementSet
81// and all the subtable classes are derived.
82// Thus, e.g., the class MSAntenna is derived from <src>
83// MSTable<MSAntennaEnums::PredefinedColumns, MSAntennaEnums::PredefinedKeywords></src>.
84//
85// The MSTable class
86// provides a large number of common column and keyword helper functions.
87// They are useful when creating a Table following the MeasurementSet
88// conventions from scratch and assist in following the agreed upon
89// column and keyword naming conventions.
90//
91// MSTable in turn is derived from Table, thus all the MS table classes are
92// Tables. Many operations on a MeasurementSet are Table operations. See the
93// <linkto module="Tables:description">Tables</linkto> module for a list of
94// those operations.
95//
96// The reason for this class hierarchy is to provide each of the table classes
97// with a separate namespace for its column and keyword enums, so that
98// e.g., they can all have a column named TIME, while sharing as much code
99// as possible. The MSTable class forwards any substantial work
100// to the MSTableImpl class which does the actual work, it is a purely
101// implementation class with static functions not of interest to the user.
102//
103// <h4> Access to columns </h4>
104// To simplify the access of columns, and catch type errors in
105// the column declarations for column access objects (TableColumns) at
106// compile time, there is a helper class for each (sub)table (e.g.,
107// MSFieldColumns). The helper class for the MeasurementSet,
108// MSColumns gives access to the main table columns and the helper objects
109// for all subtables.
110//
111// At present these classes are separate from the Table classes, mainly
112// to ensure that the member functions are only called on valid, completely
113// constructed MeasurementSet Tables. They also represent a large amount
114// of 'state' in the form of TableColumn objects of which only a couple
115// may actually be used.
116//
117// <h4> Units and Measures </h4>
118// Columns in the MeasurementSet and its subtables can have several
119// keywords attached to describe the contents of the column.
120// The UNIT keyword contains an ASCII string describing the unit of
121// the values in the column. The unit member function (in MSTable) will
122// return this unit string, it can be used to construct a
123// <linkto class=Unit>Unit</linkto> object for a particular column.
124//
125// The MEASURE_TYPE keyword gives the Casacore Measure that applies to the
126// column (if any). See the
127// <linkto module="Measures:description">Measures</linkto> module for a
128// list of available Measures and their use.
129//
130// The MEASURE_REFERENCE keyword gives (part of) the reference frame needed
131// to interpret the values in a column. An example is J2000 for the POSITION
132// column. A number of static functions in MeasurementSet are available to
133// create a 'template' Measure for a column, which has the MEASURE_TYPE filled
134// in. Currently the following functions exist: directionMeasure,
135// positionMeasure, epochMeasure and frequencyMeasure. They return a
136// Measure which can then be filled with a value from a particular row from
137// the column to obtain, e.g., a proper MDirection Measure for the phase
138// center.
139//
140// <h4> Reference Tables </h4>
141// Each of the MS classes has a member function
142// referenceCopy which takes the name of a new Table and a list (Block) of
143// column names to create a Table which references all columns in the
144// original table, except for those listed. The listed columns are
145// new columns which can be written to without affecting the original Table.
146// The main use of this is for the synthesis package where corrected and
147// model visibilities are stored as new DATA columns in an MS which
148// references the raw MS for the other columns. Except for these special
149// cases, the use of this function will be rare.
150//
151// <h4> DATA and FLOAT_DATA columns </h4>
152// To accommodate both synthesis and single dish data efficiently, it was
153// decided that a MeasurementSet can have a Complex DATA column,
154// a float FLOAT_DATA column or both. If it has only a FLOAT_DATA column, the
155// corresponding DATA column can be created with the makeComplexData()
156// member function. In special cases, both columns could be present but
157// filled for different rows, with an extra index defined indicating in
158// which column to look (e.g., multi-feed single dish with cross correlations).
159// The details of this last scheme are yet to be worked out.
160// The table consistency checks (isValid()) do not require the presence
161// of either column.
162//
163// <h4> Unset values in MeasurementSet Tables </h4>
164// For ID columns, the rule is that a value of -1 indicates that there is
165// no corresponding subtable in which to look up details. An example is
166// the PULSAR_ID column, which should be set to -1 if the optional
167// PULSAR subtable does not exist.
168//
169// The rules for non integer unset values in MS tables have not
170// settled down yet.
171// For Floating point and Complex values the recommended practice is
172// to set the values to the FITS and IEEE value NaN,
173// with a bit pattern of all 1's.
174// In much of the present filler code unused values are filled with 0 instead.
175//
176// <h4> Table destruction </h4>
177// Upon destruction, the table and all subtables are checked to see that the
178// MeasurementSet remains valid, i.e., all required columns are present.
179// An exception is thrown if not all required columns are present
180// Nevertheless, the table will be flushed to disk if it is writable -
181// preserving its state.
182//
183//
184// <h4> MS shorthand </h4>
185// While the class name, MeasurementSet, is descriptive, it is often
186// too long for many common uses. The typedef MS is provided as
187// a convenient shorthand for MeasurementSet. The example below uses this
188// typedef.
189//
190//
191// </synopsis>
192//
193// <example>
194// This example illustrates creation and filling of the MeasurementSet.
195// <srcblock>
196// // create the table descriptor
197// TableDesc simpleDesc = MS::requiredTableDesc()
198// // set up a new table
199// SetupNewTable newTab("simpleTab", simpleDesc, Table::New);
200// // create the MeasurementSet
201// MeasurementSet simpleMS(newTab);
202// // now we need to define all required subtables
203// // the following call does this for us if we don't need to
204// // specify details of Storage Managers or non-standard columns.
205// simpleMS.createDummySubtables(Table::New);
206// // fill MeasurementSet via its Table interface
207// // For example, construct one of the column access objects.
208// TableColumn feed(simpleMS, MS::columnName(MS::FEED1));
209// uInt rownr = 0;
210// // add a row
211// simpleMS.addRow();
212// // set the values in that row, e.g. the feed column
213// feed.putScalar(rownr,1);
214// // Access the position column in the ANTENNA subtable
215// ArrayColumn<Double> antpos(simpleMS.antenna(),
216// MSAntenna::columnName(MSAntenna::POSITION));
217// // Add a row to it and fill in the position
218// simpleMS.antenna().addRow();
219// Array<Double> position(3);
220// position(0)=1.; position(1)=2.; position(2)=3.;
221// antpos.put(0,position);
222// // .
223// // For standard columns the above can be done more easily using
224// // the MSColumns object.
225// // Create the MSColumns
226// MSColumns msc(simpleMS);
227// // and fill in the position
228// msc.antenna().position().put(0,position);
229// </srcblock>
230//
231// </example>
232
233// <example>
234// This example illustrates read only access to an existing MeasurementSet
235// and creation of an MDirection Measure for the phase center.
236// <srcblock>
237// // Create the MeasurementSet from an existing Table on disk
238// MeasurementSet ms("myMS");
239// // Create the RO column access objects for main table and subtables
240// MSColumns msc(ms);
241// // show data from row 5
242// cout << msc.data()(5) << endl;
243// // show phase center for row 3 in field table
244// Vector<double> phaseCtr=msc.field().phaseCenter()(3);
245// cout << phaseCtr<<endl;
246// // now create a Measure for the phaseCenter
247// MDirection phaseCenterMeasure =
248// MS::directionMeasure(msc.field().phaseCenter());
249// // put the value from row 3 in the Measure and print it
250// phaseCenterMeasure.set(MVPosition(phaseCtr));
251// cout <<"phase center:"<< phaseCenterMeasure<<endl;
252//
253// </srcblock>
254//
255// </example>
256//
257// <motivation>
258// The attempt is to define a single, extensible, Table format that will
259// be able to cope with all, or at least most, radio telescope data.
260// Having a single MeasurementSet should make it easier to combine data
261// from different instruments. The format of the MeasurementSet,
262// table with subtables, was chosen to be able to cope with items
263// varying at different rates more efficiently than a 'flat' Table layout
264// would allow.
265// </motivation>
266
267// <todo asof="1997/02/01">
268// <li> Incorporate the MSColumn classes in the MeasurementSet classes?
269// <li> Variable (row to row) ReferenceFrame (e.g., J2000 mixed with
270// galactic, different Frequency reference frames mixed in the
271// same MS, etc.). This could be done with a column named
272// "column_name"_MEASURE_REFERENCE for each column with varying
273// Measure reference frames.
274// </todo>
275
276// </module>
277
278
279} //# NAMESPACE CASACORE - END
280
281#endif
this file contains all the compiler specific defines
Definition mainpage.dox:28