30 #ifndef COORDINATES_COORDINATESYSTEM_H
31 #define COORDINATES_COORDINATESYSTEM_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,
971 Bool findWidths,
Int coordinate,
Int axisInCoordinate,
Int pixelAxis,
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;
String coordRecordName(uInt which) const
Return the name of the record field in which the coordinate is stored.
A Vector of integers, for indexing into Array<T> objects.
virtual uInt nWorldAxes() const
Int qualityPixelNumber(const String &qualityString) const
Given a quality parameter, find the pixel location.
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
const QualityCoordinate & qualityCoordinate(uInt which) const
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
virtual Vector< Double > referencePixel() 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...
CoordinateSystem()
Default constructor.
Vector< Int > directionAxesNumbers() const
Get the pixel axis numbers of the direction coordinate in this object.
virtual ~CoordinateSystem()
Destructor.
virtual Vector< Double > referenceValue() const
PtrBlock< Vector< Double > * > worldOut_tmps_p
TableExprNode downcase(const TableExprNode &node)
CoordinateSystem & operator=(const CoordinateSystem &other)
Assignment (copy semantics).
virtual Coordinate * clone() const
Make a copy of the CoordinateSystem using new.
const TabularCoordinate & tabularCoordinate(uInt which) const
PtrBlock< Vector< Double > * > world_replacement_values_p
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
const StokesCoordinate & stokesCoordinate() const
Int polarizationAxisNumber(Bool doWorld=False) const
What is the number of the polarization/stokes axis? If doWorld=True, the world axis number is returne...
void findWorldAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Given an axis number (pixel or world) in the CoordinateSystem, find the corresponding coordinate numb...
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.
static CoordinateSystem * restore(const RecordInterface &container, const String &fieldName)
Restore the CoordinateSystem from a record.
String qualityAtPixel(const uInt pixel) const
Table lookup 1-D coordinate, with interpolation.
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
virtual Vector< String > worldAxisNames() const
Return the requested attribute.
Bool hasPolarizationAxis() const
virtual Vector< Double > worldMixMin() const
const SpectralCoordinate & spectralCoordinate() const
void makeWorldAbsRelMany(Matrix< Double > &value, Bool toAbs) const
Many abs/rel conversions.
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...
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
Bool pixelMap(Vector< Int > &pixelAxisMap, Vector< Int > &pixelAxisTranspose, const CoordinateSystem &cSys) const
PtrBlock< Vector< Double > * > pixel_tmps_p
Interconvert between pixel and a linear world coordinate.
Int spectralAxisNumber(Bool doWorld=False) const
What number is the spectral axis? If doWorld=True, the world axis number is returned.
virtual Bool setReferenceValue(const Vector< Double > &refval)
const DirectionCoordinate & directionCoordinate() const
void findPixelAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Interconvert between pixel and Quality value.
ostream-like interface to creating log messages.
void deleteTemps(const uInt which)
Delete temporary maps.
static const String _class
virtual Coordinate::Type type() const
Returns Coordinate::COORDSYS
Int spectralCoordinateNumber() const
what number is the spectral coordinate? Returns -1 if no spectral coordinate exists.
PtrBlock< Vector< Double > * > world_tmps_p
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.
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.
formatType
This enum is used for formatting world values into Strings.
virtual String showType() const
Always returns "System".
virtual uInt nPixelAxes() const
Sums the number of axes in the Coordinates that the CoordinateSystem contains, allowing for removed a...
QualityCoordinate qualitySubImage(const QualityCoordinate &qc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Quality.
Store miscellaneous information related to an observation.
void listFrequencySystem(LogIO &os, MDoppler::Types velocityType) const
virtual void makePixelRelativeMany(Matrix< Double > &pixel) const
Batch up a lot of absolute/relative transformations.
Bool setRestFrequency(String &errorMsg, const Quantity &freq)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
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 Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name. ...
Int linearCoordinateNumber() const
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (relative to the reference pixel/value).
virtual Vector< Double > increment() 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...
virtual void makeWorldRelativeMany(Matrix< Double > &world) const
void copy(const CoordinateSystem &other)
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the requested attribute.
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
Interconvert pixel positions and directions (e.g. RA/DEC).
Interface for converting between world and pixel coordinates.
Bool hasDirectionCoordinate() const
void setObsInfo(const ObsInfo &obsinfo)
virtual void makeWorldAbsolute(Vector< Double > &world) 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...
uInt nCoordinates() const
Returns the number of Coordinates that this CoordinateSystem contains.
Int qualityCoordinateNumber() const
what is the number of the quality coordinate? Returns -1 if no quality coordinate exists...
Bool hasQualityAxis() const
Does this coordinate system have a quality axis?
virtual Bool setReferencePixel(const Vector< Double > &refPix)
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
void listDirectionSystem(LogIO &os) const
All these functions are in support of the list function.
Bool checkAxesInThisCoordinate(const Vector< Bool > &axes, uInt which) const
Bool isDirectionAbscissaLongitude() const
Is the abscissa in the DirectionCoordinate the longitude axis? Throws exception if there is no Direct...
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
const Coordinate & coordinate(uInt which) const
Return the given Coordinate as a reference to the base class object.
PtrBlock< Vector< Double > * > pixelOut_tmps_p
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 Bool
Define the standard types used by Casacore.
Vector< String > list(LogIO &os, MDoppler::Types doppler, const IPosition &latticeShape, const IPosition &tileShape, Bool postLocally=False) const
List all header information.
void restoreOriginal()
Untranspose and undelete all axes.
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
Bool removeWorldAxis(uInt axis, Double replacement)
Remove a world or pixel axis.
Int findCoordinate(Coordinate::Type type, Int afterCoord=-1) const
Find the Coordinate number that corresponds to the given type.
PtrBlock< Vector< Double > * > worldMax_tmps_p
Bool velocityIncrement(Double &velocityInc, SpectralCoordinate &sc, MDoppler::Types velocityType, const String &velUnits) const
A drop-in replacement for Block<T*>.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
virtual Matrix< Double > linearTransform() const
Type
This enum lists the types of the derived classes.
void _downcase(Vector< String > &vec) const
StokesCoordinate stokesSubImage(const StokesCoordinate &sc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Stokes.
Wrapper around a pthreads mutex.
Interconvert pixel and frequency values.
Int directionCoordinateNumber() const
PtrBlock< Block< Int > * > pixel_maps_p
Same meanings as for the world*'s above.
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
PtrBlock< Vector< Bool > * > worldAxes_tmps_p
These temporaries all needed for the toMix function.
Vector< Int > linearAxesNumbers() const
void addCoordinate(const Coordinate &coord)
Add another Coordinate to this CoordinateSystem.
Bool removePixelAxis(uInt axis, Double replacement)
virtual Vector< Double > worldMixMax() 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.
virtual void makeWorldAbsoluteMany(Matrix< Double > &world) const
const Double e
e and functions thereof:
CoordinateSystem stripRemovedAxes(const CoordinateSystem &cSys) const
Strip out coordinates with all world and pixel axes removed.
Interconvert between pixel and Stokes value.
static Mutex _mapInitMutex
Vector< Int > pixelAxes(uInt whichCoord) const
virtual Bool setLinearTransform(const Matrix< Double > &xform)
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...
void clearFlags(LogIO &os) 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.
PtrBlock< Vector< Double > * > worldMin_tmps_p
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.
String: the storage and methods of handling collections of characters.
static std::map< String, String > _friendlyAxisMap
void subImageInSitu(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape)
PtrBlock< Vector< Double > * > pixel_replacement_values_p
virtual void makePixelAbsolute(Vector< Double > &pixel) const
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
static void _initFriendlyAxisMap()
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...
void cleanUpSpecCoord(PtrBlock< SpectralCoordinate * > &in, PtrBlock< SpectralCoordinate * > &out)
Delete some pointer blocks.
Bool replaceCoordinate(const Coordinate &newCoordinate, uInt whichCoordinate)
Replace one Coordinate with another.
virtual Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the units.
Abstract base class for Record classes.
void listPointingCenter(LogIO &os) 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...
PtrBlock< Coordinate * > coordinates_p
Where we store copies of the coordinates we are created with.
virtual Bool setIncrement(const Vector< Double > &inc)
virtual void setDefaultWorldMixRanges()
Int worldAxisToPixelAxis(uInt worldAxis) const
Find the pixel axis for the given world axis in a CoordinateSystem.
virtual Quantity toWorldLength(const Double nPixels, const uInt pixelAxis) const
convert a pixel "length" to a world "length"
ObsInfo obsinfo_p
Miscellaneous information about the observation associated with this Coordinate System.
Bool setSpectralConversion(String &errorMsg, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
virtual void makePixelAbsoluteMany(Matrix< Double > &pixel) const
Int pixelAxisToWorldAxis(uInt pixelAxis) const
Find the world axis for the given pixel axis in a CoordinateSystem.
Interconvert pixel and world coordinates.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Vector< Int > worldAxes(uInt whichCoord) const
For a given Coordinate say where its world and pixel axes are in this CoordinateSystem.
Int stokesPixelNumber(const String &stokesString) const
Given a stokes or polarization parameter, find the pixel location.
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
virtual Vector< String > worldAxisUnits() const
virtual void makeWorldRelative(Vector< Double > &world) const
Bool hasLinearCoordinate() 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...
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.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.
Bool hasPolarizationCoordinate() const
does this coordinate system have a polarizaion/stokes coordinate?