casacore
Loading...
Searching...
No Matches
CoordinateUtil.h
Go to the documentation of this file.
1//# CoordinateUtils.h: static functions dealing with coordinates
2//# Copyright (C) 1997,1998,1999,2000,2001,2002,2004
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: 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#ifndef COORDINATES_COORDINATEUTIL_H
27#define COORDINATES_COORDINATEUTIL_H
28
29
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Vector.h>
32#include <casacore/measures/Measures/Stokes.h>
33#include <casacore/coordinates/Coordinates/Coordinate.h>
34
35#include <casacore/measures/Measures/MDirection.h> //# For enums
36#include <casacore/measures/Measures/MFrequency.h>
37#include <casacore/measures/Measures/MeasConvert.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41class CoordinateSystem;
42class DirectionCoordinate;
43class ObsInfo;
44class String;
45class LogIO;
46class MEpoch;
47class MPosition;
48class Unit;
49
50
51// <summary>Functions for creating default CoordinateSystems</summary>
52// <use visibility=export>
53
54// <reviewed reviewer="" date="" tests="" demos="">
55// </reviewed>
56
57// <prerequisite>
58// <li> <linkto class="CoordinateSystem">CoordinateSystem</linkto>
59// </prerequisite>
60//
61// <etymology>
62// CoordinateUtils follows the Casacore naming convention for static functions
63// that are associated with a class.
64// </etymology>
65//
66// <synopsis>
67// This file contains declarations for static functions that manipulate
68// coordinate systems. It currently contains functions for:
69// <ul>
70// <li> Adding default axes to a CoordinateSystem
71// <li> Creating a default CoordinateSystem
72// <li> Finding specified axes in a CoordinateSystem
73// </ul>
74//
75// The functions for adding default axes to a CoordinateSystem can add
76// either a RA/DEC pair of axes, a Polarisation Axis, or a Spectral Axis to
77// a user supplied coordinate system. The default values for these functions
78// are:
79// <ul>
80// <li> <src>addDirAxes</src> this adds a DirectionCoordinate with a
81// reference pixel of (0,0) corresponding to an RA/DEC of (0,0) in a
82// J2000 reference frame. The pixel increment is 1 arc-minute.
83// <li> <src>addIQUVAxis</src> this adds a polarization axis with four
84// elements corresponding to the Stokes (I,Q,U,V) components.
85// <li> <src>addIAxis</src> this adds a polarization axis with one
86// element corresponding to the Stokes I component only
87// <li> <src>addFreqAxis</src> this adds a spectral axis with a reference
88// frequency of 1.415GHz on channel 0. The channel bandwidth (pixel
89// increment) is 1kHz, and the reference frame is the kinematical Local Standard of
90// rest (<linkto class="MFrequency">MFrequency</linkto>::LSRK).
91// </ul>
92//
93// The <src>defaultCoords</src> functions, create from scratch a
94// CoordinateSystem using the above described <src>addXXXAxis</src>
95// functions to add the required number of dimensions to the
96// CoordinateSystem. Only 2, 3 or 4 dimensional coordinate systems can be
97// constructed using these functions. The coordinate systems always have
98// RA/Dec axes. Three dimensional Systems add a spectral axis and
99// four-dimensional systems add an IQUV polarization axis. An exception
100// (AipsError) is thrown if <src>defaultCoords(uInt)</src> is called with a
101// parameter that is not 2, 3, or 4.
102//
103// The <src>defaultCoordsXX</src> functions return the coordinate system by
104// value (which involves a copy of the CoordinateSystem) and hence are not
105// as effcient as the <src>addXXXAxis</src> functions.
106//
107// If the default axes provided by these functions are not quite what is
108// required it is possible to use member functions of the
109// <linkto class="CoordinateSystem">CoordinateSystem</linkto>
110// and <linkto class="Coordinate">Coordinate</linkto> classes
111// (<linkto class="DirectionCoordinate">DirectionCoordinate</linkto>,
112// <linkto class="StokesCoordinate">StokesCoordinate</linkto>,
113// <linkto class="SpectralCoordinate">SpectralCoordinate</linkto> etc.)
114// to tweak the appropriate parameters of the specified axis.
115//
116// Now we turn to the functions for finding axes in a CoordinateSystem. With
117// a CoordinateSystem object it is not required that the first Coordinate
118// axis in the the CoordinateSystem map to the first pixel axis in an
119// image. Hence it is necessary to determine which pixel axis corresponds to a
120// specified Coordinate and this can be done using these functions. Some
121// coordinate types, in particular DirectionCoordinate, usually map to more
122// than one pixel axis (DirectionsCoordinates are inherently two-dimensional).
123//
124// This group contains declarations for static functions that search
125// CoordinateSystem's for a coordinate of the specified type. It returns the
126// pixel axis (zero relative) of the specified coordinate type. If the supplied
127// Coordinate system does not contain the specified coordinate type the
128// returned value is function specific (but usually -1). If the supplied
129// CoordinateSystem contains two or more of the specified coordinateType then
130// an exception (AipsError) is thrown.
131//
132// Finally functions are provided for removing lists of pixel/world axes
133// from a CoordinateSystem.
134// This process is made a little awkward by the fact that when you
135// remove one axis, all the rest shuffle down one, so it is
136// provided here. Generally, one only needs to remove one axis
137// (in which case you should use the CoordinateSystem::removeWorldAxis and
138// CoordinateSystem::removcePixelAxis functions), but on occaision,
139// the multiple need is there.
140// </synopsis>
141//
142// <example>
143// I use these functions when creating test images.
144// <srcblock>
145// PagedImage(IPosition(4,256,256,4,32), CoordinateUtil::defaultCoords4D(),
146// String("test.image"));
147// </srcblock>
148// </example>
149//
150// <example>
151// Functions are needed to handle images without specifying a canonical
152// coordinate order. For example suppose we want to find the spectral aixs
153// of a PagedImage object.
154//
155// <srcblock>
156// const Int spectralAxis = CoordinateUtil::findSpectralAxis(image.coordinates());
157// cout << "The spectral axis is of shape " << image.shape()(spectralAxis) << endl;
158// </srcblock>
159// </example>
160//
161// <example>
162// Here we remove the first and last world axes, and their associated
163// pixel axes from a 3D CoordinateSystem. The reference values and
164// reference pixels are used for the replacement values.
165//
166// <srcblock>
167// CoordinateSystem cSys = CoordinateUtil::defaultCoords3D();
168// Vector<Int> worldAxes(2);
169// worldAxes(0) = 0; worldAxes(1) = cSys.nWorldAxes()-1;
170// Vector<Double> worldRep;
171// Bool ok = CoordinateUtil::removeAxes(cSys, worldRep, worldAxes, True);
172// cout << "For world axes used " << worldRep << " for replacement" << endl;
173// </srcblock>
174// </example>
175//
176//
177// <motivation>
178// I got fed up writing small functions to create and find coordinates when writing
179// test programs involving Images and ComponentModels.
180// </motivation>
181//
182// <thrown>
183// <li> AipsError
184// </thrown>
185//
186// <todo asof="1997/01/23">
187// Many of these methods belong in the CoordinateSystem class,
188// eg all the add* methods, and in fact CoordinateSystem already has analogs
189// for many of them. The factory methods which create a CoordinateSystem
190// could also arguably go in CoordinateSystem as static methods. Having a separate
191// utility class that really just has methods that operate on or create CoordinateSystem
192// objects makes no sense. CoordinateUtil is the antithesis of object oriented design,
193// and we need to endeavor to expunge it from our system.
194// </todo>
195
196// <linkfrom anchor=defaultAxes classes="CoordinateSystem">
197// Static functions for creating <here>default</here> coordinate systems
198// </linkfrom>
199
201{
202public:
203
204// Add a RA/DEC pair of direction axes (ie. a DirectionCoordinate) to the
205// user supplied CoordinateSystem. See the synopsis above for the current
206// default values.
207static void addDirAxes(CoordinateSystem& coords);
208
209// Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem.
210static void addIQUVAxis(CoordinateSystem& coords);
211
212// Add a Stokes I (only) axis to the user supplied CoordinateSystem.
213static void addIAxis(CoordinateSystem& coords);
214
215// Add a Stokes axis of length 1 to 4 selected from I,Q,U,V
216// E.g. if shape=2 you get IQ. Returns False if shape
217// is not in the range 1 to 4
219
220// Add Linear axes. The LinearCoordinate can have > 1 axes (like
221// the DirectionCoordinate has 2). The number of axes is given
222// by the length of the names argument. If you supply a shape,
223// it will be used to set the reference pixel to 1/2 the shape.
224// If the shape does not have the same number of elements as
225// the names variable, the reference pixel will be 0
226static void addLinearAxes (CoordinateSystem & coords,
227 const Vector<String>& names,
228 const IPosition& shape);
229
230// Add a spectral axis to the user supplied CoordinateSystem. See the
231// synopsis above for the current default values.
232static void addFreqAxis(CoordinateSystem& coords);
233
234
235// Add one axis for each of the specified coordinate types.
236// Returns the number of axes added.
237// If silent==True, existing axes are silently ignored.
238// This should really be a method of CoordinateSystem, but the
239// code was moved from ImageUtilities which makes heavy use
240// of CoordUtil methods (which aren't available to CoordinateSystem)
241static uInt addAxes (
242 CoordinateSystem& csys,
243 Bool direction,
244 Bool spectral, const String& stokes,
245 Bool linear, Bool tabular,
246 Bool silent=False
247);
248
249// Return a 2-dimensional coordinate system with RA/DEC axes only.
251
252// Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis.
254
255// Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV
256// polarisation axis and a spectral axis.
258
259// Calls one of the above three functions depending of the arguement. An
260// AipsError is thrown if dims is not 2, 3, or 4.
262
263// If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem
264// depending upon the shape. The shape for the Stokes axis
265// must be <= 4. If axis 2 can't be Stokes it will be a Spectral
266// axis instead. AFter the standard types, the rest (if any)
267// of the CoordinateSystem consists of LinearCoordinates.
268// If doLinear=True, then you just get a linear coordinate system
270 Bool doLinear=False);
271
272//
273// Find which pixel axis in the CoordinateSystem corresponds to the
274// SpectralCoordinate. If there is no SpectralCoordinate in the coordinate
275// system then return -1.
276static Int findSpectralAxis(const CoordinateSystem & coords);
277
278// Find the SpectralCoordinate in the CoordinateSystem, and then
279// return the most general description of where it is.
280// If there is no SpectralCoordinate in the CoordinateSystem then return
281// -1 for coordinate. If the world or pixel axis has been removed,
282// return -1 for that value.
283static void findSpectralAxis(Int& pixelAxis, Int& worldAxis, Int& coordinate,
284 const CoordinateSystem & coords);
285
286// Find which pixel axes correspond to the DirectionCoordinate in the
287// supplied coordinate system and return this as a Vector. If there is no
288// DirectionCoordinate in the CoordinateSystem then return a Vector of zero
289// length. Normally the returned Vector will have a length of two.
290// However, if the pixel axis has been removed, then the resultant
291// vector will take the value -1 for that axis.
293
294// Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate
295// system and return the most general description of where it is. If there is
296// no DirectionCoordinate then coordinate is returned with value -1.
297// Values of -1 in the returned vectors indicate an axis has been removed.
298static void findDirectionAxes(Vector<Int>& pixelAxes, Vector<Int>& worldAxes,
299 Int& coordinate, const CoordinateSystem & coords);
300
301// Find which pixel axis is the polarisation axis in the supplied
302// CoordinateSystem and return this. If there is no StokesCoordinate in the
303// CoordinateSystem return a negative number. The actual polarisations on the
304// returned pixel axis are returned in the whichPols Vector. Each element of
305// this Vector is a Stokes::StokesTypes enumerator and the length of the Vector
306// is the same as the length of the polarisation axis. If there is no
307// polarisation axis the whichPols returns a unit length Vector containing
308// Stokes::I
310 const CoordinateSystem& coords);
311
312// Find the StokesCoordinate in the CoordinateSystem, and then
313// return the most general description of where it is.
314// If there is no StokesCoordinate in the CoordinateSystem then return
315// -1 for coordinate. If the world or pixel axis has been removed,
316// return -1 for that value.
317static void findStokesAxis(Int& pixelAxis, Int& worldAxis, Int& coordinate,
318 const CoordinateSystem & coords);
319
320// Find Coordinate type for this pixel or world axis
321// <group>
324// </group>
325
326// Remove a list of world axes and their associated
327// pixel axes from a <src>CoordinateSystem</src>. The list of world
328// axes to be removed is derived from a list giving either axes to remove,
329// or axes to keep (controlled by whether <src>remove</src>
330// is <src>True</src> or <src>False</src>. The replacement values (see functions
331// <src>CoordinateSystem::removeWorldAxis</src>) for the world axes
332// can be given. For the associated pixel axes, the pixel replacement
333// coordinate is found by converting the world coordinate
334// to a pixel coordinate. If the length of the replacement value
335// vector is not the number of world axes to be removed then
336// the reference values will be used (e.g. use zero length
337// vectors).
339 Vector<Double>& worldReplacement,
340 const Vector<Int>& worldAxes,
341 const Bool remove);
342
343// Remove a list of pixel axes but not their associated
344// world axes from a <src>CoordinateSystem</src>.
345// The list of pixel axes to be removed is derived from a
346// list giving either axes to remove,
347// or axes to keep (controlled by whether <src>remove</src>
348// is <src>True</src> or <src>False</src>. The replacement values (see functions
349// <src>CoordinateSystem::removePixelAxis</src>) for the pixel axes
350// can be given. If the length of the replacement value
351// vector is not the number of pixel axes to be removed then
352// the reference pixel will be used (e.g. use zero length
353// vectors).
355 Vector<Double>& pixelReplacement,
356 const Vector<Int>& pixelAxes,
357 const Bool remove);
358
359// Physically (nont just virtually) drop coordinates from the CoordinateSystem
360// if all axes are fully removed. For coordinates with axes partially removed
361// (world/pixel) preserve that removal state in the output CS. No effort
362// is made to deal in any way with transposed systems, unless perserveAxesOrder
363// is True, and then the ordering of the axes of the output coordinate system
364// will be the same as the input cSysIn (sans dropped axes of course).
366 CoordinateSystem& cSysOut, const CoordinateSystem& cSysIn,
367 Bool preserveAxesOrder=False
368);
369
370// Setup Measures conversion machine for MDirections.
371// Returns True if the machine was needed and set. Returns False
372// if the machine was not needed and not set.
374 const DirectionCoordinate& dirCoordTo,
375 const DirectionCoordinate& dirCoordFrom,
376 const ObsInfo& obsTo,
377 const ObsInfo& obsFrom);
378
379// Setup Measures conversion machines for MFrequencies.
380// Returns False if a trial conversion failed, else returns True.
381// There must be both a Direction and a Spectral
382// Coordinate in the CoordinateSystem when making the Frequency machine,
383// else an exception occurs.
385 Int coordinateTo, Int coordinateFrom,
386 const CoordinateSystem& coordsTo,
387 const CoordinateSystem& coordsFrom,
388 const Unit& unit=Unit(String("Hz")));
389
390// Setup Measures conversion machines for MFrequencies.
391// Returns False if a trial conversion failed, else returns True.
393 MFrequency::Types typeTo, MFrequency::Types typeFrom,
394 const MDirection& dirTo, const MDirection& dirFrom,
395 const MEpoch& epochTo, const MEpoch& epochFrom,
396 const MPosition& posTo, const MPosition& posFrom,
397 const Unit& unit=Unit(String("Hz")));
398
399// Find the Sky in the CoordinateSystem. Assumes only one DirectionCoordinate.
400// <src>pixelAxes</src> and <src>worldAxes</src> say where
401// in the CS the DirectionCoordinate axes are (long then lat).
402// Returns False and an error message if it can't find the sky.
403 static Bool findSky(String& errorMessage, Int& dirCoord, Vector<Int>& pixelAxes,
404 Vector<Int>& worldAxes, const CoordinateSystem& cSys);
405
406// Do the specified axes hold the sky ? Returns False if no DirectionCoordinate
407// or if only one axis of the DirectionCoordinate is held or the specified
408// pixel axes don't pertain to the DirectionCoordinate.
409 static Bool holdsSky (Bool& holdsOneSkyAxis, const CoordinateSystem& cSys,
410 Vector<Int> pixelAxes);
411
412
413// Find the Stokes for the specified pixel. If there is no Stokes in the
414// CoordinateSystem, returns Stokes::I
416 uInt pixel=0);
417
418// Set the world axis units in the CS to 'deg' for Direction. For Spectral
419// set the velocity handling to use 'km/s' units. Other coordinates
420// are not touched.
422
423// Set world axis units for specific Coordinate. Returnd False if fails to set units
424// with error in cSys.errorMessage().
426 uInt which);
427
428// Set a unit for all unremoved world axes in the DirectionCoordinate in the
429// CS. Returns False if fails to set unit with error in cSys. If no DC
430// returns True
431 static Bool setDirectionUnit (CoordinateSystem& cSys, const String& unit, Int which=-1);
432
433// Set Direction conversion layer of DirectionCoordinate in CoordinateSystem
434// so that pixel<->world go to the specified direction system (a valid
435// MDirection::Types string). Returns False with error if direction
436// system invalid. If no DirectionCoordinate returns True
438 const String directionSystem);
439
440// Set spectral state of SpectralCoordinate in CoordinateSystem.
441// Unit must be consistent with Hz or m/s and the doppler a valid MDoppler string.
442// For no change, leave either String empty.
443// Returns False if invalid inputs (and CS not changed) and an error message.
444 static Bool setSpectralState (String& errorMsg, CoordinateSystem& cSys,
445 const String& unit, const String& spcquant);
446
447// Set velocity state of SpectralCoordinate in CoordinateSystem.
448// Unit must be consistent m/s and the doppler a valid MDoppler string.
449// For no change, leave either String empty.
450// Returns False if invalid inputs (and CS not changed) and an error message.
451 static Bool setVelocityState (String& errorMsg, CoordinateSystem& cSys,
452 const String& unit, const String& spcquant);
453
454 //#/// Kept setRestFrequency for CASA-4.2
455// Does the CoordinateSystem hold just the sky?
456// Returns True if CS pixel axis 0 is the longitude and 1 latitude
457// else returns False
458 static Bool isSky (LogIO& os, const CoordinateSystem& cSys);
459
460 //#/// Kept setRestFrequency for CASA-4.2
461// Set rest frequency of SpectralCoordinate in CoordinateSystem.
462// Unit must be consistent with Hz or m.
463// Returns False if invalid inputs (and CS not changed) and an error message.
465 const String& unit,
466 const Double& value);
467
468 //#/// Kept setSpectralConversion for old casarest
469// Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem
470// so that pixel<->world go to the specified frequency system (a valid
471// MFrequency::Types string). Returns False if frequency system invalid
472// or if no DirectionCoordinate or if cant get Date/Epoch
474 const String frequencySystem);
475
476// Set default format unit and doppler velocity state of SpectralCoordinate in CoordinateSystem.
477// Unit can be consistent with Hz or m/s
478// Returns False if invalid inputs (and CS not changed) and an error message.
480 const String& unit, const String& spcquant);
481
482// Convert an absolute pixel coordinate to world and format with
483// default Coordinate formatting
484// <group>
485 static String formatCoordinate(const IPosition& pixel, const CoordinateSystem& cSys, Int precision = -1);
486 static String formatCoordinate(const Vector<Double>& pixel, const CoordinateSystem& cSys, Int precision = -1);
487// </group>
488
489// Generate axis label String from coordinate. Specify coordinate axis,
490// whether world or pixel labels required, whether absolute or
491// relative. For spectral coordinates, doVel says if you want to
492// use the velocity information contained in it to generate the label
493 static String axisLabel (const Coordinate& coord, uInt axisInCoordinate=0,
494 Bool doWorld=True, Bool doAbs=True, Bool doVel=False);
495
496 // <group name=Coordinate comparison>
497 // Check how the coordinates of this and that compare.
498 // The return value tells how they compare.
499 // <br>-1: left is subset
500 // <br>0: equal
501 // <br>1: left is superset
502 // <br>9: invalid (mismatch)
503 static Int compareCoordinates (const CoordinateSystem& thisCsys,
504 const CoordinateSystem& thatCsys);
505
506 // Convert the world axes map given in worldAxes to a pixel axes map.
507 static Vector<Int> toPixelAxes (const CoordinateSystem& thisCsys,
508 const CoordinateSystem& thatCsys,
509 const Vector<Int>& worldAxes);
510
511 // Check if the axes in the pixel axes map are in ascending order.
512 static Bool checkOrder (const Vector<Int>& pixelAxes);
513
514 // Find the new and stretch axes when comparing the old and new
515 // coordinates and shapes (helper for ExtendImage).
516 static Bool findExtendAxes (IPosition& newAxes,
517 IPosition& stretchAxes,
518 const IPosition& newShape,
519 const IPosition& oldShape,
520 const CoordinateSystem& newCsys,
521 const CoordinateSystem& oldCsys);
522 // </group>
523
524 // Fix up Cylindrical parameters in any DirectionCoordinate for when the longitude
525 // is outside of [-180,180] range. If it returns False, it failed and an error
526 // message is returned as well. This function should be called on any
527 // CS made from an imported image like FITS
528 static Bool cylindricalFix (CoordinateSystem& cSys, String& errorMessage, const IPosition& shape);
529
530 // Apply the binning factors to the CS and create a new one reflecting the binning
531 // You can optionally throw an exception if factors is non-unit for any Stokes axis
533 const CoordinateSystem& cSysIn,
534 Bool failOnStokes=False);
535private:
536 // Sets pos to the position found for tel in the database, or
537 // raises an exception + error message.
539 const String& tel);
540};
541
542
543} //# NAMESPACE CASACORE - END
544
545#endif
static String axisLabel(const Coordinate &coord, uInt axisInCoordinate=0, Bool doWorld=True, Bool doAbs=True, Bool doVel=False)
Generate axis label String from coordinate.
static void addFreqAxis(CoordinateSystem &coords)
Add a spectral axis to the user supplied CoordinateSystem.
static Int compareCoordinates(const CoordinateSystem &thisCsys, const CoordinateSystem &thatCsys)
static CoordinateSystem defaultCoords2D()
Return a 2-dimensional coordinate system with RA/DEC axes only.
static void findStokesAxis(Int &pixelAxis, Int &worldAxis, Int &coordinate, const CoordinateSystem &coords)
Find the StokesCoordinate in the CoordinateSystem, and then return the most general description of wh...
static Bool setSpectralConversion(String &errorMsg, CoordinateSystem &cSys, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
static void addIQUVAxis(CoordinateSystem &coords)
Add a Stokes I,Q,U,V axis to the user supplied CoordinateSystem.
static void findSpectralAxis(Int &pixelAxis, Int &worldAxis, Int &coordinate, const CoordinateSystem &coords)
Find the SpectralCoordinate in the CoordinateSystem, and then return the most general description of ...
static void addLinearAxes(CoordinateSystem &coords, const Vector< String > &names, const IPosition &shape)
Add Linear axes.
static Bool findExtendAxes(IPosition &newAxes, IPosition &stretchAxes, const IPosition &newShape, const IPosition &oldShape, const CoordinateSystem &newCsys, const CoordinateSystem &oldCsys)
Find the new and stretch axes when comparing the old and new coordinates and shapes (helper for Exten...
static void findDirectionAxes(Vector< Int > &pixelAxes, Vector< Int > &worldAxes, Int &coordinate, const CoordinateSystem &coords)
Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and ret...
static Vector< Int > findDirectionAxes(const CoordinateSystem &coords)
Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and ret...
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.
static Bool cylindricalFix(CoordinateSystem &cSys, String &errorMessage, const IPosition &shape)
Fix up Cylindrical parameters in any DirectionCoordinate for when the longitude is outside of [-180,...
static Bool setVelocityState(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set velocity state of SpectralCoordinate in CoordinateSystem.
static Bool makeDirectionMachine(LogIO &os, MDirection::Convert &machine, const DirectionCoordinate &dirCoordTo, const DirectionCoordinate &dirCoordFrom, const ObsInfo &obsTo, const ObsInfo &obsFrom)
Setup Measures conversion machine for MDirections.
static void addDirAxes(CoordinateSystem &coords)
Add a RA/DEC pair of direction axes (ie.
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.
static uInt addAxes(CoordinateSystem &csys, Bool direction, Bool spectral, const String &stokes, Bool linear, Bool tabular, Bool silent=False)
Add one axis for each of the specified coordinate types.
static Bool findSky(String &errorMessage, Int &dirCoord, Vector< Int > &pixelAxes, Vector< Int > &worldAxes, const CoordinateSystem &cSys)
Find the Sky in the CoordinateSystem.
static String formatCoordinate(const IPosition &pixel, const CoordinateSystem &cSys, Int precision=-1)
Convert an absolute pixel coordinate to world and format with default Coordinate formatting.
static void findObservatoryOrRaiseException(LogIO &os, MPosition &pos, const String &tel)
Sets pos to the position found for tel in the database, or raises an exception + error message.
static Bool addStokesAxis(CoordinateSystem &coords, uInt shape)
Add a Stokes axis of length 1 to 4 selected from I,Q,U,V E.g.
static Bool makeFrequencyMachine(LogIO &os, MFrequency::Convert &machine, Int coordinateTo, Int coordinateFrom, const CoordinateSystem &coordsTo, const CoordinateSystem &coordsFrom, const Unit &unit=Unit(String("Hz")))
Setup Measures conversion machines for MFrequencies.
static Bool setRestFrequency(String &errorMsg, CoordinateSystem &cSys, const String &unit, const Double &value)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
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.
static Int findStokesAxis(Vector< Stokes::StokesTypes > &whichPols, const CoordinateSystem &coords)
Find which pixel axis is the polarisation axis in the supplied CoordinateSystem and return this.
static Bool setCoordinateUnits(CoordinateSystem &cSys, const Vector< String > &units, uInt which)
Set world axis units for specific Coordinate.
static CoordinateSystem defaultCoords3D()
Return a 3-dimensional coordinate system with RA/DEC axes and a spectral axis.
static Bool holdsSky(Bool &holdsOneSkyAxis, const CoordinateSystem &cSys, Vector< Int > pixelAxes)
Do the specified axes hold the sky ? Returns False if no DirectionCoordinate or if only one axis of t...
static Bool isSky(LogIO &os, const CoordinateSystem &cSys)
Does the CoordinateSystem hold just the sky? Returns True if CS pixel axis 0 is the longitude and 1 l...
static Bool makeFrequencyMachine(LogIO &os, MFrequency::Convert &machine, MFrequency::Types typeTo, MFrequency::Types typeFrom, const MDirection &dirTo, const MDirection &dirFrom, const MEpoch &epochTo, const MEpoch &epochFrom, const MPosition &posTo, const MPosition &posFrom, const Unit &unit=Unit(String("Hz")))
Setup Measures conversion machines for MFrequencies.
static Bool checkOrder(const Vector< Int > &pixelAxes)
Check if the axes in the pixel axes map are in ascending order.
static Coordinate::Type findPixelAxis(const CoordinateSystem &cSys, Int axis)
Find Coordinate type for this pixel or world axis.
static Bool setDirectionConversion(String &errorMsg, CoordinateSystem &cSys, const String directionSystem)
Set Direction conversion layer of DirectionCoordinate in CoordinateSystem so that pixel<->world go to...
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.
static Bool setSpectralState(String &errorMsg, CoordinateSystem &cSys, const String &unit, const String &spcquant)
Set spectral state of SpectralCoordinate in CoordinateSystem.
static void setNiceAxisLabelUnits(CoordinateSystem &cSys)
Set the world axis units in the CS to 'deg' for Direction.
static Coordinate::Type findWorldAxis(const CoordinateSystem &cSys, Int axis)
static void addIAxis(CoordinateSystem &coords)
Add a Stokes I (only) axis to the user supplied CoordinateSystem.
static CoordinateSystem makeBinnedCoordinateSystem(const IPosition &factors, const CoordinateSystem &cSysIn, Bool failOnStokes=False)
Apply the binning factors to the CS and create a new one reflecting the binning You can optionally th...
static Int findSpectralAxis(const CoordinateSystem &coords)
Find which pixel axis in the CoordinateSystem corresponds to the SpectralCoordinate.
static CoordinateSystem makeCoordinateSystem(const IPosition &shape, Bool doLinear=False)
If doLinear=False, Tries to make a standard RA/DEC/Stokes/Frequency CoordinateSystem depending upon t...
static String formatCoordinate(const Vector< Double > &pixel, const CoordinateSystem &cSys, Int precision=-1)
static CoordinateSystem defaultCoords(uInt dims)
Calls one of the above three functions depending of the arguement.
static CoordinateSystem defaultCoords4D()
Return a 4-dimensional coordinate system with RA/DEC axes, an IQUV polarisation axis and a spectral a...
static Bool dropRemovedAxes(CoordinateSystem &cSysOut, const CoordinateSystem &cSysIn, Bool preserveAxesOrder=False)
Physically (nont just virtually) drop coordinates from the CoordinateSystem if all axes are fully rem...
static Vector< Int > toPixelAxes(const CoordinateSystem &thisCsys, const CoordinateSystem &thatCsys, const Vector< Int > &worldAxes)
Convert the world axes map given in worldAxes to a pixel axes map.
static Stokes::StokesTypes findSingleStokes(LogIO &os, const CoordinateSystem &cSys, uInt pixel=0)
Find the Stokes for the specified pixel.
Type
This enum lists the types of the derived classes.
Definition Coordinate.h:141
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition MFrequency.h:173
StokesTypes
The Stokes types are defined by this enum.
Definition Stokes.h:64
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition ExprNode.h:1991
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53