casacore
BasicFITS.h
Go to the documentation of this file.
1 //# FITS.h: Transform a Casacore Array to or from a FITS disk file.
2 //# Copyright (C) 1993,1994,1995,1999
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef FITS_BASICFITS_H
29 #define FITS_BASICFITS_H
30 
31 #include <casacore/casa/aips.h>
32 //# Would like to forward declare
33 #include <casacore/casa/Arrays/Vector.h>
34 #include <map>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 class String; // Forward declarations
39 
40 //<summary> read a FITS file from a Casacore array</summary>
41 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
42 // </reviewed>
43 //<linkfrom anchor=ReadFITS classes=FitsInput>
44 // <here>ReadFITS</here> Casacore interface routines.
45 //</linkfrom>
46 
47 //<motivation>
48 // Quick and dirty interface to the FITS classes for turning Casacore
49 // arrays into FITS files and back. N.B. this will have many more features
50 // in the future, also some files should be renamed since we now have
51 // FITS.h and fits.h.
52 //</motivation>
53 //<synopsis>
54 // Read FITS from a file into a Casacore Array. Sets "ok" to False if there
55 // is any problem. We only deal with data in the primary data array.
56 // If ReadFITS fails, the state of array is undefined. Trailing
57 // degenerate (length==1) axes are NOT removed. If desired, you may do
58 // this yourself with the nonDegenerate array member function.
59 // If ok is false, ErrorMessage will contain an information error message.
60 // If necessary, the data is converted from whatever type it is stored as
61 // to Float. BSCALE and BZERO are applied. Blanks are not handled.
62 //
63 // If unitName is non-null, the string it points to is filled with the FITS
64 // BUNIT keyword. If axisNames is name of the axes (CTYPEn).
65 // If refPixel is non-null, it is set to the reference pixel of the FITS file
66 // (CRPIX). Similarly refLocation is set to the position
67 // (image coordinates) of the reference pixel (CRVALn) and delta is
68 // set to the increment along each axis (CDELTn). All
69 // the vectors are resized if necessary. Note that FITS pixel indexing is
70 // one-based, Casacore is 0-based, this correction is made. unitName and
71 // axisNames have trailing blanks (a FITS "feature") removed.
72 //
73 // If "keywords" is non-null, the integral and floating point keywords
74 // (excluding NAXIS*, BSCALE, BZERO) are read into keywords. Case is not
75 // changed.
76 //</synopsis>
77 //
78 // If objectName is non-null, the string it points to is set to the
79 // value of the FITS OBJECT keyword.
80 //
81 //<note role=caution> This will only work properly on an IEEE big-endian
82 // machine at the moment.
83 //</note>
84 
85 
86 //<group name=ReadFITS>
87 // blabla
88 Array<Float> ReadFITS(const char *FileName, Bool &ok, String &ErrorMessage,
89  String *unitName = 0,
90  Vector<String> *axisNames = 0,
91  Vector<Float> *refPixel = 0,
92  Vector<Float> *refLocation = 0,
93  Vector<Float> *delta = 0,
94  std::map<String, Double> *keywords = 0,
95  String *objectName = 0);
96 //</group>
97 
98 //<summary> write a FITS file to a Casacore array</summary>
99 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
100 // </reviewed>
101 //<linkfrom anchor=WriteFITS classes=FitsOutput>
102 // <here>WriteFITS</here> Casacore interface routines.
103 //</linkfrom>
104 //<synopsis>
105 // Write a FITS file from a Casacore Array. Returns False if there is any
106 // proglem. The data is written into the primary data array, and the data
107 // is written in floating point (BITPIX=-32). If the operation fails,
108 // ErrorMessage will contain an informative error. At the moment this
109 // probably isn't bulletproof enough at finding errors on output.
110 //
111 // If any of unitName, axisNames, refPixel, refLocation, or delta are
112 // non-null, the corresponding FITS keywords (BUNIT, CTYPEn, CRPIXn,
113 // CRVALn, CDELTn) are set. CRVALn is corrected for the difference in
114 // addressing between FITS and Casacore (1 vs. 0). If a Vector pointer
115 // is non-null, then that vector must be the correct length.
116 //
117 // If keywords is non-null, the contents are written out as FITS keywords.
118 // The names are upper-cased and truncated to 8 characters (yuck). No other
119 // validation is done (e.g. that SIMPLE or NAXIS is not in the map).
120 //
121 // If objectName is non-null, the OBJECT keyword is set.
122 //
123 // BITPIX can presently be set to -32 or 16 only. When BITPIX is 16 it will
124 // write BSCALE and BZERO into the FITS file. If minPix is greater than maxPix
125 // the minimum and maximum pixel values will be determined from the array,
126 // otherwise the supplied values will be used and pixels outside that range
127 // will be truncated to the minimum and maximum pixel values (note that this
128 // truncation does not occur for BITPIX=-32).
129 //</synopsis>
130 
131 //<group name=WriteFITS>
132 // blabla
133 Bool WriteFITS(const char *FileName, const Array<Float> &array,
134  String &ErrorMessage,
135  const char *unitName = 0,
136  const Vector<String> *axisNames = 0,
137  const Vector<Float> *refPixel = 0,
138  const Vector<Float> *refLocation = 0,
139  const Vector<Float> *delta = 0,
140  const std::map<String, Double> *keywords = 0,
141  const char *objectName = 0,
142  Int BITPIX=-32,
143  Float minPix = 1.0, Float maxPix = -1.0);
144 //</group>
145 
146 } //# NAMESPACE CASACORE - END
147 
148 #endif
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1929
float Float
Definition: aipstype.h:54
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42