FITSCoordinateUtil.h
Classes
- FITSCoordinateUtil -- (full description)
Interface
- Public Members
- FITSCoordinateUtil()
- Bool toFITSHeader(RecordInterface &header, IPosition &shape, const IPosition& cSys, Bool oneRelative, Char prefix = 'c', Bool writeWCS=False, Bool preferVelocity=True, Bool opticalVelocity=True) const
- Bool fromFITSHeader(Int& stokesFITSValue, CoordinateSystem& coordsys, RecordInterface& recHeader, const Vector<Vector>& header, const String& shape, uInt which=0) const
- Bool fromFITSHeaderOld(Int& stokesFITSValue, CoordinateSystem &coordsys, const RecordInterface &header, const IPosition& shape, Bool oneRelative, Char prefix = 'c')
- static Vector<String> cTypeFromDirection (Bool& isNCP, const Projection& proj, const Vector<String>& axisNames, Double refLat, Bool printError)
- Private Members
- Bool generateFITSKeywords (LogIO& os, Bool& isNCP, Double& longPole, Double& latPole, Vector<Double>& crval, Vector<Double>& crpix, Vector<Double>& cdelt, Vector<Double>& crota, Vector<Double>& projp, Vector<String>& ctype, Vector<String>& cunit, Matrix<Double>& pc, const CoordinateSystem& cSys, Int skyCoord, Int longAxis, Int latAxis, Int specAxis, Int stokesAxis, Bool writeWCS, Double offset, const String& sprefix) const
- Bool toFITSHeaderStokes(Vector<Double>& crval, Vector<Double>& crpix, Vector<Double>& cdelt, LogIO& os, const CoordinateSystem& coordsys, Int stokesAxis, Int stokesCoord) const
- Bool addDirectionCoordinate (CoordinateSystem& cSys, Vector<Int>& axes, const wcsprm& wcs, LogIO& os) const
- Bool addSpectralCoordinate (CoordinateSystem& cSys, Int& axis, const wcsprm& wcs, LogIO& os) const
- Bool addStokesCoordinate (CoordinateSystem& cSys, Int& axis, Int& stokesFITSValue, const wcsprm& wcs, const IPosition& shape, IPosition& os) const
- Bool addLinearCoordinate (CoordinateSystem& cSys, Vector<Int>& axes, const wcsprm& wcs, LogIO& os) const
- Bool directionSystemFromWCS (LogIO& os, MDirection::Types& type, String& errMsg, const wcsprm& wcs) const
- Bool frequencySystemFromWCS (LogIO& os, MFrequency::Types& type, String& errMsg, const wcsprm& wcs) const
- Bool stokesCoordinateFromWCS (LogIO& os, StokesCoordinate& coord, Int& stokesFITSValue, String& errMSg, const wcsprm& wcs, uInt shape, Bool warnStokes) const
- ObsInfo getObsInfo(LogIO& os, RecordInterface& header, const wcsprm& wcs) const
- void setWCS (wcsprm& wcs) const
- Bool getCDFromHeader(Matrix<Double>& cd, uInt n, const RecordInterface& header)
- void getPCFromHeader(LogIO& os, Int& rotationAxis, Matrix<Double>& pc, uInt n, const RecordInterface& header, const String& sprefix)
- void cardsToRecord (LogIO& os, RecordInterface& rec, char* pHeader) const
- void fixCoordinate(Coordinate& c, LogIO& os) const
Prerequisite
Synopsis
Helper functions to inter-converft between a CoordinateSystem and FITS
headers.
Example
Motivation
I hate FITS
Thrown Exceptions
To Do
Member Description
Constructor
Bool toFITSHeader(RecordInterface &header, IPosition &shape, const IPosition& cSys, Bool oneRelative, Char prefix = 'c', Bool writeWCS=False, Bool preferVelocity=True, Bool opticalVelocity=True) const
Convert CoordinateSystem to a FITS header. In the record
the keywords are vectors, it is expected that the actual FITS code will
split them into scalars and upcase the names. Returns False if one of the
keywords is already taken.
If writeWCS is True, attempt to write the WCS convention (Greisen and
Calabretta "Representation of celestial coordinates in FITS"). This is
a DRAFT convention evolving rapidly. It is not recommended that you
write this convention in general.
Use oneRelative=True to convert zero-relative pixel coordinates to
one-relative FITS coordinates.
prefix gives the prefix for the FITS keywords. E.g.,
if prefix="c" then crval, cdelt etc.
if prefix="d" then drval, ddelt etc.
Bool fromFITSHeaderOld(Int& stokesFITSValue, CoordinateSystem &coordsys, const RecordInterface &header, const IPosition& shape, Bool oneRelative, Char prefix = 'c')
Probably even if we return False we should set up the best linear
coordinate that we can. On output, stokesFITSValue
holds the FITS value of any unofficial Stokes (beam, optical depth,
spectral index) for the last unofficial value accessed (-1 if none).
The idea is that if the Stokes axis is of length one and holds an unofficial value,
you should drop the STokes axis and convert that value to ImageInfo::ImageTypes
with ImageInfo::imageTypeFromFITSValue. If on input, stokesFITSValue
is positive, then a warning is issued if any unofficial values are encountered.
Otherwise no warning is issued.
Old version
Bool fromFITSHeader(Int& stokesFITSValue, CoordinateSystem& coordsys, RecordInterface& recHeader, const Vector<Vector>& header, const String& shape, uInt which=0) const
Probably even if we return False we should set up the best linear
coordinate that we can. On output, stokesFITSValue
holds the FITS value of any unofficial Stokes (beam, optical depth,
spectral index) for the last unofficial value accessed (-1 if none).
The idea is that if the Stokes axis is of length one and holds an unofficial value,
you should drop the STokes axis and convert that value to ImageInfo::ImageTypes
with ImageInfo::imageTypeFromFITSValue. If on input, stokesFITSValue
is positive, then a warning is issued if any unofficial values are encountered.
Otherwise no warning is issued.
Helper function to create a FITS style CTYPE vector from the
axis names from a DirectionCoordinate
Bool generateFITSKeywords (LogIO& os, Bool& isNCP, Double& longPole, Double& latPole, Vector<Double>& crval, Vector<Double>& crpix, Vector<Double>& cdelt, Vector<Double>& crota, Vector<Double>& projp, Vector<String>& ctype, Vector<String>& cunit, Matrix<Double>& pc, const CoordinateSystem& cSys, Int skyCoord, Int longAxis, Int latAxis, Int specAxis, Int stokesAxis, Bool writeWCS, Double offset, const String& sprefix) const
Generate actual FITS keywords
Bool toFITSHeaderStokes(Vector<Double>& crval, Vector<Double>& crpix, Vector<Double>& cdelt, LogIO& os, const CoordinateSystem& coordsys, Int stokesAxis, Int stokesCoord) const
Special Stokes processing for conversion to FITS header
Look for Coordinate type and add to CS
Decode values from WCS structures which are generated via the wcs FITS parser
ObsInfo getObsInfo(LogIO& os, RecordInterface& header, const wcsprm& wcs) const
Decode ObsInfo from wcs structure
void setWCS (wcsprm& wcs) const
Call wcsset
Bool getCDFromHeader(Matrix<Double>& cd, uInt n, const RecordInterface& header)
Decode CD cards from FITS file header (Record interface)
void getPCFromHeader(LogIO& os, Int& rotationAxis, Matrix<Double>& pc, uInt n, const RecordInterface& header, const String& sprefix)
Decode PC matrix from FITS header (Record interface)
void cardsToRecord (LogIO& os, RecordInterface& rec, char* pHeader) const
Helper function to convert a wcs structure holding FITS keywords
into a Record for later consumption.
Fix up Coordinate for zero increments and the like
Possibly the wcs FITS parser could do this