LCOV - code coverage report
Current view: top level - mstransform/TVI - SDAtmosphereCorrectionTVI.h (source / functions) Hit Total Coverage
Test: casa_coverage.info Lines: 2 5 40.0 %
Date: 2023-10-25 08:47:59 Functions: 3 7 42.9 %

          Line data    Source code
       1             : //# SDAtmosphereCorrectionTVI.h: Transforming VI for polarization averaging
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the Implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: aips2-request@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id: $
      27             : 
      28             : #ifndef _SD_ATMOSPHERE_CORRECTION_TVI_H_
      29             : #define _SD_ATMOSPHERE_CORRECTION_TVI_H_
      30             : 
      31             : #include <casacore/casa/aips.h>
      32             : 
      33             : #include <atmosphere/ATM/ATMProfile.h>
      34             : #include <atmosphere/ATM/ATMSpectralGrid.h>
      35             : #include <atmosphere/ATM/ATMSkyStatus.h>
      36             : 
      37             : #include <msvis/MSVis/ViImplementation2.h>
      38             : #include <msvis/MSVis/TransformingVi2.h>
      39             : #include <msvis/MSVis/VisibilityIterator2.h>
      40             : 
      41             : #include <map>
      42             : #include <vector>
      43             : 
      44             : #include <casacore/measures/Measures/Stokes.h>
      45             : #include <casacore/casa/Containers/Record.h>
      46             : #include <casacore/ms/MeasurementSets/MSStateColumns.h>
      47             : #include <casacore/scimath/Functionals/Interpolate1D.h>
      48             : 
      49             : namespace casa { //# NAMESPACE CASA - BEGIN
      50             : 
      51             : namespace vi { // # NAMESPACE VI - BEGIN
      52             : 
      53             : class SDAtmosphereCorrectionVi2Factory;
      54             : 
      55             : // <summary>
      56             : // SDAtmosphereCorrectionTVI
      57             : // </summary>
      58             : 
      59             : // <use visibility=export>
      60             : 
      61             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      62             : // </reviewed>
      63             : 
      64             : // <prerequisite>
      65             : //   <li> <linkto class="MSIter">MSIter</linkto>
      66             : //   <li> <linkto class="casacore::MeasurementSet">casacore::MeasurementSet</linkto>
      67             : //   <li> <linkto class="VisSet">VisSet</linkto>
      68             : // </prerequisite>
      69             : //
      70             : // <etymology>
      71             : // SDAtmosphereCorrectionTVI
      72             : // </etymology>
      73             : //
      74             : // <synopsis>
      75             : //
      76             : // </synopsis>
      77             : //
      78             : // <example>
      79             : // <code>
      80             : // //
      81             : // </code>
      82             : // </example>
      83             : //
      84             : // <motivation>
      85             : //
      86             : // </motivation>
      87             : //
      88             : // <thrown>
      89             : //    <li>
      90             : //    <li>
      91             : // </thrown>
      92             : //
      93             : // <todo asof="1997/05/30">
      94             : //   <li> cleanup the currently dual interface for visibilities and flags
      95             : //   <li> sort out what to do with weights when interpolating
      96             : // </todo>
      97             : 
      98             : class SDAtmosphereCorrectionTVI final : public TransformingVi2 {
      99             : 
     100             : public:
     101             :   using SpwId = casacore::Int;
     102             : 
     103             :   // Destructor
     104             : 
     105          54 :   virtual ~SDAtmosphereCorrectionTVI() = default;
     106             : 
     107             :   // Report the the ViImplementation type
     108             :   //  (should be specialized in child classes)
     109           0 :   virtual casacore::String ViiType() const override {
     110           0 :     return casacore::String("SDAtmosphereCorrection( ") + getVii()->ViiType() + " )";
     111             :   }
     112             : 
     113             :   // Methods to control and monitor subchunk iteration
     114             :   virtual void origin() override;
     115             :   virtual void next() override;
     116             :   virtual void originChunks(casacore::Bool forceRewind = false) override;
     117             :   virtual void nextChunk() override;
     118             : 
     119             :   // Return the visibilities as found in the casacore::MS, casacore::Cube (npol,nchan,nrow).
     120             :   virtual void visibilityCorrected(casacore::Cube<casacore::Complex> & vis) const override;
     121             :   virtual void visibilityModel(casacore::Cube<casacore::Complex> & vis) const override;
     122             :   virtual void visibilityObserved(casacore::Cube<casacore::Complex> & vis) const override;
     123             : 
     124             :   // Return FLOAT_DATA as a casacore::Cube (npol, nchan, nrow) if found in the MS.
     125             :   virtual void floatData(casacore::Cube<casacore::Float> & fcube) const override;
     126             : 
     127             : protected:
     128             :   // Constructor
     129             :   SDAtmosphereCorrectionTVI(ViImplementation2 * inputVi,
     130             :     casacore::Record const &configuration);
     131             :   SDAtmosphereCorrectionTVI() = delete;
     132             : 
     133             : private:
     134             :   // initial configuratin of the correction
     135             :   void initializeAtmosphereCorrection(casacore::Record const &configuration);
     136             : 
     137             :   // initialize AtmosphereModel
     138             :   void initializeAtmosphereModel(casacore::Record const &configuration);
     139             : 
     140             :   // prologue function for each chunk
     141             :   void initializeChunk();
     142             : 
     143             :   // sync with the current chunk/subchunk
     144             :   casacore::Bool updateSkyStatus(atm::SkyStatus &skyStatus, casacore::Int atmTimeIndex);
     145             :   casacore::Vector<casacore::Double> updateCorrectionFactor(atm::SkyStatus &skyStatus, casacore::Double const currentTime);
     146             :   void updateCorrectionFactorInAdvance();
     147             : 
     148             :   // read necessary data from MS
     149             :   void readMain(casacore::String const &msName);
     150             :   void readPointing(casacore::String const &msName, casacore::Int const referenceAntenna);
     151             :   void readAsdmAsIsTables(casacore::String const &msName);
     152             : 
     153             :   // user inputs
     154             :   casacore::Vector<SpwId> processSpwList_;
     155             :   casacore::Vector<casacore::Double> gainFactorList_;
     156             :   casacore::Double userPressureValue_;
     157             :   casacore::Double userTemperatureValue_;
     158             :   casacore::Double userRelHumidityValue_;
     159             :   casacore::Double userPwvValue_;
     160             :   casacore::Record configuration_;
     161             : 
     162             :   // measurements recorded in MS
     163             :   casacore::Vector<casacore::Double> offSourceTime_;
     164             :   casacore::Interpolate1D<casacore::Double, casacore::Double> elevationInterpolator_;
     165             : 
     166             :   casacore::Vector<casacore::Double> pwvData_;
     167             : 
     168             :   casacore::Vector<casacore::Double> atmTime_;
     169             :   casacore::Vector<casacore::Double> atmTemperatureData_;
     170             :   casacore::Vector<casacore::Double> atmPressureData_;
     171             :   casacore::Vector<casacore::Double> atmRelHumidityData_;
     172             : 
     173             :   // spw related
     174             :   std::map<SpwId, bool> isTdmSpw_;
     175             :   std::map<SpwId, bool> doSmooth_;
     176             :   std::map<SpwId, casacore::uInt> nchanPerSpw_;
     177             : 
     178             :   // current iterator status
     179             :   SpwId currentSpwId_;
     180             :   bool transformSubchunk_;
     181             : 
     182             :   // ATM
     183             :   unsigned int atmType_;
     184             :   std::map<SpwId, std::unique_ptr<atm::SkyStatus> > atmSkyStatusPerSpw_;
     185             :   std::vector<casacore::Vector<casacore::Double> > correctionFactorList_;
     186             :   std::vector<casacore::Int> indexForCorrection_;
     187             : 
     188             :   // OpenMP related stuff
     189             :   int numThreads_;
     190             : 
     191             :   friend SDAtmosphereCorrectionVi2Factory;
     192             : };
     193             : 
     194             : 
     195             : // <summary>
     196             : // A factory for generating ViImplementation2 for offline ATM correction.
     197             : // </summary>
     198             : //
     199             : // <use visibility=export>
     200             : //
     201             : // <prerequisite>
     202             : //   <li> <linkto class="VisibilityIterator2:description">VisibilityIterator2</linkto>
     203             : // </prerequisite>
     204             : //
     205             : // <etymology>
     206             : // Factory for layered ViImplementation2 construction
     207             : // </etymology>
     208             : //
     209             : // <synopsis>
     210             : // PolAverageVi2Factory
     211             : // </synopsis>
     212             : //
     213             : // <motivation>
     214             : //
     215             : // </motivation>
     216             : //
     217             : // <example>
     218             : //
     219             : // </example>
     220             : 
     221             : class SDAtmosphereCorrectionVi2Factory final : public ViFactory {
     222             : 
     223             : public:
     224             :   // Constructor
     225             :   SDAtmosphereCorrectionVi2Factory(casacore::Record const &configuration,
     226             :     ViImplementation2 *inputVII);
     227             :   SDAtmosphereCorrectionVi2Factory(casacore::Record const &configuration,
     228             :     casacore::MeasurementSet const *ms, SortColumns const sortColumns,
     229             :     casacore::Double timeInterval, casacore::Bool isWritable);
     230             : 
     231             :   // Destructor
     232          27 :   virtual ~SDAtmosphereCorrectionVi2Factory() = default;
     233             : 
     234             :   ViImplementation2 * createVi() const;
     235             : 
     236             : private:
     237             :   ViImplementation2 *inputVII_p;
     238             :   casacore::Record configuration_p;
     239             : };
     240             : 
     241             : class SDAtmosphereCorrectionTVILayerFactory final : public ViiLayerFactory {
     242             : 
     243             : public:
     244             :   SDAtmosphereCorrectionTVILayerFactory(casacore::Record const &configuration);
     245           0 :   virtual ~SDAtmosphereCorrectionTVILayerFactory() = default;
     246             : 
     247             : protected:
     248             :   ViImplementation2 * createInstance(ViImplementation2* vii0) const;
     249             : 
     250             :   casacore::Record configuration_p;
     251             : 
     252             : };
     253             : 
     254             : } //# NAMESPACE VI - END
     255             : 
     256             : } //# NAMESPACE CASA - END
     257             : 
     258             : #endif // _SD_ATMOSPHERE_CORRECTION_TVI_H_
     259             : 

Generated by: LCOV version 1.16