LCOV - code coverage report
Current view: top level - msvis/MSVis - Partition.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 5 0.0 %
Date: 2024-10-12 00:35:29 Functions: 0 2 0.0 %

          Line data    Source code
       1             : //# Partition.h: this defines Partition which creates an casacore::MS that is a subset of
       2             : //# an casacore::MS without any changes to the subtables.
       3             : //# 
       4             : //# Copyright (C) 2011
       5             : //# Associated Universities, Inc. Washington DC, USA.
       6             : //#
       7             : //# This library is free software; you can redistribute it and/or modify it
       8             : //# under the terms of the GNU Library General Public License as published by
       9             : //# the Free Software Foundation; either version 2 of the License, or (at your
      10             : //# option) any later version.
      11             : //#
      12             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      13             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      15             : //# License for more details.
      16             : //#
      17             : //# You should have received a copy of the GNU Library General Public License
      18             : //# along with this library; if not, write to the Free Software Foundation,
      19             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      20             : //#
      21             : //# Correspondence concerning AIPS++ should be addressed as follows:
      22             : //#        Internet email: casa-feedback@nrao.edu.
      23             : //#        Postal address: AIPS++ Project Office
      24             : //#                        National Radio Astronomy Observatory
      25             : //#                        520 Edgemont Road
      26             : //#                        Charlottesville, VA 22903-2475 USA
      27             : //#
      28             : //#
      29             : //# $Id$
      30             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      31             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      32             : #include <casacore/ms/MeasurementSets/MSMainColumns.h>
      33             : #include <casacore/ms/MeasurementSets/MSMainEnums.h>
      34             : //#include <msvis/MSVis/VisIterator.h>
      35             : #include <casacore/casa/aips.h>
      36             : #include <casacore/casa/Arrays/Array.h>
      37             : #include <casacore/casa/Arrays/Vector.h>
      38             : //#include <casa/Utilities/CountedPtr.h>
      39             : #include <msvis/MSVis/SubMS.h>
      40             : 
      41             : #ifndef MSVIS_PARTITION_H
      42             : namespace casacore{
      43             : 
      44             : template<class T> class ArrayColumn;
      45             : }
      46             : 
      47             : namespace casa { //# NAMESPACE CASA - BEGIN
      48             : 
      49             : #define MSVIS_PARTITION_H
      50             : 
      51             : // <summary>
      52             : // Partition makes a subset of an existing casacore::MS without remapping any indices
      53             : // or resizing any subtables (unlike SubMS).
      54             : // </summary>
      55             : 
      56             : // <visibility=export>
      57             : 
      58             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      59             : // </reviewed>
      60             : 
      61             : // <prerequisite>
      62             : //   <li> MeasurementSet
      63             : //   <li> SubMS
      64             : // </prerequisite>
      65             : //
      66             : // <etymology>
      67             : // Partition an MS.
      68             : // </etymology>
      69             : //
      70             : // <synopsis>
      71             : // The order of operations (as in ms::partition()) is:
      72             : //      ctor
      73             : //      setmsselect
      74             : //      selectTime
      75             : //      makePartition
      76             : // </synopsis>
      77             : 
      78             : //casacore::Bool isAllColumns(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
      79             : 
      80             : class Partition
      81             : {
      82             : public:
      83             :   Partition(casacore::String& theMS, casacore::Table::TableOption option = casacore::Table::Old);
      84             :   
      85             :   // construct from an MS
      86             :   Partition(casacore::MeasurementSet& ms);
      87             : 
      88             :   virtual ~Partition();
      89             :   
      90             :   // Change or Set the casacore::MS this casacore::MSSelector refers to.
      91             :   void setMS(casacore::MeasurementSet& ms);
      92             : 
      93             :   // Select spw and channels for each spw.
      94             :   // It returns true on success and false on failure.
      95             :   casacore::Bool selectSpw(const casacore::String& spwstr);
      96             : 
      97             :   //select casacore::Time and time averaging or regridding
      98             :   //void selectTime();
      99             : 
     100             :   //select stuff using msselection syntax ...time is left out
     101             :   // call it separately with timebin
     102             :   casacore::Bool setmsselect(const casacore::String& spw="", const casacore::String& field="", 
     103             :                    const casacore::String& baseline="", const casacore::String& scan="",
     104             :                    const casacore::String& uvrange="", const casacore::String& taql="", 
     105             :                    const casacore::String& subarray="", const casacore::String& intent="",
     106             :                    const casacore::String& obs="");
     107             : 
     108             :   // Select source or field
     109             :   casacore::Bool selectSource(const casacore::Vector<casacore::Int>& fieldid);
     110             :   
     111             :   // Select Antennas to split out  
     112           0 :   void selectAntenna(casacore::Vector<casacore::Int>& antennaids, casacore::Vector<casacore::String>& antennaSel)
     113             :   {
     114           0 :     antennaSel_p = SubMS::pickAntennas(antennaId_p, antennaSelStr_p,
     115             :                                        antennaids, antennaSel);
     116           0 :   } 
     117             : 
     118             :   // Select array IDs to use.
     119             :   void selectArray(const casacore::String& subarray);
     120             : 
     121             :   //select time parameters
     122             :   void selectTime(casacore::Double timeBin=-1.0, casacore::String timerng="");
     123             : 
     124             :   //void selectSource(casacore::Vector<casacore::String> sourceid);
     125             : 
     126             :   //Method to set if a phase Center rotation is needed
     127             :   //void setPhaseCenter(casacore::Int fieldid, casacore::MDirection& newPhaseCenter);
     128             : 
     129             :   //Method to make the partition.
     130             :   //
     131             :   //TileShape of size 1 can have 2 values [0], and [1] ...these are used in to
     132             :   //determine the tileshape by using MSTileLayout. Otherwise it has to be a
     133             :   //vector size 3 e.g [4, 15, 351] => a tile shape of 4 stokes, 15 channels 351
     134             :   //rows.
     135             :   //
     136             :   // combine sets combine_p.  (Columns to ignore while time averaging.)
     137             :   //
     138             :   casacore::Bool makePartition(casacore::String& outname, casacore::String& whichDataCol,
     139             :                      const casacore::Vector<casacore::Int>& tileShape=casacore::Vector<casacore::Int>(1, 0),
     140             :                      const casacore::String& combine="");
     141             : 
     142             :   //Method to make a scratch partition and even in memory if posssible
     143             :   //Useful if temporary subselection/averaging is necessary
     144             :   // It'll be in memory if the basic output ms is less than half of 
     145             :   // memory reported by casacore::HostInfo unless forced to by user...
     146             :   virtual casacore::MeasurementSet* makeScratchPartition(const casacore::Vector<casacore::MS::PredefinedColumns>& whichDataCols, 
     147             :                                    const casacore::Bool forceInMemory=false);
     148             :   // In this form whichDataCol gets passed to parseColumnNames().
     149             :   virtual casacore::MeasurementSet* makeScratchPartition(const casacore::String& whichDataCol, 
     150             :                                    const casacore::Bool forceInMemory=false);
     151             : 
     152             :   // This sets up a default new ms
     153             :   // Declared static as it can be called directly outside of Partition.
     154             :   // Therefore it is not dependent on any member variable.
     155             :   static casacore::MeasurementSet* setupMS(const casacore::String& msname, const casacore::MeasurementSet& inms,
     156             :                                  const casacore::Int nchan, const casacore::Int npol, const casacore::String& telescop,
     157             :                                  const casacore::Vector<casacore::MS::PredefinedColumns>& colNamesTok,
     158             :                                  const casacore::Int obstype=0);
     159             : 
     160             :   // Same as above except allowing manual tileshapes
     161             :   static casacore::MeasurementSet* setupMS(const casacore::String& msname, const casacore::MeasurementSet& inms,
     162             :                                  const casacore::Int nchan, const casacore::Int npol,
     163             :                                  const casacore::Vector<casacore::MS::PredefinedColumns>& colNamesTok,
     164             :                                  const casacore::Vector<casacore::Int>& tileShape=casacore::Vector<casacore::Int>(1,0));
     165             :   
     166             :   void verifyColumns(const casacore::MeasurementSet& ms, const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
     167             : private:
     168             :   //method that returns the selected ms (?! - but it's Boolean - RR)
     169             :   casacore::Bool makeSelection();
     170             : 
     171             :   // (Sub)table fillers.
     172             :   casacore::Bool fillAllTables(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
     173             :   casacore::Bool fillMainTable(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
     174             : 
     175             :   //  casacore::Bool writeDiffSpwShape(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
     176             :   casacore::Bool fillAccessoryMainCols();
     177             : 
     178             :   // *** Private member functions ***
     179             :   casacore::Bool getDataColumn(casacore::ArrayColumn<casacore::Complex>& data,
     180             :                      const casacore::MS::PredefinedColumns colName);
     181             :   casacore::Bool getDataColumn(casacore::ArrayColumn<casacore::Float>& data,
     182             :                      const casacore::MS::PredefinedColumns colName);
     183             :   casacore::Bool putDataColumn(casacore::MSColumns& msc, casacore::ArrayColumn<casacore::Complex>& data,
     184             :                      const casacore::MS::PredefinedColumns datacol,
     185             :                      const casacore::Bool writeToDataCol=false);
     186             :   casacore::Bool putDataColumn(casacore::MSColumns& msc, casacore::ArrayColumn<casacore::Float>& data,
     187             :                      const casacore::MS::PredefinedColumns datacol,
     188             :                      const casacore::Bool writeToDataCol=false);
     189             : 
     190             :   // This method uses VisIter for efficient copy mode data transfer
     191             :   casacore::Bool copyDataFlagsWtSp(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames,
     192             :                          const casacore::Bool writeToDataCol);
     193             : 
     194             :   // Used in a couple of places to estimate how much memory to grab.
     195           0 :   casacore::Double n_bytes() {return mssel_p.nrow() * maxnchan_p * maxncorr_p *
     196           0 :                            sizeof(casacore::Complex);}
     197             : 
     198             :   // Read the input, time average it to timeBin_p, and write the output.
     199             :   casacore::Bool doTimeAver(const casacore::Vector<casacore::MS::PredefinedColumns>& dataColNames);
     200             : 
     201             :   // Fills mapper[ntok] with a map from dataColumn indices to ArrayColumns in
     202             :   // the output.  mapper must have ntok slots!
     203             :   static void getDataColMap(casacore::MSMainColumns* msc, casacore::ArrayColumn<casacore::Complex>* mapper,
     204             :                             casacore::uInt ntok,
     205             :                             const casacore::Vector<casacore::MS::PredefinedColumns>& colEnums);
     206             : 
     207             :   // *** Member variables ***
     208             : 
     209             :   // Initialized* by ctors.  (Maintain order both here and in ctors.)
     210             :   //  * not necessarily to anything useful.
     211             :   casacore::MeasurementSet ms_p, mssel_p;
     212             :   casacore::MSMainColumns * msc_p;              // columns of msOut_p
     213             :   casacore::MSColumns * mscIn_p;
     214             :   casacore::Bool   antennaSel_p;                // Selecting by antenna?
     215             :   casacore::Double timeBin_p;
     216             :   casacore::String scanString_p,          // Selects scans by #number#.  Historically named.
     217             :          intentString_p,        // Selects scans by string.  scanString_p was taken.
     218             :          obsString_p,           // casacore::String for observationID selection.
     219             :          uvrangeString_p, taqlString_p;
     220             :   casacore::String timeRange_p, arrayExpr_p, corrString_p;
     221             :   casacore::String combine_p;          // Should time averaging not split bins by
     222             :                              // scan #, observation, and/or state ID?
     223             :                              // Must be lowercase at all times.
     224             :   casacore::Int maxnchan_p,    // The maximum # of channels and correlations for each
     225             :       maxncorr_p;    // selected DDID.  (casacore::Int because NUM_CHAN and NUM_CORR
     226             :                      // are casacore::Int instead of uInt.)
     227             : 
     228             :   // Uninitialized by ctors.
     229             :   casacore::MeasurementSet msOut_p;
     230             :   casacore::Vector<casacore::Int> spw_p;      // Selected spw numbers
     231             :   casacore::Vector<casacore::Int> fieldid_p;
     232             :   casacore::Vector<casacore::String> antennaSelStr_p;
     233             :   casacore::Vector<casacore::Int> antennaId_p;
     234             :   casacore::Vector<casacore::Int> arrayId_p;
     235             :   casacore::Matrix<casacore::Double> selTimeRanges_p;
     236             : };
     237             : 
     238             : } //# NAMESPACE CASA - END
     239             : 
     240             : #endif
     241             : 

Generated by: LCOV version 1.16