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 : #include <casacore/casa/aips.h> 29 : #include <casacore/images/Images/SubImage.h> 30 : 31 : #include <casacore/coordinates/Coordinates/CoordinateSystem.h> 32 : #include <casacore/coordinates/Coordinates/DirectionCoordinate.h> 33 : #include <casacore/coordinates/Coordinates/SpectralCoordinate.h> 34 : #include <casacore/coordinates/Coordinates/StokesCoordinate.h> 35 : #include <casacore/coordinates/Coordinates/Projection.h> 36 : #include <casacore/casa/Logging/LogSink.h> 37 : #include <casacore/casa/Logging/LogMessage.h> 38 : 39 : #include <imageanalysis/Utilities/SpectralImageUtil.h> 40 : 41 : #include <iostream> 42 : using namespace casacore; 43 : namespace casa { 44 : 45 : 46 313 : Double SpectralImageUtil::worldFreq(const CoordinateSystem& cs, Double spectralpix){ 47 : ///freq part 48 313 : Int spectralIndex=cs.findCoordinate(Coordinate::SPECTRAL); 49 : SpectralCoordinate 50 : spectralCoord= 51 313 : cs.spectralCoordinate(spectralIndex); 52 313 : Vector<String> units(1); units = "Hz"; 53 313 : spectralCoord.setWorldAxisUnits(units); 54 313 : Vector<Double> spectralWorld(1); 55 313 : Vector<Double> spectralPixel(1); 56 313 : spectralPixel(0) = spectralpix; 57 313 : spectralCoord.toWorld(spectralWorld, spectralPixel); 58 313 : Double freq = spectralWorld(0); 59 313 : return freq; 60 313 : } 61 : 62 : } //#End casa namespace