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
return the header of the chdu as a vector of String. You can
force the strings to be length 80 (padded with spaces)
Protected Members
- PrimaryArray(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- PrimaryArray(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- PrimaryArray(FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- int offset(int, int) const
- int offset(int, int, int) const
- int offset(int, int, int, int) const
- int offset(int, int, int, int, int) const
- void pa_assign()
Synopsis
A Primary Data Array is represented by the following:
<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:
`set_next(N)',
fill the array using `data(N)' or other `data()' functions
`write(fout)'.
The `set_next()' function must NOT be used with
`read()' or `store()' functions; unpredictable results will occur.
Example
The following example illustrates the output cases.
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);
}
Template Type Argument Requirements
typedef PrimaryArray<unsigned char> BytePrimaryArray;
typedef PrimaryArray<short> ShortPrimaryArray;
typedef PrimaryArray<FitsLong> LongPrimaryArray;
typedef PrimaryArray<float> FloatPrimaryArray;
typedef PrimaryArray<double> DoublePrimaryArray;
Member Description
PrimaryArray(FitsInput &, FITSErrorHandler= FITSError::defaultHandler)
constructor from a FitsInput
constructor from a FitsKeywordList
PrimaryArray(FITSErrorHandler= FITSError::defaultHandler)
constructor does not require a FitsKeywordList. call write_priArr_hdr() after construction.
destructor
double bscale() const
double bzero() const
char *bunit() const
Bool isablank() const
Int blank() const
char *ctype(int n) const
double crpix(int n) const
double crota(int n) const
double crval(int n) const
double cdelt(int n) const
double datamax() const
double datamin() const
OFF_T nelements() const
General access routines for a primary array
double operator () (int, int, int, int, int) const
double operator () (int, int, int, int) const
double operator () (int, int, int) const
double operator () (int, int) const
double operator () (int) const
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().
TYPE & data(int, int, int, int, int)
TYPE & data(int, int, int, int)
TYPE & data(int, int, int)
TYPE & data(int, int)
TYPE & data(int)
The various `data()' functions allow one to access and set the raw data
itself.
int store(const TYPE *source, int npixels)
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.
int store(const TYPE *source, FITS::FitsArrayOption = FITS::NoOpt)
void copy(double *target, FITS::FitsArrayOption = FITS::NoOpt) const
void copy(float *target, FITS::FitsArrayOption = FITS::NoOpt) const
void move(TYPE *target, FITS::FitsArrayOption = FITS::NoOpt) const
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.
void copy(double *target, int npixels) const
void copy(float *target, int npixels) const
void move(TYPE *target, int npixels) const
int write_priArr_hdr( FitsOutput &fout, int simple, int bitpix, int naxis, long naxes[], int extend )
virtual int read()
virtual int read( int )
virtual int write(FitsOutput &)
virtual OFF_T set_next(OFF_T)
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.
PrimaryArray(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
construct from a FitsInput with given HDU type
PrimaryArray(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
construct from a FitsKeywordList with given HDU type
PrimaryArray(FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
construct witout FitsKeywordList for given HDU type( for ImageExtension and PrimaryGroup)
int offset(int, int) const
int offset(int, int, int) const
int offset(int, int, int, int) const
int offset(int, int, int, int, int) const
factors needed to compute array position offsets
compute a linear offset from array indicies
Interface
Public Members
- ImageExtension(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- ImageExtension(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- ImageExtension(FITSErrorHandler errhandler = FITSError::defaultHandler)
- ~ImageExtension()
- char *xtension()
- char *extname()
- Int extver()
- Int extlevel()
- Int pcount()
- Int gcount()
- int write_imgExt_hdr( FitsOutput &fout, int bitpix, int naxis, long *naxes)
Private Members
- void ie_assign()
Template Type Argument Requirements
typedef ImageExtension<unsigned char> ByteImageExtension;
typedef ImageExtension<short> ShortImageExtension;
typedef ImageExtension<FitsLong> LongImageExtension;
typedef ImageExtension<float> FloatImageExtension;
typedef ImageExtension<double> DoubleImageExtension;
Member Description
ImageExtension(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
ImageExtension(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
ImageExtension(FITSErrorHandler errhandler = FITSError::defaultHandler)
constructor for header consisted required keywords only
write required keywords for ImageExtension
Interface
Public Members
- PrimaryGroup(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- PrimaryGroup(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- PrimaryGroup(FITSErrorHandler errhandler = FITSError::defaultHandler)
- ~PrimaryGroup()
- Int gcount() const
- Int pcount() const
- char *ptype(int n) const
- double pscal(int n) const
- double pzero(int n) const
- Int currgroup() const
- double parm(int)
- TYPE & rawparm(int)
- void storeparm(const TYPE *source)
- void copyparm(double *target) const
- void copyparm(float *target) const
- void moveparm(TYPE *target) const
- int read()
- int write(FitsOutput &)
- int write_priGrp_hdr( FitsOutput &fout, int simple, int bitpix, int naxis, long naxes[], long pcount, long gcount )
- OFF_T set_next(OFF_T)
- int read(int)
Private Members
- void pg_assign()
Synopsis
A Random Group Structure is represented by the following:
struct GroupData {
<Type> group_parms [PCOUNT];
<Type> data_array [NAXIS2][NAXIS3]...[NAXISN];
} group_data[GCOUNT];
Template Type Argument Requirements
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.
Member Description
PrimaryGroup(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
PrimaryGroup(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
PrimaryGroup(FITSErrorHandler errhandler = FITSError::defaultHandler)
constructor for header consisted required keywords only
Int gcount() const
Int pcount() const
char *ptype(int n) const
double pscal(int n) const
double pzero(int n) const
Return basic parameters of a random group
double parm(int)
return physical parms
void storeparm(const TYPE *source)
access raw parms
void copyparm(double *target) const
void copyparm(float *target) const
void moveparm(TYPE *target) const
read, or write the next group
int write_priGrp_hdr( FitsOutput &fout, int simple, int bitpix, int naxis, long naxes[], long pcount, long gcount )
write the required keywords for PrimaryGroup
disable these functions, since they
are inherited from PrimaryArray
Interface
Public Members
- ExtensionHeaderDataUnit(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- ExtensionHeaderDataUnit(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- ~ExtensionHeaderDataUnit()
- char *xtension()
- char *extname()
- Int extver()
- Int extlevel()
- Int pcount()
- Int gcount()
- int read(char *addr, int nbytes)
- int write(FitsOutput &fout, char *addr, int nbytes)
Protected Members
- ExtensionHeaderDataUnit(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- ExtensionHeaderDataUnit(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- ExtensionHeaderDataUnit(FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
Private Members
- void ex_assign()
Member Description
int read(char *addr, int nbytes)
read next N bytes into addr
int write(FitsOutput &fout, char *addr, int nbytes)
write next N bytes from addr to the FITS output fout
ExtensionHeaderDataUnit(FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
This constructor is used for writing only required keywords.
Interface
Public Members
- FitsBase(const FITS::ValueType &t, int n) : no_elements(n), data_type(t)
- virtual ~FitsBase()
- unsigned int nelements() const
- virtual int fitsfieldsize() const = 0
- virtual int localfieldsize() const = 0
- virtual void *data() = 0
- virtual int dims() const
- virtual int dim(int n) const
- virtual int *vdim()
- FITS::ValueType fieldtype() const
- static FitsBase *make(const FITS::ValueType &, int = 1)
- static FitsBase *make(const FITS::ValueType &, int, int *)
- static FitsBase *make(FitsBase &)
- FitsBase & operator = (FitsBase &)
- virtual void show(std::ostream &) = 0
Protected Members
- virtual void setaddr(void **) = 0
Member Description
FitsBase(const FITS::ValueType &t, int n) : no_elements(n), data_type(t)
unsigned int nelements() const
virtual void *data() = 0
virtual int dims() const
virtual int dim(int n) const
virtual int *vdim()
static FitsBase *make(const FITS::ValueType &, int = 1)
static FitsBase *make(const FITS::ValueType &, int, int *)
static FitsBase *make(FitsBase &)
FitsBase & operator = (FitsBase &)
virtual void show(std::ostream &) = 0
virtual void setaddr(void **) = 0
template <> class FitsField<FitsBit> : public FitsBase
Interface
Public Members
- FitsField(int n = 1)
- ~FitsField()
- FitsField<FitsBit> & operator () ()
- FitsField<FitsBit> & operator () (unsigned i)
- FitsField<FitsBit> & operator = (unsigned i)
- int fitsfieldsize() const
- int localfieldsize() const
- operator int()
- void *data()
- void show(std::ostream &)
Protected Members
- void setaddr(void **addr)
Template Type Argument Requirements
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
Member Description
operator int()
void show(std::ostream &)
void setaddr(void **addr)
template <> class FitsField<FitsBit> : public FitsBase
Interface
Public Members
- FitsField(int n = 1)
- ~FitsField()
- FitsField<FitsBit> & operator () ()
- FitsField<FitsBit> & operator () (unsigned i)
- FitsField<FitsBit> & operator = (unsigned i)
- int fitsfieldsize() const
- int localfieldsize() const
- operator int()
- void *data()
- void show(std::ostream &)
Protected Members
- void setaddr(void **addr)
Template Type Argument Requirements
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
Member Description
operator int()
void show(std::ostream &)
void setaddr(void **addr)
template <> class FitsArray<FitsBit> : public FitsField<FitsBit>
Interface
- FitsArray(int, const int *)
- ~FitsArray()
- FitsField<FitsBit> & operator () (int d0, int d1)
- FitsField<FitsBit> & operator () (int, int, int)
- FitsField<FitsBit> & operator () (int, int, int, int)
- FitsField<FitsBit> & operator () (int, int, int, int, int)
- int dims() const
- int dim(int n) const
- int *vdim()
Template Type Argument Requirements
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;
We must specify a FitsArray as a specialization.
Member Description
int dims() const
int dim(int n) const
template <> class FitsArray<FitsBit> : public FitsField<FitsBit>
Interface
- FitsArray(int, const int *)
- ~FitsArray()
- FitsField<FitsBit> & operator () (int d0, int d1)
- FitsField<FitsBit> & operator () (int, int, int)
- FitsField<FitsBit> & operator () (int, int, int, int)
- FitsField<FitsBit> & operator () (int, int, int, int, int)
- int dims() const
- int dim(int n) const
- int *vdim()
Template Type Argument Requirements
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;
We must specify a FitsArray as a specialization.
Member Description
int dims() const
int dim(int n) const
Interface
- BinaryTableExtension(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- BinaryTableExtension(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- BinaryTableExtension( FITSErrorHandler errhandler = FITSError::defaultHandler)
- virtual ~BinaryTableExtension()
- Int nrows() const
- Int ncols() const
- uInt rowsize() const
- Int tfields() const
- char *tform(int n) const
- double tscal(int n) const
- double tzero(int n) const
- Bool isatnull(int n) const
- Int tnull(int n) const
- char *ttype(int n) const
- char *tunit(int n) const
- char *tdisp(int n) const
- char *tdim(int n) const
- char *ctype(int n) const
- double crpix(int n) const
- double crota(int n) const
- double crval(int n) const
- double cdelt(int n) const
- Int theap() const
- char *author() const
- char *referenc() const
- int bind(int, FitsBase &)
- BinaryTableExtension & operator ++ ()
- BinaryTableExtension & operator -- ()
- BinaryTableExtension & operator () (int)
- int read()
- int read(int)
- int set_next(int)
- int write(FitsOutput &)
- int write_binTbl_hdr(FitsOutput &, long, int, char**, char**, char**, char*, long )
- FitsBase &field(int i) const
- Int currrow() const
Protected Members
- BinaryTableExtension(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- BinaryTableExtension(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- BinaryTableExtension(FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
- virtual int readrow()
- virtual int writerow(FitsOutput &)
- void set_fitsrow(Int)
Private Members
- void bt_assign()
Member Description
BinaryTableExtension(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
BinaryTableExtension( FITSErrorHandler errhandler = FITSError::defaultHandler)
constructor to match write_bintbl_hdr()
Int nrows() const
Int ncols() const
uInt rowsize() const
Int tfields() const
char *tform(int n) const
double tscal(int n) const
double tzero(int n) const
Bool isatnull(int n) const
Int tnull(int n) const
char *ttype(int n) const
char *tunit(int n) const
char *tdisp(int n) const
char *tdim(int n) const
char *ctype(int n) const
double crpix(int n) const
double crota(int n) const
double crval(int n) const
double cdelt(int n) const
Int theap() const
char *author() const
char *referenc() const
return basic elements of a table
binds a FitsField to a column
BinaryTableExtension & operator ++ ()
BinaryTableExtension & operator -- ()
BinaryTableExtension & operator () (int)
row selector functions
read entire table into memory
int read(int)
read next N rows into memory
prepare to write the next N rows
write current rows
int write_binTbl_hdr(FitsOutput &, long, int, char**, char**, char**, char*, long )
create a binary table header without using FitsKeywordList objet.
select a field
get current row
BinaryTableExtension(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
BinaryTableExtension(FITS::HDUType, FITSErrorHandler errhandler = FITSError::defaultHandler)
read and write the next FITS data row
tells whether optimum case exists or not
sets field addresses in the current row
Interface
Public Members
- AsciiTableExtension(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- AsciiTableExtension(FitsKeywordList &, FITSErrorHandler errhandler = FITSError::defaultHandler)
- AsciiTableExtension(FITSErrorHandler errhandler = FITSError::defaultHandler)
- ~AsciiTableExtension()
- Int tbcol(int n)
- char *tnull(int n)
- int write_ascTbl_hdr( FitsOutput &, long, long, int, char **, long *, char **, char **, char *e)
Protected Members
- int readrow()
- int writerow(FitsOutput &)
Private Members
- void at_assign()
Member Description
AsciiTableExtension(FitsInput &, FITSErrorHandler errhandler = FITSError::defaultHandler)
AsciiTableExtension(FITSErrorHandler errhandler = FITSError::defaultHandler)
Int tbcol(int n)
position in which column starts
char *tnull(int n)
ascii string that represents the NULL value
int write_ascTbl_hdr( FitsOutput &, long, long, int, char **, long *, char **, char **, char *e)
write the required keywords for ASCIITableExtension
converted formats of the fields
read and write the next FITS data row