LCOV - code coverage report
Current view: top level - synthesis/CalTables - CalInterp.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 41 0.0 %
Date: 2024-10-10 11:40:37 Functions: 0 41 0.0 %

          Line data    Source code
       1             : //# CalInterp.h: Definition for Calibration parameter Interpolation
       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 adressed 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             : //#
      27             : 
      28             : #ifndef CALTABLES_CALINTERP_H
      29             : #define CALTABLES_CALINTERP_H
      30             : #include <casacore/casa/aips.h>
      31             : #include <casacore/casa/BasicSL/Constants.h>
      32             : #include <synthesis/CalTables/CalSet.h>
      33             : #include <casacore/casa/OS/File.h>
      34             : #include <casacore/casa/Logging/LogMessage.h>
      35             : #include <casacore/casa/Logging/LogSink.h>
      36             : 
      37             : namespace casa { //# NAMESPACE CASA - BEGIN
      38             : 
      39             : 
      40             : class CalInterp
      41             : {
      42             : public:
      43             : 
      44             :   // Null ctor does nothing
      45             :   CalInterp() {};
      46             : 
      47             :   // From CalSet 
      48             :   CalInterp(CalSet<casacore::Complex>& cs,
      49             :             const casacore::String& timetype,
      50             :             const casacore::String& freqtype);
      51             : 
      52             :   // Destructor
      53             :   virtual ~CalInterp();
      54             : 
      55             : 
      56             :   // Set non-trivial spw mapping
      57             :   void setSpwMap(const casacore::Vector<casacore::Int>& spwmap) {spwMap_ = spwmap; setSpwOK();};
      58             : 
      59             :   // Interpolate, given timestamp, spw, freq list; returns T if new result
      60             :   casacore::Bool interpolate(const casacore::Double& time,
      61             :                    const casacore::Int& spw,
      62             :                    const casacore::Vector<casacore::Double>& freq=casacore::Vector<casacore::Double>());
      63             : 
      64             :   // Do time-dep interpolation (called by interpolate)
      65             :   casacore::Bool interpTime(const casacore::Double& time);
      66             : 
      67             :   // Do freq-dep interpolation (called by interpolate)
      68             :   void interpFreq(const casacore::Vector<casacore::Double>& freq);
      69             : 
      70             :   // Timestamp of current Slot
      71             :   casacore::Double slotTime() { return csTimes()(currSlot()); };
      72             : 
      73             :   // Access to result (by reference)
      74             :   inline casacore::Cube<casacore::Complex>& result() { return r; };
      75             :   inline casacore::Cube<casacore::Bool>& resultOK() { return ok; };
      76             : 
      77             :   // Spwmap-sensitive spwOK()
      78             :   inline casacore::Vector<casacore::Bool> spwOK() { return spwOK_; };
      79             : 
      80             :   // Set spwOK_ according to spwmap  RI made public 200910
      81             :   void setSpwOK();
      82             : 
      83             : protected:
      84             : 
      85             :   // Find the reference timeslot for requested time
      86             :   casacore::Bool findSlot(const casacore::Double& time);
      87             : 
      88             :   void updTimeCoeff();
      89             : 
      90             :   void interpTimeCalc(const casacore::Double& time);
      91             : 
      92             :   void initFreqInterp(const casacore::Vector<casacore::Double> freq);
      93             : 
      94             :   void calcAPC();
      95             : 
      96             :   void updFreqCoeff();
      97             : 
      98             :   void interpFreqCalc();
      99             : 
     100             :   void finalize();
     101             : 
     102             :   void inflTimeC();
     103             :   void inflFreqC();
     104             :   void deflTimeC();
     105             :   void deflFreqC();
     106             :   void deflFreqA();
     107             : 
     108             :   // Access to private shape data (reflecting CalSet)
     109           0 :   inline casacore::Int& nSpw()  { return cs_->nSpw();  };
     110           0 :   inline casacore::Int& nPar()  { return cs_->nPar();  };
     111           0 :   inline casacore::Int& nElem() { return cs_->nElem(); };
     112             : 
     113             :   // Access to imutable private data
     114           0 :   inline casacore::String& timeType()  { return timeType_; };
     115           0 :   inline casacore::Bool   nearestT() { return (timeType()=="nearest"); };
     116             :   inline casacore::Bool   linearT()  { return (timeType()=="linear"); };
     117             :   inline casacore::Bool   aipslinT() { return (timeType()=="aipslin"); };
     118           0 :   inline casacore::String& freqType()  { return freqType_; };
     119             :   inline casacore::Bool   nearestF() { return (freqType()=="nearest"); };
     120             :   inline casacore::Bool   linearF()  { return (freqType()=="linear"); };
     121             :   inline casacore::Bool   aipslinF() { return (freqType()=="aipslin"); };
     122             : 
     123             :   inline casacore::Vector<casacore::Int>& spwMap()  { return spwMap_; };
     124           0 :   inline casacore::Int spwMap(const casacore::Int& spw) { return ((spwMap_(spw)>-1) ? spwMap_(spw) : spw); };
     125             : 
     126             :   // Access to info relevant to currSpw
     127           0 :   inline casacore::Int& currSpw()     { return currSpw_; };
     128           0 :   inline casacore::Int currSpwMap()  { return spwMap(currSpw()); };
     129           0 :   inline casacore::Int& currSlot()    { return currSlot_(currSpw()); };
     130           0 :   inline casacore::Int& nFreq()       { return nFreq_(currSpw()); };
     131           0 :   inline casacore::Vector<casacore::Double>& datFreq() { return (*datFreq_[currSpw()]); };
     132           0 :   inline casacore::Bool& finit()      { return finit_(currSpw()); };
     133           0 :   inline casacore::Double& lastTime() { return lastTime_(currSpw_); };
     134           0 :   inline casacore::Bool& exactTime()  { return exactTime_; };
     135             : 
     136             :   // Access to in-focus portion of CalSet (spwmap'd)
     137           0 :   inline casacore::Int& nTime()              { return cs_->nTime(currSpwMap()); };
     138           0 :   inline casacore::Int& nChan()              { return cs_->nChan(currSpwMap()); }
     139           0 :   inline casacore::Vector<casacore::Double>& csTimes() { return cs_->time(currSpwMap()); };
     140           0 :   inline casacore::Vector<casacore::Double>& csFreq()  { return cs_->frequencies(currSpwMap()); };
     141           0 :   inline casacore::Array<casacore::Complex>& csPar()   { return cs_->par(currSpwMap()); };
     142           0 :   inline casacore::Array<casacore::Bool>&    csParOK() { return cs_->parOK(currSpwMap()); };
     143             : 
     144             :   // Access to IPositions
     145           0 :   inline casacore::IPosition&  ip4d() { return (*ip4d_[currSpw_]); };
     146           0 :   inline casacore::IPosition&  ip3d() { return (*ip3d_[currSpw_]); };
     147           0 :   inline casacore::IPosition&  ip2d() { return (*ip2d_[currSpw_]); };
     148             : 
     149             :   // Access to in-focus interpolation abscissa data
     150           0 :   inline casacore::Double&         t0()  {return t0_(currSpw_);};
     151           0 :   inline casacore::Double&         tS()  {return tS_(currSpw_);};
     152           0 :   inline casacore::Int&        lastlo()  {return lastlo_(currSpw_); };
     153             : 
     154           0 :   inline casacore::Vector<casacore::Int>&    ch0() {return (*ch0_[currSpw_]); };
     155           0 :   inline casacore::Vector<casacore::Bool>&   ef()  {return (*ef_[currSpw_]); };
     156           0 :   inline casacore::Vector<casacore::Double>& df()  {return (*df_[currSpw_]); };
     157           0 :   inline casacore::Vector<casacore::Double>& fdf() {return (*df_[currSpw_]); };
     158             : 
     159             :   // In-focus casacore::Time Interpolation coefficients 
     160           0 :   inline casacore::Array<casacore::Float>&   tAC() {return (*tAC_[currSpw()]); };
     161           0 :   inline casacore::Array<casacore::Float>&   tPC() {return (*tPC_[currSpw()]); };
     162           0 :   inline casacore::Array<casacore::Complex>& tCC() {return (*tCC_[currSpw()]); };
     163           0 :   inline casacore::Cube<casacore::Bool>&     tOk() {return (*tOk_[currSpw()]); };
     164             : 
     165             :   // In-focus Freq Interpolation coefficients
     166           0 :   inline casacore::Array<casacore::Float>&   fAC() {return (*fAC_[currSpw()]); };
     167           0 :   inline casacore::Array<casacore::Float>&   fPC() {return (*fPC_[currSpw()]); };
     168           0 :   inline casacore::Array<casacore::Complex>& fCC() {return (*fCC_[currSpw()]); };
     169           0 :   inline casacore::Cube<casacore::Bool>&     fOk() {return (*fOk_[currSpw()]); };
     170             : 
     171           0 :   inline void rPart(casacore::Array<casacore::Complex>& c,casacore::Array<casacore::Float>& rp) { return part(c,0,rp); };
     172           0 :   inline void iPart(casacore::Array<casacore::Complex>& c,casacore::Array<casacore::Float>& ip) { return part(c,1,ip); };
     173             : 
     174             :   void asFloatArr(const casacore::Array<casacore::Complex>& in, casacore::Array<casacore::Float>& out);
     175             : 
     176             :   void part(const casacore::Array<casacore::Complex>& c, const casacore::Int& which, casacore::Array<casacore::Float>& f);
     177             : 
     178             : private:
     179             : 
     180             :   // The CalSet from which we interpolate
     181             :   CalSet<casacore::Complex>* cs_;
     182             : 
     183             :   // Interpolation modes
     184             :   casacore::String timeType_, freqType_;
     185             : 
     186             :   // Spw map
     187             :   casacore::Vector<casacore::Int> spwMap_;
     188             : 
     189             :   // SpwOK
     190             :   casacore::Vector<casacore::Bool> spwOK_;
     191             : 
     192             :   // Prior interp time, per spw
     193             :   casacore::Vector<casacore::Double> lastTime_;
     194             : 
     195             :   // Frequency initialization flag (true if init complete)
     196             :   casacore::Vector<casacore::Bool> finit_;
     197             : 
     198             :   // Number of channels
     199             :   casacore::Vector<casacore::Int> nFreq_;          // (nSpw_) number of _data_ channels per spw
     200             : 
     201             :   // Freq lists
     202             :   casacore::PtrBlock<casacore::Vector<casacore::Double>*> solFreq_;   // [nSpw](nChan)
     203             :   casacore::PtrBlock<casacore::Vector<casacore::Double>*> datFreq_;   // [nSpw](nFreq)
     204             : 
     205             :   casacore::Int currSpw_;
     206             :   casacore::Vector<casacore::Int> currSlot_;
     207             : 
     208             :   // Exact time match flag
     209             :   casacore::Bool exactTime_;
     210             : 
     211             :   casacore::Cube<casacore::Float> a,p;    // For referencing interp results
     212             :   casacore::Cube<casacore::Complex> c;
     213             :   casacore::Cube<casacore::Bool> ok;
     214             : 
     215             :   casacore::Cube<casacore::Complex> r, r_;
     216             : 
     217             :   // casacore::Array shapes
     218             :   casacore::PtrBlock<casacore::IPosition*> ip4d_;     // [nSpw]
     219             :   casacore::PtrBlock<casacore::IPosition*> ip3d_;     // [nSpw]
     220             :   casacore::PtrBlock<casacore::IPosition*> ip2d_;     // [nSpw]
     221             : 
     222             :   // casacore::Time Interpolation ordinate info (per spw)
     223             :   casacore::Vector<casacore::Double>            t0_;         // (nSpw)
     224             :   casacore::Vector<casacore::Double>            tS_;         // (nSpw)
     225             :   casacore::Vector<casacore::Int>               lastlo_;     // (nSpw)
     226             : 
     227             :   // casacore::Time Interpolation coefficients (per spw)
     228             :   casacore::PtrBlock<casacore::Array<casacore::Float>*>   tAC_, tPC_;  // [nSpw](2,nPar,nChan,nElem)
     229             :   casacore::PtrBlock<casacore::Array<casacore::Complex>*> tCC_;        // [nSpw](2,nPar,nChan,nElem)
     230             :   casacore::PtrBlock<casacore::Cube<casacore::Bool>*>     tOk_;        // [nSpw](nPar,nChan,nElem)
     231             : 
     232             :   // casacore::Time Interpolation results (currSpw)
     233             :   casacore::Cube<casacore::Float>    tA_, tP_;    // (nPar,nChan,nElem)
     234             :   casacore::Cube<casacore::Complex>  tC_;         // (nPar,nChan,nElem)
     235             : 
     236             :   // Freq Interpolation ordinate info (per spw)
     237             :   casacore::PtrBlock<casacore::Vector<casacore::Int>*>    ch0_;        // [nSpw](nFreq)
     238             :   casacore::PtrBlock<casacore::Vector<casacore::Bool>*>   ef_;         // [nSpw](nFreq)
     239             :   casacore::PtrBlock<casacore::Vector<casacore::Double>*> df_;         // [nSpw](nFreq)
     240             :   casacore::PtrBlock<casacore::Vector<casacore::Double>*> fdf_;        // [nSpw](nFreq)
     241             : 
     242             :   // Freq Interpolation coefficients (per spw)
     243             :   casacore::PtrBlock<casacore::Array<casacore::Float>*>   fAC_, fPC_;  // [nSpw](2,nPar,nFreq,nElem)
     244             :   casacore::PtrBlock<casacore::Array<casacore::Complex>*> fCC_;        // [nSpw](2,nPar,nFreq,nElem)
     245             :   casacore::PtrBlock<casacore::Cube<casacore::Bool>*>     fOk_;        // [nSpw](nPar,nFreq,nElem)
     246             : 
     247             :   // Freq Interpolation results (currSspw)
     248             :   casacore::Cube<casacore::Float>    fA_, fP_;               // (nPar,nFreq,nElem)
     249             :   casacore::Cube<casacore::Complex>  fC_;                    // (nPar,nFreq,nElem)
     250             : 
     251             :   casacore::LogSink logSink_p;
     252             :   casacore::LogSink& logSink() {return logSink_p;};
     253             : 
     254             :   casacore::Bool verbose_;
     255             : 
     256             : };
     257             : 
     258             : 
     259             : } //# NAMESPACE CASA - END
     260             : 
     261             : #endif

Generated by: LCOV version 1.16