28 #ifndef COORDINATES_COORDINATEUTIL_H
29 #define COORDINATES_COORDINATEUTIL_H
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/Arrays/Vector.h>
34 #include <casacore/measures/Measures/Stokes.h>
35 #include <casacore/coordinates/Coordinates/Coordinate.h>
37 #include <casacore/measures/Measures/MDirection.h>
38 #include <casacore/measures/Measures/MFrequency.h>
39 #include <casacore/measures/Measures/MeasConvert.h>
43 class CoordinateSystem;
44 class DirectionCoordinate;
387 Int coordinateTo,
Int coordinateFrom,
440 const String directionSystem);
476 const String frequencySystem);
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 Vector< Int > findDirectionAxes(const CoordinateSystem &coords)
Find which pixel axes correspond to the DirectionCoordinate in the supplied coordinate system and ret...
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 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 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 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 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.
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
StokesTypes
The Stokes types are defined by this enum.
String: the storage and methods of handling collections of characters.
this file contains all the compiler specific defines
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.