LCOV - code coverage report
Current view: top level - imageanalysis/Utilities - SpectralImageUtil.tcc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 17 22 77.3 %
Date: 2024-12-11 20:54:31 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: 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             : //# $Id$
      28             : 
      29             : 
      30             : 
      31        6264 : template <typename T>  casacore::SubImage<T>* SpectralImageUtil::getChannel(casacore::ImageInterface<T>& theIm, casacore::Int beginchannel, casacore::Int endchannel, casacore::Bool writeAccess){
      32        6264 :     casacore::CoordinateSystem csys=theIm.coordinates();
      33        6264 :     if(endchannel<0 )
      34           0 :       endchannel=beginchannel;
      35        6264 :     if(beginchannel > endchannel){ 
      36           0 :       casacore::Int temp=endchannel;
      37           0 :       endchannel=beginchannel;
      38           0 :       beginchannel=temp;
      39             :     }
      40        6264 :     casacore::Int spectralIndex=casacore::CoordinateUtil::findSpectralAxis(csys);
      41        6264 :     casacore::IPosition blc(theIm.shape());
      42        6264 :     casacore::IPosition trc(theIm.shape());
      43        6264 :     blc-=blc; //set all values to 0
      44        6264 :     trc=theIm.shape();
      45        6264 :     trc-=1; // set trc to image size -1
      46        6264 :     if(beginchannel > trc[spectralIndex] || beginchannel <0 || endchannel >  trc[spectralIndex] )
      47           0 :       throw(casacore::AipsError("Channel requested does not exist"));
      48        6264 :     blc[spectralIndex]=beginchannel;
      49        6264 :     trc[spectralIndex]=endchannel;
      50        6264 :     casacore::Slicer sl(blc, trc, casacore::Slicer::endIsLast);
      51        6264 :     casacore::SubImage<T> * imageSub=new casacore::SubImage<T>(theIm, sl, writeAccess);
      52        6264 :     return imageSub;
      53        6264 :   };
      54             : 
      55             : 
      56             :  
      57             : 

Generated by: LCOV version 1.16