27#ifndef COORDINATES_SPECTRALCOORDINATE_H
28#define COORDINATES_SPECTRALCOORDINATE_H
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Vector.h>
32#include <casacore/coordinates/Coordinates/Coordinate.h>
33#include <casacore/coordinates/Coordinates/ObsInfo.h>
34#include <casacore/measures/Measures/MFrequency.h>
35#include <casacore/measures/Measures/MDoppler.h>
36#include <casacore/measures/Measures/MDirection.h>
37#include <casacore/measures/Measures/MPosition.h>
38#include <casacore/measures/Measures/MEpoch.h>
39#include <casacore/casa/Quanta/Quantum.h>
42#include <wcslib/wcs.h>
48class TabularCoordinate;
52template<
class T>
class Quantum;
571 const String &fieldName)
const;
651 const Unit& freqUnit,
692 const String& fieldName)
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...
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
static void makeWCS(wcsprm &wcs, const String &ctype, Double refPix, Double refVal, Double inc, Double pc, Double restFreq)
Make spectral wcs structure (items in Hz)
Bool velocityToFrequency(Vector< Double > &frequency, const Vector< Double > &velocity) const
static SpectralCoordinate * restoreVersion1(const RecordInterface &container)
Record restoration handling.
Bool frequencyToAirWavelength(Vector< Double > &wavelength, const Vector< Double > &frequency) const
SpectralCoordinate(MFrequency::Types freqType, const Vector< Double > &wavelengths, const String &waveUnit, Double restFrequency=0.0, Bool inAir=False)
Construct a SpectralCoordinate with the specified wavelengths (in mm).
virtual void convertTo(Vector< Double > &world) const
Convert to and from conversion reference type.
virtual Vector< Double > referenceValue() const
SpectralCoordinate(MFrequency::Types type, const Vector< Double > &freqs, Double restFrequency=0.0)
Construct a SpectralCoordinate with the specified frequencies (in Hz).
Bool wcsSave(RecordInterface &rec, const wcsprm &wcs, const String &fieldName) const
Save wcs stuff into Record.
static SpectralCoordinate * restore(const RecordInterface &container, const String &fieldName)
Recover the SpectralCoordinate from a record.
virtual void convertFrom(Vector< Double > &world) const
Bool velocityToPixel(Vector< Double > &pixel, const Vector< Double > &velocity) const
SpectralCoordinate(const SpectralCoordinate &other)
Copy constructor (copy semantics).
SpectralCoordinate(MFrequency::Types type, const Quantum< Double > &f0, const Quantum< Double > &inc, Double refPix, const Quantum< Double > &restFrequency=Quantum< Double >(0.0,"Hz"))
Create linear frequency axis SpectralCoordinate with Quantum-based interface.
Bool transformFrequencySystem(MFrequency::Types type, const MEpoch &epoch, const MPosition &position, const MDirection &direction)
Transform the SpectralCoordinate to a different native reference frame keeping the conversion layer a...
String wavelengthUnit() const
Vector< Double > restfreqs_p
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the value of the requested attribute.
Bool toWorld(MFrequency &world, Double pixel) const
Convert a pixel (channel number) into an MFrequency or MVFrequency and vice versa.
Bool pixelToVelocity(Quantum< Double > &velocity, Double pixel) const
Functions to convert to velocity (uses the current active rest frequency) or wavelength.
virtual Bool toWorldMany(Matrix< Double > &world, const Matrix< Double > &pixel, Vector< Bool > &failures) const
Batch up a lot of transformations.
virtual Coordinate::Type type() const
Always returns Coordinate::SPECTRAL.
std::unique_ptr< TabularCoordinate > _tabular
const Vector< Double > toCurrentFactors() const
Return unit conversion vector for converting to current units.
Bool frequencyToVelocity(Quantum< Double > &velocity, Double frequency) const
static void restoreVelocity(SpectralCoordinate *&pSpectral, const RecordInterface &subrec)
static void restoreRestFrequencies(SpectralCoordinate *&pSpectral, const RecordInterface &subrec, Double restFreq)
Bool frequencyToVelocity(Double &velocity, Double frequency) const
Bool pixelToVelocity(Vector< Double > &velocity, const Vector< Double > &pixel) const
String formatUnit() const
Set the default formatter unit (which is initialized to empty).
MFrequency::Convert * pConversionMachineTo_p
Conversion machines; for pixel<->world conversions only.
virtual Vector< Double > increment() const
Bool wavelengthToFrequency(Vector< Double > &frequency, const Vector< Double > &wavelength) const
Bool toPixel(Double &pixel, const Double &world) const
SpectralCoordinate()
Default constructor.
virtual Vector< String > worldAxisNames() const
Report the value of the requested attribute.
Bool toPixel(Double &pixel, const MVFrequency &world) const
Vector< Double > pixelValues() const
Get the table, i.e.
Double restFrequency() const
The SpectralCoordinate can maintain a list of rest frequencies (e.g.
void selectRestFrequency(Double frequency)
virtual Bool setReferencePixel(const Vector< Double > &refPix)
MDoppler::Types velType_p
SpectralCoordinate(MFrequency::Types type, Double f0, Double inc, Double refPix, Double restFrequency=0.0)
Create a linear frequency axis SpectralCoordinate f0 is the frequency of the reference pixel,...
static Bool stringtoSpecType(SpecType &specType, const String &stypeString)
virtual Vector< String > worldAxisUnits() const
MFrequency::Types conversionType_p
Bool frequencyToVelocity(Quantum< Double > &velocity, const MVFrequency &frequency) const
virtual Bool toPixelMany(Matrix< Double > &pixel, const Matrix< Double > &world, Vector< Bool > &failures) const
Vector< Double > worldValues() const
void toCurrent(Vector< Double > &value) const
Interconvert between the current units and wcs units (Hz)
static Bool specTypetoString(String &stypeString, const SpecType &specType)
Convert from String to spectral type and vice versa.
void setRestFrequencies(const Vector< Double > &newFrequencies, uInt which=0, Bool append=False)
SpectralCoordinate(MFrequency::Types freqType, MDoppler::Types velType, const Vector< Double > &velocities, const String &velUnit, Double restFrequency=0.0)
Construct a SpectralCoordinate with the specified velocities (in km/s).
String formatRestFrequencies() const
SpectralCoordinate(MFrequency::Types type, const Quantum< Vector< Double > > &freqs, const Quantum< Double > &restFrequency=Quantum< Double >(0.0,"Hz"))
Construct a SpectralCoordinate with the specified frequencies with Quantum-based interface.
Bool setFormatUnit(const String &unit)
virtual String format(String &unit, Coordinate::formatType format, Double worldValue, uInt worldAxis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1, Bool usePrecForFixed=False) const
Format a SpectralCoordinate coordinate world value nicely through the common format interface.
VelocityMachine * pVelocityMachine_p
void _setTabulatedFrequencies(const Vector< Double > &freqs)
Bool setWavelengthUnit(const String &waveUnit=String("mm"))
void makeVelocityMachine(const String &velUnit, MDoppler::Types velType, const Unit &freqUnit, MFrequency::Types freqType, Double restFreq)
Create velocity<->frequency machine
virtual Matrix< Double > linearTransform() const
virtual Bool save(RecordInterface &container, const String &fieldName) const
Old interface.
void setFrequencySystem(MFrequency::Types type, Bool verbose=True)
static void restoreConversion(SpectralCoordinate *&pSpectral, const RecordInterface &subrec)
Bool airWavelengthToFrequency(Vector< Double > &frequency, const Vector< Double > &wavelength) const
Int makeConversionMachines(MFrequency::Types type, MFrequency::Types conversionType, const MEpoch &epoch, const MPosition &position, const MDirection &direction)
Set up pixel<->world conversion machines Returns: 3 (machines were noOPs, machines deleted) 2 (types ...
virtual uInt nWorldAxes() const
virtual Coordinate * clone() const
Make a copy of the SpectralCoordinate using new.
virtual String showType() const
Always returns the String "Spectral".
static Bool wcsRestore(Double &crval, Double &crpix, Double &cdelt, Double &pc, String &ctype, const RecordInterface &rec)
Restore wcs stuff from Record.
String velocityUnit() const
virtual Bool setReferenceValue(const Vector< Double > &refval)
SpectralCoordinate & operator=(const SpectralCoordinate &other)
Assignment (copy semantics).
SpectralCoordinate::SpecType nativeType() const
Bool frequencyToWavelength(Vector< Double > &wavelength, const Vector< Double > &frequency) const
Bool frequencyToVelocity(Vector< Double > &velocity, const Vector< Double > &frequency) const
Bool velocityToFrequency(Double &frequency, Double velocity) const
void getReferenceConversion(MFrequency::Types &type, MEpoch &epoch, MPosition &position, MDirection &direction) const
virtual Bool toWorld(Vector< Double > &world, const Vector< Double > &pixel, Bool useConversionFrame=True) const
Convert a pixel to a world coordinate or vice versa.
MFrequency::Types frequencySystem(Bool showConversion=False) const
Retrieve/set the frequency system.
virtual Bool setWorldAxisUnits(const Vector< String > &units)
Set/get the unit.
void selectRestFrequency(uInt which)
void deleteConversionMachines()
Deletes and sets pointers to 0.
Bool setRestFrequency(Double newFrequency, Bool append=False)
Bool setVelocity(const String &velUnit=String("km/s"), MDoppler::Types velType=MDoppler::RADIO)
Set the state that is used for conversions from pixel and frequency to velocity or wavelength.
Bool pixelToVelocity(Double &velocity, Double pixel) const
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
static SpectralCoordinate * restoreVersion2(const RecordInterface &container)
virtual Bool setIncrement(const Vector< Double > &inc)
Bool isTabular() const
is this a tabular coordinate?
void toFITS(RecordInterface &header, uInt whichAxis, LogIO &logger, Bool oneRelative=True, Bool preferVelocity=True, Bool opticalVelDef=True, Bool preferWavelength=False, Bool airWaveDef=False) const
Convert to FITS header record.
virtual ~SpectralCoordinate()
Destructor.
void checkFormat(Coordinate::formatType &format, const Bool) const
Format checker.
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
Bool setNativeType(const SpectralCoordinate::SpecType spcType)
Bool toWorld(MVFrequency &world, Double pixel) const
SpectralCoordinate(MFrequency::Types freqType, const ::wcsprm &wcs, Bool oneRel=True)
Construct from wcs structure.
Bool velocityToPixel(Double &pixel, Double velocity) const
The refractive index of air (argument can be wavelength or airwavelength) according to Greisen et al....
void fromCurrent(Vector< Double > &value) const
virtual Bool near(const Coordinate &other, const Vector< Int > &excludeAxes, Double tol=1e-6) const
MDoppler::Types velocityDoppler() const
Bool setReferenceConversion(MFrequency::Types type, const MEpoch &epoch, const MPosition &position, const MDirection &direction)
Set extra conversion layer.
void updateVelocityMachine(const String &velUnit, MDoppler::Types velType)
Update Velocity Machine.
virtual Coordinate * makeFourierCoordinate(const Vector< Bool > &axes, const Vector< Int > &shape) const
Find the Coordinate for when we Fourier Transform ourselves.
SpectralCoordinate::SpecType nativeType_p
void deleteVelocityMachine()
Deletes and sets pointer to 0.
Bool toPixel(Double &pixel, const MFrequency &world) const
const Vector< Double > & restFrequencies() const
virtual Bool setLinearTransform(const Matrix< Double > &xform)
virtual Vector< Double > referencePixel() const
ostream & print(ostream &os) const
Bool toWorld(Double &world, const Double &pixel) const
void copy(const SpectralCoordinate &other)
Copy private data.
virtual uInt nPixelAxes() const
Always returns 1.
Bool frequencyToVelocity(Quantum< Double > &velocity, const MFrequency &frequency) const
MFrequency::Convert * pConversionMachineFrom_p
String: the storage and methods of handling collections of characters.
this file contains all the compiler specific defines
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
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.