casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VLAFiller.h
Go to the documentation of this file.
1 //# VLAFiller.h:
2 //# Copyright (C) 1999,2000,2001,2003
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: 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 NRAO_VLAFILLER_H
30 #define NRAO_VLAFILLER_H
31 
32 #include <casa/aips.h>
33 #include <casa/Arrays/Vector.h>
34 #include <casa/Arrays/IPosition.h>
35 #include <casa/Containers/Block.h>
36 #include <casa/Containers/Record.h>
37 #include <casa/Logging/LogIO.h>
42 #include <measures/Measures/Muvw.h>
48 #include <nrao/VLA/VLAEnum.h>
49 #include <nrao/VLA/VLAFilterSet.h>
51 
52 #include <unordered_map>
53 #include <string>
54 
55 #include <casa/namespace.h>
56 namespace casacore{
57 
58 class Path;
59 class MPosition;
60 template <class T> class Vector;
61 }
62 
63 namespace casa { //# NAMESPACE CASA - BEGIN
64 } //# NAMESPACE CASA - END
65 
66 struct IterationStatus;
67 
68 // <summary>Functions to convert from VLA archive format to a casacore::MeasurementSet</summary>
69 
70 // <use visibility=export>
71 
72 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
73 // </reviewed>
74 
75 // <prerequisite>
76 // <li> SomeClass
77 // <li> SomeOtherClass
78 // <li> some concept
79 // </prerequisite>
80 //
81 // <etymology>
82 // </etymology>
83 //
84 // <synopsis>
85 // </synopsis>
86 //
87 // <example>
88 // </example>
89 //
90 // <motivation>
91 // </motivation>
92 //
93 // <templating arg=T>
94 // <li>
95 // <li>
96 // </templating>
97 //
98 // <thrown>
99 // <li>
100 // <li>
101 // </thrown>
102 //
103 // <todo asof="yyyy/mm/dd">
104 // <li> add this feature
105 // <li> fix this bug
106 // <li> start discussion of this possible extension
107 // </todo>
108 
109 class VLAFiller: public MSColumns
110 {
111 public:
112  // Construct a VLAFiller object that will data from the specified input, and
113  // writes it to the supplied MeasurementSet.
114  // We set the default tolerance for frequency to be 6 times of the
115  // channel width and also give user the ability to pass in a tolerance
116  // for frequency into vlafillerfromdisk(). The default tolerance of frequency
117  // works for dataset G192. But for dataset NGC7538, one has to give a tolerance
118  // as larger as 60 times its channel width ( 60000000Hz ). For other dataset, the
119  // user has to try out the proper tolerance.
120  VLAFiller(casacore::MeasurementSet& output, VLALogicalRecord& input, casacore::Double freqTolerance=0.0, casacore::Bool autocorr=false, const casacore::String& antnamescheme="new", const casacore::Bool& applyTsys=true);
121 
122  // Does nothing special
123  ~VLAFiller();
124 
125  // Set the filter that will be used to restrict which input records get
126  // copied to the output MS.
127  void setFilter(const VLAFilterSet& filter);
128 
129  // fill the supplied casacore::MeasurementSet from the the supplied VLABuffer. The
130  // number/type of messages describing the progress sent to the logger are
131  // controlled using the verbose argument. If verbose is -1 or less then no
132  // messages are sent to the logger. If verbose is zero then a summary is sent
133  // to the logger just before this function completes. If verbose is one then
134  // a message is sent for every record copied to the output MS. If verbose is
135  // two a message is sent every second record and so on.
136  void fill(casacore::Int verbose=1);
137 
138  // Construct an empty casacore::MeasurementSet with the supplied table name. Throw
139  // an exception (casacore::AipsError) if the specified casacore::Table already exists unless the
140  // overwrite argument is set to true.
141  static casacore::MeasurementSet emptyMS(const casacore::Path& tableName,
142  const casacore::Bool overwrite=false);
143 
144  // Open the casacore::MeasurementSet with the supplied name. Throw an exception
145  // (casacore::AipsError) if the specified casacore::Table does not exist. By default the casacore::Table is
146  // opened for read/write access. The Type/SubType MUST be "Measurement
147  // Set/VLA" ie., the casacore::MS must have been created with this class. Otherwise an
148  // exception is thrown.
149  static casacore::MeasurementSet openMS(const casacore::Path& tableName,
150  const casacore::Bool readonly=false);
151 
152  // Return an empty casacore::MeasurementSet with the supplied table name. Creates a
153  // empty measurement set unless one with the specified name already exists
154  // and overwrite is false. Then it opens the existing measurement set for
155  // read/write access.
156  static casacore::MeasurementSet getMS(const casacore::Path& tableName,
157  const casacore::Bool overwrite=false);
158 
159  // Set the stop Parameters for filling
161 private:
162  // Read one record from the input and copies it to the casacore::MS if it is not
163  // filtered out. Returns false if a record could not be read.
165 
166  // Send to the logger info about how the filler is going
167  void logCurrentRecord(IterationStatus& counts);
168  void logChanges(IterationStatus& counts);
169 
170  // Send to the logger info about how much data is in the (sub)tables
171  void summarise();
172 
173  //# Add an entry to the antenna subtable
174  casacore::uInt addAntenna(const casacore::MPosition& antennaPos, casacore::uInt whichAnt);
175 
176  //# Add an entry to the feed subtable
177  void addFeed(casacore::uInt whichAnt);
178 
179  //# Add an entry to the field subtable
181 
182  //# Add an entry to the pointing subtable
184  const casacore::MDirection& fieldDir, casacore::uInt whichAnt);
185  // # Add an entry to the doppler dubtable
186  casacore::uInt addDoppler( const VLAEnum::CDA cda );
187  //# Add an entry to the spectral-window subtable
189  const casacore::uInt nChan,
190  const casacore::Double bandwidth,
191  const casacore::uInt ifChain);
192 
193  //# Add an entry to the polarization subtable
195 
196  //# Add an entry to the data description subtable
198 
199  //# Add an entry in the source subtable
201 
202  //# Add a hypercube to the columns that use the Tiled casacore::Data Storage manager.
203  void addHypercubes(casacore::uInt nPol, casacore::uInt nChan);
204 
205  //# Add the specified number of rows tp the specified hypercubes
207  casacore::uInt rows);
208 
209  //# Reconcile duplicate field names
211 
212  //# Determine whether to stop the fill for on-line filling
218  //# pol index RR=0, RL=1, LR=2, LL needed just for index data
220 
221  //# Makes sure the type (epoch) is valid, logs a warning (once) if not
222  //# assumes B1950_VLA if not valid
224 
225  //# Contains a logical record
227 
228  //# Only logical records that match the specified criteria will be used.
230 
231  //# The output MS
233 
234  //# The reference frame of the observation is cached here and used when
235  //# conversions from the observed frame to the one used in the MS.
237  //# The reference frame of the observation whose spw is identified different
238  //# from what in the SPECTRAL_WINDOWS table and been added in. So the current
239  //# length of casacore::Vector equal the number of row in table SPECTRAL WINDOW( no use).
240  //# casacore::Vector<casacore::MeasFrame> theirFrames;
241  //# This is the direction reference for the Measurement set. It is cached
242  //# here.
244  //# This is the reference frame of the last record copied. Initially it is
245  //# set to a meaningless value.
247  //# This converter is used to convert from the direction types on the archive
248  //# to the one in the Measurement set. Its is cached to prevent it
249  //# continually having to be recreated. It is never used if all the data on
250  //# the archive and all the data in the casacore::MS have the same direction type.
252 
253  //# This converter is used to convert from the direction types on the archive
254  //# to Az, El. It is only needed for holography data.
256 
257  //# This converter is used to convert the UVW coordinates from the type on
258  //# the archive to the one in the Measurement set. It is cached to
259  //# prevent it continually having to be recreated. It is never used if all
260  //# the data on the archive and all the data in the casacore::MS have the same
261  //# direction type.
263 
264  //# This converter is used to convert from the channel frequency types on the
265  //# archive to the one in the Measurement set. Its is cached hear to prevent
266  //# it continually having to be recreated. It is only used if
267  //# data in the archive was observed with online Doppler tracking.
269 
270  //# This converter is used to the VLA baselines which are in the HADEC frame
271  //#to the ITRF frame so that they can be properly added with the VLA reference
272  //# position, which is also in the ITRF frame.
274 
275  //# The field Id for the most recently copied record. Negative if no record
276  //# has been copied.
278 
279  //# The antenna Id's for all the antennas in the most recently copied
280  //# record. Zero length if no record has been copied.
282 
283  //# The spectral window Id's for all the CDA's in the most recently copied
284  //# record. Always of length 4. Contains -1 is the CDA is unused.
286 
287  //# The polarization Id for the most recently copied record. Negative if no
288  //# record has been copied. There is one for each Spectral Id.
290 
291  //# The data description Id's for the most recently copied record. Negative
292  //# if no record has been copied.
294 
295  //# The length of these blocks is set to the maximum number of
296  //# subarrays(4). The itsNewScan block is true if the field, spectral window
297  //# etc. has changed and the itsScan casacore::Block indicates the scan number.
300  //# A string, containing projkect names, that is accumulated when filling and
301  //# written to the OBSERVATION subtable.
303  //# The place to log messages
305 
306  //# These data members needed because of the use of the TiledData Storage
307  //# Manager. It may be possible to remove these when the casacore::TiledShape storage
308  //# manager can be used (the holdup is currently in VisSet).
325  std::unordered_map<std::string, bool> itsTransferWarned;
328 };
329 #endif
void summarise()
Send to the logger info about how much data is in the (sub)tables.
A Measure: astronomical direction.
Definition: MDirection.h:174
A 1-D Specialization of the Array class.
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
casacore::Block< casacore::Int > itsSpId
Definition: VLAFiller.h:285
casacore::Bool itsInitEpoch
Definition: VLAFiller.h:323
static casacore::MeasurementSet openMS(const casacore::Path &tableName, const casacore::Bool readonly=false)
Open the casacore::MeasurementSet with the supplied name.
casacore::MDirection::Types itsDirType
Definition: VLAFiller.h:246
casacore::uInt addPointing(const casacore::MDirection &antennaDir, const casacore::MDirection &fieldDir, casacore::uInt whichAnt)
casacore::uInt addAntenna(const casacore::MPosition &antennaPos, casacore::uInt whichAnt)
void setFilter(const VLAFilterSet &filter)
Set the filter that will be used to restrict which input records get copied to the output MS...
casacore::Bool itsKeepAutoCorr
Definition: VLAFiller.h:321
casacore::TiledDataStManAccessor itsDataAcc
Definition: VLAFiller.h:309
casacore::uInt addField(const casacore::MDirection &refDir)
This class interprets a VLA logical record.
casacore::MBaseline::Convert itsBlCtr
Definition: VLAFiller.h:273
casacore::TiledDataStManAccessor itsImagingWeightAcc
Definition: VLAFiller.h:313
casacore::uInt addDataDescription(casacore::uInt spwId, casacore::uInt polId)
casacore::uInt addSpectralWindow(const VLAEnum::CDA cda, const casacore::MFrequency &refFreq, const casacore::uInt nChan, const casacore::Double bandwidth, const casacore::uInt ifChain)
casacore::Bool stopFilling(VLALogicalRecord &)
casacore::Bool fillOne()
Read one record from the input and copies it to the casacore::MS if it is not filtered out...
VLAFilterSet itsInputFilters
Definition: VLAFiller.h:229
Container for Measure frame.
Definition: MeasFrame.h:137
casacore::Bool itsEVLAisOn
Definition: VLAFiller.h:322
casacore::MVEpoch stopTime
Definition: VLAFiller.h:214
casacore::TiledDataStManAccessor itsModDataAcc
Definition: VLAFiller.h:314
casacore::TiledDataStManAccessor itsChanFlagAcc
Definition: VLAFiller.h:316
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Block< Block< casacore::Int > > itsDataId
Definition: VLAFiller.h:293
void setStopParams(casacore::String &, casacore::String &)
Set the stop Parameters for filling.
void logChanges(IterationStatus &counts)
casacore::Double itsFreqTolerance
Definition: VLAFiller.h:318
casacore::LogIO itsLog
Definition: VLAFiller.h:304
void addHypercubes(casacore::uInt nPol, casacore::uInt nChan)
Path name of a file.
Definition: Path.h:126
casacore::String projectCode
Definition: VLAFiller.h:213
bool itsZeroEpochWarned
Definition: VLAFiller.h:327
casacore::Bool itsApplyTsys
Definition: VLAFiller.h:319
static casacore::MeasurementSet getMS(const casacore::Path &tableName, const casacore::Bool overwrite=false)
Return an empty casacore::MeasurementSet with the supplied table name.
casacore::MDirection::Convert itsAzElCtr
Definition: VLAFiller.h:255
Functions to convert from VLA archive format to a casacore::MeasurementSet.
Definition: VLAFiller.h:109
StokesTypes
The Stokes types are defined by this enum.
Definition: Stokes.h:66
casacore::MeasFrame itsFrame
Definition: VLAFiller.h:236
casacore::MDirection::Types itsMSDirType
Definition: VLAFiller.h:243
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
casacore::uInt addPolarization(const casacore::Vector< casacore::Stokes::StokesTypes > &pol)
A Measure: wave characteristics.
Definition: MFrequency.h:161
VLALogicalRecord itsRecord
Definition: VLAFiller.h:226
casacore::uInt addSource(const casacore::MDirection &dir)
casacore::Bool fillStarted
Definition: VLAFiller.h:216
~VLAFiller()
Does nothing special.
casacore::MFrequency::Convert itsFreqCtr
Definition: VLAFiller.h:268
bool itsNoPolInfoWarned
Definition: VLAFiller.h:326
casacore::uInt addDoppler(const VLAEnum::CDA cda)
Add an entry to the doppler dubtable
casacore::Muvw::Convert itsUvwCtr
Definition: VLAFiller.h:262
casacore::MDirection::Types validEpoch(casacore::MDirection::Types mdType)
double Double
Definition: aipstype.h:55
casacore::String itsProject
Definition: VLAFiller.h:302
void fixFieldDuplicates(casacore::MSField &msFld)
casacore::TiledDataStManAccessor itsFlagAcc
Definition: VLAFiller.h:312
void logCurrentRecord(IterationStatus &counts)
Send to the logger info about how the filler is going.
casacore::Block< casacore::Int > itsScan
Definition: VLAFiller.h:299
casacore::Block< casacore::Int > itsFldId
Definition: VLAFiller.h:277
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
static casacore::MeasurementSet emptyMS(const casacore::Path &tableName, const casacore::Bool overwrite=false)
Construct an empty casacore::MeasurementSet with the supplied table name.
casacore::Bool checkStop
Definition: VLAFiller.h:215
void addFeed(casacore::uInt whichAnt)
Give access to some TiledDataStMan functions.
casacore::Record itsTileId
Definition: VLAFiller.h:310
casacore::Block< casacore::Int > itsPolId
Definition: VLAFiller.h:289
casacore::TiledDataStManAccessor itsCorrDataAcc
Definition: VLAFiller.h:315
A Table intended to hold a MeasurementSet FIELD table.
Definition: MSField.h:78
A Table intended to hold astronomical data (a set of Measurements).
std::unordered_map< std::string, bool > itsTransferWarned
Definition: VLAFiller.h:325
std::set< ScanKey > filter(const std::set< ScanKey > scans, const ArrayKey &arrayKey)
given a set of scan keys, return the subset that matches the given array key
casacore::Int polIndexer(casacore::Stokes::StokesTypes &stokes)
A class for high precision time.
Definition: MVEpoch.h:90
casacore::Block< casacore::IPosition > itsDataShapes
Definition: VLAFiller.h:317
VLAFiller(casacore::MeasurementSet &output, VLALogicalRecord &input, casacore::Double freqTolerance=0.0, casacore::Bool autocorr=false, const casacore::String &antnamescheme="new", const casacore::Bool &applyTsys=true)
Construct a VLAFiller object that will data from the specified input, and writes it to the supplied M...
A class to provide easy read-write access to MeasurementSet columns.
Definition: MSColumns.h:221
casacore::MDirection::Convert itsDirCtr
Definition: VLAFiller.h:251
CDA
Names for the different correlator data areas&#39;s.
Definition: VLAEnum.h:84
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool itsNewScan
Definition: VLAFiller.h:298
void extendHypercubes(const casacore::Block< casacore::uInt > &nPol, const casacore::Block< casacore::uInt > &nChan, casacore::uInt rows)
casacore::Bool itsRevBeenWarned
Definition: VLAFiller.h:324
casacore::TiledDataStManAccessor itsSigmaAcc
Definition: VLAFiller.h:311
casacore::MeasurementSet itsMS
Definition: VLAFiller.h:232
casacore::Bool itsNewAntName
Definition: VLAFiller.h:320
unsigned int uInt
Definition: aipstype.h:51
casacore::Block< casacore::Int > itsAntId
Definition: VLAFiller.h:281
void fill(casacore::Int verbose=1)
fill the supplied casacore::MeasurementSet from the the supplied VLABuffer.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42