casa
$Rev:20696$
|
00001 //# LatticeSlice1D.h: 1-D slice from a Lattice 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: LatticeSlice1D.h 20299 2008-04-03 05:56:44Z gervandiepen $ 00027 00028 #ifndef LATTICES_LATTICESLICE1D_H 00029 #define LATTICES_LATTICESLICE1D_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <casa/Arrays/Vector.h> 00035 #include <casa/iosstrfwd.h> 00036 00037 00038 namespace casa { //# NAMESPACE CASA - BEGIN 00039 00040 //# Forward Declarations 00041 template <class T> class MaskedLattice; 00042 class IPosition; 00043 class Interpolate2D; 00044 class PixelCurve1D; 00045 class String; 00046 00047 // <summary> 00048 // Extract a 1-D slice from a Lattice 00049 // </summary> 00050 // <use visibility=export> 00051 // <reviewed reviewer="" date="yyyy/mm/dd" tests="test/tLatticeSlice1D" demos=""> 00052 // </reviewed> 00053 // <prerequisite> 00054 // <li> <linkto class=MaskedLattice>MaskedLattice</linkto> 00055 // </prerequisite> 00056 00057 // <etymology> 00058 // </etymology> 00059 00060 // <synopsis> 00061 // This class extracts an interpolated 1-D slice from a Lattice 00062 // with a range of interpolation schemes available. The slice must lie in 00063 // the plane of two cardinal axes. 00064 // </synopsis> 00065 // 00066 // <note role=tip> 00067 // </note> 00068 // 00069 // <example> 00070 // <srcBlock> 00071 // IPosition shape(2, 20, 30); // Create MaskedLattice 00072 // ArrayLattice<Float> arrLat(shape); 00073 // SubLattice<Float> subLat(arrLat); 00074 // LatticeSlice1D<Float> slicer(subLat); 00075 // 00076 // IPosition blc(2); blc = 0; // Extract slice between corners 00077 // IPosition trc(shape-1); 00078 // Vector<Float> data; 00079 // Vector<Bool> mask; 00080 // slicer.getSlice (data, mask, blc, trc); 00081 // </srcBlock> 00082 // </example> 00083 00084 // <motivation> 00085 // Users often want to see cross-cuts through their data. 00086 // </motivation> 00087 00088 // <todo asof="2004/04/16"> 00089 // <li> Handle curves not in cardinal axis plane 00090 // <li> Derive from MaskedLattice ? 00091 // </todo> 00092 00093 00094 template <class T> class LatticeSlice1D 00095 { 00096 public: 00097 00098 // Interpolation method 00099 enum Method {NEAREST=0, LINEAR=1, CUBIC=2, N_TYPES}; 00100 00101 // Default constructor - object useless 00102 LatticeSlice1D (); 00103 00104 // Constructor 00105 LatticeSlice1D (const MaskedLattice<T>& lattice, Method method=LINEAR); 00106 00107 // Copy constructor (reference semantics) 00108 LatticeSlice1D(const LatticeSlice1D<T> &other); 00109 00110 // Destructor 00111 virtual ~LatticeSlice1D (); 00112 00113 // Assignment operator (reference semantics) 00114 LatticeSlice1D<T>& operator=(const LatticeSlice1D<T> &other); 00115 00116 // Get 1-D slice. PixelCurve1D supplies the locus of the slice in 00117 // the plane specified by axis0 and axis1. The pixel coordinate for 00118 // the rest of the lattice is specified in <src>coord</src>. 00119 void getSlice (Vector<T>& data, Vector<Bool>& mask, 00120 const PixelCurve1D& curve, uInt axis0, uInt axis1, 00121 const IPosition& coord); 00122 00123 // Get 1-D slice between blc & trc. These start and end points must be 00124 // in a cardinal plane of the lattice. If nPts is 0 it is set automatically to 00125 // the length of the slice. 00126 void getSlice (Vector<T>& data, Vector<Bool>& mask, 00127 const IPosition& blc, const IPosition& trc, uInt nPts=0); 00128 00129 // Get the (x,y) pixel coordinates from the last slice and the distance along 00130 // the slice in pixels.. Also recover the axes of the slice plane 00131 void getPosition (uInt& axis0, uInt& axis1, Vector<Float>& x, 00132 Vector<Float>& y, Vector<Float>& distance) const; 00133 00134 // Recover interpolation method 00135 Method interpolationMethod () const {return itsMethod;}; 00136 00137 static Method stringToMethod (const String& method); 00138 00139 private: 00140 // Check the suppliec curve is valid. 00141 void checkCurve (IPosition& blc, IPosition& trc, 00142 const IPosition& coord, const PixelCurve1D& curve); 00143 // Find the slice plane. 00144 void findPlane (const IPosition& blc, 00145 const IPosition& trc); 00146 // Get the interpolated slice 00147 void doGetSlice (Vector<T>& data, Vector<Bool>& mask, 00148 const PixelCurve1D& curve, 00149 const IPosition& blc, const IPosition& trc); 00150 // Make Interpolator 00151 void makeInterpolator (Method method); 00152 00153 // 00154 MaskedLattice<T>* itsLatticePtr; 00155 Interpolate2D* itsInterpPtr; 00156 Method itsMethod; 00157 Vector<Float> itsX; 00158 Vector<Float> itsY; 00159 Vector<Double> itsPos; 00160 uInt itsAxis0; 00161 uInt itsAxis1; 00162 }; 00163 00164 00165 } //# NAMESPACE CASA - END 00166 00167 #ifndef CASACORE_NO_AUTO_TEMPLATES 00168 #include <lattices/Lattices/LatticeSlice1D.tcc> 00169 #endif //# CASACORE_NO_AUTO_TEMPLATES 00170 #endif