Go to the documentation of this file.
30 #ifndef COORDINATES_COORDINATESYSTEM_H
31 #define COORDINATES_COORDINATESYSTEM_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/coordinates/Coordinates/Coordinate.h>
35 #include <casacore/measures/Measures/MDirection.h>
36 #include <casacore/measures/Measures/MFrequency.h>
37 #include <casacore/coordinates/Coordinates/ObsInfo.h>
38 #include <casacore/casa/Containers/Block.h>
39 #include <casacore/measures/Measures/MDoppler.h>
44 template<
class T>
class Matrix;
45 class DirectionCoordinate;
46 class LinearCoordinate;
47 class SpectralCoordinate;
48 class StokesCoordinate;
49 class QualityCoordinate;
50 class TabularCoordinate;
391 uInt axisInCoordinateSystem)
const;
393 uInt axisInCoordinateSystem)
const;
591 Double pixOutOffset = 0.0);
601 Double pixOutOffset = 0.0);
632 Bool throwException);
699 const String &fieldName)
const;
917 const uInt coord,
const uInt coord2)
const;
953 uInt& widthCoordNumber,
uInt& widthName,
955 uInt& widthTile,
uInt& widthRefValue,
956 uInt& widthRefPixel,
uInt& widthInc,
957 uInt& widthUnits,
Int& precRefValSci,
958 Int& precRefValFloat,
Int& precRefValRADEC,
959 Int& precRefPixFloat,
Int& precIncSci,
String& nameAxis,
972 Int precRefValSci,
Int precRefValFloat,
Int precRefValRADEC,
Int precRefPixFloat,
975 uInt widthCoordType,
uInt widthCoordNumber,
979 Bool findWidths,
Int axisInCoordinate,
Int pixelAxis,
981 Int precRefValRADEC,
Int precRefPixFloat,
Int precIncSci)
const;
988 {
for (
uInt i=0; i<vec.size(); ++i) vec[i].
downcase(); }
Interconvert pixel and world coordinates.
PtrBlock< Vector< Double > * > pixel_replacement_values_p
static std::map< String, String > _friendlyAxisMap
Int directionCoordinateNumber() const
CoordinateSystem & operator=(const CoordinateSystem &other)
Assignment (copy semantics).
virtual Vector< Double > toPixel(const Vector< Double > &world) const
This one throws an exception rather than returning False.
virtual Vector< Double > referenceValue() const
String qualityAtPixel(const uInt pixel) const
PtrBlock< Vector< Double > * > world_replacement_values_p
void findPixelAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
virtual Quantity toWorldLength(const Double nPixels, const uInt pixelAxis) const
convert a pixel "length" to a world "length"
Bool setWorldAxisUnits(const Vector< String > &units, Bool throwException)
Interface for converting between world and pixel coordinates.
Bool toFITSHeader(RecordInterface &header, IPosition &shape, Bool oneRelative, Char prefix='c', Bool writeWCS=True, Bool preferVelocity=True, Bool opticalVelocity=True, Bool preferWavelength=False, Bool airWavelength=False) const
Convert a CoordinateSystem to FITS, i.e.
A Vector of integers, for indexing into Array<T> objects.
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...
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
PtrBlock< Coordinate * > coordinates_p
Where we store copies of the coordinates we are created with.
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
virtual void setDefaultWorldMixRanges()
Int worldAxisToPixelAxis(uInt worldAxis) const
Find the pixel axis for the given world axis in a CoordinateSystem.
void listFrequencySystem(LogIO &os, MDoppler::Types velocityType) const
PtrBlock< Vector< Double > * > pixel_tmps_p
virtual Bool near(const Coordinate &other, const Vector< Int > &excludePixelAxes, Double tol=1e-6) const
virtual void makePixelAbsoluteMany(Matrix< Double > &pixel) const
virtual Coordinate * makeFourierCoordinate(const Vector< Bool > &axes, const Vector< Int > &shape) const
Find the CoordinateSystem (you can safely caste the pointer to a CoordinateSystem) for when we Fourie...
A drop-in replacement for Block<T*>.
virtual Bool toWorld(Vector< Double > &world, const Vector< Double > &pixel, Bool useConversionFrame=True) const
Convert a pixel position to a world position or vice versa.
virtual Vector< String > worldAxisUnits() const
static const String _class
PtrBlock< Vector< Double > * > world_tmps_p
PtrBlock< Vector< Double > * > worldOut_tmps_p
virtual void makeWorldRelative(Vector< Double > &world) const
Bool hasQualityAxis() const
Does this coordinate system have a quality axis?
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
CoordinateSystem(const CoordinateSystem &other)
Copying constructor (copy semantics)
Interconvert pixel positions and directions (e.g. RA/DEC).
static CoordinateSystem * restore(const RecordInterface &container, const String &fieldName)
Restore the CoordinateSystem from a record.
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
void listDirectionSystem(LogIO &os) const
All these functions are in support of the list function.
const SpectralCoordinate & spectralCoordinate(uInt which) const
void deleteTemps(const uInt which)
Delete temporary maps.
virtual ~CoordinateSystem()
Destructor.
String coordRecordName(uInt which) const
Return the name of the record field in which the coordinate is stored.
virtual Vector< Double > worldMixMin() const
void _downcase(Vector< String > &vec) const
Bool nearPixel(const CoordinateSystem &other, Double tol=1e-6) const
This function compares this and the other coordinate system, but ONLY for the non-removed pixel axes.
Interconvert between pixel and Stokes value.
CoordinateSystem subImage(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape) const
Return a CoordinateSystem appropriate for a shift of origin (the shift is subtracted from the referen...
const DirectionCoordinate & directionCoordinate(uInt which) const
Coordinate::Type type(uInt whichCoordinate) const
Return the type of the given Coordinate.
const SpectralCoordinate & spectralCoordinate() const
virtual void makeWorldRelativeMany(Matrix< Double > &world) const
Int polarizationCoordinateNumber() const
what is the number of the polarization/stokes coordinate? Returns -1 if no stokes coordinate exists.
Int polarizationAxisNumber(Bool doWorld=False) const
What is the number of the polarization/stokes axis? If doWorld=True, the world axis number is returne...
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
uInt nCoordinates() const
Returns the number of Coordinates that this CoordinateSystem contains.
void copy(const CoordinateSystem &other)
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the requested attribute.
String showType(uInt whichCoordinate) const
Returns the type of the given Coordinate as a string.
Type
This enum lists the types of the derived classes.
Vector< Int > getWorldAxesOrder(Vector< String > &myNames, Bool requireAll, Bool allowFriendlyNames=False) const
Get the 0 based order of the minimal match strings specified in order.
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (relative to the reference pixel/value).
void findWorldAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Given an axis number (pixel or world) in the CoordinateSystem, find the corresponding coordinate numb...
QualityCoordinate qualitySubImage(const QualityCoordinate &qc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Quality.
const QualityCoordinate & qualityCoordinate(uInt which) const
Bool isDirectionAbscissaLongitude() const
Is the abscissa in the DirectionCoordinate the longitude axis? Throws exception if there is no Direct...
virtual String showType() const
Always returns "System".
virtual Matrix< Double > linearTransform() const
Interconvert between pixel and a linear world coordinate.
formatType
This enum is used for formatting world values into Strings.
PtrBlock< Vector< Bool > * > pixelAxes_tmps_p
virtual Bool toMix(Vector< Double > &worldOut, Vector< Double > &pixelOut, const Vector< Double > &worldIn, const Vector< Double > &pixelIn, const Vector< Bool > &worldAxes, const Vector< Bool > &pixelAxes, const Vector< Double > &worldMin, const Vector< Double > &worldMax) const
Mixed pixel/world coordinate conversion.
ostream-like interface to creating log messages.
void makeWorldAbsRelMany(Matrix< Double > &value, Bool toAbs) const
Many abs/rel conversions.
Bool convert(Matrix< Double > &coordOut, const Matrix< Double > &coordIn, const Vector< Bool > &absIn, const Vector< String > &unitsIn, MDoppler::Types dopplerIn, const Vector< Bool > &absOut, const Vector< String > &unitsOut, MDoppler::Types dopplerOut, Double pixInOffset=0.0, Double pixOutOffset=0.0)
virtual Bool setReferenceValue(const Vector< Double > &refval)
virtual Vector< Double > referencePixel() const
Table lookup 1-D coordinate, with interpolation.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void setObsInfo(const ObsInfo &obsinfo)
virtual Coordinate::Type type() const
Returns Coordinate::COORDSYS
Bool setRestFrequency(String &errorMsg, const Quantity &freq)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
String stokesAtPixel(const uInt pixel) const
Bool removeWorldAxis(uInt axis, Double replacement)
Remove a world or pixel axis.
void listPointingCenter(LogIO &os) const
Vector< Int > worldAxes(uInt whichCoord) const
For a given Coordinate say where its world and pixel axes are in this CoordinateSystem.
Bool mapOne(Vector< Int > &worldAxisMap, Vector< Int > &worldAxisTranspose, Vector< Bool > &refChange, const CoordinateSystem &cSys, const CoordinateSystem &cSys2, const uInt coord, const uInt coord2) const
Helper functions to group common code.
virtual uInt nPixelAxes() const
Sums the number of axes in the Coordinates that the CoordinateSystem contains, allowing for removed a...
virtual void makeWorldAbsolute(Vector< Double > &world) const
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
PtrBlock< Vector< Double > * > pixelOut_tmps_p
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
void transpose(const Vector< Int > &newWorldOrder, const Vector< Int > &newPixelOrder)
Transpose the CoordinateSystem so that world axis 0 is newWorldOrder(0) and so on for all the other a...
Bool hasPolarizationAxis() const
virtual void makeWorldAbsoluteRef(Vector< Double > &world, const Vector< Double > &refVal) const
Make absolute coordinates relative and vice versa with respect to the given reference value.
Bool hasLinearCoordinate() const
PtrBlock< Block< Int > * > pixel_maps_p
Same meanings as for the world*'s above.
virtual Vector< Double > toWorld(const Vector< Double > &pixel) const
This one throws an exception rather than returning False.
Vector< Double > toWorld(const IPosition &pixel) const
Bool toWorld(Vector< Double > &world, const IPosition &pixel) const
This is provided as a convenience since it is a very commonly desired operation through CoordinateSys...
PtrBlock< Vector< Bool > * > worldAxes_tmps_p
These temporaries all needed for the toMix function.
const StokesCoordinate & stokesCoordinate() const
Int qualityCoordinateNumber() const
what is the number of the quality coordinate? Returns -1 if no quality coordinate exists.
Bool removePixelAxis(uInt axis, Double replacement)
virtual void makeWorldAbsoluteMany(Matrix< Double > &world) const
Interconvert between pixel and Quality value.
this file contains all the compiler specific defines
Int spectralAxisNumber(Bool doWorld=False) const
What number is the spectral axis? If doWorld=True, the world axis number is returned.
static Mutex _mapInitMutex
PtrBlock< Vector< Double > * > worldMin_tmps_p
virtual Vector< Double > worldMixMax() const
void addCoordinate(const Coordinate &coord)
Add another Coordinate to this CoordinateSystem.
StokesCoordinate stokesSubImage(const StokesCoordinate &sc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Stokes.
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
virtual Bool setReferencePixel(const Vector< Double > &refPix)
static Bool fromFITSHeader(Int &stokesFITSValue, CoordinateSystem &coordsys, RecordInterface &recHeader, const Vector< String > &header, const IPosition &shape, uInt which=0)
Probably even if we return False we should set up the best linear coordinate that we can.
Vector< Int > pixelAxes(uInt whichCoord) const
Vector< String > list(LogIO &os, MDoppler::Types doppler, const IPosition &latticeShape, const IPosition &tileShape, Bool postLocally=False) const
List all header information.
static void _initFriendlyAxisMap()
const Double e
e and functions thereof:
void listVelocity(LogIO &os, Coordinate *pc, uInt widthAxis, uInt widthCoordType, uInt widthCoordNumber, uInt &widthName, uInt widthProj, uInt widthShape, uInt widthTile, uInt &widthRefValue, uInt widthRefPixel, uInt &widthInc, uInt &widthUnits, Bool findWidths, Int axisInCoordinate, Int pixelAxis, MDoppler::Types velocityType, Int precRefValSci, Int precRefValFloat, Int precRefValRADEC, Int precRefPixFloat, Int precIncSci) const
PtrBlock< Vector< Double > * > worldMax_tmps_p
virtual Bool setLinearTransform(const Matrix< Double > &xform)
Interconvert pixel and frequency values.
Bool hasPolarizationCoordinate() const
does this coordinate system have a polarizaion/stokes coordinate?
Abstract base class for Record classes.
Int linearCoordinateNumber() const
Vector< Int > directionAxesNumbers() const
Get the pixel axis numbers of the direction coordinate in this object.
const Coordinate & coordinate(uInt which) const
Return the given Coordinate as a reference to the base class object.
virtual void makePixelAbsolute(Vector< Double > &pixel) const
TableExprNode downcase(const TableExprNode &node)
ObsInfo obsinfo_p
Miscellaneous information about the observation associated with this Coordinate System.
void subImageInSitu(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape)
void restoreOriginal()
Untranspose and undelete all axes.
Bool checkAxesInThisCoordinate(const Vector< Bool > &axes, uInt which) const
void cleanUpSpecCoord(PtrBlock< SpectralCoordinate * > &in, PtrBlock< SpectralCoordinate * > &out)
Delete some pointer blocks.
const TabularCoordinate & tabularCoordinate(uInt which) const
virtual Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the units.
const DirectionCoordinate & directionCoordinate() const
Bool replaceCoordinate(const Coordinate &newCoordinate, uInt whichCoordinate)
Replace one Coordinate with another.
Int spectralCoordinateNumber() const
what number is the spectral coordinate? Returns -1 if no spectral coordinate exists.
String: the storage and methods of handling collections of characters.
Int findCoordinate(Coordinate::Type type, Int afterCoord=-1) const
Find the Coordinate number that corresponds to the given type.
Wrapper around a pthreads mutex.
bool Bool
Define the standard types used by Casacore.
CoordinateSystem stripRemovedAxes(const CoordinateSystem &cSys) const
Strip out coordinates with all world and pixel axes removed.
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name.
Bool velocityIncrement(Double &velocityInc, SpectralCoordinate &sc, MDoppler::Types velocityType, const String &velUnits) const
PtrBlock< Block< Int > * > world_maps_p
For coordinate[i] axis[j], world_maps_p[i][j], if >=0 gives the location in the input vector that map...
Bool convert(Vector< Double > &coordOut, const Vector< Double > &coordin, const Vector< Bool > &absIn, const Vector< String > &unitsIn, MDoppler::Types dopplerIn, const Vector< Bool > &absOut, const Vector< String > &unitsOut, MDoppler::Types dopplerOut, Double pixInOffset=0.0, Double pixOutOffset=0.0)
General coordinate conversion.
virtual String format(String &units, Coordinate::formatType format, Double worldValue, uInt worldAxis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1, Bool usePrecForMixed=False) const
Format a world value nicely through the common format interface.
void getFieldWidths(LogIO &os, uInt &widthAxis, uInt &widthCoordType, uInt &widthCoordNumber, uInt &widthName, uInt &widthProj, uInt &widthShape, uInt &widthTile, uInt &widthRefValue, uInt &widthRefPixel, uInt &widthInc, uInt &widthUnits, Int &precRefValSci, Int &precRefValFloat, Int &precRefValRADEC, Int &precRefPixFloat, Int &precIncSci, String &nameAxis, String &nameCoordType, String &nameCoordNumber, String &nameName, String &nameProj, String &nameShape, String &nameTile, String &nameRefValue, String &nameRefPixel, String &nameInc, String &nameUnits, MDoppler::Types velocityType, const IPosition &latticeShape, const IPosition &tileShape) const
Store miscellaneous information related to an observation.
Bool setSpectralConversion(String &errorMsg, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
virtual Vector< Double > increment() const
Bool hasDirectionCoordinate() const
void setSpectralConversion(const String frequencySystem)
This version throws an exception rather than returning False.
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
virtual uInt nWorldAxes() const
Int pixelAxisToWorldAxis(uInt pixelAxis) const
Find the world axis for the given pixel axis in a CoordinateSystem.
virtual Coordinate * clone() const
Make a copy of the CoordinateSystem using new.
void clearFlags(LogIO &os) const
Bool worldMap(Vector< Int > &worldAxisMap, Vector< Int > &worldAxisTranspose, Vector< Bool > &refChange, const CoordinateSystem &cSys) const
Find the world and pixel axis mappings to the supplied CoordinateSystem from the current coordinate s...
const StokesCoordinate & stokesCoordinate(uInt which) const
Int stokesPixelNumber(const String &stokesString) const
Given a stokes or polarization parameter, find the pixel location.
Vector< Int > linearAxesNumbers() const
Bool pixelMap(Vector< Int > &pixelAxisMap, Vector< Int > &pixelAxisTranspose, const CoordinateSystem &cSys) const
virtual Vector< String > worldAxisNames() const
Return the requested attribute.
Int qualityPixelNumber(const String &qualityString) const
Given a quality parameter, find the pixel location.
virtual Bool setIncrement(const Vector< Double > &inc)
CoordinateSystem()
Default constructor.
void listHeader(LogIO &os, Coordinate *pc, uInt &widthAxis, uInt &widthCoordType, uInt &widthCoordNumber, uInt &widthName, uInt &widthProj, uInt &widthShape, uInt &widthTile, uInt &widthRefValue, uInt &widthRefPixel, uInt &widthInc, uInt &widthUnits, Bool findWidths, Int coordinate, Int axisInCoordinate, Int pixelAxis, Int precRefValSci, Int precRefValFloat, Int precRefValRADEC, Int precRefPixFloat, Int precIncSci, const IPosition &latticeShape, const IPosition &tileShape) const
virtual void makePixelRelativeMany(Matrix< Double > &pixel) const
Batch up a lot of absolute/relative transformations.
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const