27#ifndef COORDINATES_COORDINATESYSTEM_H
28#define COORDINATES_COORDINATESYSTEM_H
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/coordinates/Coordinates/Coordinate.h>
33#include <casacore/measures/Measures/MDirection.h>
34#include <casacore/measures/Measures/MFrequency.h>
35#include <casacore/coordinates/Coordinates/ObsInfo.h>
36#include <casacore/casa/Containers/Block.h>
37#include <casacore/measures/Measures/MDoppler.h>
42class DirectionCoordinate;
43class LinearCoordinate;
44class SpectralCoordinate;
45class StokesCoordinate;
46class QualityCoordinate;
47class TabularCoordinate;
388 uInt axisInCoordinateSystem)
const;
390 uInt axisInCoordinateSystem)
const;
588 Double pixOutOffset = 0.0);
598 Double pixOutOffset = 0.0);
629 Bool throwException);
696 const String &fieldName)
const;
914 const uInt coord,
const uInt coord2)
const;
950 uInt& widthCoordNumber,
uInt& widthName,
952 uInt& widthTile,
uInt& widthRefValue,
953 uInt& widthRefPixel,
uInt& widthInc,
954 uInt& widthUnits,
Int& precRefValSci,
955 Int& precRefValFloat,
Int& precRefValRADEC,
956 Int& precRefPixFloat,
Int& precIncSci,
String& nameAxis,
969 Int precRefValSci,
Int precRefValFloat,
Int precRefValRADEC,
Int precRefPixFloat,
972 uInt widthCoordType,
uInt widthCoordNumber,
976 Bool findWidths,
Int axisInCoordinate,
Int pixelAxis,
978 Int precRefValRADEC,
Int precRefPixFloat,
Int precIncSci)
const;
const SpectralCoordinate & spectralCoordinate(uInt which) const
virtual void makeWorldRelative(Vector< Double > &world) const
void setObsInfo(const ObsInfo &obsinfo)
const TabularCoordinate & tabularCoordinate(uInt which) const
const DirectionCoordinate & directionCoordinate(uInt which) const
String coordRecordName(uInt which) const
Return the name of the record field in which the coordinate is stored.
PtrBlock< Vector< Double > * > pixelOut_tmps_p
String qualityAtPixel(const uInt pixel) const
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.
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.
Bool replaceCoordinate(const Coordinate &newCoordinate, uInt whichCoordinate)
Replace one Coordinate with another.
Vector< String > list(LogIO &os, MDoppler::Types doppler, const IPosition &latticeShape, const IPosition &tileShape, Bool postLocally=False) const
List all header information.
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.
Bool velocityIncrement(Double &velocityInc, SpectralCoordinate &sc, MDoppler::Types velocityType, const String &velUnits) const
Int qualityPixelNumber(const String &qualityString) const
Given a quality parameter, find the pixel location.
Bool hasQualityAxis() const
Does this coordinate system have a quality axis?
Bool hasLinearCoordinate() const
PtrBlock< Vector< Bool > * > pixelAxes_tmps_p
static void _initFriendlyAxisMap()
const SpectralCoordinate & spectralCoordinate() const
Int qualityCoordinateNumber() const
what is the number of the quality coordinate? Returns -1 if no quality coordinate exists.
static const String _class
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
String stokesAtPixel(const uInt pixel) const
Int polarizationCoordinateNumber() const
what is the number of the polarization/stokes coordinate? Returns -1 if no stokes coordinate exists.
virtual Vector< Double > toPixel(const Vector< Double > &world) const
This one throws an exception rather than returning False.
void listDirectionSystem(LogIO &os) const
All these functions are in support of the list function.
virtual void makeWorldAbsolute(Vector< Double > &world) const
static CoordinateSystem * restore(const RecordInterface &container, const String &fieldName)
Restore the CoordinateSystem from a record.
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.
void restoreOriginal()
Untranspose and undelete all axes.
virtual uInt nPixelAxes() const
Sums the number of axes in the Coordinates that the CoordinateSystem contains, allowing for removed a...
Bool removeWorldAxis(uInt axis, Double replacement)
Remove a world or pixel axis.
Int polarizationAxisNumber(Bool doWorld=False) const
What is the number of the polarization/stokes axis? If doWorld=True, the world axis number is returne...
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.
QualityCoordinate qualitySubImage(const QualityCoordinate &qc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Quality.
void findWorldAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Given an axis number (pixel or world) in the CoordinateSystem, find the corresponding coordinate numb...
StokesCoordinate stokesSubImage(const StokesCoordinate &sc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Stokes.
virtual void makePixelAbsoluteMany(Matrix< Double > &pixel) const
const QualityCoordinate & qualityCoordinate(uInt which) const
CoordinateSystem(const CoordinateSystem &other)
Copying constructor (copy semantics)
Coordinate::Type type(uInt whichCoordinate) const
Return the type of the given Coordinate.
Vector< Int > pixelAxes(uInt whichCoord) const
Int pixelAxisToWorldAxis(uInt pixelAxis) const
Find the world axis for the given pixel axis in a CoordinateSystem.
Bool hasPolarizationAxis() const
virtual Bool setWorldMixRanges(const IPosition &shape)
Compute and recover the world min and max ranges, for use in function toMix, for a lattice of the giv...
PtrBlock< Coordinate * > coordinates_p
Where we store copies of the coordinates we are created with.
void cleanUpSpecCoord(PtrBlock< SpectralCoordinate * > &in, PtrBlock< SpectralCoordinate * > &out)
Delete some pointer blocks.
virtual Coordinate::Type type() const
Returns Coordinate::COORDSYS
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...
void deleteTemps(const uInt which)
Delete temporary maps.
String showType(uInt whichCoordinate) const
Returns the type of the given Coordinate as a string.
PtrBlock< Vector< Double > * > world_tmps_p
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
PtrBlock< Block< Int > * > pixel_maps_p
Same meanings as for the world*'s above.
virtual Bool setIncrement(const Vector< Double > &inc)
uInt nCoordinates() const
Returns the number of Coordinates that this CoordinateSystem contains.
Bool removePixelAxis(uInt axis, Double replacement)
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 Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the units.
PtrBlock< Vector< Double > * > pixel_tmps_p
virtual Vector< Double > increment() const
static std::map< String, String > _friendlyAxisMap
Bool setSpectralConversion(String &errorMsg, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
Int findCoordinate(Coordinate::Type type, Int afterCoord=-1) const
Find the Coordinate number that corresponds to the given type.
const StokesCoordinate & stokesCoordinate() const
virtual Vector< Double > toWorld(const Vector< Double > &pixel) const
This one throws an exception rather than returning False.
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...
const StokesCoordinate & stokesCoordinate(uInt which) const
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (relative to the reference pixel/value).
virtual Vector< Double > referenceValue() const
Bool setWorldAxisUnits(const Vector< String > &units, Bool throwException)
void listPointingCenter(LogIO &os) const
void addCoordinate(const Coordinate &coord)
Add another Coordinate to this CoordinateSystem.
Int spectralAxisNumber(Bool doWorld=False) const
What number is the spectral axis? If doWorld=True, the world axis number is returned.
void listFrequencySystem(LogIO &os, MDoppler::Types velocityType) const
virtual String showType() const
Always returns "System".
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...
virtual Vector< Double > referencePixel() const
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the requested attribute.
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
Vector< Int > linearAxesNumbers() const
Bool checkAxesInThisCoordinate(const Vector< Bool > &axes, uInt which) const
PtrBlock< Vector< Double > * > worldMin_tmps_p
virtual Vector< String > worldAxisUnits() const
virtual void makePixelRelativeMany(Matrix< Double > &pixel) const
Batch up a lot of absolute/relative transformations.
static std::mutex _mapInitMutex
PtrBlock< Vector< Bool > * > worldAxes_tmps_p
These temporaries all needed for the toMix function.
virtual Vector< Double > worldMixMin() const
virtual void makeWorldRelativeMany(Matrix< Double > &world) const
virtual Bool setReferencePixel(const Vector< Double > &refPix)
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
virtual Bool setLinearTransform(const Matrix< Double > &xform)
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name.
void _downcase(Vector< String > &vec) const
Vector< Int > worldAxes(uInt whichCoord) const
For a given Coordinate say where its world and pixel axes are in this CoordinateSystem.
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...
Int worldAxisToPixelAxis(uInt worldAxis) const
Find the pixel axis for the given world axis in a CoordinateSystem.
Bool pixelMap(Vector< Int > &pixelAxisMap, Vector< Int > &pixelAxisTranspose, const CoordinateSystem &cSys) const
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.
const DirectionCoordinate & directionCoordinate() const
Bool setRestFrequency(String &errorMsg, const Quantity &freq)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
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.
virtual Bool setReferenceValue(const Vector< Double > &refval)
Bool hasDirectionCoordinate() const
virtual void makePixelAbsolute(Vector< Double > &pixel) const
virtual ~CoordinateSystem()
Destructor.
Int stokesPixelNumber(const String &stokesString) const
Given a stokes or polarization parameter, find the pixel location.
virtual uInt nWorldAxes() const
Bool hasPolarizationCoordinate() const
does this coordinate system have a polarizaion/stokes coordinate?
void subImageInSitu(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape)
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 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.
virtual Vector< String > worldAxisNames() const
Return the requested attribute.
Bool isDirectionAbscissaLongitude() const
Is the abscissa in the DirectionCoordinate the longitude axis? Throws exception if there is no Direct...
void findPixelAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) 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.
PtrBlock< Vector< Double > * > worldOut_tmps_p
PtrBlock< Vector< Double > * > worldMax_tmps_p
void setSpectralConversion(const String frequencySystem)
This version throws an exception rather than returning False.
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
PtrBlock< Vector< Double > * > world_replacement_values_p
virtual Vector< Double > worldMixMax() const
void copy(const CoordinateSystem &other)
Int spectralCoordinateNumber() const
what number is the spectral coordinate? Returns -1 if no spectral coordinate exists.
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...
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
CoordinateSystem()
Default constructor.
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
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
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
CoordinateSystem stripRemovedAxes(const CoordinateSystem &cSys) const
Strip out coordinates with all world and pixel axes removed.
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.
Int directionCoordinateNumber() const
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 near(const Coordinate &other, const Vector< Int > &excludePixelAxes, Double tol=1e-6) const
virtual Coordinate * clone() const
Make a copy of the CoordinateSystem using new.
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
virtual Quantity toWorldLength(const Double nPixels, const uInt pixelAxis) const
convert a pixel "length" to a world "length"
PtrBlock< Vector< Double > * > pixel_replacement_values_p
Vector< Double > toWorld(const IPosition &pixel) const
Int linearCoordinateNumber() const
virtual void setDefaultWorldMixRanges()
virtual void makeWorldAbsoluteMany(Matrix< Double > &world) const
void makeWorldAbsRelMany(Matrix< Double > &value, Bool toAbs) const
Many abs/rel conversions.
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
ObsInfo obsinfo_p
Miscellaneous information about the observation associated with this Coordinate System.
CoordinateSystem & operator=(const CoordinateSystem &other)
Assignment (copy semantics).
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
void clearFlags(LogIO &os) const
virtual Matrix< Double > linearTransform() const
Type
This enum lists the types of the derived classes.
formatType
This enum is used for formatting world values into Strings.
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
A drop-in replacement for Block<T*>.
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.
TableExprNode downcase(const TableExprNode &node)
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.