casacore
MSMetaData.h
Go to the documentation of this file.
1 //# MSMetaData.h
2 //# Copyright (C) 1998,1999,2000,2001
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 //# $Id: MSMetaData.h 21586 2015-03-25 13:46:25Z gervandiepen $
27 
28 #ifndef MS_MSMETADATA_H
29 #define MS_MSMETADATA_H
30 
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/Quanta/QVector.h>
33 #include <casacore/measures/Measures/MFrequency.h>
34 #include <casacore/measures/Measures/MPosition.h>
35 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
36 #include <casacore/ms/MeasurementSets/MSPointingColumns.h>
37 #include <casacore/casa/Utilities/CountedPtr.h>
38 #include <map>
39 
40 namespace casacore {
41 
42 template <class T> class ArrayColumn;
43 struct ArrayKey;
44 struct ScanKey;
45 struct SourceKey;
46 struct SubScanKey;
47 
48 // <summary>
49 // Class to interrogate an MS for metadata. Interrogation happens on demand
50 // and resulting metadata are stored for use by subsequent queries if the
51 // cache has not exceeded the specified limit.
52 // </summary>
53 
54 class MSMetaData {
55 
56 public:
57 
58  // for retrieving stats
63  };
64 
65  enum SQLDSwitch {
69  };
70 
72  std::set<Int> ddIDs;
74  };
75 
77  std::set<Int> antennas;
79  std::set<uInt> ddIDs;
81  // the key is the spwID, the value is the meanInterval for
82  // the subscan and that spwID
83  map<uInt, Quantity> meanInterval;
86  std::set<uInt> spws;
87  std::set<Int> stateIDs;
88  std::map<Double, TimeStampProperties> timeProps;
89  };
90 
91  // construct an object which stores a pointer to the MS and queries the MS
92  // only as necessary. The MeasurementSet pointer passed in should not go out
93  // of scope in the calling code until the caller has finished with this object,
94  // or else subsequent method calls on this object will result in a segmentation
95  // fault; the pointer is not copied.
96  // <src>maxCacheSizeMB</src> is the maximum cache size in megabytes. <=0 means
97  // do not use a cache, in which case, each method call will have to (re)query
98  // the MS. It is highly recommended to use a cache of reasonable size for the
99  // specified MS if multiple methods are going to be called.
100  MSMetaData(const MeasurementSet *const &ms, const Float maxCacheSizeMB);
101 
102  virtual ~MSMetaData();
103 
104  // get the antenna diameters
105  QVD getAntennaDiameters() const;
106 
107  // get the antenna ID for the antenna with the specified name.
108  uInt getAntennaID(const String& antennaName) const;
109 
110  vector<uInt> getAntennaIDs(const vector<String>& antennaNames) const;
111 
112  // get the name of the antenna for the specified antenna ID
113  vector<String> getAntennaNames(
114  std::map<String, uInt>& namesToIDsMap,
115  const vector<uInt>& antennaIDs=vector<uInt>(0)
116  ) const;
117 
118  // get the antenna stations for the specified antenna IDs
119  vector<String> getAntennaStations(const vector<uInt>& antennaIDs);
120 
121  // get the antenna stations for the specified antenna names
122  vector<String> getAntennaStations(const vector<String>& antennaNames);
123 
124  // get the set of antenna IDs for the specified scan.
125  std::set<Int> getAntennasForScan(const ScanKey& scan) const;
126 
127  // POLARIZATION.CORR_PRODUCT
128  vector<Array<Int> > getCorrProducts() const;
129 
130  // POLARIZATION.CORR_TYPE
131  vector<vector<Int> > getCorrTypes() const;
132 
133  vector<uInt> getDataDescIDToSpwMap() const;
134 
135  vector<uInt> getDataDescIDToPolIDMap() const;
136 
137  // Get the FIELD.SOURCE_ID column.
138  vector<Int> getFieldTableSourceIDs() const;
139 
140  std::map<String, std::set<Int> > getIntentToFieldsMap();
141 
142  std::map<String, std::set<ScanKey> > getIntentToScansMap();
143 
144  std::map<String, std::set<uInt> > getIntentToSpwsMap();
145 
146  std::set<String> getIntentsForScan(const ScanKey& scan) const;
147 
148  std::set<String> getIntentsForSubScan(const SubScanKey& subScan) const;
149 
150  SHARED_PTR<const std::map<SubScanKey, std::set<String> > > getSubScanToIntentsMap() const;
151 
152  // get all intents, in no particular (nor guaranteed) order.
153  std::set<String> getIntents() const;
154 
155  // get a set of intents corresponding to a specified field
156  std::set<String> getIntentsForField(Int fieldID);
157 
158  // get a set of intents corresponding to the specified spectral window
159  std::set<String> getIntentsForSpw(const uInt spw);
160 
161  // number of correlations from the polarization table.
162  vector<Int> getNumCorrs() const;
163 
164  //SOURCE.PROPER_MOTION, first value in pair is longitudinal proper motion,
165  // second is latiduninal
166  vector<std::pair<Quantity, Quantity> > getProperMotions() const;
167 
168  // get unique scan numbers
169  std::set<Int> getScanNumbers(Int obsID, Int arrayID) const;
170 
171  // get a set of scan numbers for the specified stateID, obsID, and arrayID.
172  // If obsID and/or arrayID is negative, all observation IDs and/or array IDs
173  // will be used.
174  std::set<Int> getScansForState(
175  Int stateID, Int obsID, Int arrayID
176  ) const;
177 
178  // SOURCE.DIRECTION
179  vector<MDirection> getSourceDirections() const;
180 
181  // SOURCE.NAME
182  vector<String> getSourceNames() const;
183 
184  // Get the SOURCE.SOURCE_ID column. This is a very unfortunate column name,
185  // because generally an "ID" column of the table with the same name refers to
186  // the row number in that table. But not in this case.
187  vector<Int> getSourceTableSourceIDs() const;
188 
189  // get a set of spectral windows for which the specified <src>intent</src>
190  // applies.
191  virtual std::set<uInt> getSpwsForIntent(const String& intent);
192 
193  // get the number of visibilities
194  uInt nRows() const;
195 
196  uInt nRows(CorrelationType cType);
197 
198  SHARED_PTR<const map<SubScanKey, uInt> > getNRowMap(CorrelationType type) const;
199 
200  uInt nRows(
201  CorrelationType cType, Int arrayID, Int observationID,
202  Int scanNumber, Int fieldID
203  ) const;
204 
205  uInt nRows(CorrelationType cType, uInt fieldID) const;
206 
207  // get number of spectral windows
208  uInt nSpw(Bool includewvr) const;
209 
210  // number of unique states (number of rows from the STATE table)
211  uInt nStates() const;
212 
213  // get the number of fields.
214  uInt nFields() const;
215 
216  // get a mapping of spectral window ID to data descrption IDs
217  std::vector<std::set<uInt> > getSpwToDataDescriptionIDMap() const;
218 
219  // get a set of spectral windows corresponding to the specified fieldID
220  std::set<uInt> getSpwsForField(const Int fieldID);
221 
222  // get a set of spectral windows corresponding to the specified field name
223  std::set<uInt> getSpwsForField(const String& fieldName);
224 
225  // get the set of field IDs corresponding to the specified spectral window.
226  std::set<Int> getFieldIDsForSpw(const uInt spw);
227 
228  // get the set of field names corresponding to the specified spectral window.
229  std::set<String> getFieldNamesForSpw(const uInt spw);
230 
231  // get rest frequencies from the SOURCE table
232  map<SourceKey, SHARED_PTR<vector<MFrequency> > > getRestFrequencies() const;
233 
234  // get the set of spectral windows for the specified scan.
235  std::set<uInt> getSpwsForScan(const ScanKey& scan) const;
236 
237  // get the set of spectral windows for the specified subscan.
238  std::set<uInt> getSpwsForSubScan(const SubScanKey& subScan) const;
239 
240  // get the set of scan numbers for the specified spectral window.
241  std::set<Int> getScansForSpw(uInt spw, Int obsID, Int arrayID) const;
242 
243  // get the transitions from the SOURCE table. If there are no transitions
244  // for a particular key, the shared ptr contains the null ptr.
245  map<SourceKey, SHARED_PTR<vector<String> > > getTransitions() const;
246 
247  // get the number of antennas in the ANTENNA table
248  uInt nAntennas() const;
249 
250  // ALMA-specific. get set of spectral windows used for TDM. These are windows that have
251  // 64, 128, or 256 channels
252  std::set<uInt> getTDMSpw();
253 
254  // ALMA-specific. get set of spectral windows used for FDM. These are windows that do not
255  // have 1, 4, 64, 128, or 256 channels.
256  std::set<uInt> getFDMSpw();
257 
258  // ALMA-specific. get spectral windows that have been averaged. These are windows with 1 channel.
259  std::set<uInt> getChannelAvgSpw();
260 
261  // ALMA-specific. Get the spectral window set used for WVR measurements. These have 4 channels each.
262  std::set<uInt> getWVRSpw() const;
263 
264  // ALMA-specific. Get the square law detector (total power) spectral windows.
265  std::set<uInt> getSQLDSpw();
266 
267  // Get the scan numbers which fail into the specified time range (center-tol to center+tol),
268  // inclusive. A negative value of obsID and/or arrayID indicates that all observation IDs
269  // and/or all arrayIDs should be used.
270  std::set<Int> getScansForTimes(
271  Double center, Double tol, Int obsID, Int arrayID
272  ) const;
273 
274  // Get the times for the specified scans
275  std::set<Double> getTimesForScans(std::set<ScanKey> scans) const;
276 
277  // get the times for the specified scan.
278  // The return values come from the TIME column.
279  std::set<Double> getTimesForScan(const ScanKey& scan) const;
280 
281  std::map<uInt, std::set<Double> > getSpwToTimesForScan(const ScanKey& scan) const;
282 
283  // get the time range for the specified scan. The pair will contain
284  // the start and stop time of the scan, determined from min(TIME(x)-0.5*INTERVAL(x)) and
285  // max(TIME(x)-0.5*INTERVAL(x))
286  std::pair<Double, Double> getTimeRangeForScan(const ScanKey& scanKey) const;
287 
288  // get the map of scans to time ranges.
289  SHARED_PTR<const std::map<ScanKey, std::pair<Double,Double> > > getScanToTimeRangeMap() const;
290 
291  // get the times for the specified scan
292  // std::set<Double> getTimesForScan(const uInt scan) const;
293 
294  // get the stateIDs associated with the specified scan. If obsID and/or arrayID
295  // is negative, all observation IDs and/or array IDs will be used.
296  std::set<Int> getStatesForScan(Int obsID, Int arrayID, Int scan) const;
297 
298  // get the position of the specified antenna relative to the observatory position.
299  // the three vector returned represents the longitudinal, latitudinal, and elevation
300  // offsets (elements 0, 1, and 2 respectively). The longitude and latitude offsets are
301  // measured along the surface of a sphere centered at the earth's center and whose surface
302  // intersects the position of the observatory.
303  QVD getAntennaOffset(uInt which);
304 
305  QVD getAntennaOffset(const String& name);
306 
307  vector<QVD > getAntennaOffsets() const;
308 
309  // get the positions of the specified antennas. If <src>which</src> is empty, return
310  // all antenna positions.
311  vector<MPosition> getAntennaPositions(
312  const vector<uInt>& which=std::vector<uInt>(0)
313  ) const;
314 
315  // <src>names</src> cannot be empty.
316  vector<MPosition> getAntennaPositions(const vector<String>& names);
317 
318  // the first key in the returned map is the spectral window ID, the second is
319  // the average interval for the specified scan for that spw.
320  std::map<uInt, Double> getAverageIntervalsForScan(const ScanKey& scan) const;
321 
322  // the first key in the returned map is the spectral window ID, the second is
323  // the average interval for the specified sub scan for that spw.
324  std::map<uInt, Quantity> getAverageIntervalsForSubScan(const SubScanKey& subScan) const;
325 
326  vector<uInt> getBBCNos() const;
327 
328  std::map<uInt, std::set<uInt> > getBBCNosToSpwMap(SQLDSwitch sqldSwitch);
329 
330  vector<vector<Double> > getEdgeChans();
331  //Get the phase direction for a given field id and epoch
332  //interpolate polynomial if it is the field id is such or use ephemerides table
333  //if that is attached to that field id
335  const MEpoch& ep=MEpoch(Quantity(0.0, Unit("s")))) const ;
336 
337  // Get the reference direction for a given field ID and epoch interpolate
338  // polynomial if it is the field ID is such or use ephemerides table
339  // if that is attached to that field ID
341  const uInt fieldID,
342  const MEpoch& ep=MEpoch(Quantity(0.0, Unit("s")))
343  ) const;
344 
345  // get the field IDs for the specified field name. Case insensitive.
346  std::set<Int> getFieldIDsForField(const String& field) const;
347 
348  // get a list of the field names in the order in which they appear in the FIELD table.
349  vector<String> getFieldNames() const;
350 
351  // get field IDs associated with the specified scan number.
352  std::set<Int> getFieldsForScan(const ScanKey& scan) const;
353 
354  // get the field IDs associated with the specified scans
355  std::set<Int> getFieldsForScans(
356  const std::set<Int>& scans, Int obsID, Int arrayID
357  ) const;
358 
359  // get the field IDs associated with the specified scans
360  std::set<Int> getFieldsForScans(const std::set<ScanKey>& scans) const;
361 
362  // get the field IDs associated with the specified intent.
363  std::set<Int> getFieldsForIntent(const String& intent);
364 
365  // get the field IDs associated with the specified source.
366  std::set<Int> getFieldsForIntent(uInt sourceID) const;
367 
368  std::map<Int, std::set<Int> > getFieldsForSourceMap() const;
369 
370  std::map<Int, std::set<String> > getFieldNamesForSourceMap() const;
371 
372  // get the field names associated with the specified field IDs. If <src>fieldIDs</src>
373  // is empty, a vector of all the field names is returned.
374  vector<String> getFieldNamesForFieldIDs(const vector<uInt>& fieldIDs);
375 
376  // Get the fields which fail into the specified time range (center-tol to center+tol)
377  std::set<Int> getFieldsForTimes(Double center, Double tol);
378 
379  // get telescope names in the order they are listed in the OBSERVATION table. These are
380  // the telescopes (observatories), not the antenna names.
381  vector<String> getObservatoryNames();
382 
383  // get the position of the specified telescope (observatory).
385 
386  // get the phase directions from the FIELD subtable
387  vector<MDirection> getPhaseDirs() const;
388 
389  // get all ScanKeys in the dataset
390  std::set<ScanKey> getScanKeys() const;
391 
392  // get all ScanKeys in the dataset that have the specified <src>arrayKey</src>.
393  // If negative values for either the obsID and/or arrayID portions of the ArrayKey
394  // indicate that all obsIDs and/or arrayIDs should be used.
395  std::set<ScanKey> getScanKeys(const ArrayKey& arrayKey) const;
396 
397  // get the scans associated with the specified intent
398  std::set<Int> getScansForIntent(
399  const String& intent, Int obsID, Int arrayID
400  ) const;
401 
402  // get the scan numbers associated with the specified field ID.
403  std::set<Int> getScansForFieldID(Int fieldID, Int obsID, Int arrayID) const;
404 
405  // get the scan numbers associated with the specified field. Subclasses should not implement or override.
406  std::set<Int> getScansForField(const String& field, Int obsID, Int arrayID) const;
407 
408  // The first value of the pair is spw, the second is polarization ID.
409  std::map<std::pair<uInt, uInt>, uInt> getSpwIDPolIDToDataDescIDMap() const;
410 
411  // get a map of the spwIDs to spw names from the spw table
412  vector<String> getSpwNames() const;
413 
414  // get all the spws associated with the data description IDs listed in the main table.
415  // This will not correspond to a list of the row numbers in the SPECTRAL_WINDOW table
416  // if there are data description IDs that are not in the main table.
417  std::set<uInt> getSpwIDs() const;
418 
419  // get all sub scan keys for the specified array key.
420  std::set<SubScanKey> getSubScanKeys(const ArrayKey& arrayKey) const;
421 
422  // get the sub scan properties for the specified sub scan.
423 
425  const SubScanKey& subScan, Bool showProgress=False
426  ) const;
427 
428  SHARED_PTR<const std::map<SubScanKey, SubScanProperties> > getSubScanProperties(
429  Bool showProgress=False
430  ) const;
431 
432  // If True, force the subscan properties structure to be
433  // cached regardless of the stipulations on the maximum cache. Normally,
434  // the subscan properties structure is small compared to the size of any
435  // one column that is necessary to create it, and since creating this
436  // structure can be very expensive, especially for large datasets, it
437  // is often a good idea to cache it if it will be accessed many times.
439 
440  // get a data structure, consumable by users, representing a summary of the dataset
441  Record getSummary() const;
442 
443  // get the times for which the specified field was observed
444  std::set<Double> getTimesForField(Int fieldID);
445 
446  // get the time stamps associated with the specified intent
447  std::set<Double> getTimesForIntent(const String& intent) const;
448  Bool hasBBCNo() const;
449 
450  //std::map<Double, Double> getExposuresForTimes() const;
451 
452  // get the unique baselines in the MS. These are not necessarily every combination of the
453  // n(n-1)/2 possible antenna pairs, but rather the number of unique baselines represented in
454  // the main MS table, which in theory can be less than n(n-1)/2 (for example if samples for
455  // certain antenna pairs are not recorded. The returned Matrix is nAnts x nAnts in size. Pairs
456  // that are true represent baselines represented in the main MS table.
458 
459  // get the number of unique baselines represented in the main MS table which in theory can be
460  // less than n*(n-1)/2. If <src>includeAutoCorrelation</src> is True, include autocorrelation
461  // "baselines" in the enumeration.
462  virtual uInt nBaselines(Bool includeAutoCorrelation=False);
463 
464  // get the effective total exposure time. This is the effective time spent collecting unflagged data.
466 
467  // get the number of scans in the dataset
468  uInt nScans();
469 
470  // get the number of observations (from the OBSERVATIONS table) in the dataset
471  uInt nObservations() const;
472 
473  // get the contents of the OBSERVER column from the OBSERVATIONS table
474  vector<String> getObservers() const;
475 
476  // get the contents of the PROJECT column from the OBSERVATIONS table
477  vector<String> getProjects() const;
478 
479  // get the contents of the SCHEDULE column from the OBSERVATIONS table
480  // Note that the embedded vectors may have different lengths
481  vector<vector<String> > getSchedules() const;
482 
483  // get the time ranges from the OBSERVATION table
484  vector<std::pair<MEpoch, MEpoch> > getTimeRangesOfObservations() const;
485 
486  // get the number of arrays (from the ARRAY table) in the dataset
487  uInt nArrays();
488 
489  // get the number of data description IDs (from the DATA_DESCRIPTION table)
490  uInt nDataDescriptions() const;
491 
492  // get the number of unflagged rows
493  Double nUnflaggedRows() const;
494 
496 
498  CorrelationType cType, Int arrayID, uInt observationID,
499  Int scanNumber, uInt fieldID
500  ) const;
501 
502  Double nUnflaggedRows(CorrelationType cType, Int fieldID) const;
503 
504  inline Float getCache() const { return _cacheMB;}
505 
506  vector<Double> getBandWidths() const;
507 
508  vector<Quantity> getCenterFreqs() const;
509 
510  // get the effective bandwidth for each channel. Each element in
511  // the returned vector represents a separate spectral window, with
512  // ID given by its location in the vector. If asVelWidths is True,
513  // convert the values to velocity widths.
514  vector<QVD> getChanEffectiveBWs(Bool asVelWidths) const;
515 
516  vector<QVD > getChanFreqs() const;
517 
518  // get the resolution for each channel. Each element in
519  // the returned vector represents a separate spectral window, with
520  // ID given by its location in the vector. If asVelWidths is True,
521  // convert the values to velocity widths.
522  vector<QVD> getChanResolutions(Bool asVelWidths) const;
523 
524  vector<QVD > getChanWidths() const;
525 
526  vector<Quantity> getMeanFreqs() const;
527 
528  vector<Int> getNetSidebands() const;
529 
530  vector<MFrequency> getRefFreqs() const;
531 
532  vector<uInt> nChans() const;
533 
534  uInt nPol();
535 
536  // get a map of data desc ID, scan number pair to exposure time for the first time
537  // for that data desc ID, scan number pair
538  vector<std::map<Int, Quantity> > getFirstExposureTimeMap();
539 
540  // get polarization IDs for the specified scan and spwid
541  std::set<uInt> getPolarizationIDs(uInt obsID, Int arrayID, Int scan, uInt spwid) const;
542 
543  // get unique field IDs that exist in the main table.
544  std::set<Int> getUniqueFiedIDs() const;
545 
546  // get the pointing directions associated with antenna1 and antenna2 for
547  // the specified row of the main MS table
548  std::pair<MDirection, MDirection> getPointingDirection(
549  Int& ant1, Int& ant2, Double& time, uInt row,
550  Bool interpolate=false, Int initialguess=0
551  ) const;
552 
553  // get the time range for the entire dataset. min(TIME(x) - 0.5*INTERVAL(x)) to
554  // max(TIME(x) + 0.5*INTERVAL(x))
555  std::pair<Double, Double> getTimeRange() const;
556 
557  // Number of unique values from SOURCE.SOURCE_ID
559 
560 private:
561 
562  struct SpwProperties {
567  // The sum of all channel frequencies divided by the number of channels
569  // The mean of the low frequency extent of the lowest frequency channel and
570  // the high frequency extend of the highest frequency channel. Often, but not
571  // necessarily, the same as meanfreq
574  // The center frequencies of the two channels at the edges of the window
575  vector<Double> edgechans;
577  // from the REF_FREQUENCY column
580  // EFFECTIVE_BANDWIDTH
582  // RESOLUTION
584  };
585 
586  // represents non-primary key data for a SOURCE table row
589  SHARED_PTR<vector<MFrequency> > restfreq;
590  SHARED_PTR<vector<String> > transition;
591  };
592 
593  // The general pattern is that a mutable gets set only once, on demand, when its
594  // setter is called for the first time. If this pattern is broken, defective behavior
595  // will occur.
596 
598  mutable Float _cacheMB;
602  mutable std::map<ScanKey, std::set<uInt> > _scanToSpwsMap, _scanToDDIDsMap;
604  std::map<Int, std::set<uInt> > _fieldToSpwMap;
605  mutable std::map<ScanKey, std::set<Int> > _scanToStatesMap, _scanToFieldsMap, _scanToAntennasMap;
606  mutable std::map<Int, std::set<Int> > _fieldToStatesMap, _stateToFieldsMap, _sourceToFieldsMap;
607  mutable std::map<std::pair<uInt, uInt>, uInt> _spwPolIDToDataDescIDMap;
608  mutable std::map<String, uInt> _antennaNameToIDMap;
609  mutable SHARED_PTR<std::map<SubScanKey, SubScanProperties> > _subScanProperties;
610 
611  mutable std::map<String, std::set<Int> > _intentToFieldIDMap;
612  mutable std::map<String, std::set<ScanKey> > _intentToScansMap;
613  mutable std::map<String, std::set<SubScanKey> > _intentToSubScansMap;
614  mutable SHARED_PTR<const std::map<ScanKey, std::pair<Double, Double> > > _scanToTimeRangeMap;
615  mutable std::map<std::pair<ScanKey, uInt>, Double> _scanSpwToIntervalMap;
616  mutable std::map<std::pair<ScanKey, uInt>, std::set<Double> > _scanSpwToTimesMap;
617  mutable std::map<std::pair<ScanKey, uInt>, std::set<uInt> > _scanSpwToPolIDMap;
618  mutable std::set<String> _uniqueIntents;
619  mutable std::set<Int> _uniqueFieldIDs, _uniqueStateIDs;
620  mutable std::set<uInt> _avgSpw, _tdmSpw, _fdmSpw, _wvrSpw, _sqldSpw;
621  mutable SHARED_PTR<Vector<Int> > _antenna1, _antenna2, _scans, _fieldIDs,
623  mutable SHARED_PTR<std::map<SubScanKey, uInt> > _subScanToNACRowsMap, _subScanToNXCRowsMap;
624  mutable SHARED_PTR<QVD> _intervals;
625  mutable SHARED_PTR<vector<uInt> > _fieldToNACRowsMap, _fieldToNXCRowsMap;
626  mutable std::map<ScanKey, std::set<String> > _scanToIntentsMap;
627  mutable SHARED_PTR<const std::map<SubScanKey, std::set<String> > > _subScanToIntentsMap;
628  mutable vector<std::set<String> > _stateToIntentsMap, _spwToIntentsMap, _fieldToIntentsMap;
629  mutable vector<SpwProperties> _spwInfo;
630  mutable vector<std::set<Int> > _spwToFieldIDsMap, _obsToArraysMap;
631  mutable vector<std::set<ScanKey> > _spwToScansMap, _ddidToScansMap, _fieldToScansMap;
632 
633  mutable vector<String> _fieldNames, _antennaNames, _observatoryNames,
635  mutable vector<vector<String> > _schedules;
636  mutable vector<vector<Int> > _corrTypes;
637  mutable vector<Array<Int> >_corrProds;
638 
639  mutable SHARED_PTR<Vector<Double> > _times;
640  mutable SHARED_PTR<QVD > _exposures;
641  mutable SHARED_PTR<std::map<ScanKey, std::set<Double> > > _scanToTimesMap;
642  std::map<String, std::set<uInt> > _intentToSpwsMap;
643  mutable std::map<String, std::set<Double> > _intentToTimesMap;
644 
645  SHARED_PTR<std::map<Int, std::set<Double> > > _fieldToTimesMap;
646  SHARED_PTR<std::map<Double, std::set<Int> > > _timeToFieldsMap;
647 
648  mutable vector<MPosition> _observatoryPositions, _antennaPositions;
649  mutable vector<QVD > _antennaOffsets;
654  mutable SHARED_PTR<vector<Double> > _unflaggedFieldNACRows, _unflaggedFieldNXCRows;
655  mutable SHARED_PTR<std::map<SubScanKey, Double> > _unflaggedSubScanNACRows, _unflaggedSubScanNXCRows;
657  const vector<const Table*> _taqlTempTable;
658  mutable SHARED_PTR<ArrayColumn<Bool> > _flagsColumn;
659 
661  vector<std::map<Int, Quantity> > _firstExposureTimeMap;
663 
664  mutable std::set<ArrayKey> _arrayKeys;
665  mutable std::set<ScanKey> _scanKeys;
666  mutable std::set<SubScanKey> _subscans;
667  mutable std::map<ScanKey, std::set<SubScanKey> > _scanToSubScans;
668  mutable std::map<ArrayKey, std::set<SubScanKey> > _arrayToSubScans;
669 
670  mutable vector<std::pair<MEpoch, MEpoch> > _timeRangesForObs;
671 
672  mutable vector<MDirection> _phaseDirs, _sourceDirs;
673 
674  mutable vector<std::pair<Quantity, Quantity> > _properMotions;
675 
676  mutable map<SourceKey, SourceProperties> _sourceInfo;
677 
678  // disallow copy constructor and = operator
679  MSMetaData(const MSMetaData&);
681 
682  // This comment from thunter in the original ValueMapping python class
683  // # Determine the number of polarizations for the first OBSERVE_TARGET intent.
684  // # Used by plotbandpass for BPOLY plots since the number of pols cannot be inferred
685  // # correctly from the caltable alone. You cannot not simply use the first row, because
686  // # it may be a pointing scan which may have different number of polarizations than what
687  // # the TARGET and BANDPASS calibrator will have.
688  // # -- T. Hunter
689  // uInt _getNumberOfPolarizations();
690 
691  void _setSpwInfo(const MeasurementSet& ms);
692 
693  // set metadata from OBSERVATION table
694  void _setObservation(const MeasurementSet& ms);
695 
696  Bool _cacheUpdated(const Float incrementInBytes) const;
697 
698  void _checkField(uInt fieldID) const;
699 
700  void _checkScan(const ScanKey& key) const;
701 
702  void _checkScans(const std::set<ScanKey>& scanKeys) const;
703 
704  void _checkSubScan(const SubScanKey& key) const;
705 
706  static void _checkTolerance(const Double tol);
707 
708  void _createScanRecords(
709  Record& parent, const ArrayKey& arrayKey,
710  const std::map<SubScanKey, SubScanProperties>& subScanProps
711  ) const;
712 
714  Record& parent, uInt& scanNRows, std::set<Int>& antennasForScan,
715  const ScanKey& scanKey, const std::map<SubScanKey, SubScanProperties>& subScanProps
716  ) const;
717 
718  static void _createTimeStampRecords(
719  Record& parent,
720  const SubScanProperties& subScanProps
721  );
722 
723  // convert a QVD in frequency units to velocity units using
724  // the give reference frequency. No explicit checking is done
725  // for unit correctness of the inputs.
726  static QVD _freqWidthToVelWidth(const QVD& v, const Quantity& refFreq);
727 
728  vector<String> _getAntennaNames(
729  std::map<String, uInt>& namesToIDsMap
730  ) const;
731 
732  vector<MPosition> _getAntennaPositions() const;
733 
734  void _getAntennas(
735  SHARED_PTR<Vector<Int> >& ant1,
736  SHARED_PTR<Vector<Int> >& ant2
737  ) const;
738 
739  SHARED_PTR<Vector<Int> > _getArrayIDs() const;
740 
741  std::map<ArrayKey, std::set<SubScanKey> > _getArrayKeysToSubScanKeys() const;
742 
743  SHARED_PTR<Vector<Int> > _getDataDescIDs() const;
744 
745  SHARED_PTR<QVD > _getExposureTimes() const;
746 
747  // If there are no intents, then fieldToIntentsMap will be of length
748  // nFields() and all of its entries will be the empty set, and
749  // intentToFieldsMap will be empty
751  vector<std::set<String> >& fieldToIntentsMap,
752  std::map<String, std::set<Int> >& intentToFieldsMap
753  );
754 
756  vector<std::set<ScanKey> >& fieldToScansMap,
757  std::map<ScanKey, std::set<Int> >& scanToFieldsMap
758  ) const;
759 
761  std::map<Int, std::set<uInt> >& fieldToSpwMap,
762  vector<std::set<Int> >& spwToFieldMap
763  );
764 
766  std::map<Int, std::set<Int> >& fieldToStatesMap,
767  std::map<Int, std::set<Int> >& stateToFieldsMap
768  );
769 
771  SHARED_PTR<std::map<Int, std::set<Double> > >& fieldToTimesMap,
772  SHARED_PTR<std::map<Double, std::set<Int> > >& timesToFieldMap
773  );
774 
775  SHARED_PTR<Vector<Int> > _getFieldIDs() const;
776 
777  SHARED_PTR<ArrayColumn<Bool> > _getFlags() const;
778 
779  std::map<String, std::set<Double> > _getIntentsToTimesMap() const;
780 
781  SHARED_PTR<QVD> _getIntervals() const;
782 
783  SHARED_PTR<Vector<Int> > _getObservationIDs() const;
784 
785  SHARED_PTR<Vector<Int> > _getScans() const;
786 
787  vector<std::set<String> > _getSpwToIntentsMap();
788 
789  SHARED_PTR<Vector<Int> > _getStateIDs() const;
790 
791  SHARED_PTR<Vector<Double> > _getTimes() const;
792 
793  //SHARED_PTR<std::map<Double, TimeStampProperties> > _getTimeStampProperties() const;
794 
795  Bool _hasIntent(const String& intent) const;
796 
797  Bool _hasFieldID(Int fieldID) const;
798 
799  Bool _hasStateID(Int stateID) const;
800 
801  void _hasAntennaID(Int antennaID);
802 
803  std::map<Double, Double> _getTimeToTotalBWMap(
804  const Vector<Double>& times, const Vector<Int>& ddIDs
805  );
806 
808  const ROMSPointingColumns& pCols, const Int& index,
809  const Double& time
810  ) const;
811 
812  //map<SubScanKey, Quantity> _getMeanExposureTimes() const;
813 
814  vector<std::set<Int> > _getObservationIDToArrayIDsMap() const;
815 
816  vector<MPosition> _getObservatoryPositions();
817 
818  void _getRowStats(
819  uInt& nACRows, uInt& nXCRows,
820  std::map<SubScanKey, uInt>*& subScanToNACRowsMap,
821  std::map<SubScanKey, uInt>*& subScanToNXCRowsMap,
822  vector<uInt>*& fieldToNACRowsMap,
823  vector<uInt>*& fieldToNXCRowsMap
824  ) const;
825 
826  void _getRowStats(
827  uInt& nACRows, uInt& nXCRows,
828  SHARED_PTR<std::map<SubScanKey, uInt> >& scanToNACRowsMap,
829  SHARED_PTR<std::map<SubScanKey, uInt> >& scanToNXCRowsMap,
830  SHARED_PTR<vector<uInt> >& fieldToNACRowsMap,
831  SHARED_PTR<vector<uInt> >& fieldToNXCRowsMap
832  ) const;
833 
834  // get the scan keys in the specified set that have the associated arrayKey
835  std::set<ScanKey> _getScanKeys(
836  const std::set<ScanKey>& scanKeys, const ArrayKey& arrayKey
837  ) const;
838 
839  // get all valid scan numbers associated with the specified arrayKey
840  std::set<Int> _getScanNumbers(const ArrayKey& arrayKey) const;
841 
843  std::map<ScanKey, std::set<uInt> >& scanToDDIDMap,
844  vector<std::set<ScanKey> >& ddIDToScanMap
845  ) const;
846 
848  std::map<ScanKey, std::set<String> >& scanToIntentsMap,
849  std::map<String, std::set<ScanKey> >& intentToScansMap
850  ) const;
851 
852  void _getScansAndSpwMaps(
853  std::map<ScanKey, std::set<uInt> >& scanToSpwMap,
854  vector<std::set<ScanKey> >& spwToScanMap
855  ) const;
856 
857  std::map<ScanKey, std::set<Int> > _getScanToAntennasMap() const;
858 
859  std::map<ScanKey, std::set<Int> > _getScanToStatesMap() const;
860 
861  std::map<ScanKey, std::set<SubScanKey> > _getScanToSubScansMap() const;
862 
863  SHARED_PTR<std::map<ScanKey, std::set<Double> > > _getScanToTimesMap() const;
864 
865  map<SourceKey, SourceProperties> _getSourceInfo() const;
866 
867  vector<SpwProperties> _getSpwInfo(
868  std::set<uInt>& avgSpw, std::set<uInt>& tdmSpw,
869  std::set<uInt>& fdmSpw, std::set<uInt>& wvrSpw,
870  std::set<uInt>& sqldSpw
871  ) const;
872 
874  vector<std::set<String> >& spwToIntentsMap,
875  std::map<String, std::set<uInt> >& intentToSpwsMap
876  );
877 
878  vector<SpwProperties> _getSpwInfo2(
879  std::set<uInt>& avgSpw, std::set<uInt>& tdmSpw, std::set<uInt>& fdmSpw,
880  std::set<uInt>& wvrSpw, std::set<uInt>& sqldSpw
881  ) const;
882 
884  vector<std::set<String> >& statesToIntentsMap,
885  std::set<String>& uniqueIntents
886  ) const;
887 
888  vector<String> _getStationNames();
889 
891  SHARED_PTR<const std::map<SubScanKey, std::set<String> > >& subScanToIntentsMap,
892  std::map<String, std::set<SubScanKey> >& intentToSubScansMap
893  ) const;
894 
895  std::set<SubScanKey> _getSubScanKeys() const;
896 
897  // get subscans related to the given scan
898  std::set<SubScanKey> _getSubScanKeys(const ScanKey& scanKey) const;
899 
900  //In scanSpwToIntervalMap, the key is a scan, spw pair.
902  SHARED_PTR<const std::map<ScanKey, std::pair<Double, Double> > >& scanToTimeRangeMap,
903  std::map<std::pair<ScanKey, uInt>, Double>& scanSpwToIntervalMap,
904  std::map<std::pair<ScanKey, uInt>, std::set<Double> >& scanSpwToTimesMap
905  ) const;
906 
908  Double& nACRows, Double& nXCRows,
909  SHARED_PTR<std::map<SubScanKey, Double> >& subScanToNACRowsMap,
910  SHARED_PTR<std::map<SubScanKey, Double> >& subScanToNXCRowsMap,
911  SHARED_PTR<vector<Double> >& fieldToNACRowsMap,
912  SHARED_PTR<vector<Double> >& fieldToNXCRowsMap
913  ) const;
914 
916  Double& nACRows, Double& nXCRows,
917  vector<Double>*& fieldNACRows, vector<Double>*& fieldNXCRows,
918  std::map<SubScanKey, Double>*& scanNACRows,
919  std::map<SubScanKey, Double>*& scanNXCRows
920  ) const;
921 
922  static uInt _sizeof(const std::map<Double, MSMetaData::TimeStampProperties> & m);
923 
924  template <class T>
925  static uInt _sizeof(const std::map<T, std::set<String> >& m);
926 
927  template <class T, class U>
928  static uInt _sizeof(const std::map<T, std::set<U> >& m);
929 
930  template <class T, class U>
931  static uInt _sizeof(const std::map<T, U>& m);
932 
933  static uInt _sizeof(const vector<std::set<String> >& m);
934 
935  static uInt _sizeof(const vector<String>& m);
936 
937  static uInt _sizeof(const vector<vector<String> >& m);
938 
939  template <class T>
940  static uInt _sizeof(const vector<T>& v);
941 
942  static uInt _sizeof(const QVD& m);
943 
944  template <class T>
945  static uInt _sizeof(const vector<std::set<T> >& v);
946 
947  template <class T> static uInt _sizeof(const std::map<String, std::set<T> >& map);
948 
949  static uInt _sizeof(const vector<std::map<Int, Quantity> >& map);
950 
951  static uInt _sizeof(const std::map<std::pair<Int, uInt>, std::set<uInt> >& map);
952 
953  static std::map<Int, uInt> _toUIntMap(const Vector<Int>& v);
954 
955 };
956 
957 
958 
959 }
960 
961 #endif
vector< QVD > getAntennaOffsets() const
std::set< String > getIntentsForSubScan(const SubScanKey &subScan) const
std::map< Int, std::set< String > > getFieldNamesForSourceMap() const
SHARED_PTR< Vector< Int > > _fieldIDs
Definition: MSMetaData.h:621
std::set< SubScanKey > _getSubScanKeys() const
SHARED_PTR< const std::map< SubScanKey, std::set< String > > > _subScanToIntentsMap
Definition: MSMetaData.h:627
std::set< Int > getFieldIDsForField(const String &field) const
get the field IDs for the specified field name.
std::map< uInt, std::set< Double > > getSpwToTimesForScan(const ScanKey &scan) const
SHARED_PTR< Vector< Int > > _antenna2
Definition: MSMetaData.h:621
std::set< Int > getScansForSpw(uInt spw, Int obsID, Int arrayID) const
get the set of scan numbers for the specified spectral window.
A Measure: astronomical direction.
Definition: MDirection.h:174
#define SHARED_PTR
Definition: CountedPtr.h:41
MFrequency reffreq
from the REF_FREQUENCY column
Definition: MSMetaData.h:578
SHARED_PTR< Vector< Int > > _getStateIDs() const
SubScanProperties getSubScanProperties(const SubScanKey &subScan, Bool showProgress=False) const
get the sub scan properties for the specified sub scan.
SHARED_PTR< Vector< Double > > _times
Definition: MSMetaData.h:639
SHARED_PTR< ArrayColumn< Bool > > _flagsColumn
Definition: MSMetaData.h:658
vector< uInt > getBBCNos() const
map< uInt, Quantity > meanInterval
the key is the spwID, the value is the meanInterval for the subscan and that spwID ...
Definition: MSMetaData.h:83
A Measure: position on Earth.
Definition: MPosition.h:79
vector< std::set< Int > > _getObservationIDToArrayIDsMap() const
map<SubScanKey, Quantity> _getMeanExposureTimes() const;
vector< std::set< Int > > _obsToArraysMap
Definition: MSMetaData.h:630
std::set< uInt > getSpwIDs() const
get all the spws associated with the data description IDs listed in the main table.
int Int
Definition: aipstype.h:47
std::set< SubScanKey > _subscans
Definition: MSMetaData.h:666
void _getSubScansAndIntentsMaps(SHARED_PTR< const std::map< SubScanKey, std::set< String > > > &subScanToIntentsMap, std::map< String, std::set< SubScanKey > > &intentToSubScansMap) const
void setForceSubScanPropsToCache(Bool b)
If True, force the subscan properties structure to be cached regardless of the stipulations on the ma...
Definition: MSMetaData.h:438
void _checkSubScan(const SubScanKey &key) const
std::set< uInt > _avgSpw
Definition: MSMetaData.h:620
vector< vector< Int > > _corrTypes
Definition: MSMetaData.h:636
std::set< Int > getStatesForScan(Int obsID, Int arrayID, Int scan) const
get the times for the specified scan std::set<Double> getTimesForScan(const uInt scan) const; ...
std::map< String, std::set< Double > > _getIntentsToTimesMap() const
vector< uInt > _dataDescIDToSpwMap
Definition: MSMetaData.h:603
vector< MPosition > _observatoryPositions
Definition: MSMetaData.h:648
static QVD _freqWidthToVelWidth(const QVD &v, const Quantity &refFreq)
convert a QVD in frequency units to velocity units using the give reference frequency.
void _getFieldsAndStatesMaps(std::map< Int, std::set< Int > > &fieldToStatesMap, std::map< Int, std::set< Int > > &stateToFieldsMap)
std::pair< Double, Double > getTimeRangeForScan(const ScanKey &scanKey) const
get the time range for the specified scan.
vector< MPosition > _getObservatoryPositions()
std::set< Int > getFieldsForIntent(const String &intent)
get the field IDs associated with the specified intent.
vector< String > getObservatoryNames()
get telescope names in the order they are listed in the OBSERVATION table.
std::map< String, std::set< uInt > > _intentToSpwsMap
Definition: MSMetaData.h:642
vector< uInt > getAntennaIDs(const vector< String > &antennaNames) const
void _getFieldsAndScansMaps(vector< std::set< ScanKey > > &fieldToScansMap, std::map< ScanKey, std::set< Int > > &scanToFieldsMap) const
std::map< Int, std::set< Int > > _stateToFieldsMap
Definition: MSMetaData.h:606
std::map< Double, TimeStampProperties > timeProps
Definition: MSMetaData.h:88
uInt nStates() const
number of unique states (number of rows from the STATE table)
SHARED_PTR< const std::map< SubScanKey, std::set< String > > > getSubScanToIntentsMap() const
std::map< ScanKey, std::set< Int > > _getScanToAntennasMap() const
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1637
vector< MDirection > _phaseDirs
Definition: MSMetaData.h:672
std::map< String, std::set< Int > > _intentToFieldIDMap
Definition: MSMetaData.h:611
vector< Quantity > getMeanFreqs() const
vector< MDirection > getSourceDirections() const
SOURCE.DIRECTION.
std::map< Double, Double > _getTimeToTotalBWMap(const Vector< Double > &times, const Vector< Int > &ddIDs)
std::set< Int > getUniqueFiedIDs() const
get unique field IDs that exist in the main table.
std::set< ScanKey > _getScanKeys(const std::set< ScanKey > &scanKeys, const ArrayKey &arrayKey) const
get the scan keys in the specified set that have the associated arrayKey
vector< std::pair< Quantity, Quantity > > _properMotions
Definition: MSMetaData.h:674
std::map< ScanKey, std::set< SubScanKey > > _scanToSubScans
Definition: MSMetaData.h:667
void _getStateToIntentsMap(vector< std::set< String > > &statesToIntentsMap, std::set< String > &uniqueIntents) const
vector< std::set< ScanKey > > _fieldToScansMap
Definition: MSMetaData.h:631
std::map< ScanKey, std::set< Int > > _scanToFieldsMap
Definition: MSMetaData.h:605
void _setSpwInfo(const MeasurementSet &ms)
This comment from thunter in the original ValueMapping python class Determine the number of polarizat...
MSMetaData(const MeasurementSet *const &ms, const Float maxCacheSizeMB)
construct an object which stores a pointer to the MS and queries the MS only as necessary.
vector< QVD > getChanWidths() const
std::set< uInt > getFDMSpw()
ALMA-specific.
std::set< uInt > _tdmSpw
Definition: MSMetaData.h:620
Record getSummary() const
get a data structure, consumable by users, representing a summary of the dataset
std::set< uInt > getChannelAvgSpw()
ALMA-specific.
void _getTimesAndInvervals(SHARED_PTR< const std::map< ScanKey, std::pair< Double, Double > > > &scanToTimeRangeMap, std::map< std::pair< ScanKey, uInt >, Double > &scanSpwToIntervalMap, std::map< std::pair< ScanKey, uInt >, std::set< Double > > &scanSpwToTimesMap) const
In scanSpwToIntervalMap, the key is a scan, spw pair.
Quantum< Double > Quantity
Definition: Quantum.h:38
SHARED_PTR< const std::map< ScanKey, std::pair< Double, Double > > > _scanToTimeRangeMap
Definition: MSMetaData.h:614
vector< std::pair< MEpoch, MEpoch > > getTimeRangesOfObservations() const
get the time ranges from the OBSERVATION table
std::set< String > getIntentsForScan(const ScanKey &scan) const
Bool _hasFieldID(Int fieldID) const
vector< String > getFieldNames() const
get a list of the field names in the order in which they appear in the FIELD table.
std::set< uInt > _wvrSpw
Definition: MSMetaData.h:620
SHARED_PTR< Vector< Int > > _arrayIDs
Definition: MSMetaData.h:621
uInt nUniqueSourceIDsFromSourceTable() const
Number of unique values from SOURCE.SOURCE_ID.
std::map< String, std::set< uInt > > getIntentToSpwsMap()
std::set< uInt > getPolarizationIDs(uInt obsID, Int arrayID, Int scan, uInt spwid) const
get polarization IDs for the specified scan and spwid
MDirection _getInterpolatedDirection(const ROMSPointingColumns &pCols, const Int &index, const Double &time) const
vector< Int > _field_sourceIDs
Definition: MSMetaData.h:662
vector< String > _projects
Definition: MSMetaData.h:633
vector< std::set< String > > _spwToIntentsMap
Definition: MSMetaData.h:628
SHARED_PTR< Vector< Int > > _dataDescIDs
Definition: MSMetaData.h:621
std::map< String, std::set< Double > > _intentToTimesMap
Definition: MSMetaData.h:643
vector< String > _observers
Definition: MSMetaData.h:633
vector< QVD > _antennaOffsets
Definition: MSMetaData.h:649
vector< String > _sourceNames
Definition: MSMetaData.h:633
void _getScansAndDDIDMaps(std::map< ScanKey, std::set< uInt > > &scanToDDIDMap, vector< std::set< ScanKey > > &ddIDToScanMap) const
std::map< Int, std::set< uInt > > _fieldToSpwMap
Definition: MSMetaData.h:604
vector< Array< Int > > _corrProds
Definition: MSMetaData.h:637
Bool _hasIntent(const String &intent) const
SHARED_PTR<std::map<Double, TimeStampProperties> > _getTimeStampProperties() const;.
vector< Int > getSourceTableSourceIDs() const
Get the SOURCE.SOURCE_ID column.
vector< vector< String > > getSchedules() const
get the contents of the SCHEDULE column from the OBSERVATIONS table Note that the embedded vectors ma...
std::set< Int > getScansForIntent(const String &intent, Int obsID, Int arrayID) const
get the scans associated with the specified intent
std::set< ScanKey > _scanKeys
Definition: MSMetaData.h:665
uInt nDataDescriptions() const
get the number of data description IDs (from the DATA_DESCRIPTION table)
vector< std::pair< Quantity, Quantity > > getProperMotions() const
SOURCE.PROPER_MOTION, first value in pair is longitudinal proper motion, second is latiduninal...
void _createScanRecords(Record &parent, const ArrayKey &arrayKey, const std::map< SubScanKey, SubScanProperties > &subScanProps) const
vector< Int > getNetSidebands() const
vector< std::pair< MEpoch, MEpoch > > _timeRangesForObs
Definition: MSMetaData.h:670
std::map< uInt, Double > getAverageIntervalsForScan(const ScanKey &scan) const
the first key in the returned map is the spectral window ID, the second is the average interval for t...
Class to interrogate an MS for metadata. Interrogation happens on demand and resulting metadata are s...
Definition: MSMetaData.h:54
std::pair< MDirection, MDirection > getPointingDirection(Int &ant1, Int &ant2, Double &time, uInt row, Bool interpolate=false, Int initialguess=0) const
get the pointing directions associated with antenna1 and antenna2 for the specified row of the main M...
vector< std::set< ScanKey > > _ddidToScansMap
Definition: MSMetaData.h:631
SHARED_PTR< std::map< ScanKey, std::set< Double > > > _getScanToTimesMap() const
MSMetaData operator=(const MSMetaData &)
vector< String > _observatoryNames
Definition: MSMetaData.h:633
CorrelationType
for retrieving stats
Definition: MSMetaData.h:59
std::set< Int > getScanNumbers(Int obsID, Int arrayID) const
get unique scan numbers
map< SourceKey, SHARED_PTR< vector< String > > > getTransitions() const
get the transitions from the SOURCE table.
std::set< Double > getTimesForIntent(const String &intent) const
get the time stamps associated with the specified intent
std::set< String > getIntentsForField(Int fieldID)
get a set of intents corresponding to a specified field
SHARED_PTR< Vector< Int > > _scans
Definition: MSMetaData.h:621
uInt nScans()
get the number of scans in the dataset
vector< String > getSourceNames() const
SOURCE.NAME.
vector< String > getSpwNames() const
get a map of the spwIDs to spw names from the spw table
vector< std::set< String > > _stateToIntentsMap
Definition: MSMetaData.h:628
vector< String > _getAntennaNames(std::map< String, uInt > &namesToIDsMap) const
SHARED_PTR< Vector< Int > > _antenna1
Definition: MSMetaData.h:621
A Measure: instant in time.
Definition: MEpoch.h:104
std::map< String, uInt > _antennaNameToIDMap
Definition: MSMetaData.h:608
vector< std::set< String > > _getSpwToIntentsMap()
MDirection phaseDirFromFieldIDAndTime(const uInt fieldID, const MEpoch &ep=MEpoch(Quantity(0.0, Unit("s")))) const
Get the phase direction for a given field id and epoch interpolate polynomial if it is the field id i...
const MeasurementSet * _ms
The general pattern is that a mutable gets set only once, on demand, when its setter is called for th...
Definition: MSMetaData.h:597
vector< Int > _numCorrs
Definition: MSMetaData.h:662
std::set< String > getIntentsForSpw(const uInt spw)
get a set of intents corresponding to the specified spectral window
std::set< Int > getFieldsForScan(const ScanKey &scan) const
get field IDs associated with the specified scan number.
void _getSpwsAndIntentsMaps(vector< std::set< String > > &spwToIntentsMap, std::map< String, std::set< uInt > > &intentToSpwsMap)
Quantity _exposureTime
Definition: MSMetaData.h:652
vector< String > _fieldNames
Definition: MSMetaData.h:633
SHARED_PTR< QVD > _exposures
Definition: MSMetaData.h:640
vector< String > getFieldNamesForFieldIDs(const vector< uInt > &fieldIDs)
get the field names associated with the specified field IDs.
Double nUnflaggedRows() const
get the number of unflagged rows
std::map< std::pair< ScanKey, uInt >, std::set< uInt > > _scanSpwToPolIDMap
Definition: MSMetaData.h:617
std::map< ArrayKey, std::set< SubScanKey > > _arrayToSubScans
Definition: MSMetaData.h:668
std::set< Int > getScansForTimes(Double center, Double tol, Int obsID, Int arrayID) const
Get the scan numbers which fail into the specified time range (center-tol to center+tol), inclusive.
vector< uInt > getDataDescIDToPolIDMap() const
vector< QVD > getChanFreqs() const
represents non-primary key data for a SOURCE table row
Definition: MSMetaData.h:587
std::map< std::pair< ScanKey, uInt >, std::set< Double > > _scanSpwToTimesMap
Definition: MSMetaData.h:616
QVD effbw
EFFECTIVE_BANDWIDTH.
Definition: MSMetaData.h:581
vector< std::map< Int, Quantity > > _firstExposureTimeMap
Definition: MSMetaData.h:661
std::map< ScanKey, std::set< Int > > _scanToStatesMap
Definition: MSMetaData.h:605
vector< MPosition > _antennaPositions
Definition: MSMetaData.h:648
map< SourceKey, SourceProperties > _sourceInfo
Definition: MSMetaData.h:676
defines physical units
Definition: Unit.h:189
A Measure: wave characteristics.
Definition: MFrequency.h:161
void _getFieldsAndSpwMaps(std::map< Int, std::set< uInt > > &fieldToSpwMap, vector< std::set< Int > > &spwToFieldMap)
std::set< Int > getFieldsForScans(const std::set< Int > &scans, Int obsID, Int arrayID) const
get the field IDs associated with the specified scans
Bool _cacheUpdated(const Float incrementInBytes) const
std::map< ScanKey, std::set< SubScanKey > > _getScanToSubScansMap() const
vector< String > getObservers() const
get the contents of the OBSERVER column from the OBSERVATIONS table
std::set< Int > _getScanNumbers(const ArrayKey &arrayKey) const
get all valid scan numbers associated with the specified arrayKey
std::map< ScanKey, std::set< Int > > _getScanToStatesMap() const
SHARED_PTR< ArrayColumn< Bool > > _getFlags() const
void _getFieldsAndTimesMaps(SHARED_PTR< std::map< Int, std::set< Double > > > &fieldToTimesMap, SHARED_PTR< std::map< Double, std::set< Int > > > &timesToFieldMap)
SHARED_PTR< QVD > _intervals
Definition: MSMetaData.h:624
virtual uInt nBaselines(Bool includeAutoCorrelation=False)
get the number of unique baselines represented in the main MS table which in theory can be less than ...
SHARED_PTR< std::map< SubScanKey, SubScanProperties > > _subScanProperties
Definition: MSMetaData.h:609
SHARED_PTR< std::map< SubScanKey, Double > > _unflaggedSubScanNXCRows
Definition: MSMetaData.h:655
static uInt _sizeof(const std::map< Double, MSMetaData::TimeStampProperties > &m)
std::set< Int > _uniqueFieldIDs
Definition: MSMetaData.h:619
const Float _maxCacheMB
Definition: MSMetaData.h:599
vector< Int > getFieldTableSourceIDs() const
Get the FIELD.SOURCE_ID column.
std::map< ScanKey, std::set< uInt > > _scanToSpwsMap
Definition: MSMetaData.h:602
uInt nAntennas() const
get the number of antennas in the ANTENNA table
vector< std::map< Int, Quantity > > getFirstExposureTimeMap()
get a map of data desc ID, scan number pair to exposure time for the first time for that data desc ID...
std::set< uInt > getWVRSpw() const
ALMA-specific.
vector< MDirection > _sourceDirs
Definition: MSMetaData.h:672
SHARED_PTR< Vector< Int > > _getDataDescIDs() const
std::set< ScanKey > scanKeys(const std::set< Int > &scans, const ArrayKey &arrayKey)
construct scan keys given a set of scan numbers and an ArrayKey
vector< QVD > getChanEffectiveBWs(Bool asVelWidths) const
get the effective bandwidth for each channel.
std::map< ScanKey, std::set< uInt > > _scanToDDIDsMap
Definition: MSMetaData.h:602
A class to provide easy read-only access to MSPointing columns.
std::map< Int, std::set< Int > > _fieldToStatesMap
Definition: MSMetaData.h:606
const String _taqlTableName
Definition: MSMetaData.h:656
std::map< String, std::set< ScanKey > > getIntentToScansMap()
void _getFieldsAndIntentsMaps(vector< std::set< String > > &fieldToIntentsMap, std::map< String, std::set< Int > > &intentToFieldsMap)
If there are no intents, then fieldToIntentsMap will be of length nFields() and all of its entries wi...
std::set< Int > getScansForField(const String &field, Int obsID, Int arrayID) const
get the scan numbers associated with the specified field.
SHARED_PTR< QVD > _getExposureTimes() const
std::map< uInt, std::set< uInt > > getBBCNosToSpwMap(SQLDSwitch sqldSwitch)
double Double
Definition: aipstype.h:52
void _checkScans(const std::set< ScanKey > &scanKeys) const
SHARED_PTR< Vector< Int > > _getScans() const
std::set< Int > getScansForState(Int stateID, Int obsID, Int arrayID) const
get a set of scan numbers for the specified stateID, obsID, and arrayID.
Bool _hasStateID(Int stateID) const
An ArrayKey is a unique combination of observation ID and array ID Negative values are allowed to ind...
Definition: MSKeys.h:89
vector< Double > edgechans
The center frequencies of the two channels at the edges of the window.
Definition: MSMetaData.h:575
SHARED_PTR< std::map< Int, std::set< Double > > > _fieldToTimesMap
Definition: MSMetaData.h:645
void _hasAntennaID(Int antennaID)
static std::map< Int, uInt > _toUIntMap(const Vector< Int > &v)
MDirection getReferenceDirection(const uInt fieldID, const MEpoch &ep=MEpoch(Quantity(0.0, Unit("s")))) const
Get the reference direction for a given field ID and epoch interpolate polynomial if it is the field ...
SHARED_PTR< QVD > _getIntervals() const
std::map< ScanKey, std::set< String > > _scanToIntentsMap
Definition: MSMetaData.h:626
vector< uInt > nChans() const
A hierarchical collection of named fields of various types.
Definition: Record.h:181
vector< MDirection > getPhaseDirs() const
get the phase directions from the FIELD subtable
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
SHARED_PTR< std::map< SubScanKey, uInt > > _subScanToNXCRowsMap
Definition: MSMetaData.h:623
std::map< std::pair< ScanKey, uInt >, Double > _scanSpwToIntervalMap
Definition: MSMetaData.h:615
std::set< Int > getScansForFieldID(Int fieldID, Int obsID, Int arrayID) const
get the scan numbers associated with the specified field ID.
vector< MPosition > _getAntennaPositions() const
Float getCache() const
Definition: MSMetaData.h:504
vector< Quantity > getCenterFreqs() const
uInt nArrays()
get the number of arrays (from the ARRAY table) in the dataset
static void _checkTolerance(const Double tol)
vector< String > getProjects() const
get the contents of the PROJECT column from the OBSERVATIONS table
Quantity meanfreq
The sum of all channel frequencies divided by the number of channels.
Definition: MSMetaData.h:568
std::map< uInt, Quantity > getAverageIntervalsForSubScan(const SubScanKey &subScan) const
the first key in the returned map is the spectral window ID, the second is the average interval for t...
void _getScansAndIntentsMaps(std::map< ScanKey, std::set< String > > &scanToIntentsMap, std::map< String, std::set< ScanKey > > &intentToScansMap) const
std::map< std::pair< uInt, uInt >, uInt > _spwPolIDToDataDescIDMap
Definition: MSMetaData.h:607
vector< vector< Int > > getCorrTypes() const
POLARIZATION.CORR_TYPE.
SHARED_PTR< vector< uInt > > _fieldToNACRowsMap
Definition: MSMetaData.h:625
Quantity centerfreq
The mean of the low frequency extent of the lowest frequency channel and the high frequency extend of...
Definition: MSMetaData.h:572
float Float
Definition: aipstype.h:51
uInt nRows() const
get the number of visibilities
A sub scan is a unique combination of observation ID, array ID, scan number, and field ID...
Definition: MSKeys.h:42
vector< QVD > getChanResolutions(Bool asVelWidths) const
get the resolution for each channel.
SHARED_PTR< vector< Double > > _unflaggedFieldNACRows
Definition: MSMetaData.h:654
vector< Double > getBandWidths() const
SHARED_PTR< Vector< Int > > _stateIDs
Definition: MSMetaData.h:621
SHARED_PTR< vector< Double > > _unflaggedFieldNXCRows
Definition: MSMetaData.h:654
const Bool False
Definition: aipstype.h:41
std::map< String, std::set< SubScanKey > > _intentToSubScansMap
Definition: MSMetaData.h:613
void _getScansAndSpwMaps(std::map< ScanKey, std::set< uInt > > &scanToSpwMap, vector< std::set< ScanKey > > &spwToScanMap) const
void _getAntennas(SHARED_PTR< Vector< Int > > &ant1, SHARED_PTR< Vector< Int > > &ant2) const
std::map< String, std::set< ScanKey > > _intentToScansMap
Definition: MSMetaData.h:612
std::set< Int > getFieldIDsForSpw(const uInt spw)
get the set of field IDs corresponding to the specified spectral window.
vector< Int > getNumCorrs() const
number of correlations from the polarization table.
SHARED_PTR< std::map< SubScanKey, Double > > _unflaggedSubScanNACRows
Definition: MSMetaData.h:655
virtual std::set< uInt > getSpwsForIntent(const String &intent)
get a set of spectral windows for which the specified intent applies.
std::set< SubScanKey > getSubScanKeys(const ArrayKey &arrayKey) const
get all sub scan keys for the specified array key.
A Table intended to hold astronomical data (a set of Measurements).
SHARED_PTR< Vector< Int > > _getFieldIDs() const
std::set< Int > getAntennasForScan(const ScanKey &scan) const
get the set of antenna IDs for the specified scan.
std::set< uInt > getSpwsForScan(const ScanKey &scan) const
get the set of spectral windows for the specified scan.
SHARED_PTR< vector< String > > transition
Definition: MSMetaData.h:590
map< SourceKey, SourceProperties > _getSourceInfo() const
QVD getAntennaDiameters() const
get the antenna diameters
vector< Int > _source_sourceIDs
Definition: MSMetaData.h:662
const vector< const Table * > _taqlTempTable
Definition: MSMetaData.h:657
SHARED_PTR< const map< SubScanKey, uInt > > getNRowMap(CorrelationType type) const
uInt getAntennaID(const String &antennaName) const
get the antenna ID for the antenna with the specified name.
std::set< Double > getTimesForScan(const ScanKey &scan) const
get the times for the specified scan.
vector< std::set< String > > _fieldToIntentsMap
Definition: MSMetaData.h:628
uInt nFields() const
get the number of fields.
std::set< uInt > getSpwsForField(const Int fieldID)
get a set of spectral windows corresponding to the specified fieldID
std::set< ArrayKey > _arrayKeys
Definition: MSMetaData.h:664
Matrix< Bool > getUniqueBaselines()
std::map<Double, Double> getExposuresForTimes() const;
std::set< String > _uniqueIntents
Definition: MSMetaData.h:618
uInt nObservations() const
get the number of observations (from the OBSERVATIONS table) in the dataset
SHARED_PTR< std::map< ScanKey, std::set< Double > > > _scanToTimesMap
Definition: MSMetaData.h:641
A scan is a unique combination of observation ID, array ID, and scan number Negative values are allow...
Definition: MSKeys.h:59
std::map< Int, std::set< Int > > _sourceToFieldsMap
Definition: MSMetaData.h:606
std::set< Int > _uniqueStateIDs
Definition: MSMetaData.h:619
void _getUnflaggedRowStats(Double &nACRows, Double &nXCRows, SHARED_PTR< std::map< SubScanKey, Double > > &subScanToNACRowsMap, SHARED_PTR< std::map< SubScanKey, Double > > &subScanToNXCRowsMap, SHARED_PTR< vector< Double > > &fieldToNACRowsMap, SHARED_PTR< vector< Double > > &fieldToNXCRowsMap) const
vector< String > getAntennaStations(const vector< uInt > &antennaIDs)
get the antenna stations for the specified antenna IDs
vector< SpwProperties > _spwInfo
Definition: MSMetaData.h:629
vector< SpwProperties > _getSpwInfo2(std::set< uInt > &avgSpw, std::set< uInt > &tdmSpw, std::set< uInt > &fdmSpw, std::set< uInt > &wvrSpw, std::set< uInt > &sqldSpw) const
vector< uInt > _dataDescIDToPolIDMap
Definition: MSMetaData.h:603
SHARED_PTR< std::map< SubScanKey, uInt > > _subScanToNACRowsMap
Definition: MSMetaData.h:623
Bool _forceSubScanPropsToCache
Definition: MSMetaData.h:660
std::set< Int > getFieldsForTimes(Double center, Double tol)
Get the fields which fail into the specified time range (center-tol to center+tol) ...
std::map< ScanKey, std::set< Int > > _scanToAntennasMap
Definition: MSMetaData.h:605
vector< vector< Double > > getEdgeChans()
Quantity getEffectiveTotalExposureTime()
get the effective total exposure time.
vector< vector< String > > _schedules
Definition: MSMetaData.h:635
void _checkScan(const ScanKey &key) const
std::vector< std::set< uInt > > getSpwToDataDescriptionIDMap() const
get a mapping of spectral window ID to data descrption IDs
std::map< Int, std::set< Int > > getFieldsForSourceMap() const
std::set< uInt > getTDMSpw()
ALMA-specific.
std::set< uInt > getSpwsForSubScan(const SubScanKey &subScan) const
get the set of spectral windows for the specified subscan.
std::map< String, std::set< Int > > getIntentToFieldsMap()
SHARED_PTR< Vector< Int > > _observationIDs
Definition: MSMetaData.h:621
vector< uInt > getDataDescIDToSpwMap() const
SHARED_PTR< Vector< Int > > _getObservationIDs() const
static void _createTimeStampRecords(Record &parent, const SubScanProperties &subScanProps)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
std::set< uInt > _sqldSpw
Definition: MSMetaData.h:620
Matrix< Bool > _uniqueBaselines
Definition: MSMetaData.h:651
vector< String > _getStationNames()
SHARED_PTR< const std::map< ScanKey, std::pair< Double, Double > > > getScanToTimeRangeMap() const
get the map of scans to time ranges.
std::set< String > getIntents() const
get all intents, in no particular (nor guaranteed) order.
vector< std::set< ScanKey > > _spwToScansMap
Definition: MSMetaData.h:631
std::set< ScanKey > getScanKeys() const
get all ScanKeys in the dataset
ScanKey scanKey(const SubScanKey &subScanKey)
create a ScanKey from a SubScanKey, just omits the SubScanKey&#39;s fieldID
Definition: MSKeys.h:66
vector< String > _antennaNames
Definition: MSMetaData.h:633
SHARED_PTR< Vector< Int > > _getArrayIDs() const
std::set< String > getFieldNamesForSpw(const uInt spw)
get the set of field names corresponding to the specified spectral window.
SHARED_PTR< Vector< Double > > _getTimes() const
vector< MFrequency > getRefFreqs() const
void _setObservation(const MeasurementSet &ms)
set metadata from OBSERVATION table
std::map< ArrayKey, std::set< SubScanKey > > _getArrayKeysToSubScanKeys() const
vector< String > _stationNames
Definition: MSMetaData.h:633
std::set< uInt > getSQLDSpw()
ALMA-specific.
vector< MPosition > getAntennaPositions(const vector< uInt > &which=std::vector< uInt >(0)) const
get the positions of the specified antennas.
MPosition getObservatoryPosition(uInt which) const
get the position of the specified telescope (observatory).
vector< String > getAntennaNames(std::map< String, uInt > &namesToIDsMap, const vector< uInt > &antennaIDs=vector< uInt >(0)) const
get the name of the antenna for the specified antenna ID
Bool hasBBCNo() const
QVD getAntennaOffset(uInt which)
get the position of the specified antenna relative to the observatory position.
void _checkField(uInt fieldID) const
this file contains all the compiler specific defines
Definition: mainpage.dox:28
uInt nSpw(Bool includewvr) const
get number of spectral windows
vector< std::set< Int > > _spwToFieldIDsMap
Definition: MSMetaData.h:630
SHARED_PTR< vector< MFrequency > > restfreq
Definition: MSMetaData.h:589
map< SourceKey, SHARED_PTR< vector< MFrequency > > > getRestFrequencies() const
get rest frequencies from the SOURCE table
std::set< Double > getTimesForField(Int fieldID)
get the times for which the specified field was observed
void _getRowStats(uInt &nACRows, uInt &nXCRows, std::map< SubScanKey, uInt > *&subScanToNACRowsMap, std::map< SubScanKey, uInt > *&subScanToNXCRowsMap, vector< uInt > *&fieldToNACRowsMap, vector< uInt > *&fieldToNXCRowsMap) const
SHARED_PTR< std::map< Double, std::set< Int > > > _timeToFieldsMap
Definition: MSMetaData.h:646
unsigned int uInt
Definition: aipstype.h:48
std::set< uInt > _fdmSpw
Definition: MSMetaData.h:620
vector< SpwProperties > _getSpwInfo(std::set< uInt > &avgSpw, std::set< uInt > &tdmSpw, std::set< uInt > &fdmSpw, std::set< uInt > &wvrSpw, std::set< uInt > &sqldSpw) const
std::pair< Double, Double > getTimeRange() const
get the time range for the entire dataset.
void _createSubScanRecords(Record &parent, uInt &scanNRows, std::set< Int > &antennasForScan, const ScanKey &scanKey, const std::map< SubScanKey, SubScanProperties > &subScanProps) const
std::set< Double > getTimesForScans(std::set< ScanKey > scans) const
Get the times for the specified scans.
vector< Array< Int > > getCorrProducts() const
POLARIZATION.CORR_PRODUCT.
SHARED_PTR< vector< uInt > > _fieldToNXCRowsMap
Definition: MSMetaData.h:625
std::map< std::pair< uInt, uInt >, uInt > getSpwIDPolIDToDataDescIDMap() const
The first value of the pair is spw, the second is polarization ID.