LCOV - code coverage report
Current view: top level - nrao/VLA - VLALogicalRecord.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 82 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 13 0.0 %

          Line data    Source code
       1             : //# VLALogicalRecord.cc: This class reads and reconstructs VLA archive records
       2             : //# Copyright (C) 1995,1999,2000
       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             : #include <nrao/VLA/VLALogicalRecord.h>
      29             : #include <casacore/casa/Utilities/Assert.h>
      30             : #include <casacore/casa/Exceptions/Error.h>
      31             : #include <casacore/measures/Measures/Stokes.h>
      32             : #include <casacore/casa/Arrays/Vector.h>
      33             : #include <casacore/casa/Arrays/Matrix.h>
      34             : 
      35           0 : VLALogicalRecord::VLALogicalRecord() 
      36           0 :   :itsRecordPtr( ),
      37           0 :    itsRCA(),
      38           0 :    itsSDA(),
      39           0 :    itsADA(0),
      40           0 :    itsCDA(4)
      41             : {
      42           0 : }
      43             : 
      44           0 : VLALogicalRecord::VLALogicalRecord(VLAArchiveInput* input) 
      45           0 :   :itsRecordPtr(input),
      46           0 :    itsRCA(),
      47           0 :    itsSDA(),
      48           0 :    itsADA(0),
      49           0 :    itsCDA(4)
      50             : {
      51           0 : }
      52             : 
      53           0 : VLALogicalRecord::VLALogicalRecord(const VLALogicalRecord& other) 
      54           0 :   :itsRecordPtr(other.itsRecordPtr),
      55           0 :    itsRCA(other.itsRCA),
      56           0 :    itsSDA(other.itsSDA),
      57           0 :    itsADA(other.itsADA),
      58           0 :    itsCDA(other.itsCDA)
      59             : {
      60           0 : }
      61             : 
      62           0 : VLALogicalRecord::~VLALogicalRecord() {
      63           0 : }
      64             : 
      65           0 : VLALogicalRecord& VLALogicalRecord::operator=(const VLALogicalRecord& other) {
      66           0 :   if (this != &other) {
      67           0 :     itsRecordPtr = other.itsRecordPtr;
      68           0 :     itsRCA = other.itsRCA;
      69           0 :     itsSDA = other.itsSDA;
      70           0 :     itsADA = other.itsADA;
      71           0 :     itsCDA = other.itsCDA;
      72             :   }
      73           0 :   return *this;
      74             : }
      75             : 
      76           0 : ByteSource& VLALogicalRecord::logicalRecord() {
      77           0 :   DebugAssert(isValid(), AipsError);
      78           0 :   return itsRecordPtr->logicalRecord();
      79             : }
      80             : 
      81           0 : Bool VLALogicalRecord::read() {
      82           0 :   DebugAssert(isValid(), AipsError);
      83           0 :   if (itsRecordPtr->read() == false) return false;
      84           0 :   ByteSource& itsRecord = itsRecordPtr->logicalRecord();
      85           0 :   itsRCA.attach(itsRecord);
      86           0 :   itsSDA.attach(itsRecord, itsRCA.SDAOffset());
      87           0 :   const uInt nant = itsRCA.nAntennas();
      88           0 :   itsADA.resize(nant, false, false);
      89           0 :   for (uInt i = 0; i < nant; i++) {
      90           0 :     itsADA[i].attach(itsRecord, itsRCA.ADAOffset(i));
      91             :   }
      92           0 :   for (uInt i = 0; i < 4; i++) {
      93           0 :     const uInt nchan = itsSDA.trueChannels(VLAEnum::CDA(i));
      94           0 :     const uInt size = itsRCA.CDABaselineBytes(i);
      95           0 :     itsCDA[i].attach(itsRecord, itsRCA.CDAOffset(i), size, nant, nchan);
      96             :   }
      97           0 :   return true;
      98             : }
      99             : 
     100           0 : Bool VLALogicalRecord::isValid() const {
     101           0 :   return !itsRecordPtr.null();
     102             : }
     103             : 
     104           0 : const VLARCA& VLALogicalRecord::RCA() const {
     105           0 :   DebugAssert(isValid(), AipsError);
     106           0 :   return itsRCA;
     107             : }
     108             : 
     109           0 : const VLASDA& VLALogicalRecord::SDA() const {
     110           0 :   DebugAssert(isValid(), AipsError);
     111           0 :   return itsSDA;
     112             : }
     113             : 
     114           0 : const VLACDA& VLALogicalRecord::CDA(uInt which) const {
     115           0 :   DebugAssert(isValid(), AipsError);
     116           0 :   DebugAssert(which < 4, AipsError);
     117           0 :   return itsCDA[which];
     118             : }
     119             : 
     120           0 : const VLAADA& VLALogicalRecord::ADA(uInt which) const {
     121           0 :   DebugAssert(isValid(), AipsError);
     122           0 :   DebugAssert(which < itsRCA.nAntennas(), AipsError);
     123           0 :   return itsADA[which];
     124             : }
     125             : 
     126             : 
     127             : Vector<Stokes::StokesTypes> 
     128           0 : VLALogicalRecord::polarisations(VLAEnum::CDA cda, uInt ant1, uInt ant2) const {
     129           0 :   const Matrix<VLAEnum::IF> ifs = itsSDA.ifUsage(cda);
     130           0 :   const uInt nPol = ifs.ncolumn();
     131           0 :   Vector<Stokes::StokesTypes> retVal(nPol);
     132           0 :   for (uInt p = 0; p < nPol; p++) {
     133           0 :     const Stokes::StokesTypes if1= itsADA[ant1].ifPol(ifs(0,p));
     134           0 :     const Stokes::StokesTypes if2= itsADA[ant2].ifPol(ifs(1,p));
     135           0 :     if ((if1 == Stokes::RCircular) && (if2 == Stokes::RCircular)) {
     136           0 :       retVal(p) = Stokes::RR;
     137           0 :     } else if ((if1 == Stokes::LCircular) && (if2 == Stokes::LCircular)) {
     138           0 :       retVal(p) = Stokes::LL;
     139           0 :     } else if ((if1 == Stokes::RCircular) && (if2 == Stokes::LCircular)) {
     140           0 :       retVal(p) = Stokes::RL;
     141           0 :     } else if ((if1 == Stokes::LCircular) && (if2 == Stokes::RCircular)) {
     142           0 :       retVal(p) = Stokes::LR;
     143             :     }
     144             :   }
     145           0 :   return retVal;
     146           0 : }
     147             : 
     148             : // Local Variables: 
     149             : // compile-command: "gmake VLALogicalRecord; cd test; gmake OPTLIB=1 tVLALogicalRecord"
     150             : // End:

Generated by: LCOV version 1.16