casacore
Loading...
Searching...
No Matches
casacore::FITSCoordinateUtil Class Reference

More...

#include <FITSCoordinateUtil.h>

Public Member Functions

 FITSCoordinateUtil ()
 Constructor.
 
Bool toFITSHeader (RecordInterface &header, IPosition &shape, const CoordinateSystem &cSys, Bool oneRelative, Char prefix='c', Bool writeWCS=True, Bool preferVelocity=True, Bool opticalVelocity=True, Bool preferWavelength=False, Bool airWavelength=False) const
 Convert CoordinateSystem to a FITS header.
 
Bool fromFITSHeader (Int &stokesFITSValue, CoordinateSystem &coordsys, RecordInterface &recHeader, const Vector< String > &header, const IPosition &shape, uInt which=0) const
 Probably even if we return False we should set up the best linear coordinate that we can.
 

Static Public Member Functions

static Vector< StringcTypeFromDirection (Bool &isNCP, const Projection &proj, const Vector< String > &axisNames, Double refLat, Bool printError)
 Helper function to create a FITS style CTYPE vector from the axis names from a DirectionCoordinate.
 
static Vector< StringcTypeFromDirection (const Projection &proj, const Vector< String > &axisNames, Bool printError)
 

Private Member Functions

Bool generateFITSKeywords (LogIO &os, Bool &isNCP, Double &longPole, Double &latPole, Vector< Double > &crval, Vector< Double > &crpix, Vector< Double > &cdelt, Vector< Double > &pvi_ma, 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.
 
Bool addDirectionCoordinate (CoordinateSystem &cSys, Vector< Int > &axes, const wcsprm &wcs, LogIO &os) const
 Look for Coordinate type and add to CS.
 
Bool addSpectralCoordinate (CoordinateSystem &cSys, Int &axis, const wcsprm &wcs, const IPosition &shape, LogIO &os) const
 
Bool addStokesCoordinate (CoordinateSystem &cSys, Int &axis, Int &stokesFITSValue, const wcsprm &wcs, const IPosition &shape, LogIO &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
 Decode values from WCS structures which are generated via the wcs FITS parser.
 
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
 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.
 
void fixCoordinate (Coordinate &c, LogIO &os) const
 Fix up Coordinate for zero increments and the like Possibly the wcs FITS parser could do this.
 

Static Private Member Functions

static void wcsInit (::wcsprm &wcsDest)
 Initialize the wcsprm struct.
 

Detailed Description

Intended use:

Public interface

Prerequisite

Synopsis

Helper functions to inter-converft between a CoordinateSystem and FITS headers.


Caution:

Example

Motivation

I hate FITS

Thrown Exceptions

Definition at line 86 of file FITSCoordinateUtil.h.

Constructor & Destructor Documentation

◆ FITSCoordinateUtil()

casacore::FITSCoordinateUtil::FITSCoordinateUtil ( )
inline

Constructor.

Definition at line 91 of file FITSCoordinateUtil.h.

Member Function Documentation

◆ addDirectionCoordinate()

Bool casacore::FITSCoordinateUtil::addDirectionCoordinate ( CoordinateSystem & cSys,
Vector< Int > & axes,
const wcsprm & wcs,
LogIO & os ) const
private

Look for Coordinate type and add to CS.

◆ addLinearCoordinate()

Bool casacore::FITSCoordinateUtil::addLinearCoordinate ( CoordinateSystem & cSys,
Vector< Int > & axes,
const wcsprm & wcs,
LogIO & os ) const
private

◆ addSpectralCoordinate()

Bool casacore::FITSCoordinateUtil::addSpectralCoordinate ( CoordinateSystem & cSys,
Int & axis,
const wcsprm & wcs,
const IPosition & shape,
LogIO & os ) const
private

◆ addStokesCoordinate()

Bool casacore::FITSCoordinateUtil::addStokesCoordinate ( CoordinateSystem & cSys,
Int & axis,
Int & stokesFITSValue,
const wcsprm & wcs,
const IPosition & shape,
LogIO & os ) const
private

◆ cardsToRecord()

void casacore::FITSCoordinateUtil::cardsToRecord ( LogIO & os,
RecordInterface & rec,
char * pHeader ) const
private

Helper function to convert a wcs structure holding FITS keywords into a Record for later consumption.

◆ cTypeFromDirection() [1/2]

static Vector< String > casacore::FITSCoordinateUtil::cTypeFromDirection ( Bool & isNCP,
const Projection & proj,
const Vector< String > & axisNames,
Double refLat,
Bool printError )
static

Helper function to create a FITS style CTYPE vector from the axis names from a DirectionCoordinate.

◆ cTypeFromDirection() [2/2]

static Vector< String > casacore::FITSCoordinateUtil::cTypeFromDirection ( const Projection & proj,
const Vector< String > & axisNames,
Bool printError )
static

◆ directionSystemFromWCS()

Bool casacore::FITSCoordinateUtil::directionSystemFromWCS ( LogIO & os,
MDirection::Types & type,
String & errMsg,
const wcsprm & wcs ) const
private

Decode values from WCS structures which are generated via the wcs FITS parser.

◆ fixCoordinate()

void casacore::FITSCoordinateUtil::fixCoordinate ( Coordinate & c,
LogIO & os ) const
private

Fix up Coordinate for zero increments and the like Possibly the wcs FITS parser could do this.

◆ frequencySystemFromWCS()

Bool casacore::FITSCoordinateUtil::frequencySystemFromWCS ( LogIO & os,
MFrequency::Types & type,
String & errMsg,
const wcsprm & wcs ) const
private

◆ fromFITSHeader()

Bool casacore::FITSCoordinateUtil::fromFITSHeader ( Int & stokesFITSValue,
CoordinateSystem & coordsys,
RecordInterface & recHeader,
const Vector< String > & header,
const IPosition & 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.

◆ generateFITSKeywords()

Bool casacore::FITSCoordinateUtil::generateFITSKeywords ( LogIO & os,
Bool & isNCP,
Double & longPole,
Double & latPole,
Vector< Double > & crval,
Vector< Double > & crpix,
Vector< Double > & cdelt,
Vector< Double > & pvi_ma,
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
private

Generate actual FITS keywords.

◆ getCDFromHeader()

Bool casacore::FITSCoordinateUtil::getCDFromHeader ( Matrix< Double > & cd,
uInt n,
const RecordInterface & header )
private

Decode CD cards from FITS file header (Record interface)

◆ getObsInfo()

ObsInfo casacore::FITSCoordinateUtil::getObsInfo ( LogIO & os,
RecordInterface & header,
const wcsprm & wcs ) const
private

Decode ObsInfo from wcs structure.

◆ getPCFromHeader()

void casacore::FITSCoordinateUtil::getPCFromHeader ( LogIO & os,
Int & rotationAxis,
Matrix< Double > & pc,
uInt n,
const RecordInterface & header,
const String & sprefix )
private

Decode PC matrix from FITS header (Record interface)

◆ setWCS()

void casacore::FITSCoordinateUtil::setWCS ( wcsprm & wcs) const
private

Call wcsset.

◆ stokesCoordinateFromWCS()

Bool casacore::FITSCoordinateUtil::stokesCoordinateFromWCS ( LogIO & os,
StokesCoordinate & coord,
Int & stokesFITSValue,
String & errMSg,
const wcsprm & wcs,
uInt shape,
Bool warnStokes ) const
private

◆ toFITSHeader()

Bool casacore::FITSCoordinateUtil::toFITSHeader ( RecordInterface & header,
IPosition & shape,
const CoordinateSystem & cSys,
Bool oneRelative,
Char prefix = 'c',
Bool writeWCS = True,
Bool preferVelocity = True,
Bool opticalVelocity = True,
Bool preferWavelength = False,
Bool airWavelength = False ) 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") as approved in version 3.0 of the FITS standard. 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.

◆ toFITSHeaderStokes()

Bool casacore::FITSCoordinateUtil::toFITSHeaderStokes ( Vector< Double > & crval,
Vector< Double > & crpix,
Vector< Double > & cdelt,
LogIO & os,
const CoordinateSystem & coordsys,
Int stokesAxis,
Int stokesCoord ) const
private

Special Stokes processing for conversion to FITS header.

◆ wcsInit()

static void casacore::FITSCoordinateUtil::wcsInit ( ::wcsprm & wcsDest)
staticprivate

Initialize the wcsprm struct.

It sets the flag to -1, but furthermore it clears the err pointers because wcslib-4.8 (shipped with Ubuntu) sometimes fails to do so.


The documentation for this class was generated from the following file: