LCOV - code coverage report
Current view: top level - nrao/VLA - VLASpectralLineRecord.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 59 0.0 %
Date: 2024-10-10 11:40:37 Functions: 0 12 0.0 %

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

Generated by: LCOV version 1.16