casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LayeredVi2Factory.h
Go to the documentation of this file.
1 //# LayeredVi2Factory.h: Interface definition of the LayeredVi2Factory class.
2 //#
3 //# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
4 //# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
5 //# Copyright (C) European Southern Observatory, 2011, All rights reserved.
6 //#
7 //# This library is free software; you can redistribute it and/or
8 //# modify it under the terms of the GNU Lesser General Public
9 //# License as published by the Free software Foundation; either
10 //# version 2.1 of the License, or (at your option) any later version.
11 //#
12 //# This library is distributed in the hope that it will be useful,
13 //# but WITHOUT ANY WARRANTY, without even the implied warranty of
14 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 //# Lesser General Public License for more details.
16 //#
17 //# You should have received a copy of the GNU Lesser General Public
18 //# License along with this library; if not, write to the Free Software
19 //# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //# MA 02111-1307 USA
21 //# $Id: $
22 
23 #ifndef LayeredVi2Factory_H_
24 #define LayeredVi2Factory_H_
25 
26 // Where ViFactory interface is defined
29 
30 #include <casa/Containers/Record.h>
31 
32 namespace casa { //# NAMESPACE CASA - BEGIN
33 namespace vi { //# NAMESPACE VI - BEGIN
34 
35 class IteratingParameters;
36 class AveragingParameters;
37 class CalibratingVi2FactoryI;
38 
39 // <summary>
40 // A factory for generating ViImplementation2 layers that optionally include calibration
41 // (via CalibratingVi2) and time-averaging (via AveragingTvi2).
42 // </summary>
43 //
44 // <use visibility=export>
45 //
46 // <prerequisite>
47 // <li> <linkto class="VisibilityIterator2:description">VisibilityIterator2</linkto>
48 // <li> <linkto class="CalibratingVi2:description">CalibratingVi2</linkto>
49 // <li> <linkto class="AveragingTvi2:description">AveraringTvi2</linkto>
50 // </prerequisite>
51 //
52 // <etymology>
53 // Factory for layered ViImplementation2 construction
54 // </etymology>
55 //
56 // <synopsis>
57 // LayeredVi2Factory generates a Visibility Iterator implementation (ViImplementation2)
58 // object that can be plugged into a Visibility Iterator (VisibilityIterator2) object,
59 // so that the user can access the data using the Visibility Iterator interface.
60 // The ViImplementation2 generated by this factory consists of an underlying
61 // VisibilityIteratorImpl2, and (optionally) CalibratingVi2 and AveragingTvi2 ViImplementation2s,
62 // thereby supporting these operations in sequence. When both calibration and averaging
63 // are invoked, calibration is hard-wired to occur first.
64 // </synopsis>
65 //
66 // <motivation>
67 // This class makes the combination of OTF calibration application and time-averaging portable,
68 // and available to all VisibilityIterator2 users.
69 // </motivation>
70 //
71 // <example>
72 // External usage is quite simple, and compliant with the 'normal' VI/VB framework.
73 //
74 // The user first makes objects describing the data iteration, calibration parameters,
75 // and averaging parameters:
76 //
77 // <srcblock>
78 // IteratingParameters iterpar(60.0); // 60s chunk interval
79 //
80 // casacore::Float calfactor(100.0); // a simple factor with which to multiply the data
81 // casacore::Record calrec; // (in leiu of full VisEquation functionality (TBD)
82 // calrec.define("calfactor",calfactor); // in a casacore::Record
83 //
84 // AveragingParameters avepar(10.0); // 10s averaging
85 //
86 //
87 // </srcblock>
88 //
89 // Then these parameter objects, along with a casacore::MeasurementSet pointer, are used to make
90 // a factory suitable for the generic VisibilityIterator2 ctor, which is then invoked
91 //
92 // <srcblock>
93 // casacore::MeasurementSet *ms(....); // typically from elsewhere, e.g., selected
94 // LayeredVi2Factory factory(ms,&iterpar,calrec,&avepar);
95 // vi::VisibilityIterator2 *visIter = new vi::VisibilityIterator2 (factory);
96 // vi::VisBuffer2 *visBuffer = visIter->getVisBuffer();
97 // </srcblock>
98 //
99 // Once this is done one can normally iterate and access OTF calibrated and averaged data:
100 //
101 // <srcblock>
102 // while (visIter->moreChunks())
103 // {
104 // visIter->origin();
105 //
106 // while (visIter->more())
107 // {
108 //
109 // // the following will have been calibrated and averaged to 10s
110 // casacore::Vector<casacore::Int> ddi = visBuffer->dataDescriptionIds();
111 // casacore::Vector<casacore::Int> antenna1 = visBuffer->antenna1();
112 // casacore::Vector<casacore::Int> antenna2 = visBuffer->antenna2();
113 // casacore::Cube<casacore::Complex> cvis = visBuffer->visCubeCorrected();
114 //
115 // visIter->next();
116 // }
117 //
118 // visIter->nextChunk();
119 // }
120 // </srcblock>
121 //
122 // casacore::Notice that it is the responsibility of the application layer to delete the VisibilityIterator2
123 // pointer returned by the factory method. However the life cycle of the VisBuffer2 object is
124 // responsibility of the VisibilityIterator2 object.
125 //
126 // <srcblock>
127 // delete visIter;
128 // </srcblock>
129 //
130 // </example>
131 
132 
133 
135 {
136 
137 public:
138 
139  // Non-calibrating version
141  IteratingParameters* iterpar,
142  AveragingParameters* avepar=0);
143  // Calibrating version, via CalLib Record
145  IteratingParameters* iterpar,
146  const casacore::Record& calrec,
147  AveragingParameters* avepar=0);
148  // Calibrating version, vis CalLib casacore::String (filename or casacore::String)
150  IteratingParameters* iterpar,
151  const casacore::String& callib,
152  AveragingParameters* avepar=0);
154 
155  vi::ViImplementation2 * createVi () const;
157 
158 private:
159 
161 
169 
170 };
171 
172 
173 
175 //
176 // Class VisIterImpl2LayerFactory
177 //
178 // (Ideally, this should be in ViiLayerFactory.h, but it has include problems there)
179 //
180 class VisIterImpl2LayerFactory : public ViiLayerFactory {
181 
182  public:
183 
184  VisIterImpl2LayerFactory(casacore::MeasurementSet* ms,
185  const IteratingParameters& pars,
186  bool writable,
187  bool useMSIter2=false);
188 
189  void setFrequencySelections(std::shared_ptr<FrequencySelections> selections);
190 
192 
193  protected:
194 
195  // VisibilityIteratorImpl2-specific layer-creater
196  //
197  virtual ViImplementation2 * createInstance (ViImplementation2* vii0) const;
198 
199  private:
200 
201  // Pointer to _external_ ms (support only one, for now)
203 
204  // Store a copy of the parameters
206 
207  // Should VisibilityIteratorImpl2 be generated w/ write-permission
208  bool writable_;
209 
210  // Control use of ~experimental MSIter2, which has smarter time iteration
212 
213  //Frequency selections to be applied to the generated visibility iterator
214  std::shared_ptr<FrequencySelections> frequencySelections_p;
215 };
216 
217 
218 
219 } //# NAMESPACE VI - END
220 } //# NAMESPACE CASA - END
221 
222 
223 #endif /* LayeredVi2Factory_H_ */
224 
int Int
Definition: aipstype.h:50
Class VisIterImpl2LayerFactory(Ideally, this should be in ViiLayerFactory.h, but it has include problems there)*/class VisIterImpl2LayerFactory void setFrequencySelections(std::shared_ptr< FrequencySelections > selections)
vi::ViImplementation2 * createVi() const
virtual ViImplementation2 * createInstance(ViImplementation2 *vii0) const
VisibilityIteratorImpl2-specific layer-creater.
vi::IteratingParameters * iterpar_p
casacore::MeasurementSet * ms_
Pointer to external ms (support only one, for now)
A factory for generating ViImplementation2 layers that optionally include calibration (via Calibratin...
std::shared_ptr< FrequencySelections > frequencySelections_p
Frequency selections to be applied to the generated visibility iterator.
CalibratingVi2FactoryI * calvi2factory_p
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool writable_
Should VisibilityIteratorImpl2 be generated w/ write-permission.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LayeredVi2Factory(casacore::MeasurementSet *ms, IteratingParameters *iterpar, AveragingParameters *avepar=0)
Non-calibrating version.
A Table intended to hold astronomical data (a set of Measurements).
vi::AveragingParameters * avepar_p
Base class for all Casacore library errors.
Definition: Error.h:134
const vi::IteratingParameters pars_
Store a copy of the parameters.
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual ~VisIterImpl2LayerFactory()
casacore::MeasurementSet * ms_p
bool useMSIter2_
Control use of ~experimental MSIter2, which has smarter time iteration.