LCOV - code coverage report
Current view: top level - imageanalysis/Utilities - SpectralImageUtil.tcc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 16 21 76.2 %
Date: 2023-11-06 10:06:49 Functions: 2 2 100.0 %

          Line data    Source code
       1             : //# SpectralImageUtil.cc: Spectral Image Utilities
       2             : //# Copyright (C) 2013
       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: 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             : //#
      27             : //# $Id$
      28             : 
      29             : 
      30             : 
      31        6117 : template <typename T>  casacore::SubImage<T>* SpectralImageUtil::getChannel(casacore::ImageInterface<T>& theIm, casacore::Int beginchannel, casacore::Int endchannel, casacore::Bool writeAccess){
      32       12234 :     casacore::CoordinateSystem csys=theIm.coordinates();
      33        6117 :     if(endchannel<0 )
      34           0 :       endchannel=beginchannel;
      35        6117 :     if(beginchannel > endchannel){ 
      36           0 :       casacore::Int temp=endchannel;
      37           0 :       endchannel=beginchannel;
      38           0 :       beginchannel=temp;
      39             :     }
      40        6117 :     casacore::Int spectralIndex=casacore::CoordinateUtil::findSpectralAxis(csys);
      41       12234 :     casacore::IPosition blc(theIm.shape());
      42       12234 :     casacore::IPosition trc(theIm.shape());
      43        6117 :     blc-=blc; //set all values to 0
      44        6117 :     trc=theIm.shape();
      45        6117 :     trc-=1; // set trc to image size -1
      46        6117 :     if(beginchannel > trc[spectralIndex] || beginchannel <0 || endchannel >  trc[spectralIndex] )
      47           0 :       throw(casacore::AipsError("Channel requested does not exist"));
      48        6117 :     blc[spectralIndex]=beginchannel;
      49        6117 :     trc[spectralIndex]=endchannel;
      50        6117 :     casacore::Slicer sl(blc, trc, casacore::Slicer::endIsLast);
      51        6117 :     casacore::SubImage<T> * imageSub=new casacore::SubImage<T>(theIm, sl, writeAccess);
      52       12234 :     return imageSub;
      53             :   };
      54             : 
      55             : 
      56             :  
      57             : 

Generated by: LCOV version 1.16