casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisplayCoordinateSystem.h
Go to the documentation of this file.
1 //# DisplayCoordinateSystem.h: Interconvert pixel and image coordinates.
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 addressed 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: CoordinateSystem.h 20491 2009-01-16 08:33:56Z gervandiepen $
28 
29 #ifndef DISPLAY_COORDINATESYSTEM_H_
30 #define DISPLAY_COORDINATESYSTEM_H_
31 
35 
36 namespace casa {
37 
39  public:
40 
45  virtual ~DisplayCoordinateSystem( );
46 
47  operator const casacore::CoordinateSystem &( ) const { return cs_; }
48 
51  cs_ = o.cs_;
52  return *this;
53  }
55  transposition_log.clear( );
56  cs_ = o;
57  return *this;
58  }
59 
60  casacore::String showType(casacore::uInt whichCoordinate) const
61  { return cs_.showType(whichCoordinate); }
62 
64  unsigned int nPixelAxes() const { return cs_.nPixelAxes( ); }
65  unsigned int nWorldAxes() const { return cs_.nWorldAxes( ); }
66 
67  // is the first direction axis RA or Dec...
69  { return cs_.isDirectionAbscissaLongitude( ); }
70 
72  { return cs_.obsInfo( ); }
73  void setObsInfo(const casacore::ObsInfo &obsinfo)
74  { cs_.setObsInfo(obsinfo); }
75 
82 
84  { return cs_.worldMixMin( ); }
86  { return cs_.worldMixMax( ); }
88  { return cs_.setWorldMixRanges(shape); }
89 
90  bool near( const casacore::Coordinate& other, casacore::Double tol=1e-6 ) const
91  { return cs_.near(other,tol); }
92  bool near(const casacore::Coordinate& other, const casacore::Vector<casacore::Int>& excludePixelAxes, casacore::Double tol=1e-6) const
93  { return cs_.near(other,excludePixelAxes,tol); }
94 
95  void makePixelRelative( casacore::Vector<double>& pixel ) const;
96  void makePixelAbsolute( casacore::Vector<double>& pixel ) const;
97  void makeWorldAbsolute (casacore::Vector<double>& world) const;
98  void makeWorldRelative (casacore::Vector<double>& world) const;
99 
101  { return cs_.referencePixel( ); }
103  { return cs_.setReferencePixel( casacore::Vector<double>(refPix) ); }
105  { return cs_.referenceValue( ); }
107  { return cs_.setReferenceValue(refval); }
109  { return cs_.setIncrement(inc); }
110 
111 
112  casacore::Coordinate::Type type(unsigned int whichCoordinate) const { return cs_.type(whichCoordinate); }
113 
114  bool hasDirectionCoordinate( ) const { return cs_.hasDirectionCoordinate( ); }
115  const casacore::DirectionCoordinate &directionCoordinate( int which = -1 ) const
116  { return which < 0 ? cs_.directionCoordinate( ) : cs_.directionCoordinate(which); }
118 
119  bool hasSpectralAxis() const { return cs_.hasSpectralAxis( ); }
120  const casacore::SpectralCoordinate &spectralCoordinate( int which = -1 ) const
121  { return which < 0 ? cs_.spectralCoordinate( ) : cs_.spectralCoordinate(which); }
122  int spectralAxisNumber(bool doWorld=false) const { return cs_.spectralAxisNumber(doWorld); }
123 
124  const casacore::LinearCoordinate &linearCoordinate( unsigned int which ) const
125  { return cs_.linearCoordinate(which); }
127 
129  return cs_.polarizationAxisNumber(doWorld);
130  }
131  const casacore::StokesCoordinate &stokesCoordinate( int which = -1 ) const
132  { return which < 0 ? cs_.stokesCoordinate( ) : cs_.stokesCoordinate(which); }
133 
134  const casacore::TabularCoordinate &tabularCoordinate( unsigned int which ) const
135  { return cs_.tabularCoordinate(which); }
136 
137  const casacore::QualityCoordinate &qualityCoordinate(unsigned int which) const
138  { return cs_.qualityCoordinate(which); }
139  int qualityAxisNumber() const
140  { return cs_.qualityAxisNumber( ); }
141 
142  int worldAxisToPixelAxis(unsigned int worldAxis) const
143  { return cs_.worldAxisToPixelAxis(worldAxis); }
144  int pixelAxisToWorldAxis(unsigned int pixelAxis) const
145  { return cs_.pixelAxisToWorldAxis(pixelAxis); }
146 
147  void findWorldAxis( int &coordinate, int &axisInCoordinate, unsigned int axisInCoordinateSystem) const
148  { cs_.findWorldAxis( coordinate, axisInCoordinate, axisInCoordinateSystem ); }
149  void findPixelAxis( int &coordinate, int &axisInCoordinate, unsigned int axisInCoordinateSystem) const
150  { cs_.findPixelAxis( coordinate, axisInCoordinate, axisInCoordinateSystem ); }
151 
152  const casacore::Coordinate& coordinate(unsigned int which) const
153  { return cs_.coordinate(which); }
154  int findCoordinate( casacore::Coordinate::Type type, int afterCoord = -1 ) const
155  { return cs_.findCoordinate(type,afterCoord); }
156  bool replaceCoordinate( const casacore::Coordinate &newCoordinate, unsigned int whichCoordinate )
157  { return cs_.replaceCoordinate( newCoordinate, whichCoordinate ); }
158 
160  { cs_.addCoordinate(coord); }
161  bool removeWorldAxis(unsigned int axis, double replacement)
162  { return cs_.removeWorldAxis(axis,replacement); }
163  bool removePixelAxis(unsigned int axis, double replacement)
164  { return cs_.removePixelAxis(axis,replacement); }
165  void transpose(const casacore::Vector<int> &newWorldOrder, const casacore::Vector<int> &newPixelOrder);
166 
167  casacore::String format( casacore::String& units, casacore::Coordinate::formatType format, double worldValue, unsigned int worldAxis,
168  bool isAbsolute=true, bool showAsAbsolute=true, int precision=-1, bool usePrecForMixed=false ) const;
169 
170  // coordinate mapping...
171  const casacore::String& errorMessage() const { return cs_.errorMessage( ); }
172 
173  bool toWorld( casacore::Vector<double> &world, const casacore::Vector<double> &pixel ) const;
174  bool toPixel(casacore::Vector<double> &pixel, const casacore::Vector<double> &world) const;
175 
176 #if 0
177  bool toWorld( casacore::Vector<double> &world, const casacore::Vector<double> &pixel ) const;
178  bool toPixel(casacore::Vector<double> &pixel, const casacore::Vector<double> &world) const;
179 #endif
180  bool toMix( casacore::Vector<double>& worldOut, casacore::Vector<double>& pixelOut,
181  const casacore::Vector<double>& worldIn, const casacore::Vector<double>& pixelIn,
183  const casacore::Vector<double>& worldMin, const casacore::Vector<double>& worldMax) const;
184 
185  void subImageInSitu( const casacore::Vector<float> &originShift, const casacore::Vector<float> &incrFac, const casacore::Vector<int>& newShape)
186  { cs_.subImageInSitu( originShift, incrFac, newShape ); }
187 
188 
190  { return cs_.increment( ); }
191 
192  bool save( casacore::RecordInterface &container, const casacore::String &fieldName ) const
193  { return cs_.save(container,fieldName); }
194  static DisplayCoordinateSystem restore( const casacore::RecordInterface &container,const casacore::String &fieldName );
195 
196  // casacore::CoordinateUtil wrappers...
198  { return cs_.setRestFrequency( errorMsg, casacore::Quantity(value, unit) ); }
199  bool setSpectralState( casacore::String& errorMsg,const casacore::String& unit, const casacore::String& spcquant)
200  { return casacore::CoordinateUtil::setSpectralState( errorMsg, cs_, unit, spcquant ); }
201  bool setSpectralConversion( casacore::String& errorMsg, const casacore::String frequencySystem )
202  { return cs_.setSpectralConversion( errorMsg, frequencySystem); }
203  bool setSpectralFormatting( casacore::String& errorMsg, const casacore::String& unit, const casacore::String& spcquant )
204  { return casacore::CoordinateUtil::setSpectralFormatting( errorMsg, cs_, unit, spcquant ); }
205  bool setDirectionUnit( const string& unit, casacore::Int which=-1)
206  { return casacore::CoordinateUtil::setDirectionUnit( cs_, unit, which ); }
209  bool setVelocityState( casacore::String& errorMsg, const casacore::String& unit, const casacore::String& spcquant)
210  { return casacore::CoordinateUtil::setVelocityState( errorMsg, cs_, unit, spcquant ); }
212  { return casacore::CoordinateUtil::removePixelAxes( cs_, pixelReplacement,pixelAxes,remove ); }
213  bool removeAxes( casacore::Vector<double>& worldReplacement, const casacore::Vector<int>& worldAxes, bool remove)
214  { return casacore::CoordinateUtil::removeAxes( cs_, worldReplacement, worldAxes, remove); }
215 
216 
217 
218  // from ImageUtilities...
220  const casacore::IPosition& pixelAxes, bool doRef=false ) const {
221  SkyComponentFactory::worldWidthsToPixel(dParameters, parameters, cs_, pixelAxes, doRef );
222  }
223 
224  // adjust this coordinate system to match the 'other' coordinate system
225  void match( const DisplayCoordinateSystem &other );
226  casacore::Vector<int> transposeShape( const casacore::Vector<int> &original_shape, bool world=true );
227 
228  private:
230  typedef std::vector<std::pair<casacore::Vector<int>,casacore::Vector<int> > > transposition_log_t;
232  };
233 
234 }
235 
236 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual uInt nWorldAxes() const
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
const QualityCoordinate & qualityCoordinate(uInt which) const
int Int
Definition: aipstype.h:50
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
virtual Vector< Double > referencePixel() const
bool removeWorldAxis(unsigned int axis, double replacement)
virtual Vector< Double > referenceValue() const
const casacore::DirectionCoordinate & directionCoordinate(int which=-1) const
casacore::Vector< casacore::String > worldAxisUnits() const
const TabularCoordinate & tabularCoordinate(uInt which) const
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
bool setReferencePixel(const casacore::Vector< double > &refPix)
static void setNiceAxisLabelUnits(CoordinateSystem &cSys)
Set the world axis units in the CS to &#39;deg&#39; for Direction.
const StokesCoordinate & stokesCoordinate() const
Int polarizationAxisNumber(Bool doWorld=False) const
What is the number of the polarization/stokes axis? If doWorld=True, the world axis number is returne...
void findWorldAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Given an axis number (pixel or world) in the CoordinateSystem, find the corresponding coordinate numb...
Table lookup 1-D coordinate, with interpolation.
bool setIncrement(const casacore::Vector< double > &inc)
bool toWorld(casacore::Vector< double > &world, const casacore::Vector< double > &pixel) const
const casacore::TabularCoordinate & tabularCoordinate(unsigned int which) const
virtual Vector< Double > worldMixMin() const
void makePixelRelative(casacore::Vector< double > &pixel) const
static Bool setVelocityState(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set velocity state of SpectralCoordinate in CoordinateSystem.
static Bool setDirectionUnit(CoordinateSystem &cSys, const String &unit, Int which=-1)
Set a unit for all unremoved world axes in the DirectionCoordinate in the CS.
const casacore::QualityCoordinate & qualityCoordinate(unsigned int which) const
const String & errorMessage() const
If the last conversion to world or pixel coordinates resulted in an error, report that error...
Definition: Coordinate.h:584
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
String showType(uInt whichCoordinate) const
Returns the type of the given Coordinate as a string.
const casacore::Coordinate & coordinate(unsigned int which) const
void setObsInfo(const casacore::ObsInfo &obsinfo)
bool setWorldAxisUnits(const casacore::Vector< casacore::String > &units)
bool toMix(casacore::Vector< double > &worldOut, casacore::Vector< double > &pixelOut, const casacore::Vector< double > &worldIn, const casacore::Vector< double > &pixelIn, const casacore::Vector< bool > &worldAxes, const casacore::Vector< bool > &pixelAxes, const casacore::Vector< double > &worldMin, const casacore::Vector< double > &worldMax) const
static Bool setSpectralState(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set spectral state of SpectralCoordinate in CoordinateSystem.
Interconvert between pixel and a linear world coordinate.
Int spectralAxisNumber(Bool doWorld=False) const
What number is the spectral axis? If doWorld=True, the world axis number is returned.
virtual Bool setReferenceValue(const Vector< Double > &refval)
const DirectionCoordinate & directionCoordinate() const
DisplayCoordinateSystem(const DisplayCoordinateSystem &o)
void findPixelAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
casacore::Int polarizationAxisNumber(casacore::Bool doWorld=false) const
Interconvert between pixel and Quality value.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
bool setVelocityState(casacore::String &errorMsg, const casacore::String &unit, const casacore::String &spcquant)
bool near(const casacore::Coordinate &other, const casacore::Vector< casacore::Int > &excludePixelAxes, casacore::Double tol=1e-6) const
int findCoordinate(casacore::Coordinate::Type type, int afterCoord=-1) const
casacore::String showType(casacore::uInt whichCoordinate) const
formatType
This enum is used for formatting world values into Strings.
Definition: Coordinate.h:162
Coordinate::Type type(uInt whichCoordinate) const
Return the type of the given Coordinate.
const casacore::String & errorMessage() const
coordinate mapping...
virtual uInt nPixelAxes() const
Sums the number of axes in the Coordinates that the CoordinateSystem contains, allowing for removed a...
bool isDirectionAbscissaLongitude() const
is the first direction axis RA or Dec...
Store miscellaneous information related to an observation.
Definition: ObsInfo.h:97
bool removePixelAxis(unsigned int axis, double replacement)
bool removeAxes(casacore::Vector< double > &worldReplacement, const casacore::Vector< int > &worldAxes, bool remove)
Bool setRestFrequency(String &errorMsg, const Quantity &freq)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
std::vector< std::pair< casacore::Vector< int >, casacore::Vector< int > > > transposition_log_t
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name. ...
casacore::uInt nCoordinates() const
int spectralAxisNumber(bool doWorld=false) const
virtual Vector< Double > increment() const
void addCoordinate(const casacore::Coordinate &coord)
bool setSpectralFormatting(casacore::String &errorMsg, const casacore::String &unit, const casacore::String &spcquant)
const casacore::LinearCoordinate & linearCoordinate(unsigned int which) const
const casacore::StokesCoordinate & stokesCoordinate(int which=-1) const
casacore::CoordinateSystem cs_
bool setReferenceValue(const casacore::Vector< double > &refval)
bool setRestFrequency(casacore::String &errorMsg, const casacore::String &unit, const casacore::Double &value)
casacore::CoordinateUtil wrappers...
static Bool removePixelAxes(CoordinateSystem &cSys, Vector< Double > &pixelReplacement, const Vector< Int > &pixelAxes, const Bool remove)
Remove a list of pixel axes but not their associated world axes from a CoordinateSystem.
Interconvert pixel positions and directions (e.g. RA/DEC).
Interface for converting between world and pixel coordinates.
Definition: Coordinate.h:139
Bool hasDirectionCoordinate() const
void setObsInfo(const ObsInfo &obsinfo)
void subImageInSitu(const casacore::Vector< float > &originShift, const casacore::Vector< float > &incrFac, const casacore::Vector< int > &newShape)
bool toPixel(casacore::Vector< double > &pixel, const casacore::Vector< double > &world) const
bool setSpectralConversion(casacore::String &errorMsg, const casacore::String frequencySystem)
uInt nCoordinates() const
Returns the number of Coordinates that this CoordinateSystem contains.
casacore::Vector< double > referencePixel() const
double Double
Definition: aipstype.h:55
virtual Bool setReferencePixel(const Vector< Double > &refPix)
bool replaceCoordinate(const casacore::Coordinate &newCoordinate, unsigned int whichCoordinate)
static Bool removeAxes(CoordinateSystem &cSys, Vector< Double > &worldReplacement, const Vector< Int > &worldAxes, const Bool remove)
Remove a list of world axes and their associated pixel axes from a CoordinateSystem.
Bool isDirectionAbscissaLongitude() const
Is the abscissa in the DirectionCoordinate the longitude axis? Throws exception if there is no Direct...
bool setDirectionUnit(const string &unit, casacore::Int which=-1)
const Coordinate & coordinate(uInt which) const
Return the given Coordinate as a reference to the base class object.
int worldAxisToPixelAxis(unsigned int worldAxis) const
bool setWorldMixRanges(const casacore::IPosition &shape)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Bool removeWorldAxis(uInt axis, Double replacement)
Remove a world or pixel axis.
void makeWorldAbsolute(casacore::Vector< double > &world) const
Int findCoordinate(Coordinate::Type type, Int afterCoord=-1) const
Find the Coordinate number that corresponds to the given type.
bool save(casacore::RecordInterface &container, const casacore::String &fieldName) const
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
Type
This enum lists the types of the derived classes.
Definition: Coordinate.h:144
static void worldWidthsToPixel(casacore::Vector< casacore::Double > &dParameters, const casacore::Vector< casacore::Quantum< casacore::Double > > &parameters, const casacore::CoordinateSystem &cSys, const casacore::IPosition &pixelAxes, casacore::Bool doRef=false)
Convert 2d shape from world (world parameters=x, y, major axis, minor axis, position angle) to pixel ...
casacore::ObsInfo obsInfo() const
Interconvert pixel and frequency values.
DisplayCoordinateSystem(const casacore::CoordinateSystem &c)
bool near(const casacore::Coordinate &other, casacore::Double tol=1e-6) const
static Bool setSpectralFormatting(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set default format unit and doppler velocity state of SpectralCoordinate in CoordinateSystem.
casacore::Coordinate::Type type(unsigned int whichCoordinate) const
void addCoordinate(const Coordinate &coord)
Add another Coordinate to this CoordinateSystem.
Bool removePixelAxis(uInt axis, Double replacement)
virtual Vector< Double > worldMixMax() const
int pixelAxisToWorldAxis(unsigned int pixelAxis) const
void makeWorldRelative(casacore::Vector< double > &world) const
casacore::Vector< double > worldMixMax() const
const Double e
e and functions thereof:
Interconvert between pixel and Stokes value.
const Double c
Fundamental physical constants (SI units):
const SpectralCoordinate & spectralCoordinate(uInt which) const
casacore::Vector< casacore::String > worldAxisNames() const
const casacore::SpectralCoordinate & spectralCoordinate(int which=-1) const
casacore::Vector< int > directionAxesNumbers() const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
bool setSpectralState(casacore::String &errorMsg, const casacore::String &unit, const casacore::String &spcquant)
void worldWidthsToPixel(casacore::LogIO &, casacore::Vector< double > &dParameters, const casacore::Vector< casacore::Quantum< casacore::Double > > &parameters, const casacore::IPosition &pixelAxes, bool doRef=false) const
from ImageUtilities...
casacore::Vector< int > pixelAxes(casacore::uInt whichCoord) const
const DisplayCoordinateSystem & operator=(const DisplayCoordinateSystem &o)
casacore::Vector< double > referenceValue() const
casacore::String format(casacore::String &units, casacore::Coordinate::formatType format, double worldValue, unsigned int worldAxis, bool isAbsolute=true, bool showAsAbsolute=true, int precision=-1, bool usePrecForMixed=false) const
void subImageInSitu(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape)
bool setWorldAxisNames(const casacore::Vector< casacore::String > &names)
void makePixelAbsolute(casacore::Vector< double > &pixel) const
Bool replaceCoordinate(const Coordinate &newCoordinate, uInt whichCoordinate)
Replace one Coordinate with another.
static DisplayCoordinateSystem restore(const casacore::RecordInterface &container, const casacore::String &fieldName)
Abstract base class for Record classes.
casacore::Vector< int > transposeShape(const casacore::Vector< int > &original_shape, bool world=true)
casacore::Vector< double > increment() const
void match(const DisplayCoordinateSystem &other)
adjust this coordinate system to match the &#39;other&#39; coordinate system
void findPixelAxis(int &coordinate, int &axisInCoordinate, unsigned int axisInCoordinateSystem) const
virtual Bool setIncrement(const Vector< Double > &inc)
casacore::Vector< double > worldMixMin() const
Int worldAxisToPixelAxis(uInt worldAxis) const
Find the pixel axis for the given world axis in a CoordinateSystem.
Bool setSpectralConversion(String &errorMsg, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel&lt;-&gt;world go to t...
void transpose(const casacore::Vector< int > &newWorldOrder, const casacore::Vector< int > &newPixelOrder)
bool removePixelAxes(casacore::Vector< casacore::Double > &pixelReplacement, const casacore::Vector< casacore::Int > &pixelAxes, const casacore::Bool remove)
Int pixelAxisToWorldAxis(uInt pixelAxis) const
Find the world axis for the given pixel axis in a CoordinateSystem.
Interconvert pixel and world coordinates.
void findWorldAxis(int &coordinate, int &axisInCoordinate, unsigned int axisInCoordinateSystem) const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
unsigned int uInt
Definition: aipstype.h:51
casacore::Vector< int > worldAxes(casacore::uInt whichCoord) const
virtual Bool setWorldMixRanges(const IPosition &shape)
Compute and recover the world min and max ranges, for use in function toMix, for a lattice of the giv...
Bool hasPolarizationCoordinate() const
does this coordinate system have a polarizaion/stokes coordinate?