casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
BasicFITS.h
Go to the documentation of this file.
00001 //# FITS.h: Transform an AIPS++ Array to or from a FITS disk file.
00002 //# Copyright (C) 1993,1994,1995,1999
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //# 
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //# 
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //# 
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //# 
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: BasicFITS.h 18736 2005-06-08 04:04:15Z dschieb $
00027 
00028 #ifndef FITS_BasicFITS_H
00029 #define FITS_BasicFITS_H
00030 
00031 #include <casa/aips.h>
00032 //# Would like to forward declare
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Containers/Map.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 class String;        // Forward declarations
00039 
00040 //<summary>  read a FITS file from an AIPS++ array</summary>
00041 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00042 // </reviewed>
00043 //<linkfrom anchor=ReadFITS classes=FitsInput>
00044 // <here>ReadFITS</here> AIPS++ interface routines.
00045 //</linkfrom>
00046 
00047 //<motivation>
00048 // Quick and dirty interface to the FITS classes for turning aips++
00049 // arrays into FITS files and back. N.B. this will have many more features
00050 // in the future, also some files should be renamed since we now have
00051 // FITS.h and fits.h. 
00052 //</motivation>
00053 //<synopsis>
00054 // Read FITS from a file into an aips++ Array. Sets "ok" to False if there 
00055 // is any problem. We only deal with data in the primary data array.
00056 // If ReadFITS fails, the state of array is undefined. Trailing
00057 // degenerate (length==1) axes are NOT removed. If desired, you may do
00058 // this yourself with the nonDegenerate array member function.
00059 // If ok is false, ErrorMessage will contain an information error message.
00060 // If necessary, the data is converted from whatever type it is stored as 
00061 // to Float. BSCALE and BZERO are applied. Blanks are not handled.
00062 //
00063 // If unitName is non-null, the string it points to is filled with the FITS
00064 // BUNIT keyword. If axisNames is name of the axes (CTYPEn).
00065 // If refPixel is non-null, it is set to the reference pixel of the FITS file
00066 // (CRPIX). Similarly refLocation is set to the position 
00067 // (image coordinates) of the reference pixel (CRVALn) and delta is 
00068 // set to the increment along each axis (CDELTn). All
00069 // the vectors are resized if necessary. Note that FITS pixel indexing is
00070 // one-based, AIPS++ is 0-based, this correction is made. unitName and
00071 // axisNames have trailing blanks (a FITS "feature") removed.
00072 //
00073 // If "keywords" is non-null, the integral and floating point keywords
00074 // (excluding NAXIS*, BSCALE, BZERO) are read into keywords. Case is not
00075 // changed.
00076 //</synopsis>
00077 //
00078 // If objectName is non-null, the string it points to is set to the
00079 // value of the FITS OBJECT keyword.
00080 //
00081 //<note role=caution> This will only work properly on an IEEE big-endian
00082 //                    machine at the moment. 
00083 //</note>
00084 
00085 
00086 //<group name=ReadFITS>
00087 // blabla
00088 Array<Float> ReadFITS(const char *FileName, Bool &ok, String &ErrorMessage,
00089                       String *unitName = 0,
00090                       Vector<String> *axisNames = 0,
00091                       Vector<Float> *refPixel = 0,
00092                       Vector<Float> *refLocation = 0,
00093                       Vector<Float> *delta = 0,
00094                       Map<String, Double> *keywords = 0,
00095                       String *objectName = 0);
00096 //</group>
00097 
00098 //<summary> write a FITS file to an AIPS++ array</summary>
00099 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
00100 // </reviewed>
00101 //<linkfrom anchor=WriteFITS classes=FitsOutput>
00102 // <here>WriteFITS</here> AIPS++ interface routines.
00103 //</linkfrom>
00104 //<synopsis>
00105 // Write a FITS file from an aips++ Array. Returns False if there is any
00106 // proglem. The data is written into the primary data array, and the data
00107 // is written in floating point (BITPIX=-32). If the operation fails, 
00108 // ErrorMessage will contain an informative error. At the moment this
00109 // probably isn't bulletproof enough at finding errors on output.
00110 //
00111 // If any of unitName, axisNames, refPixel, refLocation, or delta are
00112 // non-null, the corresponding FITS keywords (BUNIT, CTYPEn, CRPIXn,
00113 // CRVALn, CDELTn) are set. CRVALn is corrected for the difference in
00114 // addressing between FITS and AIPS++ (1 vs. 0). If a Vector pointer
00115 // is non-null, then that vector must be the correct length.
00116 //
00117 // If keywords is non-null, the contents are written out as FITS keywords.
00118 // The names are upper-cased and truncated to 8 characters (yuck). No other
00119 // validation is done (e.g. that SIMPLE or NAXIS is not in the map).
00120 //
00121 // If objectName is non-null, the OBJECT keyword is set.
00122 //
00123 // BITPIX can presently be set to -32 or 16 only. When BITPIX is 16 it will
00124 // write BSCALE and BZERO into the FITS file. If minPix is greater than maxPix
00125 // the minimum and maximum pixel values will be determined from the array,
00126 // otherwise the supplied values will be used and pixels outside that range
00127 // will be truncated to the minimum and maximum pixel values (note that this
00128 // truncation does not occur for BITPIX=-32).
00129 //</synopsis>
00130 
00131 //<group name=WriteFITS>
00132 // blabla
00133 Bool WriteFITS(const char *FileName, const Array<Float> &array,
00134                String &ErrorMessage,
00135                const char *unitName = 0,
00136                const Vector<String> *axisNames = 0,
00137                const Vector<Float> *refPixel = 0,
00138                const Vector<Float> *refLocation = 0,
00139                const Vector<Float> *delta = 0,
00140                const Map<String, Double> *keywords = 0,
00141                const char *objectName = 0,
00142                Int BITPIX=-32,
00143                Float minPix = 1.0, Float maxPix = -1.0);
00144 //</group>
00145 
00146 } //# NAMESPACE CASA - END
00147 
00148 #endif