LCOV - code coverage report
Current view: top level - msvis/MSVis - Reweighter.h (source / functions) Hit Total Coverage
Test: casa_coverage.info Lines: 0 4 0.0 %
Date: 2023-10-25 08:47:59 Functions: 0 2 0.0 %

          Line data    Source code
       1             : //# Reweighter.h: this defines Reweighter which reweights a selected part of an
       2             : //# casacore::MS based on the properties of a (possibly different) selection of it.
       3             : //# Copyright (C) 2011
       4             : //# Associated Universities, Inc. Washington DC, USA.
       5             : //#
       6             : //# This library is free software; you can redistribute it and/or modify it
       7             : //# under the terms of the GNU Library General Public License as published by
       8             : //# the Free Software Foundation; either version 2 of the License, or (at your
       9             : //# option) any later version.
      10             : //#
      11             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      12             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      14             : //# License for more details.
      15             : //#
      16             : //# You should have received a copy of the GNU Library General Public License
      17             : //# along with this library; if not, write to the Free Software Foundation,
      18             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      19             : //#
      20             : //# Correspondence concerning AIPS++ should be addressed as follows:
      21             : //#        Internet email: aips2-request@nrao.edu.
      22             : //#        Postal address: AIPS++ Project Office
      23             : //#                        National Radio Astronomy Observatory
      24             : //#                        520 Edgemont Road
      25             : //#                        Charlottesville, VA 22903-2475 USA
      26             : //#
      27             : //#
      28             : //# $Id$
      29             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      30             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      31             : #include <casacore/ms/MeasurementSets/MSMainEnums.h>
      32             : //#include <msvis/MSVis/VisIterator.h>
      33             : #include <msvis/MSVis/SubMS.h>
      34             : #include <msvis/MSVis/VisBufferComponents.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 <map>
      40             : #include <set>
      41             : #include <vector>
      42             : 
      43             : 
      44             : #ifndef MSVIS_REWEIGHTER_H
      45             : namespace casacore{
      46             : 
      47             : class MSSelection; // #include <ms/MSSel/MSSelection.h>
      48             : template<class T> class ArrayColumn;
      49             : }
      50             : 
      51             : namespace casa { //# NAMESPACE CASA - BEGIN
      52             : 
      53             : #define MSVIS_REWEIGHTER_H
      54             : 
      55             : // <summary>
      56             : //   Reweighter reweights a selected part of an casacore::MS based on the properties of a
      57             : //   (possibly different) selection of it.
      58             : // </summary>
      59             : 
      60             : // <visibility=export>
      61             : 
      62             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      63             : // </reviewed>
      64             : 
      65             : // <prerequisite>
      66             : //   <li> MeasurementSet
      67             : // </prerequisite>
      68             : //
      69             : // <etymology>
      70             : // Reweighter ...it reweights.
      71             : // </etymology>
      72             : //
      73             : // <synopsis>
      74             : // The order of operations (as in ms::split()) is:
      75             : //      ctor
      76             : //      setmsselect
      77             : //      selectTime
      78             : //      makeReweighter
      79             : // </synopsis>
      80             : 
      81             : // These forward declarations are so the corresponding .h files don't have to
      82             : // be included in this .h file, but it's only worth it if a lot of other files
      83             : // include this file.
      84             : 
      85             : 
      86             : class Reweighter
      87             : {
      88             : public:
      89             :   Reweighter(const casacore::String& theMS,
      90             :              const casacore::Bool dorms=false,           // Reweight by rms or stddev?
      91             :              const casacore::uInt minsamp=1);            // Minimum # of visibilities for measuring a scatter.
      92             :   
      93             :   virtual ~Reweighter();
      94             :   
      95             :   // Select spw and channels for each spw in spwstr.
      96             :   // Returns true on success and false on failure.
      97             :   casacore::Bool selectSpw(std::set<casacore::Int>& spwset, casacore::Vector<casacore::Int>& chanStartv,
      98             :                  casacore::Vector<casacore::Int>& chanEndv, casacore::Vector<casacore::Int>& chanStepv,
      99             :                  const casacore::String& spwstr);
     100             : 
     101             :   // Setup polarization selection (for now, only from available correlations -
     102             :   // no casacore::Stokes transformations.)
     103             :   casacore::Bool selectCorrelations(const casacore::String& corrstr);
     104             : 
     105             :   //select stuff using msselection syntax ...time is left out
     106             :   // call it separately with timebin
     107             :   // Returns a success value.
     108             :   casacore::Bool setmsselect(const casacore::String& fitspw="", const casacore::String& outspw="",
     109             :                    const casacore::String& field="",  const casacore::String& baseline="",
     110             :                    const casacore::String& scan="",
     111             :                    const casacore::String& subarray="", const casacore::String& correlation="",
     112             :                    const casacore::String& intent="", const casacore::String& obs="");
     113             : 
     114             :   // Select source or field
     115             :   casacore::Bool selectSource(const casacore::Vector<casacore::Int>& fieldid);
     116             :   
     117           0 :   void selectAntenna(const casacore::Vector<casacore::Int>& antennaids,
     118             :                      const casacore::Vector<casacore::String>& antennaSel)
     119             :   {
     120           0 :     antennaSel_p = SubMS::pickAntennas(antennaId_p, antennaSelStr_p,
     121             :                                        antennaids, antennaSel);
     122           0 :   }
     123             :   
     124             :   // Select array IDs to use.
     125           0 :   void selectArray(const casacore::String& subarray) {arrayExpr_p = subarray;}
     126             : 
     127             :   //select time parameters
     128             :   void selectTime(casacore::Double timeBin=-1.0, casacore::String timerng="");
     129             : 
     130             :   //void selectSource(casacore::Vector<casacore::String> sourceid);
     131             : 
     132             :   // Set the selection string for line-free channels.
     133             :   void setFitSpw(const casacore::String& fitspw) {fitspw_p = fitspw;}
     134             :   // Set the selection string for output spws (not channels!).
     135             :   void setOutSpw(const casacore::String& outspw) {outspw_p = outspw;}
     136             :   
     137             :   // Do the reweighting!
     138             :   casacore::Bool reweight(casacore::String& colname, const casacore::String& combine);
     139             : 
     140             :   //void verifyColumns(const casacore::MeasurementSet& ms, const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
     141             : 
     142             :   // Fills polIDs with a map from DDID to polID, and corrTypes with a map from
     143             :   // polID to corrTypes.
     144             :   // The return value is meaningless for now.
     145             :   static casacore::Bool getCorrTypes(casacore::Vector<casacore::Int>& polIDs,
     146             :                            casacore::Vector<casacore::Vector<casacore::Int> >& corrTypes,
     147             :                            const casacore::MSColumns& msc);
     148             :   
     149             :  protected:
     150             : 
     151             :   //method that returns the selected ms (?! - but it's Boolean - RR)
     152             :   casacore::Bool makeSelection();
     153             : 
     154             :   // *** Private member functions ***
     155             : 
     156             :   // Picks a reference to DATA, MODEL_DATA, CORRECTED_DATA, or LAG_DATA out
     157             :   // of ms_p.  FLOAT_DATA is not included because it is not natively complex. 
     158             :   const casacore::ArrayColumn<casacore::Complex>& right_column(const casacore::MSColumns *ms_p,
     159             :                                              const casacore::MS::PredefinedColumns datacol);
     160             : 
     161             :   // Sets sort to a casacore::Block of columns that a VisibilityIterator should sort by,
     162             :   // according to combine_p.  Columns that should never be combined in the
     163             :   // calling function, i.e. spw for time averaging, should be listed in
     164             :   // uncombinable.
     165             :   //
     166             :   // verbose: log a message on error.
     167             :   //
     168             :   // Returns whether or not there were any conflicts between combine_p and
     169             :   // uncombinable.
     170             :   casacore::Bool setSortOrder(casacore::Block<casacore::Int>& sort, const casacore::String& uncombinable="",
     171             :                     const casacore::Bool verbose=true) const;
     172             : 
     173             :   // Returns whether col is (not in combine_p) || in uncombinable.
     174             :   // Columns that should never be combined in the
     175             :   // calling function, i.e. spw for time averaging, should be listed in
     176             :   // uncombinable.
     177             :   //
     178             :   // verbose: log a message on error.
     179             :   //
     180             :   // conflict is set to true if there is a conflict between combine_p and
     181             :   // uncombinable.
     182             :   casacore::Bool shouldWatch(casacore::Bool& conflict, const casacore::String& col,
     183             :                    const casacore::String& uncombinable="",
     184             :                    const casacore::Bool verbose=true) const;
     185             : 
     186             :   void makeUnionSpw();
     187             : 
     188             :   // Defaults to DATA.
     189             :   casacore::MS::PredefinedColumns dataColStrToEnum(const casacore::String& col);
     190             : 
     191             :   // *** Member variables ***
     192             : 
     193             :   // Initialized* by ctors.  (Maintain order both here and in ctors.)
     194             :   //  * not necessarily to anything useful.
     195             :   casacore::MeasurementSet ms_p, mssel_p;
     196             :   casacore::Bool dorms_p;                 // Reweight by rms or stddev?
     197             :   casacore::uInt minsamp_p;               // Minimum # of visibilities for measuring a scatter.
     198             :   casacore::MSColumns *msc_p;
     199             :   casacore::Bool antennaSel_p;          // Selecting by antenna?
     200             :   casacore::Double timeBin_p;
     201             :   casacore::String scanString_p,          // Selects scans by #number#.  Historically named.
     202             :          intentString_p,        // Selects scans by string.  scanString_p was taken.
     203             :          obsString_p;            // casacore::String for observationID selection.
     204             :   casacore::String timeRange_p, arrayExpr_p, corrString_p;
     205             :   casacore::String combine_p;          // Should time averaging not split bins by
     206             :                              // scan #, observation, and/or state ID?
     207             :                              // Must be lowercase at all times.
     208             :   casacore::String fitspw_p;           // Selection string for line-free channels.
     209             :   casacore::String outspw_p;           // Selection string for ddids to reweight.
     210             :   casacore::Vector<casacore::Int> unionspw_p;    // All the spws in fitspw_p or outspw_p.
     211             : 
     212             :   // Uninitialized by ctors.
     213             :   casacore::Vector<casacore::String> antennaSelStr_p;
     214             :   casacore::Vector<casacore::Int> antennaId_p;
     215             : 
     216             :   casacore::Vector<casacore::Int> fieldId_p;
     217             : 
     218             :   // casacore::Map from DDID to polID, filled in getCorrTypes().
     219             :   casacore::Vector<casacore::Int> polIDs_p;
     220             : 
     221             :   // casacore::Map from polID to corrTypes, filled in getCorrTypes().
     222             :   casacore::Vector<casacore::Vector<casacore::Int> > corrTypes_p;
     223             : 
     224             :   casacore::Vector<casacore::Vector<casacore::Slice> > chanSlices_p;  // Used by VisIterator::selectChannel()
     225             :   casacore::Vector<casacore::Slice> corrSlice_p;
     226             :   casacore::Vector<casacore::Vector<casacore::Slice> > corrSlices_p;  // Used by VisIterator::selectCorrelation()
     227             :   casacore::Matrix<casacore::Double> selTimeRanges_p;
     228             : 
     229             :   std::set<casacore::Int> fitspwset_p, outspwset_p;
     230             :   casacore::Vector<casacore::Int> fitStart_p, fitEnd_p, fitStep_p;
     231             : };
     232             : 
     233             : } //# NAMESPACE CASA - END
     234             : 
     235             : #endif
     236             : 

Generated by: LCOV version 1.16