30 #ifndef COORDINATES_COORDINATESYSTEM_H
31 #define COORDINATES_COORDINATESYSTEM_H
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/ArrayFwd.h>
35 #include <casacore/coordinates/Coordinates/Coordinate.h>
36 #include <casacore/measures/Measures/MDirection.h>
37 #include <casacore/measures/Measures/MFrequency.h>
38 #include <casacore/coordinates/Coordinates/ObsInfo.h>
39 #include <casacore/casa/Containers/Block.h>
40 #include <casacore/measures/Measures/MDoppler.h>
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;
const Coordinate & coordinate(uInt which) const
Return the given Coordinate as a reference to the base class object.
virtual void makeWorldRelative(Vector< Double > &world) const
void setObsInfo(const ObsInfo &obsinfo)
const SpectralCoordinate & spectralCoordinate(uInt which) const
const QualityCoordinate & qualityCoordinate(uInt which) const
Vector< Int > linearAxesNumbers() const
String coordRecordName(uInt which) const
Return the name of the record field in which the coordinate is stored.
virtual Vector< Double > worldMixMin() const
virtual Vector< Double > referenceValue() const
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.
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()
Int qualityCoordinateNumber() const
what is the number of the quality coordinate? Returns -1 if no quality coordinate exists.
static const String _class
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.
const DirectionCoordinate & directionCoordinate(uInt which) const
void listDirectionSystem(LogIO &os) const
All these functions are in support of the list function.
virtual void makeWorldAbsolute(Vector< Double > &world) const
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.
Vector< Int > directionAxesNumbers() const
Get the pixel axis numbers of the direction coordinate in this object.
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
CoordinateSystem(const CoordinateSystem &other)
Copying constructor (copy semantics)
Coordinate::Type type(uInt whichCoordinate) const
Return the type of the given Coordinate.
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...
virtual Vector< Double > worldMixMax() const
void deleteTemps(const uInt which)
Delete temporary maps.
virtual Vector< String > worldAxisUnits() const
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)
virtual Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the units.
const DirectionCoordinate & directionCoordinate() const
const StokesCoordinate & stokesCoordinate(uInt which) const
PtrBlock< Vector< Double > * > pixel_tmps_p
static std::map< String, String > _friendlyAxisMap
Vector< Int > pixelAxes(uInt whichCoord) const
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.
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...
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (relative to the reference pixel/value).
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".
const TabularCoordinate & tabularCoordinate(uInt which) const
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 Bool setWorldAxisNames(const Vector< String > &names)
Set the requested attribute.
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
virtual Vector< Double > referencePixel() const
const StokesCoordinate & stokesCoordinate() const
Vector< Int > worldAxes(uInt whichCoord) const
For a given Coordinate say where its world and pixel axes are in this CoordinateSystem.
Bool checkAxesInThisCoordinate(const Vector< Bool > &axes, uInt which) const
const SpectralCoordinate & spectralCoordinate() const
PtrBlock< Vector< Double > * > worldMin_tmps_p
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.
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 makeWorldRelativeMany(Matrix< Double > &world) const
virtual Bool setReferencePixel(const Vector< Double > &refPix)
virtual Vector< Double > toPixel(const Vector< Double > &world) const
This one throws an exception rather than returning False.
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
virtual Bool setLinearTransform(const Matrix< Double > &xform)
static CoordinateSystem * restore(const RecordInterface &container, const String &fieldName)
Restore the CoordinateSystem from a record.
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name.
virtual Matrix< Double > linearTransform() const
void _downcase(Vector< String > &vec) const
Vector< Double > toWorld(const IPosition &pixel) const
Vector< String > list(LogIO &os, MDoppler::Types doppler, const IPosition &latticeShape, const IPosition &tileShape, Bool postLocally=False) const
List all header information.
Int worldAxisToPixelAxis(uInt worldAxis) const
Find the pixel axis for the given world axis in a CoordinateSystem.
virtual Coordinate * clone() const
Make a copy of the CoordinateSystem using new.
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
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.
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.
virtual Vector< String > worldAxisNames() const
Return the requested attribute.
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...
CoordinateSystem & operator=(const CoordinateSystem &other)
Assignment (copy semantics).
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 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...
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
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.
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 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"
virtual Vector< Double > increment() const
PtrBlock< Vector< Double > * > pixel_replacement_values_p
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.
virtual Vector< Double > toWorld(const Vector< Double > &pixel) const
This one throws an exception rather than returning False.
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
ObsInfo obsinfo_p
Miscellaneous information about the observation associated with this Coordinate System.
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
void clearFlags(LogIO &os) 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.
const Double e
e and functions thereof:
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.