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 : #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 0 : Double SpectralImageUtil::worldFreq(const CoordinateSystem& cs, Double spectralpix){ 47 : ///freq part 48 0 : Int spectralIndex=cs.findCoordinate(Coordinate::SPECTRAL); 49 : SpectralCoordinate 50 : spectralCoord= 51 0 : cs.spectralCoordinate(spectralIndex); 52 0 : Vector<String> units(1); units = "Hz"; 53 0 : spectralCoord.setWorldAxisUnits(units); 54 0 : Vector<Double> spectralWorld(1); 55 0 : Vector<Double> spectralPixel(1); 56 0 : spectralPixel(0) = spectralpix; 57 0 : spectralCoord.toWorld(spectralWorld, spectralPixel); 58 0 : Double freq = spectralWorld(0); 59 0 : return freq; 60 : } 61 : 62 : } //#End casa namespace