casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
casacore::PrimaryArray< TYPE > Class Template Reference

templated primary array base class of given type More...

#include <hdu.h>

Inheritance diagram for casacore::PrimaryArray< TYPE >:
casacore::HeaderDataUnit casacore::ImageExtension< TYPE > casacore::PrimaryGroup< TYPE > casacore::PrimaryTable< TYPE >

Public Types

typedef TYPE ElementType
 
- Public Types inherited from casacore::HeaderDataUnit
enum  HDUErrs {
  OK,
  NOMEM,
  MISSKEY,
  BADBITPIX,
  NOAXISN,
  NOPCOUNT,
  NOGCOUNT,
  BADPCOUNT,
  BADGCOUNT,
  NOGROUPS,
  BADNAXIS,
  BADREC,
  BADTYPE,
  BADRULES,
  BADSIZE,
  BADOPER,
  BADCONV,
  BADIO
}
 error handling and error codes that can be returned More...
 

Public Member Functions

 PrimaryArray (FitsInput &, FITSErrorHandler=FITSError::defaultHandler)
 constructor from a FitsInput More...
 
 PrimaryArray (FitsKeywordList &, FITSErrorHandler=FITSError::defaultHandler)
 constructor from a FitsKeywordList More...
 
 PrimaryArray (FITSErrorHandler=FITSError::defaultHandler)
 constructor does not require a FitsKeywordList. More...
 
virtual ~PrimaryArray ()
 destructor More...
 
double bscale () const
 General access routines for a primary array. More...
 
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
 
double operator() (int, int, int, int, int) const
 The overloaded operator functions `()' all return physical data, i. More...
 
double operator() (int, int, int, int) const
 
double operator() (int, int, int) const
 
double operator() (int, int) const
 
double operator() (int) const
 
TYPE & data (int, int, int, int, int)
 The various `data()' functions allow one to access and set the raw data itself. More...
 
TYPE & data (int, int, int, int)
 
TYPE & data (int, int, int)
 
TYPE & data (int, int)
 
TYPE & data (int)
 
int store (const TYPE *source, FITS::FitsArrayOption=FITS::NoOpt)
 The `store()', `move()' and `copy()' functions allow bulk data transfer between the internal FITS array and an external data storage area. More...
 
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
 
int store (const TYPE *source, int npixels)
 Use these versions if you are reading/writing "chunk by chunk. More...
 
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 ()
 The `read()' and `write()' functions control reading and writing data from the external FITS I/O medium into the FITS array. More...
 
virtual int read (int)
 
virtual int write (FitsOutput &)
 
virtual OFF_T set_next (OFF_T)
 
- Public Member Functions inherited from casacore::HeaderDataUnit
virtual ~HeaderDataUnit ()
 
Int dims () const
 
Int dim (int n) const
 
OFF_T fitsdatasize () const
 
FITS::ValueType datatype () const
 
Int fitsitemsize () const
 
Int localitemsize () const
 
FITS::HDUType hdutype () const
 
int err () const
 
int skip (uInt n)
 skipping one or more HDU's More...
 
int skip ()
 
int write_hdr (FitsOutput &)
 write the current header More...
 
ConstFitsKeywordListkwlist ()
 Operations on the HDU's keyword list. More...
 
Vector< Stringkwlist_str (Bool length80=False)
 return the header of the chdu as a vector of String. More...
 
void firstkw ()
 
void lastkw ()
 
const FitsKeywordnextkw ()
 
const FitsKeywordprevkw ()
 
const FitsKeywordcurrkw ()
 
const FitsKeywordkw (int n)
 
const FitsKeywordkw (const FITS::ReservedName &n)
 
const FitsKeywordnextkw (FITS::ReservedName &n)
 
const FitsKeywordkw (FITS::ReservedName &n, int i)
 
const FitsKeywordnextkw (FITS::ReservedName &n, int i)
 
const FitsKeywordkw (const char *n)
 
const FitsKeywordnextkw (const char *n)
 
void mk (FITS::ReservedName k, Bool v, const char *c=0)
 
void mk (FITS::ReservedName k, const char *v=0, const char *c=0)
 
void mk (FITS::ReservedName k, Int v, const char *c=0)
 
void mk (FITS::ReservedName k, double v, const char *c=0)
 
void mk (int n, FITS::ReservedName k, Bool v, const char *c=0)
 
void mk (int n, FITS::ReservedName k, const char *v, const char *c=0)
 
void mk (int n, FITS::ReservedName k, Int v, const char *c=0)
 
void mk (int n, FITS::ReservedName k, double v, const char *c=0)
 
void mk (const char *n, Bool v, const char *c=0)
 
void mk (const char *n, const char *v=0, const char *c=0)
 
