LCOV - code coverage report
Current view: top level - nrao/VLA - VLAContinuumRecord.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 59 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 13 0.0 %

          Line data    Source code
       1             : //# VLAContinuumRecord.cc:
       2             : //# Copyright (C) 1999,2001
       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/VLAContinuumRecord.h>
      29             : #include <casacore/casa/Arrays/Vector.h>
      30             : #include <casacore/casa/IO/ByteIO.h>
      31             : #include <casacore/casa/BasicMath/Math.h>
      32             : #include <casacore/casa/Exceptions/Error.h>
      33             : #include <casacore/casa/Utilities/Assert.h>
      34             : 
      35             : 
      36           0 : VLAContinuumRecord::VLAContinuumRecord()
      37           0 :   :VLABaselineRecord()
      38             : {
      39           0 : }
      40             : 
      41           0 : VLAContinuumRecord::VLAContinuumRecord(ByteSource& record, uInt offset)
      42           0 :   :VLABaselineRecord(record, offset)
      43             : {
      44           0 : }
      45             : 
      46           0 : VLAContinuumRecord::~VLAContinuumRecord() {
      47           0 : }
      48             : 
      49           0 : void VLAContinuumRecord::attach(ByteSource& record, uInt offset) {
      50           0 :   VLABaselineRecord::attach(record, offset);
      51           0 : }
      52             : 
      53           0 : Vector<Complex> VLAContinuumRecord::data() const {
      54           0 :   Vector<Complex> v(4);
      55           0 :   data(v);
      56           0 :   return v;
      57           0 : }
      58             : 
      59           0 : void VLAContinuumRecord::data(Array<Complex>& values) const {
      60             :   // Note this function slows down lots if the data is not contigious.
      61           0 :   if (values.nelements() == 0) {
      62           0 :     values.resize(IPosition(1,4));
      63             :   } else {
      64           0 :     DebugAssert(values.nelements() == 4, AipsError);
      65             :   }
      66             : 
      67           0 :   const Float fscale = scale();
      68           0 :   const Int64 where = itsOffset + 4;
      69           0 :   itsRecord.seek(where);
      70             :   Bool isACopy;
      71           0 :   Complex* dataPtr = values.getStorage(isACopy);
      72           0 :   Complex* curDataPtr = dataPtr;
      73             :   Short idata[2];
      74             :   // #if defined(AIPS_DEBUG)
      75             :   // check on max idata value >= 16384 seems to be wrong, data identified with max value of 0 that otherwise fills OK
      76             :   // Short max = 0;
      77             :   // #endif
      78           0 :   for (uInt i = 0; i < 4; i++, curDataPtr++) {
      79           0 :     itsRecord.read(2, idata);
      80             :     // #if defined(AIPS_DEBUG)
      81             :     // Short absData = abs(idata[0]);
      82             :     // if (absData > max) max = absData;
      83             :     // absData = abs(idata[1]);
      84             :     // if (absData > max) max = absData;
      85             :     // #endif
      86           0 :     *curDataPtr = Complex (Float(idata[0])/fscale, Float(idata[1])/fscale);
      87           0 :     itsRecord.seek(2, ByteIO::Current); // skip over the variance;
      88             :   }
      89           0 :   values.putStorage(dataPtr, isACopy);
      90             :   // #if defined(AIPS_DEBUG)
      91             :   // AlwaysAssert(max >= 16384, AipsError);
      92             :   // #endif
      93           0 : }
      94             : 
      95           0 : Vector<Bool> VLAContinuumRecord::flags() const {
      96           0 :   Vector<Bool> flags(4);
      97             :   Bool isACopy;
      98           0 :   Bool* dataPtr = flags.getStorage(isACopy);
      99           0 :   const Int64 where = itsOffset + 2;
     100           0 :   itsRecord.seek(where);
     101           0 :   itsRecord.read(4, dataPtr);
     102           0 :   flags.putStorage(dataPtr, isACopy);
     103             : 
     104             : //   const uInt n = 4;
     105             : //   uChar bytes[n];
     106             : //   itsRecord.seek(itsOffset);
     107             : //   itsRecord.read(n, bytes);
     108             :   //  cout << "Header bytes from a continuum record. [" << setbase(16);
     109             : //   for (uInt i = 0; i < n; i++) {
     110             : //     cout << Int(bytes[i]) << ":";
     111             : //   }
     112             : //   cout << "]" << setbase(10) << endl;
     113           0 :   return flags;
     114           0 : }
     115             : 
     116           0 : Vector<Float> VLAContinuumRecord::variance() const {
     117           0 :   const Float fscale = scale();
     118           0 :   const Int64 where = itsOffset + 8;
     119           0 :   itsRecord.seek(where);
     120           0 :   Vector<Float> var(4);
     121             :   uShort ivar;
     122           0 :   for (uInt i = 0; i < 4; i++) {
     123           0 :     itsRecord >> ivar;
     124           0 :     var(i) = Float(ivar)/fscale;
     125           0 :     itsRecord.seek(4, ByteIO::Current); // skip over the data;
     126             :   }
     127           0 :   return var;
     128           0 : }
     129             : 
     130           0 : uInt VLAContinuumRecord::scale() const {
     131           0 :   return VLABaselineRecord::scale(0u);
     132             : }
     133             : 
     134           0 : uInt VLAContinuumRecord::ant1() const {
     135           0 :   return VLABaselineRecord::ant1(2u);
     136             : }
     137             : 
     138           0 : uInt VLAContinuumRecord::ant2() const {
     139           0 :   return VLABaselineRecord::ant2(2u);
     140             : }
     141             :   
     142           0 : VLABaselineRecord::Type VLAContinuumRecord::type() const {
     143           0 :   return VLABaselineRecord::CONTINUUM;
     144             : }
     145             : 
     146             : // Local Variables: 
     147             : // compile-command: "gmake VLAContinuumRecord"
     148             : // End: 

Generated by: LCOV version 1.16