casa
$Rev:20696$
|
Interconvert between AIPS++ Images and FITS files. More...
#include <ImageFITSConverter.h>
Static Public Member Functions | |
static Bool | FITSToImage (ImageInterface< Float > *&newImage, String &error, const String &imageName, const String &fitsName, uInt whichRep=0, uInt whichHDU=0, uInt memoryInMB=64, Bool allowOverwrite=False, Bool zeroBlanks=False) |
Convert a FITS file to an AIPS++ image. | |
static Bool | ImageToFITS (String &error, ImageInterface< Float > &image, const String &fitsName, uInt memoryInMB=64, Bool preferVelocity=True, Bool opticalVelocity=True, Int BITPIX=-32, Float minPix=1.0, Float maxPix=-1.0, Bool allowOverwrite=False, Bool degenerateLast=False, Bool verbose=True, Bool stokesLast=False, Bool preferWavelength=False, Bool airWavelength=False, const String &origin=String(), Bool history=True) |
Old version static Bool FITSToImageOld(ImageInterface<Float>*& newImage, String &error, const String &imageName, const String &fitsName, uInt whichHDU = 0, uInt memoryInMB = 64, Bool allowOverwrite=False, Bool zeroBlanks=False);. | |
static IPosition | copyCursorShape (String &report, const IPosition &shape, uInt imagePixelSize, uInt fitsPixelSize, uInt memoryInMB) |
Helper function - used to calculate a cursor appropriate for the desired memory use. | |
static CoordinateSystem | getCoordinateSystem (Int &imageType, RecordInterface &headerRec, const Vector< String > &header, LogIO &os, uInt whichRep, IPosition &shape, Bool dropStokes) |
Recover CoordinateSystem from header. | |
static ImageInfo | getImageInfo (RecordInterface &header) |
Old version static CoordinateSystem getCoordinateSystemOld (Int& imageType, RecordInterface& header, LogIO& os, IPosition& shape, Bool dropStokes);. | |
static Unit | getBrightnessUnit (RecordInterface &header, LogIO &os) |
Old version static ImageInfo getImageInfoOld (RecordInterface& header);. | |
static void | restoreHistory (LoggerHolder &logger, ConstFitsKeywordList &kw) |
Old version static Unit getBrightnessUnitOld (RecordInterface& header, LogIO& os);. | |
static Bool | extractMiscInfo (RecordInterface &miscInfo, const RecordInterface &header) |
Parse header record and set MiscInfo. | |
static void | readBeamsTable (ImageInfo &info, const String &filename, const DataType type) |
read the BEAMS table if present and add the restoring beams to info | |
Static Public Attributes | |
static const String | CASAMBM |
Static Private Member Functions | |
static Bool | ImageToFITSOut (String &error, LogIO &os, const ImageInterface< Float > &image, FitsOutput *output, uInt memoryInMB=64, Bool preferVelocity=True, Bool opticalVelocity=True, Int BITPIX=-32, Float minPix=1.0, Float maxPix=-1.0, Bool degenerateLast=False, Bool verbose=True, Bool stokesLast=False, Bool preferWavelength=False, Bool airWavelength=False, Bool primHead=True, Bool allowAppend=False, const String &origin=String(), Bool history=True) |
Put a CASA image to an opened FITS image Parameters as in "ImageToFITS". | |
static Bool | QualImgToFITSOut (String &error, LogIO &os, ImageInterface< Float > &image, FitsOutput *outfile, uInt memoryInMB, Bool preferVelocity, Bool opticalVelocity, Int BITPIX, Float minPix, Float maxPix, Bool degenerateLast, Bool verbose, Bool stokesLast, Bool preferWavelength, Bool airWavelength, const String &origin, Bool history) |
Put a CASA image with quality coordinate to an opened FITS file Parameters as in "ImageToFITS". | |
static Bool | removeFile (String &error, const File &outFile, const String &outName, Bool allowOverwrite) |
static Bool | openFitsOutput (String &error, FitsOutput *(&openFitsOutput), const String &fitsName, const Bool &allowOverwrite) |
Create an open FITS file with the name given. | |
static void | _writeBeamsTable (FitsOutput *const &outfile, const ImageInfo &info) |
Interconvert between AIPS++ Images and FITS files.
Public interface
This class is a helper class that is used to interconvert between AIPS++ images and FITS files. This adds no functionality over the general abilities available in the underlying FITS classes, however it is a useful higher-level packaging.
There are two fundamental member functions in this class. FITSToImage
which turns a FITS file into an AIPS++ image, and ImageToFITS
which does the opposite.
We can read images from any HDU inside the FITS file (although this isn't well tested). Images with a quality axis (i.e. contain data and error values) are stored in the primary HDU (data) and an extension HDU (error). Other images are always written to the primary HDU.
Pixels in the FITS file which are blanked are masked out (the mask is set to False) in the output image. On conversion to FITS, masked values are blanked. The mask which is read is the current default mask.
A FITS to image conversion may be accomplished as follows:
PagedImage<Float> *image = 0; String fitsName = "exists.fits"; String imageName = "new.image"; String error; Bool ok = ImageFITSConverter::FITSToImage(image, error, imageName, fitsName); if (!image) ... error ..\.
A couple of things to note:
ok
is False, the conversion failed and error
will be set. error
will contain an error message. image
when the conversion is successful. Similarly, an image to FITS conversion may be accomplished as follows:
String imageName = argv[1]; PagedImage<Float> image = ...; // An existing image from somewhere String fitsName = "new.fits"; String error; Bool ok = ImageFITSConverter::ImageToFITS(error, image, fitsName);
A couple of similar remarks can be made about this example:
ok
is False, the conversion failed and error
will be set. FITS files are the fundamental transport format for images in Astronomy.
Definition at line 143 of file ImageFITSConverter.h.
static void casa::ImageFITSConverter::_writeBeamsTable | ( | FitsOutput *const & | outfile, |
const ImageInfo & | info | ||
) | [static, private] |
static IPosition casa::ImageFITSConverter::copyCursorShape | ( | String & | report, |
const IPosition & | shape, | ||
uInt | imagePixelSize, | ||
uInt | fitsPixelSize, | ||
uInt | memoryInMB | ||
) | [static] |
Helper function - used to calculate a cursor appropriate for the desired memory use.
It's not intended that application programmers call this, but you may if it's useful to you.
static Bool casa::ImageFITSConverter::extractMiscInfo | ( | RecordInterface & | miscInfo, |
const RecordInterface & | header | ||
) | [static] |
Parse header record and set MiscInfo.
static Bool casa::ImageFITSConverter::FITSToImage | ( | ImageInterface< Float > *& | newImage, |
String & | error, | ||
const String & | imageName, | ||
const String & | fitsName, | ||
uInt | whichRep = 0 , |
||
uInt | whichHDU = 0 , |
||
uInt | memoryInMB = 64 , |
||
Bool | allowOverwrite = False , |
||
Bool | zeroBlanks = False |
||
) | [static] |
Convert a FITS file to an AIPS++ image.
newImage
will be zero if the conversion fail. If the conversion succeeds, the caller is responsible for deleting this pointer. error
will be set if the conversion fails. imageName
is empty, a TempImage will be created, otherwise a PagedImage on disk. fitsName
must already exist (and have an image at the indicated HDU). whichRep
Zero-relative coordinate representation (Starting with wcs FITS multiple coordinate representations can be stored in a FITS file) whichHDU
Zero-relative hdu. The default is correct for a primary array, set it for an image extension. Only zero has been tested. memoryInMB
. Setting this to zero will result in row-by-row copying, otherwise it will attempt to with as large a chunk-size as possible, while fitting in the desired memory. allowOverwrite
If True, allow imageName to be overwritten if it already exists. zeroBlanks
If True, allow any blanked pixels are set to zero rather than NaN static Unit casa::ImageFITSConverter::getBrightnessUnit | ( | RecordInterface & | header, |
LogIO & | os | ||
) | [static] |
Old version static ImageInfo getImageInfoOld (RecordInterface& header);.
Recover brightness unit from header. Used keywords are removed from header
static CoordinateSystem casa::ImageFITSConverter::getCoordinateSystem | ( | Int & | imageType, |
RecordInterface & | headerRec, | ||
const Vector< String > & | header, | ||
LogIO & | os, | ||
uInt | whichRep, | ||
IPosition & | shape, | ||
Bool | dropStokes | ||
) | [static] |
Recover CoordinateSystem from header.
Used keywords are removed from header and the unused one returned in a Record for ease of use. Degenerate axes may be added to shape if needed
static ImageInfo casa::ImageFITSConverter::getImageInfo | ( | RecordInterface & | header | ) | [static] |
Old version static CoordinateSystem getCoordinateSystemOld (Int& imageType, RecordInterface& header, LogIO& os, IPosition& shape, Bool dropStokes);.
Recover ImageInfo from header. Used keywords are removed from header
static Bool casa::ImageFITSConverter::ImageToFITS | ( | String & | error, |
ImageInterface< Float > & | image, | ||
const String & | fitsName, | ||
uInt | memoryInMB = 64 , |
||
Bool | preferVelocity = True , |
||
Bool | opticalVelocity = True , |
||
Int | BITPIX = -32 , |
||
Float | minPix = 1.0 , |
||
Float | maxPix = -1.0 , |
||
Bool | allowOverwrite = False , |
||
Bool | degenerateLast = False , |
||
Bool | verbose = True , |
||
Bool | stokesLast = False , |
||
Bool | preferWavelength = False , |
||
Bool | airWavelength = False , |
||
const String & | origin = String() , |
||
Bool | history = True |
||
) | [static] |
Old version static Bool FITSToImageOld(ImageInterface<Float>*& newImage, String &error, const String &imageName, const String &fitsName, uInt whichHDU = 0, uInt memoryInMB = 64, Bool allowOverwrite=False, Bool zeroBlanks=False);.
Convert an AIPS++ image to a FITS file.
return
True if the conversion succeeds, False otherwise. error
will be set if the conversion fails. image
The image to convert. fitsName
If the name is "-" (the minus character), then write to stdout Always writes to the primary array. memoryInMB
. Setting this to zero will result in row-by-row copying, otherwise it will attempt to with as large a chunk-size as possible, while fitting in the desired memory. preferVelocity
Write a velocity primary spectral axis if possible. opticalVelocity
If writing a velocity, use the optical definition (otherwise use radio). BITPIX, minPix, maxPix
BITPIX can presently be set to -32 or 16 only. When BITPIX is 16 it will write BSCALE and BZERO into the FITS file. If minPix is greater than maxPix the minimum and maximum pixel values will be determined from the array, otherwise the supplied values will be used and pixels outside that range will be truncated to the minimum and maximum pixel values (note that this truncation does not occur for BITPIX=-32). allowOverwrite
If True, allow fitsName to be overwritten if it already exists. degenerateLast
If True, axes of length 1 will be written last to the header. preferWavelength
If True, write a wavelength primary axis. airWavelength
If True and preferWavelength
is True write an air wavelength primary axis. origin
gives the origin, i.e., the name of the package. If empty, it defaults to "casacore-"getVersion(). static Bool casa::ImageFITSConverter::ImageToFITSOut | ( | String & | error, |
LogIO & | os, | ||
const ImageInterface< Float > & | image, | ||
FitsOutput * | output, | ||
uInt | memoryInMB = 64 , |
||
Bool | preferVelocity = True , |
||
Bool | opticalVelocity = True , |
||
Int | BITPIX = -32 , |
||
Float | minPix = 1.0 , |
||
Float | maxPix = -1.0 , |
||
Bool | degenerateLast = False , |
||
Bool | verbose = True , |
||
Bool | stokesLast = False , |
||
Bool | preferWavelength = False , |
||
Bool | airWavelength = False , |
||
Bool | primHead = True , |
||
Bool | allowAppend = False , |
||
const String & | origin = String() , |
||
Bool | history = True |
||
) | [static, private] |
static Bool casa::ImageFITSConverter::openFitsOutput | ( | String & | error, |
FitsOutput *& | openFitsOutput, | ||
const String & | fitsName, | ||
const Bool & | allowOverwrite | ||
) | [static, private] |
Create an open FITS file with the name given.
static Bool casa::ImageFITSConverter::QualImgToFITSOut | ( | String & | error, |
LogIO & | os, | ||
ImageInterface< Float > & | image, | ||
FitsOutput * | outfile, | ||
uInt | memoryInMB, | ||
Bool | preferVelocity, | ||
Bool | opticalVelocity, | ||
Int | BITPIX, | ||
Float | minPix, | ||
Float | maxPix, | ||
Bool | degenerateLast, | ||
Bool | verbose, | ||
Bool | stokesLast, | ||
Bool | preferWavelength, | ||
Bool | airWavelength, | ||
const String & | origin, | ||
Bool | history | ||
) | [static, private] |
static void casa::ImageFITSConverter::readBeamsTable | ( | ImageInfo & | info, |
const String & | filename, | ||
const DataType | type | ||
) | [static] |
read the BEAMS table if present and add the restoring beams to info
static Bool casa::ImageFITSConverter::removeFile | ( | String & | error, |
const File & | outFile, | ||
const String & | outName, | ||
Bool | allowOverwrite | ||
) | [static, private] |
static void casa::ImageFITSConverter::restoreHistory | ( | LoggerHolder & | logger, |
ConstFitsKeywordList & | kw | ||
) | [static] |
Old version static Unit getBrightnessUnitOld (RecordInterface& header, LogIO& os);.
Recover history from FITS file keywrod list into logger
const String casa::ImageFITSConverter::CASAMBM [static] |
Definition at line 146 of file ImageFITSConverter.h.