- OK
- NOMEM
- MISSKEY
- BADBITPIX
- NOAXISN
- NOPCOUNT
- NOGCOUNT
- BADPCOUNT
- BADGCOUNT
- NOGROUPS
- BADNAXIS
- BADREC
- BADTYPE
- BADRULES
- BADSIZE
- BADOPER
- BADCONV
- BADIO
The following inheritence hierarchy illustrates the current derived classes:
HeaderDataUnit / | / | PrimaryArray ExtensionHeaderDataUnit / \ | / \ | PrimaryGroup ImageExtension | | BinaryTableExtension / / AsciiTableExtension
error handling and error codes that can be returned
skipping one or more HDU's
write the current header
Determines the HDU type and the data type Parameterss: keyword list, hdu type, data type, error handler and error status. Returns False if a serious error was detected, otherwise True
Compute the total size of the data associated with an HDU. The number of dimensions is also determined. This routine assumes that hdu type has been appropriately set, but it may be changed in the process. Data type is also determined. Returns False if a serious error was detected, otherwise True
Operations on the HDU's keyword list
Operations on the HDU's keyword list
<Type> data_array [NAXIS1][NAXIS2]...[NAXISN]
For a PrimaryArray, dims() gives the number of dimensions and dim(i) gives the value of the i-th dimension
WARNING! Multi-dimensional arrays are stored in FORTRAN order, NOT in C order. Options on the store, copy, and move functions exist to convert from one order to the other, if that is necessary.
It is important to understand the proper sequence of operations with respect to I/O and data access. For input, the `read()' functions allocate an internal buffer of the appropriate size, if not already allocated, as well as reading and converting data; a `read()' function must be performed prior to accessing the data, i. e. before executing any `()', `data()', `copy()', or `move()' function. For output, the `store()' function similarly allocates an internal buffer before transfering data, and must be executed prior to any data access or `write()' function. Note: If you call any version of store(), do not call set_next().
Writing portions of an array at a time, rather than the entire array,
is a special case. The `set_next()' function is provided for this
purpose. It declares the intention to write out the next N elements and
must be executed prior to any `data()' function. It allocates a buffer
of appropriate size, if not already allocated. Again, via the `data()'
functions, one accesses the array as if the entire array were in
memory. The `write()' function always writes the number of current
elements in the internal buffer. The sequence of operations for each
portion of the array written would be:
The `set_next()' function must NOT be used with
`read()' or `store()' functions; unpredictable results will occur.
Suppose we have an image array with 512 rows and 1024 columns stored in C-order. The C declaration would be:
int source[1024][512];To write out the entire array:
FitsOutput fout; // some properly constructed FitsOutput PrimaryArray<FitsLong> pa; // some properly constructed PrimaryArray pa.store(source,CtoF); pa.write(fout);
Suppose we wanted to write out the two-dimensional image array a column at a time, rather than write out the entire array. For FITS, dim(0) is 512, dim(1) is 1024. The following code fragment writes one column at a time in the proper FITS Fortran-order.
for (i = 0; i < dim(1); ++i) { pa.set_next(dim(0)); for (j = 0; j < dim(0); ++j) data(j,i) = source[i][j]; pa.write(fout); }
typedef PrimaryArray<unsigned char> BytePrimaryArray; typedef PrimaryArray<short> ShortPrimaryArray; typedef PrimaryArray<FitsLong> LongPrimaryArray; typedef PrimaryArray<float> FloatPrimaryArray; typedef PrimaryArray<double> DoublePrimaryArray;
constructor from a FitsInput
General access routines for a primary array
The overloaded operator functions `()' all return physical data, i. e., data to which bscale() and bzero() have been applied, via the formula
physical_data[i] = bscale() * raw_data[i] + bzero().
The various `data()' functions allow one to access and set the raw data itself.
The `store()', `move()' and `copy()' functions allow bulk data transfer between the internal FITS array and an external data storage area. The external storage must have already been allocated and it is assumed that the entire data array is in memory. `store()' transfers raw data at `source' into the FITS array; an allowable option is CtoF, which specifies to convert the array from C-order to Fortran-order. `move()' is the opposite of `store()'. `move()' transfers raw data from the FITS array to `target'; an allowable option is FtoC, which specifies to convert the array from Fortran-order to C-order. `copy()' is similar to `move()' except that what is copied is physical data and not raw data; the physical data can be either double or float. copy() also turns blanks into NaN's.
Use these versions if you are reading/writing "chunk by chunk." No FtoC option is available. You are responsible for ensuring that npixels corresponds to he number actually read or written. Note that copy() turns blanks into NaN's.
The `store()', `move()' and `copy()' functions allow bulk data transfer between the internal FITS array and an external data storage area. The external storage must have already been allocated and it is assumed that the entire data array is in memory. `store()' transfers raw data at `source' into the FITS array; an allowable option is CtoF, which specifies to convert the array from C-order to Fortran-order. `move()' is the opposite of `store()'. `move()' transfers raw data from the FITS array to `target'; an allowable option is FtoC, which specifies to convert the array from Fortran-order to C-order. `copy()' is similar to `move()' except that what is copied is physical data and not raw data; the physical data can be either double or float. copy() also turns blanks into NaN's.
The `read()' and `write()' functions control reading and writing data from the external FITS I/O medium into the FITS array. Appropriate conversions are made between FITS and local data representations. One can read the entire array into memory, or one can only read portions of the array. In the latter case, one must specify that the next N elements are to be read or written. Note that the number of elements must be specified, NOT the number of bytes. If one reads portions of the array, as opposed to the entire array, only that portion is in memory at a given time. One can still access the elements of the array via the `()' and `data()' functions, as if the entire array was in memory; obviously care must be taken in this case to access only those portions that are actually in memory.
compute a linear offset from array indicies
typedef ImageExtension<unsigned char> ByteImageExtension; typedef ImageExtension<short> ShortImageExtension; typedef ImageExtension<FitsLong> LongImageExtension; typedef ImageExtension<float> FloatImageExtension; typedef ImageExtension<double> DoubleImageExtension;
struct GroupData { <Type> group_parms [PCOUNT]; <Type> data_array [NAXIS2][NAXIS3]...[NAXISN]; } group_data[GCOUNT];
typedef PrimaryGroup<unsigned char> BytePrimaryGroup; typedef PrimaryGroup<short> ShortPrimaryGroup; typedef PrimaryGroup<FitsLong> LongPrimaryGroup; typedef PrimaryGroup<float> FloatPrimaryGroup; typedef PrimaryGroup<double> DoublePrimaryGroup;
Please note that the NOST has deprecated the Random Group datastructure, it has been replaced by the much more powerfull BINTABLE extension.
Return basic parameters of a random group
read, or write the next group
disable these functions, since they are inherited from PrimaryArray
read next N bytes into addr
write next N bytes from addr to the FITS output fout
typedef FitsField<FitsLogical> LogicalFitsField; typedef FitsField<FitsBit> BitFitsField; typedef FitsField<char> CharFitsField; typedef FitsField<unsigned char> ByteFitsField; typedef FitsField<short> ShortFitsField; typedef FitsField<FitsLong> LongFitsField; typedef FitsField<float> FloatFitsField; typedef FitsField<double> DoubleFitsField; typedef FitsField<Complex> ComplexFitsField; typedef FitsField<IComplex> IComplexFitsField; typedef FitsField<DComplex> DComplexFitsField; typedef FitsField<FitsVADesc> VADescFitsField;
Bit fields require special treatment
typedef FitsField<FitsLogical> LogicalFitsField; typedef FitsField<FitsBit> BitFitsField; typedef FitsField<char> CharFitsField; typedef FitsField<unsigned char> ByteFitsField; typedef FitsField<short> ShortFitsField; typedef FitsField<FitsLong> LongFitsField; typedef FitsField<float> FloatFitsField; typedef FitsField<double> DoubleFitsField; typedef FitsField<Complex> ComplexFitsField; typedef FitsField<IComplex> IComplexFitsField; typedef FitsField<DComplex> DComplexFitsField; typedef FitsField<FitsVADesc> VADescFitsField;
Bit fields require special treatment
typedef FitsArray<FitsLogical> LogicalFitsArray; typedef FitsArray<FitsBit> BitFitsArray; typedef FitsArray<char> CharFitsArray; typedef FitsArray<unsigned char> ByteFitsArray; typedef FitsArray<short> ShortFitsArray; typedef FitsArray<FitsLong> LongFitsArray; typedef FitsArray<float> FloatFitsArray; typedef FitsArray<double> DoubleFitsArray; typedef FitsArray<Complex> ComplexFitsArray; typedef FitsArray<IComplex> IComplexFitsArray; typedef FitsArray<DComplex> DComplexFitsArray; typedef FitsArray<FitsVADesc> VADescFitsArray;
typedef FitsArray<FitsLogical> LogicalFitsArray; typedef FitsArray<FitsBit> BitFitsArray; typedef FitsArray<char> CharFitsArray; typedef FitsArray<unsigned char> ByteFitsArray; typedef FitsArray<short> ShortFitsArray; typedef FitsArray<FitsLong> LongFitsArray; typedef FitsArray<float> FloatFitsArray; typedef FitsArray<double> DoubleFitsArray; typedef FitsArray<Complex> ComplexFitsArray; typedef FitsArray<IComplex> IComplexFitsArray; typedef FitsArray<DComplex> DComplexFitsArray; typedef FitsArray<FitsVADesc> VADescFitsArray;
return basic elements of a table
binds a FitsField to a column
row selector functions
read entire table into memory
select a field
get current row
read and write the next FITS data row
sets field addresses in the current row
position in which column starts
ascii string that represents the NULL value
read and write the next FITS data row