void mk (const char *n, Int v, const char *c=0)
 
void mk (const char *n, float v, const char *c=0)
 
void mk (const char *n, double v, const char *c=0)
 
void mk (const char *n, Int r, Int i, const char *c=0)
 
void mk (const char *n, float r, float i, const char *c=0)
 
void mk (const char *n, double r, double i, const char *c=0)
 
void spaces (const char *n=0, const char *c=0)
 
void comment (const char *n=0, const char *c=0)
 
void history (const char *c=0)
 
Bool notnull (double x) const
 
Bool notnull (char *s) const
 
Bool notnull (Int l) const
 
int get_hdr (FITS::HDUType, FitsKeywordList &)
 
int read_data (char *, Int)
 
int write_data (FitsOutput &, char *, Int)
 
OFF_T read_all_data (char *)
 
int write_all_data (FitsOutput &, char *)
 

Protected Member Functions

 PrimaryArray (FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
 construct from a FitsInput with given HDU type More...
 
 PrimaryArray (FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
 construct from a FitsKeywordList with given HDU type More...
 
 PrimaryArray (FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
 construct witout FitsKeywordList for given HDU type(for ImageExtension and PrimaryGroup) More...
 
int offset (int, int) const
 compute a linear offset from array indicies More...
 
int offset (int, int, int) const
 
int offset (int, int, int, int) const
 
int offset (int, int, int, int, int) const
 
void pa_assign ()
 
- Protected Member Functions inherited from casacore::HeaderDataUnit
 HeaderDataUnit (FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
 For input – ~ should delete the keyword list: kwflag = 1. More...
 
 HeaderDataUnit (FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler, FitsInput *=0)
 For output – ~ should not delete keyword list: kwflag = 0 07/21/98 AKH Clarification: HeaderDataUnit has a copy of the FitsKeywordList, and should delete it. More...
 
 HeaderDataUnit (FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler, FitsInput *=0)
 constructor for objects that write only required keyword to fits file. More...
 
bool init_data_unit (FITS::HDUType t)
 for write required keywords only to use. More...
 
void posEnd ()
 
void errmsg (HDUErrs, const char *)
 
char * assign (FITS::ReservedName)
 
char * assign (FITS::ReservedName, int)
 
double asgdbl (FITS::ReservedName, double)
 
double asgdbl (FITS::ReservedName, int, double)
 

Protected Attributes

double bscale_x
 
double bzero_x
 
char * bunit_x
 
Bool isablank_x
 
Int blank_x
 
char ** ctype_x
 
double * crpix_x
 
double * crota_x
 
double * crval_x
 
double * cdelt_x
 
double datamax_x
 
double datamin_x
 
OFF_T totsize
 
int * factor
 
OFF_T alloc_elems
 
OFF_T beg_elem
 
OFF_T end_elem
 
TYPE * array
 the allocated array More...
 
- Protected Attributes inherited from casacore::HeaderDataUnit
FitsKeywordListkwlist_
 
ConstFitsKeywordList constkwlist_
 
FitsInputfin
 
FITSErrorHandler errfn
 
HDUErrs err_status
 
Int no_dims
 
Intdimn
 
OFF_T fits_data_size
 uInt fits_data_size; // size in bytes of total amount of data More...
 
FITS::ValueType data_type
 
Int fits_item_size
 
Int local_item_size
 
FITS::HDUType hdu_type
 
char pad_char
 
double double_null
 
char char_null
 
Int Int_null
 

Additional Inherited Members

- Static Public Member Functions inherited from casacore::HeaderDataUnit
static Bool determine_type (FitsKeywordList &, FITS::HDUType &, FITS::ValueType &, FITSErrorHandler, HDUErrs &)
 Determines the HDU type and the data type Parameterss: keyword list, hdu type, data type, error handler and error status. More...
 
static Bool compute_size (FitsKeywordList &, OFF_T &, Int &, FITS::HDUType &, FITS::ValueType &, FITSErrorHandler, HDUErrs &)
 Compute the total size of the data associated with an HDU. More...
 

Detailed Description

template<class TYPE>
class casacore::PrimaryArray< TYPE >

templated primary array base class of given type

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:

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);
}

Definition at line 340 of file hdu.h.

Member Typedef Documentation

template<class TYPE>
typedef TYPE casacore::PrimaryArray< TYPE >::ElementType

Definition at line 342 of file hdu.h.

Constructor & Destructor Documentation

constructor from a FitsInput

constructor from a FitsKeywordList

constructor does not require a FitsKeywordList.

call write_priArr_hdr() after construction.

template<class TYPE>
virtual casacore::PrimaryArray< TYPE >::~PrimaryArray ( )
virtual

destructor

template<class TYPE>
casacore::PrimaryArray< TYPE >::PrimaryArray ( FitsInput ,
FITS::HDUType  ,
FITSErrorHandler  errhandler = FITSError::defaultHandler 
)
protected

construct from a FitsInput with given HDU type

template<class TYPE>
casacore::PrimaryArray< TYPE >::PrimaryArray ( FitsKeywordList ,
FITS::HDUType  ,
FITSErrorHandler  errhandler = FITSError::defaultHandler 
)
protected

construct from a FitsKeywordList with given HDU type

template<class TYPE>
casacore::PrimaryArray< TYPE >::PrimaryArray ( FITS::HDUType  ,
FITSErrorHandler  errhandler = FITSError::defaultHandler 
)
protected

construct witout FitsKeywordList for given HDU type(for ImageExtension and PrimaryGroup)

Member Function Documentation

template<class TYPE>
Int casacore::PrimaryArray< TYPE >::blank ( ) const
inline

Definition at line 361 of file hdu.h.

template<class TYPE>
double casacore::PrimaryArray< TYPE >::bscale ( ) const
inline

General access routines for a primary array.

Definition at line 357 of file hdu.h.

template<class TYPE>
char* casacore::PrimaryArray< TYPE >::bunit ( ) const
inline

Definition at line 359 of file hdu.h.

template<class TYPE>
double casacore::PrimaryArray< TYPE >::bzero ( ) const
inline

Definition at line 358 of file hdu.h.

template<class TYPE>
double casacore::PrimaryArray< TYPE >::cdelt ( int  n) const
inline
template<class TYPE>
void casacore::PrimaryArray< TYPE >::copy ( double *  target,
FITS::FitsArrayOption  = FITS::NoOpt 
) const
template<class TYPE>
void casacore::PrimaryArray< TYPE >::copy ( float *  target,
FITS::FitsArrayOption  = FITS::NoOpt 
) const
template<class TYPE>
void casacore::PrimaryArray< TYPE >::copy ( double *  target,
int  npixels 
) const
template<class TYPE>
void casacore::PrimaryArray< TYPE >::copy ( float *  target,
int  npixels 
) const
template<class TYPE>
double casacore::PrimaryArray< TYPE >::crota ( int  n) const
inline

Definition at line 364 of file hdu.h.

template<class TYPE>
double casacore::PrimaryArray< TYPE >::crpix ( int  n) const
inline
template<class TYPE>
double casacore::PrimaryArray< TYPE >::crval ( int  n) const
inline
template<class TYPE>
char* casacore::PrimaryArray< TYPE >::ctype ( int  n) const
inline
template<class TYPE>
TYPE& casacore::PrimaryArray< TYPE >::data ( int  ,
int  ,
int  ,
int  ,
int   
)

The various `data()' functions allow one to access and set the raw data itself.

template<class TYPE>
TYPE& casacore::PrimaryArray< TYPE >::data ( int  ,
int  ,
int  ,
int   
)
template<class TYPE>
TYPE& casacore::PrimaryArray< TYPE >::data ( int  ,
int  ,
int   
)
template<class TYPE>
TYPE& casacore::PrimaryArray< TYPE >::data ( int  ,
int   
)
template<class TYPE>
TYPE& casacore::PrimaryArray< TYPE >::data ( int  )
template<class TYPE>
double casacore::PrimaryArray< TYPE >::datamax ( ) const
inline

Definition at line 367 of file hdu.h.

template<class TYPE>
double casacore::PrimaryArray< TYPE >::datamin ( ) const
inline

Definition at line 368 of file hdu.h.

template<class TYPE>
Bool casacore::PrimaryArray< TYPE >::isablank ( ) const
inline

Definition at line 360 of file hdu.h.

template<class TYPE>
void casacore::PrimaryArray< TYPE >::move ( TYPE *  target,
FITS::FitsArrayOption  = FITS::NoOpt 
) const
template<class TYPE>
void casacore::PrimaryArray< TYPE >::move ( TYPE *  target,
int  npixels 
) const
template<class TYPE>
OFF_T casacore::PrimaryArray< TYPE >::nelements ( ) const
inline

Definition at line 369 of file hdu.h.

template<class TYPE>
int casacore::PrimaryArray< TYPE >::offset ( int  ,
int   
) const
protected

compute a linear offset from array indicies

template<class TYPE>
int casacore::PrimaryArray< TYPE >::offset ( int  ,
int  ,
int   
) const
protected
template<class TYPE>
int casacore::PrimaryArray< TYPE >::offset ( int  ,
int  ,
int  ,
int   
) const
protected
template<class TYPE>
int casacore::PrimaryArray< TYPE >::offset ( int  ,
int  ,
int  ,
int  ,
int   
) const
protected
template<class TYPE>
double casacore::PrimaryArray< TYPE >::operator() ( int  ,
int  ,
int  ,
int  ,
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().
template<class TYPE>
double casacore::PrimaryArray< TYPE >::operator() ( int  ,
int  ,
int  ,
int   
) const
template<class TYPE>
double casacore::PrimaryArray< TYPE >::operator() ( int  ,
int  ,
int   
) const
template<class TYPE>
double casacore::PrimaryArray< TYPE >::operator() ( int  ,
int   
) const
template<class TYPE>
double casacore::PrimaryArray< TYPE >::operator() ( int  ) const
template<class TYPE>
void casacore::PrimaryArray< TYPE >::pa_assign ( )
protected
template<class TYPE>
virtual int casacore::PrimaryArray< TYPE >::read ( )
virtual

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.

Reimplemented in casacore::PrimaryTable< TYPE >, casacore::PrimaryTable< FitsLong >, casacore::PrimaryTable< Float >, casacore::PrimaryTable< uChar >, casacore::PrimaryTable< Short >, casacore::PrimaryGroup< TYPE >, casacore::PrimaryGroup< FitsLong >, casacore::PrimaryGroup< Float >, and casacore::PrimaryGroup< Short >.

template<class TYPE>
virtual int casacore::PrimaryArray< TYPE >::read ( int  )
virtual
template<class TYPE>
virtual OFF_T casacore::PrimaryArray< TYPE >::set_next ( OFF_T  )
virtual
template<class TYPE>
int casacore::PrimaryArray< TYPE >::store ( const TYPE *  source,
FITS::FitsArrayOption  = FITS::NoOpt 
)

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.

template<class TYPE>
int casacore::PrimaryArray< TYPE >::store ( const TYPE *  source,
int  npixels 
)

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.

template<class TYPE>
virtual int casacore::PrimaryArray< TYPE >::write ( FitsOutput )
virtual
template<class TYPE>
int casacore::PrimaryArray< TYPE >::write_priArr_hdr ( FitsOutput fout,
int  simple,
int  bitpix,
int  naxis,
long  naxes[],
int  extend 
)

Member Data Documentation

template<class TYPE>
OFF_T casacore::PrimaryArray< TYPE >::alloc_elems
protected

Definition at line 489 of file hdu.h.

template<class TYPE>
TYPE* casacore::PrimaryArray< TYPE >::array
protected

the allocated array

Definition at line 493 of file hdu.h.

template<class TYPE>
OFF_T casacore::PrimaryArray< TYPE >::beg_elem
protected

Definition at line 490 of file hdu.h.

template<class TYPE>
Int casacore::PrimaryArray< TYPE >::blank_x
protected

Definition at line 470 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::blank().

template<class TYPE>
double casacore::PrimaryArray< TYPE >::bscale_x
protected

Definition at line 466 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::bscale().

template<class TYPE>
char* casacore::PrimaryArray< TYPE >::bunit_x
protected

Definition at line 468 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::bunit().

template<class TYPE>
double casacore::PrimaryArray< TYPE >::bzero_x
protected

Definition at line 467 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::bzero().

template<class TYPE>
double* casacore::PrimaryArray< TYPE >::cdelt_x
protected

Definition at line 475 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::cdelt().

template<class TYPE>
double* casacore::PrimaryArray< TYPE >::crota_x
protected

Definition at line 473 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::crota().

template<class TYPE>
double* casacore::PrimaryArray< TYPE >::crpix_x
protected

Definition at line 472 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::crpix().

template<class TYPE>
double* casacore::PrimaryArray< TYPE >::crval_x
protected

Definition at line 474 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::crval().

template<class TYPE>
char** casacore::PrimaryArray< TYPE >::ctype_x
protected

Definition at line 471 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::ctype().

template<class TYPE>
double casacore::PrimaryArray< TYPE >::datamax_x
protected

Definition at line 476 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::datamax().

template<class TYPE>
double casacore::PrimaryArray< TYPE >::datamin_x
protected

Definition at line 477 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::datamin().

template<class TYPE>
OFF_T casacore::PrimaryArray< TYPE >::end_elem
protected

Definition at line 491 of file hdu.h.

template<class TYPE>
int* casacore::PrimaryArray< TYPE >::factor
protected

Definition at line 480 of file hdu.h.

template<class TYPE>
Bool casacore::PrimaryArray< TYPE >::isablank_x
protected

Definition at line 469 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::isablank().

template<class TYPE>
OFF_T casacore::PrimaryArray< TYPE >::totsize
protected

Definition at line 478 of file hdu.h.

Referenced by casacore::PrimaryArray< Short >::nelements().


The documentation for this class was generated from the following file: