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