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> 43 template<
class T>
class Matrix;
44 class DirectionCoordinate;
45 class LinearCoordinate;
46 class SpectralCoordinate;
47 class StokesCoordinate;
48 class QualityCoordinate;
49 class TabularCoordinate;
390 uInt axisInCoordinateSystem)
const;
392 uInt axisInCoordinateSystem)
const;
590 Double pixOutOffset = 0.0);
600 Double pixOutOffset = 0.0);
631 Bool throwException);
698 const String &fieldName)
const;
916 const uInt coord,
const uInt coord2)
const;
952 uInt& widthCoordNumber,
uInt& widthName,
954 uInt& widthTile,
uInt& widthRefValue,
955 uInt& widthRefPixel,
uInt& widthInc,
956 uInt& widthUnits,
Int& precRefValSci,
957 Int& precRefValFloat,
Int& precRefValRADEC,
958 Int& precRefPixFloat,
Int& precIncSci,
String& nameAxis,
970 Bool findWidths,
Int coordinate,
Int axisInCoordinate,
Int pixelAxis,
971 Int precRefValSci,
Int precRefValFloat,
Int precRefValRADEC,
Int precRefPixFloat,
974 uInt widthCoordType,
uInt widthCoordNumber,
978 Bool findWidths,
Int axisInCoordinate,
Int pixelAxis,
980 Int precRefValRADEC,
Int precRefPixFloat,
Int precIncSci)
const;
A Vector of integers, for indexing into Array<T> objects.
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the CoordinateSystem into the supplied record using the supplied field name. ...
void listFrequencySystem(LogIO &os, MDoppler::Types velocityType) const
ObsInfo obsInfo() const
Miscellaneous information related to an observation, for example the observation date.
CoordinateSystem()
Default constructor.
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...
virtual ~CoordinateSystem()
Destructor.
Bool hasDirectionCoordinate() const
Int pixelAxisToWorldAxis(uInt pixelAxis) const
Find the world axis for the given pixel axis in a CoordinateSystem.
PtrBlock< Vector< Double > * > worldOut_tmps_p
virtual void makeWorldRelative(Vector< Double > &world) const
TableExprNode downcase(const TableExprNode &node)
CoordinateSystem & operator=(const CoordinateSystem &other)
Assignment (copy semantics).
const SpectralCoordinate & spectralCoordinate() const
Bool pixelMap(Vector< Int > &pixelAxisMap, Vector< Int > &pixelAxisTranspose, const CoordinateSystem &cSys) const
PtrBlock< Vector< Double > * > world_replacement_values_p
Vector< Int > linearAxesNumbers() const
const LinearCoordinate & linearCoordinate(uInt which) const
Return the given Coordinate.
virtual Quantity toWorldLength(const Double nPixels, const uInt pixelAxis) const
convert a pixel "length" to a world "length"
void findPixelAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
uInt nCoordinates() const
Returns the number of Coordinates that this CoordinateSystem contains.
static CoordinateSystem * restore(const RecordInterface &container, const String &fieldName)
Restore the CoordinateSystem from a record.
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
Table lookup 1-D coordinate, with interpolation.
virtual void makePixelRelativeMany(Matrix< Double > &pixel) const
Batch up a lot of absolute/relative transformations.
String coordRecordName(uInt which) const
Return the name of the record field in which the coordinate is stored.
const QualityCoordinate & qualityCoordinate(uInt which) const
virtual Vector< Double > worldMixMin() const
void findWorldAxis(Int &coordinate, Int &axisInCoordinate, uInt axisInCoordinateSystem) const
Given an axis number (pixel or world) in the CoordinateSystem, find the corresponding coordinate numb...
virtual Matrix< Double > linearTransform() const
Int polarizationCoordinateNumber() const
what is the number of the polarization/stokes coordinate? Returns -1 if no stokes coordinate exists...
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
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.
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.
PtrBlock< Vector< Double > * > pixel_tmps_p
Interconvert between pixel and a linear world coordinate.
virtual Vector< Double > referencePixel() const
virtual Bool setReferenceValue(const Vector< Double > &refval)
Interconvert between pixel and Quality value.
ostream-like interface to creating log messages.
virtual String showType() const
Always returns "System".
void deleteTemps(const uInt which)
Delete temporary maps.
void _downcase(Vector< String > &vec) const
static const String _class
virtual Vector< String > worldAxisUnits() 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...
PtrBlock< Vector< Double > * > world_tmps_p
Bool hasQualityAxis() const
Does this coordinate system have a quality axis?
void cleanUpSpecCoord(PtrBlock< SpectralCoordinate *> &in, PtrBlock< SpectralCoordinate *> &out)
Delete some pointer blocks.
PtrBlock< Vector< Bool > * > pixelAxes_tmps_p
void makeWorldAbsRelMany(Matrix< Double > &value, Bool toAbs) const
Many abs/rel conversions.
formatType
This enum is used for formatting world values into Strings.
virtual void makeWorldRelativeMany(Matrix< Double > &world) 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 listDirectionSystem(LogIO &os) const
All these functions are in support of the list function.
Store miscellaneous information related to an observation.
Bool setRestFrequency(String &errorMsg, const Quantity &freq)
Set rest frequency of SpectralCoordinate in CoordinateSystem.
String stokesAtPixel(const uInt pixel) const
QualityCoordinate qualitySubImage(const QualityCoordinate &qc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Quality.
Bool isDirectionAbscissaLongitude() const
Is the abscissa in the DirectionCoordinate the longitude axis? Throws exception if there is no Direct...
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 void makeWorldAbsolute(Vector< Double > &world) const
void copy(const CoordinateSystem &other)
Bool hasSpectralAxis() const
Does this coordinate system have a spectral axis?
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the requested attribute.
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa (relative to the reference pixel/value).
Interconvert pixel positions and directions (e.g. RA/DEC).
Interface for converting between world and pixel coordinates.
void setObsInfo(const ObsInfo &obsinfo)
Int qualityCoordinateNumber() const
what is the number of the quality coordinate? Returns -1 if no quality coordinate exists...
virtual Bool setReferencePixel(const Vector< Double > &refPix)
Vector< Int > pixelAxes(uInt whichCoord) 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 Vector< Double > worldMixMax() const
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.
virtual Coordinate::Type type() const
Returns Coordinate::COORDSYS
Bool hasPolarizationAxis() const
Bool hasLinearCoordinate() const
static map< String, String > _friendlyAxisMap
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...
void listPointingCenter(LogIO &os) const
Bool removeWorldAxis(uInt axis, Double replacement)
Remove a world or pixel axis.
virtual uInt nPixelAxes() const
Sums the number of axes in the Coordinates that the CoordinateSystem contains, allowing for removed a...
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.
PtrBlock< Vector< Double > * > worldMax_tmps_p
const StokesCoordinate & stokesCoordinate() 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...
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
Type
This enum lists the types of the derived classes.
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.
virtual void makePixelAbsolute(Vector< Double > &pixel) 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...
Wrapper around a pthreads mutex.
Interconvert pixel and frequency values.
PtrBlock< Block< Int > * > pixel_maps_p
Same meanings as for the world*'s above.
Bool checkAxesInThisCoordinate(const Vector< Bool > &axes, uInt which) const
const DirectionCoordinate & directionCoordinate() const
PtrBlock< Vector< Bool > * > worldAxes_tmps_p
These temporaries all needed for the toMix function.
void clearFlags(LogIO &os) const
void addCoordinate(const Coordinate &coord)
Add another Coordinate to this CoordinateSystem.
Bool removePixelAxis(uInt axis, Double replacement)
virtual Coordinate * clone() const
Make a copy of the CoordinateSystem using new.
Int stokesPixelNumber(const String &stokesString) const
Given a stokes or polarization parameter, find the pixel location.
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 void makeWorldAbsoluteMany(Matrix< Double > &world) const
const Double e
e and functions thereof:
Bool velocityIncrement(Double &velocityInc, SpectralCoordinate &sc, MDoppler::Types velocityType, const String &velUnits) const
Interconvert between pixel and Stokes value.
static Mutex _mapInitMutex
virtual Bool setLinearTransform(const Matrix< Double > &xform)
virtual Vector< String > worldAxisNames() const
Return the requested attribute.
Int spectralAxisNumber(Bool doWorld=False) const
What number is the spectral axis? If doWorld=True, the world axis number is returned.
Int qualityPixelNumber(const String &qualityString) const
Given a quality parameter, find the pixel location.
Bool hasPolarizationCoordinate() const
does this coordinate system have a polarizaion/stokes coordinate?
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 > * > worldMin_tmps_p
String: the storage and methods of handling collections of characters.
void makePixelAbsRelMany(Matrix< Double > &value, Bool toAbs) const
Int qualityAxisNumber() const
what number is the quality axis? Returns -1 if no quality axis exists.
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
StokesCoordinate stokesSubImage(const StokesCoordinate &sc, Int originShift, Int pixincFac, Int newShape) const
Do subImage for Stokes.
void subImageInSitu(const Vector< Float > &originShift, const Vector< Float > &incrFac, const Vector< Int > &newShape)
PtrBlock< Vector< Double > * > pixel_replacement_values_p
static void _initFriendlyAxisMap()
virtual Vector< Double > referenceValue() const
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...
Int directionCoordinateNumber() const
Vector< String > list(LogIO &os, MDoppler::Types doppler, const IPosition &latticeShape, const IPosition &tileShape, Bool postLocally=False) const
List all header information.
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 qualityAtPixel(const uInt pixel) const
virtual Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the units.
Abstract base class for Record classes.
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
CoordinateSystem stripRemovedAxes(const CoordinateSystem &cSys) const
Strip out coordinates with all world and pixel axes removed.
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.
Int linearCoordinateNumber() const
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.
ObsInfo obsinfo_p
Miscellaneous information about the observation associated with this Coordinate System.
virtual void makePixelAbsoluteMany(Matrix< Double > &pixel) const
virtual Vector< Double > increment() const
Bool setSpectralConversion(String &errorMsg, const String frequencySystem)
Set Spectral conversion layer of SpectralCoordinate in CoordinateSystem so that pixel<->world go to t...
this file contains all the compiler specific defines
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.
Interconvert pixel and world coordinates.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
virtual uInt nWorldAxes() const
const TabularCoordinate & tabularCoordinate(uInt which) const
Int findCoordinate(Coordinate::Type type, Int afterCoord=-1) const
Find the Coordinate number that corresponds to the given type.
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 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.