casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VisSet.h
Go to the documentation of this file.
1 //# VisSet.h: VisSet definitions
2 //# Copyright (C) 1996,1997,1998,2001,2002
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 MSVIS_VISSET_H
30 #define MSVIS_VISSET_H
31 
32 #include <casa/aips.h>
33 #include <casa/BasicSL/Complex.h>
34 #include <casa/Arrays/Matrix.h>
37 
38 namespace casa { //# NAMESPACE CASA - BEGIN
39 
40 // <summary>
41 // The interface to the casacore::MeasurementSet for synthesis processing
42 // </summary>
43 
44 // <reviewed reviewer="" date="" tests="t" demos="">
45 
46 // <prerequisite>
47 // <li> <linkto module="casacore::MeasurementSet">casacore::MeasurementSet</linkto>
48 // </prerequisite>
49 //
50 // <etymology>
51 // VisSet is the Set of Visibilities
52 // </etymology>
53 //
54 // <synopsis>
55 // The VisSet is a class that simplifies access to the visibility data
56 // for the synthesis processing code. It holds a reference to an original
57 // casacore::MeasurementSet with observed data and creates two extra data
58 // columns for the storage of model visibilities and
59 // corrected visibilities. All access to the casacore::MeasurementSet is done via
60 // the <linkto class="VisibilityIterator">VisibilityIterator</linkto>
61 // and the <linkto class="VisBuffer">VisBuffer</linkto>
62 //
63 // The VisSet allows selection and sorting of the casacore::MeasurementSet to be applied.
64 // A number of columns can be specified to define the iteration order, a
65 // a time interval can be given to iterate in chunks of time and a channel
66 // selection can be made for each spectral window present in the data.
67 // </synopsis>
68 //
69 // <example>
70 // <srcblock>
71 // casacore::MeasurementSet ms("Example.MS",casacore::Table::Update);
72 // cout << "Constructing VisSet"<<endl;
73 // casacore::Block<casacore::Int> bi(2);
74 // bi[0]=casacore::MS::SPECTRAL_WINDOW_ID;
75 // bi[1]=casacore::MS::TIME;
76 // casacore::Matrix<casacore::Int> chanSelection; // no channel selection
77 // // iterate in 600s chunks within each SpectralWindow
78 // casacore::Double interval=600.;
79 // VisSet vs(ms,bi,chanSelection,interval);
80 // </srcblock>
81 // </example>
82 //
83 // <motivation>
84 // This class provides an easy interface to the MS.
85 // It keeps the iterator around
86 // for reuse, thus avoiding repeated sorting of the data.
87 // </motivation>
88 //
89 // <todo asof="">
90 // </todo>
91 
96 
98 
101 
102 class VisSet {
103 
104 public:
105  // default constructor, only useful to assign to later.
106  VisSet() {}
107 
108  // Construct from a casacore::MeasurementSet, with iteration order specified in
109  // columns (giving the casacore::MS enum for the column)
110  // Specify channel selection as a casacore::Matrix(3,nSpw) where for each
111  // spectral window the three values are start,nChannel and
112  // spectral window number. Spectral windows without an entry will have
113  // all channels selected.
114  // Specify a time interval for iterating in 'chunks' of time.
115  // The default time interval of 0 groups all times together.
116  // This constructor creates two new columns:
117  // MODEL_DATA and CORRECTED_DATA
118  // If they already exist and have the
119  // same channel selection applied, they are reused.
120  // Note that the contents of these columns are NOT initialized,
121  // you should fill them before trying to read the data.
122  // The casacore::MS calibration scratch columns can be optionally compressed.
124  const casacore::Matrix<casacore::Int>& chanSelection, casacore::Double timeInterval=0,
125  casacore::Bool compress=false, casacore::Bool doModelData=true);
126 
127  // Same as above, but provide scratch column option
129  const casacore::Matrix<casacore::Int>& chanSelection,
130  casacore::Bool addScratch,
131  casacore::Double timeInterval=0,casacore::Bool compress=false, casacore::Bool doModelData=true);
132 
133  // This is a constructor for multiple MS...but everything is same as the one
134  // above
135 
136 
138  const casacore::Block< casacore::Matrix<casacore::Int> >& chanSelections, casacore::Bool addStratch=false, casacore::Double timeInterval=0,
139  casacore::Bool compress=false, casacore::Bool doModelData=true);
140 
141 
142 
143 
144 
145  // This is a no frills constructor, no re-sorting, the default order is used,
146  // no scratch columns is made even if they don't exist. So if you use
147  // this constructor and plan to use the scratch columns make sure
148  // that they exist prior to constructing the VisSet this way.
150  casacore::Double timeInterval=0);
151 
152  //Constructor from visibility iterator ....a temporary fix
153  //as EPJones as Imager stops using VisSet
155  // Construct from an existing VisSet, this references the underlying
156  // casacore::MeasurementSet(s) but allows a new iteration order and time interval
157  // to be specified.
158  VisSet(const VisSet & vs, const casacore::Block<casacore::Int>& columns, casacore::Double timeInterval=0);
159 
160  // Destructor, flushes the data to disk
161  ~VisSet();
162  // referencing assignment operator
163  VisSet& operator=(const VisSet& other);
164 
165  // Re-initialize the VisibilityIterator (cf copy ctor)
166  void resetVisIter(const casacore::Block<casacore::Int>& columns, casacore::Double timeInterval = 0,
167  asyncio::PrefetchColumns * prefetchColumns = NULL);
168 
169  // Initializes scratch columns
170  void initCalSet(casacore::Int calSet=0);
171 
172  // Flushes the data to disk
173  void flush();
174  // Iterator access to the data
175  VisIter& iter();
176 
177  // Reset the channel selection. Only subsets of the original selection
178  // (set in constructor) can be specified.
179  // Note: this calls origin on the iterator.
180  void selectChannel(casacore::Int nGroup,casacore::Int start, casacore::Int width, casacore::Int increment,
181  casacore::Int spectralWindow);
182  // call to VisIter origin optional:
183  void selectChannel(casacore::Int nGroup,casacore::Int start, casacore::Int width, casacore::Int increment,
184  casacore::Int spectralWindow, casacore::Bool callOrigin);
185 
186  // Collective selection via casacore::MSSelection channel selection Matrix
187  void selectChannel(const casacore::Matrix<casacore::Int>& chansel);
188 
189  // Set nominal selection to ALL channels
190  void selectAllChans();
191 
192  // number of antennas
194 
195  // number of fields
197 
198  // number of spectral windows
200 
201  // number of channels in each spectral window
203 
204  // start channel of VisSet selection in each spectral window
206 
207  // number of coherences
208  casacore::Int numberCoh() const;
209 
210  // Lock and unlock the associated MS
211  void lock() {ms_p.lock();};
212  void unlock() {ms_p.unlock();};
213 
214  // Return the associated casacore::MS name
216 
217  // SYSCAL table name of the associated MS
219 
220  // SPECTRAL_WINDOW table name of the associated MS
222 
223  // FIELD table name of the associated MS
225 
226  // SYSPOWER table name of the associated MS
228 
229  // CALDEVICE table name of the associated MS
231 
232 private:
233 
234  //Add the scratch columns
235  void addScratchCols(casacore::MeasurementSet& ms, casacore::Bool compress=false, casacore::Bool doModelData=true);
236 
237  // Add a calibration set (comprising a set of CORRECTED_DATA and MODEL_DATA)
238  // to the casacore::MeasurementSet (casacore::MS). Optionally compress these columns using the
239  // casacore::CompressComplex column engine.
240  void addCalSet(casacore::MeasurementSet& ms, casacore::Bool compress=true, casacore::Bool doModelData=true);
241  void addCalSet2(casacore::MeasurementSet& ms, casacore::Bool compress=false, casacore::Bool doModelData=true);
242 
243 
249 
250 };
251 
252 
253 } //# NAMESPACE CASA - END
254 
255 #endif
256 
257 
casacore::String syspowerTableName()
SYSPOWER table name of the associated MS.
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
casacore::String caldeviceTableName()
CALDEVICE table name of the associated MS.
casacore::Block< casacore::MeasurementSet > * blockOfMS_p
Definition: VisSet.h:247
VisibilityIterator VisIter
Definition: VisSet.h:100
casacore::Int numberCoh() const
number of coherences
casacore::RigidVector< casacore::Float, 3 > Position
Definition: VisSet.h:94
casacore::Vector< CStokesVector > vvCoh
Definition: VisSet.h:97
void unlock()
Definition: VisSet.h:212
casacore::Bool multims_p
Definition: VisSet.h:248
void addScratchCols(casacore::MeasurementSet &ms, casacore::Bool compress=false, casacore::Bool doModelData=true)
Add the scratch columns.
casacore::String sysCalTableName()
SYSCAL table name of the associated MS.
void initCalSet(casacore::Int calSet=0)
Initializes scratch columns.
casacore::MeasurementSet ms_p
Definition: VisSet.h:244
casacore::uInt Antenna
The interface to the casacore::MeasurementSet for synthesis processing.
Definition: VisSet.h:92
void flush()
Flushes the data to disk.
The PrefetchColumns class is used to specify a set of columns that can be prefetched when the (RO)Vis...
double Double
Definition: aipstype.h:55
void addCalSet2(casacore::MeasurementSet &ms, casacore::Bool compress=false, casacore::Bool doModelData=true)
casacore::RigidVector< casacore::Double, 3 > Direction
Definition: VisSet.h:95
ROVisibilityIterator ROVisIter
Definition: VisSet.h:99
VisIter & iter()
Iterator access to the data.
casacore::Vector< casacore::Int > startChan() const
start channel of VisSet selection in each spectral window
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Bool lock(FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
Try to lock the table for read or write access (default is write).
Definition: Table.h:1142
casacore::Matrix< casacore::Int > selection_p
Definition: VisSet.h:246
void resetVisIter(const casacore::Block< casacore::Int > &columns, casacore::Double timeInterval=0, asyncio::PrefetchColumns *prefetchColumns=NULL)
Re-initialize the VisibilityIterator (cf copy ctor)
A Table intended to hold astronomical data (a set of Measurements).
VisIter * iter_p
Definition: VisSet.h:245
casacore::String fieldTableName()
FIELD table name of the associated MS.
void selectChannel(casacore::Int nGroup, casacore::Int start, casacore::Int width, casacore::Int increment, casacore::Int spectralWindow)
Reset the channel selection.
casacore::String spectralWindowTableName()
SPECTRAL_WINDOW table name of the associated MS.
VisSet()
default constructor, only useful to assign to later.
Definition: VisSet.h:106
casacore::Int numberSpw()
number of spectral windows
VisSet & operator=(const VisSet &other)
referencing assignment operator
casacore::Int numberAnt()
number of antennas
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Double Frequency
Definition: VisSet.h:93
VisibilityIterator iterates through one or more writable MeasurementSets.
casacore::Int numberFld()
number of fields
casacore::String msName()
Return the associated casacore::MS name.
ROVisibilityIterator iterates through one or more readonly MeasurementSets.
void lock()
Lock and unlock the associated MS.
Definition: VisSet.h:211
~VisSet()
Destructor, flushes the data to disk.
void selectAllChans()
Set nominal selection to ALL channels.
unsigned int uInt
Definition: aipstype.h:51
void unlock()
Unlock the table.
Definition: Table.h:1149
casacore::Vector< casacore::Int > numberChan() const
number of channels in each spectral window
void addCalSet(casacore::MeasurementSet &ms, casacore::Bool compress=true, casacore::Bool doModelData=true)
Add a calibration set (comprising a set of CORRECTED_DATA and MODEL_DATA) to the casacore::Measuremen...