LCOV - code coverage report
Current view: top level - synthesis/Utilities - FixVis.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 12 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 10 0.0 %

          Line data    Source code
       1             : //# FixVis.h: Does for MSes various fixes which do not involve calibrating.
       2             : //# Copyright (C) 2008
       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: casa-feedback@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$
      27             : //#
      28             : #ifndef SYN_FIXVIS_H
      29             : #define SYN_FIXVIS_H
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : #include <casacore/casa/BasicSL/String.h>
      33             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      34             : #include <msvis/MSVis/MSUVWGenerator.h>
      35             : 
      36             : // casacore::UVWMachine Does rotation, including B1950 <-> J2000, refocusing, and maybe
      37             : // even SIN <-> (-)NCP reprojection of existing UVWs, but it does not generate
      38             : // UVWs from an antenna table.
      39             : // FTMachine::rotateUVW(casacore::Matrix<casacore::Double>& uvw, casacore::Vector<casacore::Double>& dphase,
      40             : //                      const VisBuffer& vb)
      41             : #include <synthesis/TransformMachines/FTMachine.h>
      42             : 
      43             : namespace casacore{
      44             : 
      45             : class MeasurementSet;
      46             : class LogIO;
      47             : }
      48             : 
      49             : namespace casa { //# NAMESPACE CASA - BEGIN
      50             : 
      51             : 
      52             : // <summary>Performs for MeasurementSets various fixes which do not involve calibrating.
      53             : // This includes (in order of implementation):
      54             : //   1. Generating and inserting (u, v, w)s into a casacore::MS that may or may not
      55             : //      already have them.  Includes antenna offsets when known.
      56             : //   2. Correcting for differential aberration.
      57             : //   3. Changing the phase tracking center.
      58             : //   4. Changing the equinox (B1950 -> J2000).
      59             : //   5. (maybe never) Changing the projection, i.e. SIN <-> (-)NCP.
      60             : // </summary>
      61             : // <use visibility=export>
      62             : // 
      63             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      64             : // </reviewed>
      65             : // 
      66             : // <prerequisite>
      67             : //   <li> <linkto class=casacore::MeasurementSet>MeasurementSet</linkto>
      68             : // </prerequisite>
      69             : //
      70             : // <etymology>
      71             : // It is a variation on the UVFIX task of AIPS.
      72             : // </etymology>
      73             : //
      74             : // <synopsis>
      75             : // (u, v, w)s are needed for imaging, but some data sets may not come with them
      76             : // included.
      77             : //
      78             : // FixVis can also be used to shift the tangent point, and correct for
      79             : // differential aberration.
      80             : // </synopsis>
      81             : //
      82             : // <example>
      83             : // <srcBlock>
      84             : //     casacore::MS inMS(fileName);
      85             : //     FixVis uvwfixer(inMS);
      86             : //     uvwfixer.setDataDescriptionIds(ddIds);
      87             : //     uvwfixer.setFields(fieldIds);
      88             : //     uvwfixer.fixuvw();
      89             : // </srcBlock>
      90             : // A <src>FixVis</src> object is constructed 
      91             : // and the baselines are calculated and stored in inMS.
      92             : // </example>
      93             : //
      94             : // <motivation>
      95             : // Currently (10/30/2008), ASDMs from either the ALMA Test Facility or the
      96             : // EVLA do not come with (u, v, w)s, and need to be processed with the UVFIX
      97             : // task in AIPS.  It would be preferable to process them entirely inside CASA.
      98             : // </motivation>
      99             : //
     100             : // <todo asof="">
     101             : // </todo>
     102             : 
     103             : // class FixVis;
     104             : 
     105             : class FixVis : public FTMachine
     106             : {
     107             : public:
     108             : // Constructor
     109             :   FixVis (casacore::MeasurementSet& ms, const casacore::String& dataColName=casacore::String("all"));
     110             : 
     111             : // Assignment (only copies reference to casacore::MS, need to reset selection etc)
     112             :   FixVis& operator=(FixVis& other);
     113             : 
     114             : // Destructor
     115             :   ~FixVis();
     116             : 
     117             : // Set the required field Ids and return the # of selected fields.
     118             :   casacore::uInt setFields(const casacore::Vector<casacore::Int>& fieldIds);
     119             : 
     120             :   //// Select by observationIDs (problematic at best)
     121             :   //void setObsIDs(const casacore::String& obs) {obsString_p = obs;}
     122             : 
     123             :   // Specifies new phase tracking centers for the selected fields
     124             :   void setPhaseDirs(const casacore::Vector<casacore::MDirection>& phaseDirs);
     125             : 
     126             :   // Specifies distances for each selected field according to distances, which
     127             :   // must be in m and the same order as the casacore::Vector given to setFields.  Throws
     128             :   // an exception if distances.nelements() != nsel_p.
     129             :   // Because of the way refocus() works, zeroes are ignored (no refocusing
     130             :   // done), but negative distances are accepted!
     131             :   void setDistances(const casacore::Vector<casacore::Double>& distances);
     132             : 
     133             :   // Calculate the (u, v, w)s and store them in ms_p.
     134             :   casacore::Bool calc_uvw(const casacore::String& refcode, const casacore::Bool reuse=true);
     135             : 
     136             :   // Convert the UVW column to a new reference frame by rotating the old
     137             :   // baselines instead of calculating fresh ones.
     138             :   void rotateUVW(const casacore::MDirection &indir, const casacore::MDirection::Ref& newref);
     139             : 
     140             :   // For things like rotation, differential aberration correction, etc., when
     141             :   // there already is a UVW column, using FTMachine.  Returns true if _any_
     142             :   // fields are modified.
     143             :   casacore::Bool fixvis(const casacore::String& refcode);
     144           0 :   virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
     145           0 :   virtual void ComputeResiduals(VisBuffer&, casacore::Bool //useCorrected
     146           0 :                                 ) {}
     147           0 :   virtual casacore::String name() const { return "FixVis";};
     148             : 
     149             : private:
     150             :   // Interpret field indices (casacore::MSSelection)
     151             :   casacore::Vector<casacore::Int> getFieldIdx(const casacore::String& fields);
     152             :   
     153             :   // Makes sure msc_p is ready, and returns false if it fails.
     154             :   casacore::Bool ready_msc_p();
     155             :   
     156             :   // Convert the directions (phase tracking centers, + DELAY_DIR and
     157             :   // REFERENCE_DIR if they start in the same frame) in the FIELD table to
     158             :   // newFrame.  Note that each direction column in the table only allows one
     159             :   // reference frame for the entire column, so all fields must share the same
     160             :   // frame.  Calls ready_msc_p() as a side effect.
     161             :   void convertFieldDirs(const casacore::MDirection::Types outType);
     162             : 
     163             :   // Private worker function for convertFieldDirs().
     164             :   void convertFieldCols(casacore::MSFieldColumns& msfcs,
     165             :                         const casacore::MDirection::Ref& newFrame,
     166             :                         const casacore::Bool doAll3);
     167             : 
     168             :   // Calls ready_msc_p() as a side effect.
     169             :   casacore::Bool makeSelection(const casacore::Int selectedField);
     170             :   
     171             :   // Does phase tracking center and distance adjustment for mssel_p.
     172             :   void processSelected(casacore::uInt numInSel);
     173             : 
     174             :   // FTMachine declares a LOT of pure virtual functions which FixVis does not
     175             :   // need.  They are declared as no-ops here for now.
     176           0 :   casacore::ImageInterface<casacore::Complex>& getImage(casacore::Matrix<float>&, casacore::Bool) {return *image;}
     177           0 :   virtual void normalizeImage(casacore::Lattice<casacore::Complex>&,// skyImage,
     178             :                               const casacore::Matrix<casacore::Double>&,// sumOfWts,
     179             :                               casacore::Lattice<casacore::Float>&,// sensitivityImage,
     180             :                               casacore::Bool //fftNorm
     181             :                               )
     182           0 :   {throw(casacore::AipsError("normalizeImage::normalizeImage() called"));}
     183             : 
     184           0 :   void getWeightImage(casacore::ImageInterface<float>&, casacore::Matrix<float>&) {}
     185           0 :   void get(VisBuffer&, casacore::Int) {}
     186           0 :   void put(const VisBuffer& , casacore::Int , casacore::Bool , FTMachine::Type) {};
     187             : 
     188             :   // casacore::Bool getRestFreq(casacore::Vector<casacore::Double>& restFreq, const casacore::Int spw, const casacore::Int fldID);
     189             :   //  void setObsInfo(casacore::ObsInfo& obsinfo);
     190             : 
     191             :   void ok();
     192             :   void init();
     193             : 
     194             :   // Initialize transform to Visibility plane using the image
     195             :   // as a template.
     196             :   void initializeToVis(casacore::ImageInterface<casacore::Complex>& image,
     197             :                        const VisBuffer& vb);
     198             :   
     199             :   // Finalize transform to Visibility plane.
     200             :   void finalizeToVis();
     201             : 
     202             :   // Initialize transform to Sky plane: initializes the image
     203             :   void initializeToSky(casacore::ImageInterface<casacore::Complex>& image,  casacore::Matrix<casacore::Float>& weight,
     204             :                        const VisBuffer& vb);
     205             :   
     206             :   // Defined here only because FTMachine declares it purely virtual.
     207           0 :   void finalizeToSky() {}
     208             : 
     209             :   // TODO?: trackDir.
     210             :   casacore::Bool setImageField(const casacore::Int fieldid,
     211             :                      const casacore::Bool dotrackDir=false //, const casacore::MDirection& trackDir
     212             :                      );
     213             : 
     214             :   casacore::Bool lock();
     215             :   void unlock();
     216             : 
     217             :   // Log functions and variables
     218             :   casacore::LogIO sink_p;
     219           0 :   casacore::LogIO& logSink() {return sink_p;}
     220             : 
     221             :   // Initialized in ctor.  Make sure the order there matches with the order here.
     222             :   casacore::MeasurementSet ms_p;                        // casacore::Input/Output MS
     223             :   casacore::MSColumns      *msc_p;              // Ptr. to columns of mssel_p.
     224             :   casacore::uInt           nsel_p;              // Number of selected fields.
     225             :   casacore::uInt           nAllFields_p;                // The total # of fields in the MS.
     226             :   const casacore::uInt       npix_p;              // Not that there are any real pixels.
     227             :   const casacore::IPosition  cimageShape_p;       // No image will be made, but
     228             :   const casacore::IPosition  tileShape_p;         // the coords are stored in a fake one.
     229             :   const casacore::TiledShape tiledShape_p;
     230             :   casacore::Bool             antennaSel_p;        // Is selection being done by antenna?
     231             :   casacore::Bool             freqFrameValid_p;    // Freq frame is good and valid
     232             :                                         // conversions can be done (or not)
     233             :   //casacore::String           obsString_p;       // obsID selection
     234             :   casacore::Vector<casacore::Int>      antennaId_p;         // casacore::MSSelection::indexExprStr() doesn't
     235             :                                         // work with casacore::Vector<casacore::uInt>.
     236             :   casacore::Vector<casacore::String>   antennaSelStr_p;
     237             :   casacore::Vector<casacore::Double>   distances_p;               // new distances (m) for each selected
     238             :                                         // field
     239             :   casacore::Vector<casacore::MS::PredefinedColumns> dataCols_p;
     240             :   casacore::uInt             nDataCols_p;
     241             :   casacore::uInt             nchan_p;
     242             :   casacore::Vector<casacore::Int>      spectralwindowids_p;
     243             :   casacore::uInt             lockCounter_p;
     244             :   
     245             :   // Not initialized in ctor.
     246             :   casacore::MeasurementSet     mssel_p;           // The selected part of ms_p.
     247             :   casacore::ObsInfo            latestObsInfo_p;  
     248             :   casacore::Vector<casacore::Int>        DDIds_p;         // DataDescription Ids to process
     249             :   casacore::Vector<casacore::Int>        FieldIds_p;        // Field Ids to process
     250             :   casacore::Vector<casacore::MDirection> phaseDirs_p;       // new phase centers for each selected
     251             :                                         // field
     252             :   casacore::Int                nSpw_p;          // Number of spws
     253             :   casacore::MPosition          mLocation_p;
     254             :   casacore::Bool               doTrackSource_p;
     255             :   casacore::Int                fieldid_p;
     256             : };
     257             :   
     258             : } //# NAMESPACE CASA - END
     259             : 
     260             : #endif

Generated by: LCOV version 1.16