casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hdu.h
Go to the documentation of this file.
1 //# hdu.h:
2 //# Copyright (C) 1993,1994,1995,1996,1997,1999,2000,2002,2003
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_HDU_H
29 #define FITS_HDU_H
30 
31 # include <casacore/casa/aips.h>
32 # include <casacore/fits/FITS/fits.h>
36 
37 //# # include <stdarg.h> // If we ever wan to put varargs support back
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 class FitsInput;
42 class FitsOutput;
43 
44 //<summary> base class that defines a HDU </summary>
45 //<synopsis>
46 // The class HeaderDataUnit contains what is common to all
47 // header-data-units, including the collection of keywords.
48 // From this class a number of FITS header-data-units are
49 // derived, each of them with their own rich assortment of
50 // functions for accessing and manipulating data of specific types.
51 //
52 // The following inheritence hierarchy illustrates the current
53 // derived classes:
54 //<srcblock>
55 //
56 // HeaderDataUnit
57 // / |
58 // / |
59 // PrimaryArray ExtensionHeaderDataUnit
60 // / | \ |
61 // / | \ |
62 // PrimaryGroup | ImageExtension |
63 // | |
64 // PrimaryTable BinaryTableExtension
65 // /
66 // /
67 // AsciiTableExtension
68 //</srcblock>
69 //</synopsis>
70 
72  friend std::ostream & operator << (std::ostream &, HeaderDataUnit &);
73  public:
74  virtual ~HeaderDataUnit();
75 
76  Int dims() const { return no_dims; }
77  Int dim(int n) const { return (0<no_dims && n<no_dims ? dimn[n] : 0); }
78  OFF_T fitsdatasize() const { return fits_data_size; }
79  FITS::ValueType datatype() const { return data_type; }
80  Int fitsitemsize() const { return fits_item_size; }
81  Int localitemsize() const { return local_item_size; }
82  FITS::HDUType hdutype() const { return hdu_type; }
83 
84  // error handling and error codes that can be returned
85  //<group>
90  int err() const { return err_status; }
91  //</group>
92 
93  // skipping one or more HDU's
94  //<group>
95  int skip(uInt n);
96  int skip();
97  //</group>
98 
99  // write the current header
100  int write_hdr(FitsOutput &);
101 
102  // Determines the HDU type and the data type
103  // Parameterss: keyword list, hdu type, data type, error handler and
104  // error status.
105  // Returns False if a serious error was detected, otherwise True
108 
109 
110  // Compute the total size of the data associated with an HDU.
111  // The number of dimensions is also determined. This routine
112  // assumes that hdu type has been appropriately set, but it may
113  // be changed in the process. Data type is also determined.
114  // Returns False if a serious error was detected, otherwise True
115  static Bool compute_size(FitsKeywordList &, OFF_T &, Int &,
117 
118  // Operations on the HDU's keyword list
119  //<group>
121  // return the header of the chdu as a vector of String. You can
122  // force the strings to be length 80 (padded with spaces)
124  void firstkw() { kwlist_.first(); }
125  void lastkw() { kwlist_.last(); }
126  const FitsKeyword *nextkw() { return kwlist_.next(); }
127  const FitsKeyword *prevkw() { return kwlist_.prev(); }
128  const FitsKeyword *currkw() { return kwlist_.curr(); }
129  const FitsKeyword *kw(int n) { return kwlist_(n); }
130  //# 07/21/98 AKH Added const to quite Apogee warnings:
131  const FitsKeyword *kw(const FITS::ReservedName &n) {
132  return kwlist_(n); }
134  return kwlist_.next(n); }
135  const FitsKeyword *kw(FITS::ReservedName &n, int i) {
136  return kwlist_(n,i); }
137  const FitsKeyword *nextkw(FITS::ReservedName &n, int i) {
138  return kwlist_.next(n,i); }
139  const FitsKeyword *kw(const char *n) { return kwlist_(n); }
140  const FitsKeyword *nextkw(const char *n) { return kwlist_.next(n); }
141  void mk(FITS::ReservedName k, Bool v, const char *c = 0);
142  void mk(FITS::ReservedName k, const char *v = 0, const char *c = 0);
143  void mk(FITS::ReservedName k, Int v, const char *c = 0);
144  void mk(FITS::ReservedName k, double v, const char *c = 0);
145  void mk(int n, FITS::ReservedName k, Bool v, const char *c = 0);
146  void mk(int n, FITS::ReservedName k, const char *v, const char *c = 0);
147  void mk(int n, FITS::ReservedName k, Int v, const char *c = 0);
148  void mk(int n, FITS::ReservedName k, double v, const char *c = 0);
149  void mk(const char *n, Bool v, const char *c = 0);
150  void mk(const char *n, const char *v = 0, const char *c = 0);
151  void mk(const char *n, Int v, const char *c = 0);
152  void mk(const char *n, float v, const char *c = 0);
153  void mk(const char *n, double v, const char *c = 0);
154  void mk(const char *n, Int r, Int i, const char *c = 0);
155  void mk(const char *n, float r, float i, const char *c = 0);
156  void mk(const char *n, double r, double i, const char *c = 0);
157  void spaces(const char *n = 0, const char *c = 0);
158  void comment(const char *n = 0, const char *c = 0);
159  void history(const char *c = 0);
160  //</group>
161 
162  Bool notnull(double x) const { return double_null < x ? True : False; }
163  Bool notnull(char *s) const { return ! s ? False : (s[0] != '\0' ? True : False); }
164  Bool notnull(Int l) const { return Int_null < l ? True : False; }
165 
166  protected:
167  // For input -- ~ should delete the keyword list: kwflag = 1
170  // For output -- ~ should not delete keyword list: kwflag = 0
171  // 07/21/98 AKH Clarification: HeaderDataUnit has a copy of the
172  // FitsKeywordList, and should delete it. The kwflag
173  // comments above are not important now.
176  FitsInput * = 0);
177  // constructor for objects that write only required keyword to fits file.
178  // the write method to call by these object should be those for the specific
179  // hdu, such as write_bintbl_hdr().
182  FitsInput * = 0);
183  // for write required keywords only to use.
184  bool init_data_unit( FITS::HDUType t );
185 
188  void posEnd();
189 
193  void errmsg(HDUErrs, const char *);
194 
195  Int no_dims; // number of dimensions
196  Int *dimn; // size of dimension N
197  //uInt fits_data_size; // size in bytes of total amount of data
198  OFF_T fits_data_size; // size in bytes of total amount of data
199  FITS::ValueType data_type; // type of data - derived from BITPIX
200  Int fits_item_size; // size in bytes of an item of FITS data
201  Int local_item_size; // size in bytes of an item of local data
202  FITS::HDUType hdu_type; // type of header/data unit
203  char pad_char; // char to pad FITS data block
204 
205  //<group>
206  char * assign(FITS::ReservedName);
207  char * assign(FITS::ReservedName, int);
208  double asgdbl(FITS::ReservedName, double);
209  double asgdbl(FITS::ReservedName, int, double);
210  //</group>
211  double double_null;
212  char char_null;
214 
215  public:
217  int read_data(char *, Int);
218  int write_data(FitsOutput &, char *, Int);
219  OFF_T read_all_data(char *);
220  int write_all_data(FitsOutput &, char *);
221 };
222 
223 inline std::ostream & operator << (std::ostream &o, HeaderDataUnit &h) {
224  return o << h.kwlist_; }
225 inline void HeaderDataUnit::mk(FITS::ReservedName k, Bool v, const char *c) {
226  posEnd(); kwlist_.mk(k,v,c); }
227 inline void HeaderDataUnit::mk(FITS::ReservedName k, const char *v,
228  const char *c) { posEnd(); kwlist_.mk(k,v,c); }
229 inline void HeaderDataUnit::mk(FITS::ReservedName k, Int v, const char *c) {
230  posEnd(); kwlist_.mk(k,v,c); }
231 inline void HeaderDataUnit::mk(FITS::ReservedName k, double v, const char *c) {
232  posEnd(); kwlist_.mk(k,v,c); }
233 inline void HeaderDataUnit::mk(int n, FITS::ReservedName k, Bool v,
234  const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
235 inline void HeaderDataUnit::mk(int n, FITS::ReservedName k, const char *v,
236  const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
237 inline void HeaderDataUnit::mk(int n, FITS::ReservedName k, Int v,
238  const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
239 inline void HeaderDataUnit::mk(int n, FITS::ReservedName k, double v,
240  const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
241 inline void HeaderDataUnit::mk(const char *n, Bool v, const char *c) {
242  posEnd(); kwlist_.mk(n,v,c); }
243 inline void HeaderDataUnit::mk(const char *n, const char *v, const char *c) {
244  posEnd(); kwlist_.mk(n,v,c); }
245 inline void HeaderDataUnit::mk(const char *n, Int v, const char *c) {
246  posEnd(); kwlist_.mk(n,v,c); }
247 inline void HeaderDataUnit::mk(const char *n, float v, const char *c) {
248  posEnd(); kwlist_.mk(n,v,c); }
249 inline void HeaderDataUnit::mk(const char *n, double v, const char *c) {
250  posEnd(); kwlist_.mk(n,v,c); }
251 inline void HeaderDataUnit::mk(const char *n, Int r, Int i, const char *c) {
252  posEnd(); kwlist_.mk(n,r,i,c); }
253 inline void HeaderDataUnit::mk(const char *n, float r, float i, const char *c) {
254  posEnd(); kwlist_.mk(n,r,i,c); }
255 inline void HeaderDataUnit::mk(const char *n, double r, double i,
256  const char *c) { posEnd(); kwlist_.mk(n,r,i,c); }
257 inline void HeaderDataUnit::spaces(const char *n, const char *c) {
258  posEnd(); kwlist_.spaces(n,c); }
259 inline void HeaderDataUnit::comment(const char *n, const char *c) {
260  posEnd(); kwlist_.comment(n,c); }
261 inline void HeaderDataUnit::history(const char *c) {
262  posEnd(); kwlist_.history(c); }
263 
264 //<summary> templated primary array base class of given type </summary>
265 //<synopsis>
266 // A Primary Data Array is represented by the following:
267 //<srcblock>
268 // <Type> data_array [NAXIS1][NAXIS2]...[NAXISN]
269 //</srcblock>
270 //
271 // For a PrimaryArray, dims() gives the number of dimensions
272 // and dim(i) gives the value of the i-th dimension
273 //
274 // WARNING! Multi-dimensional arrays are stored in FORTRAN order,
275 // NOT in C order. Options on the store, copy, and move functions exist
276 // to convert from one order to the other, if that is necessary.
277 //
278 //
279 // It is important to understand the proper sequence of operations with
280 // respect to I/O and data access. For input, the `read()' functions
281 // allocate an internal buffer of the appropriate size, if not already
282 // allocated, as well as reading and converting data; a `read()' function
283 // must be performed prior to accessing the data, i. e. before executing
284 // any `()', `data()', `copy()', or `move()' function. For output, the
285 // `store()' function similarly allocates an internal buffer before
286 // transfering data, and must be executed prior to any data access or
287 // `write()' function. Note: If you call any version of store(), do not
288 // call set_next().
289 //
290 // Writing portions of an array at a time, rather than the entire array,
291 // is a special case. The `set_next()' function is provided for this
292 // purpose. It declares the intention to write out the next N elements and
293 // must be executed prior to any `data()' function. It allocates a buffer
294 // of appropriate size, if not already allocated. Again, via the `data()'
295 // functions, one accesses the array as if the entire array were in
296 // memory. The `write()' function always writes the number of current
297 // elements in the internal buffer. The sequence of operations for each
298 // portion of the array written would be:
299 // <ul>
300 // <li> `set_next(N)',
301 // <li> fill the array using `data(N)' or other `data()' functions
302 // <li> `write(fout)'.
303 // </ul>
304 // The `set_next()' function must NOT be used with
305 // `read()' or `store()' functions; unpredictable results will occur.
306 //<example>
307 // The following example illustrates the output cases.
308 //
309 // Suppose we have an image array with 512 rows and 1024 columns
310 // stored in C-order. The C declaration would be:
311 //<srcblock>
312 // int source[1024][512];
313 //</srcblock>
314 // To write out the entire array:
315 //<srcblock>
316 // FitsOutput fout; // some properly constructed FitsOutput
317 // PrimaryArray<FitsLong> pa; // some properly constructed PrimaryArray
318 // pa.store(source,CtoF);
319 // pa.write(fout);
320 //</srcblock>
321 //
322 // Suppose we wanted to write out the two-dimensional image array a column
323 // at a time, rather than write out the entire array. For FITS, dim(0)
324 // is 512, dim(1) is 1024. The following code fragment writes one column
325 // at a time in the proper FITS Fortran-order.
326 //
327 //<srcblock>
328 // for (i = 0; i < dim(1); ++i) {
329 // pa.set_next(dim(0));
330 // for (j = 0; j < dim(0); ++j)
331 // data(j,i) = source[i][j];
332 // pa.write(fout);
333 // }
334 //</srcblock>
335 //</example>
336 //
337 //</synopsis>
338 
339 template <class TYPE>
340 class PrimaryArray : public HeaderDataUnit {
341  public:
342  typedef TYPE ElementType;
343 
344  // constructor from a FitsInput
346  // constructor from a FitsKeywordList
349  // constructor does not require a FitsKeywordList. call write_priArr_hdr() after construction.
351 
352  // destructor
353  virtual ~PrimaryArray();
354 
355  // General access routines for a primary array
356  //<group>
357  double bscale() const { return bscale_x; }
358  double bzero() const { return bzero_x; }
359  char *bunit() const { return bunit_x; }
360  Bool isablank() const { return isablank_x; }
361  Int blank() const { return blank_x; }
362  char *ctype(int n) const { return ctype_x[n]; }
363  double crpix(int n) const { return crpix_x[n]; }
364  double crota(int n) const { return crota_x[n]; }
365  double crval(int n) const { return crval_x[n]; }
366  double cdelt(int n) const { return cdelt_x[n]; }
367  double datamax() const { return datamax_x; }
368  double datamin() const { return datamin_x; }
369  OFF_T nelements() const { return totsize; }
370  //</group>
371 
372  // The overloaded operator functions `()' all return physical data, i. e.,
373  // data to which bscale() and bzero() have been applied, via the formula
374  //<srcblock>
375  // physical_data[i] = bscale() * raw_data[i] + bzero().
376  //</srcblock>
377  //<group>
378  double operator () (int, int, int, int, int) const;
379  double operator () (int, int, int, int) const;
380  double operator () (int, int, int) const;
381  double operator () (int, int) const;
382  double operator () (int) const;
383  //</group>
384 
385  // The various `data()' functions allow one to access and set the raw data
386  // itself.
387  //<group>
388  TYPE & data(int, int, int, int, int);
389  TYPE & data(int, int, int, int);
390  TYPE & data(int, int, int);
391  TYPE & data(int, int);
392  TYPE & data(int);
393  //</group>
394 
395  // The `store()', `move()' and `copy()' functions allow bulk data
396  // transfer between the internal FITS array and an external data
397  // storage area. The external storage must have already been allocated
398  // and it is assumed that the entire data array is in memory.
399  // `store()' transfers raw data at `source' into the FITS array; an
400  // allowable option is CtoF, which specifies to convert the array from
401  // C-order to Fortran-order. `move()' is the opposite of `store()'.
402  // `move()' transfers raw data from the FITS array to `target'; an
403  // allowable option is FtoC, which specifies to convert the array from
404  // Fortran-order to C-order. `copy()' is similar to `move()' except
405  // that what is copied is physical data and not raw data; the physical
406  // data can be either double or float. copy() also turns blanks into
407  // NaN's.
408  //<group>
409  int store(const TYPE *source, FITS::FitsArrayOption = FITS::NoOpt);
410  void copy(double *target, FITS::FitsArrayOption = FITS::NoOpt) const;
411  void copy(float *target, FITS::FitsArrayOption = FITS::NoOpt) const;
412  void move(TYPE *target, FITS::FitsArrayOption = FITS::NoOpt) const;
413  // <group>
414  // Use these versions if you are reading/writing "chunk by
415  // chunk." No FtoC option is available. You are responsible for
416  // ensuring that npixels corresponds to he number actually read or
417  // written. Note that copy() turns blanks into NaN's.
418  int store(const TYPE *source, int npixels);
419  void copy(double *target, int npixels) const;
420  void copy(float *target, int npixels) const;
421  void move(TYPE *target, int npixels) const;
422  // </group>
423  // </group>
424  //<group>
425  int write_priArr_hdr( FitsOutput &fout, int simple, int bitpix,
426  int naxis, long naxes[], int extend );
427  //</group>
428  // The `read()' and `write()' functions control reading and writing data
429  // from the external FITS I/O medium into the FITS array. Appropriate
430  // conversions are made between FITS and local data representations. One
431  // can read the entire array into memory, or one can only read portions of
432  // the array. In the latter case, one must specify that the next N
433  // elements are to be read or written. Note that the number of elements
434  // must be specified, NOT the number of bytes. If one reads portions of
435  // the array, as opposed to the entire array, only that portion is in
436  // memory at a given time. One can still access the elements of the array
437  // via the `()' and `data()' functions, as if the entire array was in
438  // memory; obviously care must be taken in this case to access only those
439  // portions that are actually in memory.
440  //<group>
441  virtual int read();
442  virtual int read( int );
443  virtual int write(FitsOutput &);
444  virtual OFF_T set_next(OFF_T);
445  //</group>
446  //### if these, even as interspersed comments, cxx2html repeats the global
447  //# group info..
448  //# read: read entire array into memory
449  //# read() read next N elements into memory
450  //# write; write current data
451  //# set_next(): prepare to write next N elements
452 
453  protected:
454  // construct from a FitsInput with given HDU type
457  // construct from a FitsKeywordList with given HDU type
460 
461  // construct witout FitsKeywordList for given HDU type( for ImageExtension and PrimaryGroup)
464 
465 
466  double bscale_x;
467  double bzero_x;
468  char *bunit_x;
471  char **ctype_x;
472  double *crpix_x;
473  double *crota_x;
474  double *crval_x;
475  double *cdelt_x;
476  double datamax_x;
477  double datamin_x;
478  OFF_T totsize;
479 
480  int *factor; // factors needed to compute array position offsets
481 
482  // compute a linear offset from array indicies
483  //<group>
484  int offset(int, int) const;
485  int offset(int, int, int) const;
486  int offset(int, int, int, int) const;
487  int offset(int, int, int, int, int) const;
488  //</group>
489  OFF_T alloc_elems; // current number of allocated elements
490  OFF_T beg_elem; // offset of first element in the buffer
491  OFF_T end_elem; // offset of last element in the buffer
492  // the allocated array
493  TYPE *array;
494 
495  void pa_assign();
496 };
497 
503 
504 
505 //<summary> IMAGE extension of given type </summary>
506 //<templating>
507 // <li> typedef ImageExtension<unsigned char> ByteImageExtension;
508 // <li> typedef ImageExtension<short> ShortImageExtension;
509 // <li> typedef ImageExtension<FitsLong> LongImageExtension;
510 // <li> typedef ImageExtension<float> FloatImageExtension;
511 // <li> typedef ImageExtension<double> DoubleImageExtension;
512 //</templating>
513 
514 template <class TYPE>
515 class ImageExtension : public PrimaryArray<TYPE> {
516  public:
517  typedef TYPE ElementType;
518 
523  // constructor for header consisted required keywords only
525 
526  ~ImageExtension();
527  char *xtension() { return xtension_x; }
528  char *extname() { return extname_x; }
529  Int extver() { return extver_x; }
530  Int extlevel() { return extlevel_x; }
531  Int pcount() { return pcount_x; }
532  Int gcount() { return gcount_x; }
533  // write required keywords for ImageExtension
534  int write_imgExt_hdr( FitsOutput &fout,
535  int bitpix, int naxis, long *naxes);
536  protected:
537  char *xtension_x;
538  char *extname_x;
543 
544  private:
545  void ie_assign();
546 
547  //# Make members in parent known
548  protected:
562 };
563 
569 
570 //<summary> Random Group datastructure </summary>
571 //<synopsis>
572 // A Random Group Structure is represented by the following:
573 //<srcblock>
574 // struct GroupData {
575 // <Type> group_parms [PCOUNT];
576 // <Type> data_array [NAXIS2][NAXIS3]...[NAXISN];
577 // } group_data[GCOUNT];
578 //</srcblock>
579 //</synopsis>
580 //<templating>
581 //#until cxx2html can handle this, duplicate
582 // <li>typedef PrimaryGroup<unsigned char> BytePrimaryGroup;
583 // <li> typedef PrimaryGroup<short> ShortPrimaryGroup;
584 // <li> typedef PrimaryGroup<FitsLong> LongPrimaryGroup;
585 // <li> typedef PrimaryGroup<float> FloatPrimaryGroup;
586 // <li> typedef PrimaryGroup<double> DoublePrimaryGroup;
587 //</templating>
588 //<note role=warning>
589 // Please note that the NOST has deprecated the Random Group
590 // datastructure, it has been replaced by the much more powerfull
591 // BINTABLE extension.
592 //</note>
593 template <class TYPE>
594 class PrimaryGroup : public PrimaryArray<TYPE> {
595  public:
600  // constructor for header consisted required keywords only
602 
603  ~PrimaryGroup();
604 
605  // Return basic parameters of a random group
606  //<group>
607  Int gcount() const { return gcount_x; }
608  Int pcount() const { return pcount_x; }
609  char *ptype(int n) const { return ptype_x[n]; }
610  double pscal(int n) const { return pscal_x[n]; }
611  double pzero(int n) const { return pzero_x[n]; }
612  //</group>
613 
614  Int currgroup() const { return current_group; }
615 
616  double parm(int); // return physical parms
617  TYPE & rawparm(int); // access raw parms
618 
619  void storeparm(const TYPE *source);
620  void copyparm(double *target) const;
621  void copyparm(float *target) const;
622  void moveparm(TYPE *target) const;
623 
624  // read, or write the next group
625  //<group>
626  int read();
627  int write(FitsOutput &);
628  //</group>
629  // write the required keywords for PrimaryGroup
630  //<group>
631  int write_priGrp_hdr( FitsOutput &fout, int simple, int bitpix,
632  int naxis, long naxes[], long pcount, long gcount );
633  //</group>
634 
635  // disable these functions, since they
636  // are inherited from PrimaryArray
637  //<group>
638  OFF_T set_next(OFF_T) { return 0; }
639  int read(int) { return -1; }
640  //</group>
641 
642  protected:
645  char **ptype_x;
646  double *pscal_x;
647  double *pzero_x;
648  TYPE *group_parm;
650 
651  private:
652  void pg_assign();
653 
654  //# Make members in parent known
655  protected:
688 };
689 
695 
696 //<summary> Primary Table structure </summary>
697 //<templating>
698 // <li> typedef PrimaryTable<unsigned char> BytePrimaryTable;
699 // <li> typedef PrimaryTable<short> ShortPrimaryTable;
700 // <li> typedef PrimaryTable<FitsLong> LongPrimaryTable;
701 // <li> typedef PrimaryTable<float> FloatPrimaryTable;
702 // <li> typedef PrimaryTable<double> DoublePrimaryTable;
703 //</templating>
704 
705 template <class TYPE>
706 class PrimaryTable : public PrimaryArray<TYPE> {
707  public:
708  typedef TYPE ElementType;
709 
714  // constructor for header consisted required keywords only
716 
717  ~PrimaryTable();
718  // write required keywords for PrimaryTable
719  int write_priTable_hdr( FitsOutput &fout,
720  int bitpix, int naxis, long *naxes);
721 
722  int read();
723  int read(int) { return -1; }
724  int write(FitsOutput &){ return -1; }
725 
726  char* object() const { return object_x; }
727  char* telescop() const { return telescop_x; }
728  char* instrume() const { return instrume_x; }
729  char* dateobs() const { return dateobs_x; }
730  char* datemap() const { return datemap_x; }
731  char* bunit() const { return bunit_x; }
732  float bscal() const { return bscale_x; }
733  float bzero() const { return bzero_x; }
734  float equinox() const { return equinox_x; }
735  float altrpix() const { return altrpix_x; }
736 
737  protected:
738  char* object_x; //OBJECT
739  char* telescop_x; //TELESCOP
740  char* instrume_x; //INSTRUME
741  char* dateobs_x; //DATE-OBS
742  char* datemap_x; //DATE-MAP
743  Float bscale_x; //BSCALE
744  Float bzero_x; //BZERO
745  char* bunit_x; //BUNIT
746  Float equinox_x; //EQUINOX
747  Float altrpix_x; //ALTRPIX
748 
749 
750  private:
751  void pt_assign();
752 
753  //# Make members in parent known
754  protected:
787 };
788 
794 
795 //<summary> base class for generalized exentensions HDU </summary>
796 
798  public:
804  char *xtension() { return xtension_x; }
805  char *extname() { return extname_x; }
806  Int extver() { return extver_x; }
807  Int extlevel() { return extlevel_x; }
808  Int pcount() { return pcount_x; }
809  Int gcount() { return gcount_x; }
810 
811  // read next N bytes into addr
812  int read(char *addr, int nbytes) {
813  return read_data(addr, Int(nbytes)); }
814  // write next N bytes from addr to the FITS output fout
815  int write(FitsOutput &fout, char *addr, int nbytes) {
816  return write_data(fout,addr,nbytes); }
817 
818  protected:
823  // This constructor is used for writing only required keywords.
826 
827  char *xtension_x;
828  char *extname_x;
833 
834  private:
835  void ex_assign();
836 };
837 
838 //<summary> helper class </summary>
839 
840 class FitsBase {
841  friend class BinaryTableExtension;
842  friend class AsciiTableExtension;
843  public:
844  FitsBase(const FITS::ValueType &t, int n) : no_elements(n),
845  data_type(t) { }
846  virtual ~FitsBase();
847 
848  unsigned int nelements() const { return (unsigned int)no_elements; }
849  virtual int fitsfieldsize() const = 0;
850  virtual int localfieldsize() const = 0;
851  virtual void *data() = 0;
852  virtual int dims() const;
853  virtual int dim(int n) const;
854  virtual int *vdim();
855  FITS::ValueType fieldtype() const { return data_type; }
856 
857  static FitsBase *make(const FITS::ValueType &, int = 1);
858  static FitsBase *make(const FITS::ValueType &, int, int *);
859  static FitsBase *make(FitsBase &);
860 
861  FitsBase & operator = (FitsBase &) = delete;
862  virtual void show(std::ostream &) = 0;
863 
864  protected:
865  int no_elements; // the number of elements in the field
867  virtual void setaddr(void **) = 0;
868 };
869 
870 inline std::ostream & operator << (std::ostream &o, FitsBase &x) {
871  x.show(o); return o;
872 }
873 
874 //<summary> helper class </summary>
875 //<note>
876 // Note that FitsField does not allocate space for the data.
877 // Space is external to FitsField and its address is set via the
878 // setaddr function.
879 //</note>
880 
881 template <class TYPE>
882 class FitsField : public FitsBase {
883  public:
884  FitsField(int n = 1) :
885  FitsBase(FITS::getfitstype(NoConvert<TYPE>()),n), field(0) { }
886  ~FitsField();
887 
888  TYPE & operator () () { return (*field)[0]; }
889  TYPE & operator () (int i) { return (*field)[i]; }
890  FitsField<TYPE> & operator = (const TYPE &x) {
891  (*field)[0] = x; return *this; }
892 
893  int fitsfieldsize() const;
894  int localfieldsize() const;
895 
896  void *data();
897 
898  void show(std::ostream &);
899 
900  protected:
901  TYPE **field;
902  void setaddr(void **addr);
903 };
904 
905 //<summary> helper class </summary>
906 //<templating>
907 //#until cxx2html can handle this, duplicate
908 // <li> typedef FitsField<FitsLogical> LogicalFitsField;
909 // <li> typedef FitsField<FitsBit> BitFitsField;
910 // <li> typedef FitsField<char> CharFitsField;
911 // <li> typedef FitsField<unsigned char> ByteFitsField;
912 // <li> typedef FitsField<short> ShortFitsField;
913 // <li> typedef FitsField<FitsLong> LongFitsField;
914 // <li> typedef FitsField<float> FloatFitsField;
915 // <li> typedef FitsField<double> DoubleFitsField;
916 // <li> typedef FitsField<Complex> ComplexFitsField;
917 // <li> typedef FitsField<IComplex> IComplexFitsField;
918 // <li> typedef FitsField<DComplex> DComplexFitsField;
919 // <li> typedef FitsField<FitsVADesc> VADescFitsField;
920 //</templating>
921 //<note role=caution>
922 // Bit fields require special treatment
923 //</note>
924 
925 template <> class FitsField<FitsBit> : public FitsBase {
926  public:
927  FitsField(int n = 1);
928  ~FitsField();
929 
930  FitsField<FitsBit> & operator () () { byte_offset = 0; mask = 0200;
931  return *this; }
932 
934  byte_offset = i / 8; mask = 0200 >> (i % 8); return *this; }
935 
937  (*field)[byte_offset] =
938  (i == 0 ? ((*field)[byte_offset] & ~mask) :
939  ((*field)[byte_offset] | mask)); return *this; }
940 
941  int fitsfieldsize() const;
942  int localfieldsize() const;
943 
944  operator int() { return (((*field)[byte_offset] & mask) != 0); }
945 
946  void *data();
947 
948  void show(std::ostream &);
949 
950  protected:
952  unsigned char mask;
954  void setaddr(void **addr);
955 };
956 
969 
970 //<summary> FITS array of given type </summary>
971 template <class TYPE>
972 class FitsArray : public FitsField<TYPE> {
973  public:
974  FitsArray(int, const int *);
975  ~FitsArray();
976  TYPE & operator () (int d0, int d1);
977  TYPE & operator () (int, int, int);
978  TYPE & operator () (int, int, int, int);
979  TYPE & operator () (int, int, int, int, int);
980  int dims() const;
981  int dim(int n) const;
982  int *vdim();
983  protected:
984  int no_dims;
985  int *dimn;
986  int *factor;
988  //# Make members in parent known
989  protected:
992 };
993 
994 //<summary> FITS array of FitsBit type </summary>
995 
996 //<note>
997 // We must specify a FitsArray<FitsBit> as a specialization.
998 //</note>
999 
1000 template <> class FitsArray<FitsBit> : public FitsField<FitsBit> {
1001  public:
1002  FitsArray(int, const int *);
1003  ~FitsArray();
1004  FitsField<FitsBit> & operator () (int d0, int d1);
1005  FitsField<FitsBit> & operator () (int, int, int);
1006  FitsField<FitsBit> & operator () (int, int, int, int);
1007  FitsField<FitsBit> & operator () (int, int, int, int, int);
1008 //# Disabled for now - we might eventually want to put varargs support back
1009 //# FitsField<FitsBit> & operator () (int, int, int, int, int, int ...);
1010 
1011  int dims() const;
1012  int dim(int n) const;
1013  int *vdim();
1014  protected:
1015  int no_dims;
1016  int *dimn;
1017  int *factor;
1018 };
1019 
1032 
1033 //<summary> BINTABLE extension </summary>
1034 
1036  public:
1039 
1042  // constructor to match write_bintbl_hdr()
1044 
1045  virtual ~BinaryTableExtension();
1046 
1047  // return basic elements of a table
1048  //<group>
1049  Int nrows() const { return dim(1); }
1050  Int ncols() const { return tfields_x; }
1051  uInt rowsize() const { return fitsrowsize; }
1052  Int tfields() const { return tfields_x; }
1053  const char *tform(int n) const { return tform_x[n]; }
1054  double tscal(int n) const { return tscal_x[n]; }
1055  double tzero(int n) const { return tzero_x[n]; }
1056  Bool isatnull(int n) const { return isatnull_x[n]; }
1057  Int tnull(int n) const { return tnull_x[n]; }
1058  const char *ttype(int n) const { return ttype_x[n]; }
1059  const char *tunit(int n) const { return tunit_x[n]; }
1060  const char *tdisp(int n) const { return tdisp_x[n]; }
1061  const char *tdim(int n) const { return tdim_x[n]; }
1062  const char *ctype(int n) const { return ctype_x[n]; }
1063  double crpix(int n) const { return crpix_x[n]; }
1064  double crota(int n) const { return crota_x[n]; }
1065  double crval(int n) const { return crval_x[n]; }
1066  double cdelt(int n) const { return cdelt_x[n]; }
1067  Int theap() const { return theap_x; }
1068  const char *author() const { return author_x; }
1069  const char *referenc() const { return referenc_x; }
1070  //</group>
1071 
1072  // binds a FitsField to a column
1073  int bind(int, FitsBase &);
1074 
1075  // row selector functions
1076  //<group>
1080  //</group>
1081 
1082  // read entire table into memory
1083  int read();
1084  // read next N rows into memory
1085  int read(int);
1086  // prepare to write the next N rows
1087  int set_next(int);
1088  // write current rows
1089  int write(FitsOutput &);
1090  // create a binary table header without using FitsKeywordList objet.
1091  int write_binTbl_hdr(FitsOutput &, long, int, const char**,
1092  const char**, const char**, const char*, long );
1093 
1094  // select a field
1095  FitsBase &field(int i) const { return *fld[i]; }
1096  // get current row
1097  Int currrow() const { return curr_row; }
1098  // sets field addresses in the current row
1099  //void set_fitsrow(Int);
1100 
1101  protected:
1108 
1110  char **tform_x;
1111  double *tscal_x;
1112  double *tzero_x;
1115  char **ttype_x;
1116  char **tunit_x;
1117  char **tdisp_x;
1118  char **tdim_x;
1119  char **ctype_x;
1120  double *crpix_x;
1121  double *crota_x;
1122  double *crval_x;
1123  double *cdelt_x;
1126  char *author_x;
1127  char *referenc_x;
1128 
1129  // read and write the next FITS data row
1130  //<group>
1131  virtual int readrow();
1132  virtual int writerow(FitsOutput &);
1133  //</group>
1134  unsigned char *fitsrow; // the FITS data row buffer
1135  uInt *fits_offset; // Offsets to the fields within a FITS row
1136  uInt fitsrowsize; // size in bytes of a FITS data row
1137  Bool isoptimum; // tells whether optimum case exists or not
1138 
1139  // sets field addresses in the current row
1140  void set_fitsrow(Int);
1141 
1142  unsigned char *table; // the table in local format
1143  uInt tablerowsize; // size in bytes of a table row
1144  uInt alloc_row; // number of currently allocated rows
1145  Int beg_row; // range of rows currently in memory
1148  FitsBase **fld; // The array of fields
1149  uInt *table_offset; // Offsets to the fields within a table row
1150  // data addresses of fields of current row
1151  void **data_addr;
1152 
1153  private:
1154  void bt_assign();
1155 };
1156 
1157 
1158 //<summary> (ascii) TABLE extension </summary>
1159 
1161  public:
1167 
1169 
1170  //# special overriden functions for ascii TABLE only
1171  // position in which column starts
1172  Int tbcol(int n) { return tbcol_x[n]; }
1173  // ascii string that represents the NULL value
1174  char *tnull(int n) { return tnulla_x[n]; }
1175  // write the required keywords for ASCIITableExtension
1176  int write_ascTbl_hdr( FitsOutput &, long,
1177  long, int, const char **, long *,
1178  const char **, const char **, const char *e);
1179 
1180  protected:
1182  char **tnulla_x;
1183  uInt *fits_width; // widths of the fields within a FITS row
1184  char **format; // converted formats of the fields
1185 
1186  // read and write the next FITS data row
1187  //<group>
1188  int readrow();
1189  int writerow(FitsOutput &);
1190  //</group>
1191 
1192  private:
1193  void at_assign();
1194 };
1195 
1196 
1197 } //# NAMESPACE CASACORE - END
1198 
1199 #ifndef CASACORE_NO_AUTO_TEMPLATES
1200 #include <casacore/fits/FITS/hdu.tcc>
1201 #endif //# CASACORE_NO_AUTO_TEMPLATES
1202 # endif
virtual int dim(int n) const
virtual int localfieldsize() const =0
int write_priTable_hdr(FitsOutput &fout, int bitpix, int naxis, long *naxes)
write required keywords for PrimaryTable
FitsKeywordList & kwlist_
Definition: hdu.h:186
base class for generalized exentensions HDU
Definition: hdu.h:797
float bscal() const
Definition: hdu.h:732
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.
A 1-D Specialization of the Array class.
Definition: ArrayFwd.h:9
templated primary array base class of given type
Definition: hdu.h:340
char * instrume_x
Definition: hdu.h:740
virtual int write(FitsOutput &)
FitsArray< unsigned char > ByteFitsArray
Definition: hdu.h:1023
Int pcount() const
Definition: hdu.h:608
ImageExtension< FitsLong > LongImageExtension
Definition: hdu.h:566
PrimaryArray< short > ShortPrimaryArray
Definition: hdu.h:499
int Int
Definition: aipstype.h:50
FITS::ValueType data_type
Definition: hdu.h:199
FitsBase & operator=(FitsBase &)=delete
char * bunit() const
Definition: hdu.h:731
char * datemap() const
Definition: hdu.h:730
double * cdelt_x
Definition: hdu.h:475
int read()
The `read()&#39; and `write()&#39; functions control reading and writing data from the external FITS I/O medi...
char * ptype(int n) const
Definition: hdu.h:609
FitsBase(const FITS::ValueType &t, int n)
Definition: hdu.h:844
Int fitsitemsize() const
Definition: hdu.h:80
int writerow(FitsOutput &)
FITS templated helper class.
Definition: fits.h:63
FitsKeyword * next(const FITS::ReservedName &)
static FitsBase * make(const FITS::ValueType &, int=1)
int write(FitsOutput &)
write current rows
TYPE ** field
Definition: hdu.h:901
unsigned int nelements() const
Definition: hdu.h:848
FitsField< FitsVADesc > VADescFitsField
Definition: hdu.h:968
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
TYPE & operator()()
Definition: hdu.h:888
void mk(FITS::ReservedName k, Bool v, const char *c=0)
Add (make) a reserved keyword with the given value and optional comment The comment will be truncated...
Definition: fits.h:890
Int currgroup() const
Definition: hdu.h:614
const FitsKeyword * currkw()
Definition: hdu.h:128
char * instrume() const
Definition: hdu.h:728
int write_imgExt_hdr(FitsOutput &fout, int bitpix, int naxis, long *naxes)
write required keywords for ImageExtension
virtual int fitsfieldsize() const =0
const FitsKeyword * kw(int n)
Definition: hdu.h:129
const FitsKeyword * prevkw()
Definition: hdu.h:127
BINTABLE extension.
Definition: hdu.h:1035
void history(const char *c=0)
Definition: hdu.h:261
double crota(int n) const
Definition: hdu.h:364
BinaryTableExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
Vector< String > kwlist_str(Bool length80=False)
return the header of the chdu as a vector of String.
Primary Table structure.
Definition: hdu.h:706
void comment(const char *n=0, const char *c=0)
add a comment card
Definition: fits.h:938
double * crval_x
Definition: hdu.h:474
const char * tform(int n) const
Definition: hdu.h:1053
double bscale() const
General access routines for a primary array.
Definition: hdu.h:357
char * tnull(int n)
ascii string that represents the NULL value
Definition: hdu.h:1174
Int nrows() const
return basic elements of a table
Definition: hdu.h:1049
FitsArray< double > DoubleFitsArray
Definition: hdu.h:1027
float altrpix() const
Definition: hdu.h:735
double cdelt(int n) const
Definition: hdu.h:366
HeaderDataUnit(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
For input – ~ should delete the keyword list: kwflag = 1.
double datamin() const
Definition: hdu.h:368
TYPE * group_parm
Definition: hdu.h:648
BinaryTableExtension & operator++()
row selector functions
const FitsKeyword * kw(const char *n)
Definition: hdu.h:139
virtual OFF_T set_next(OFF_T)
char ** ctype_x
Definition: hdu.h:471
char * extname()
Definition: hdu.h:528
int * factor
Definition: hdu.h:987
HDUErrs err_status
Definition: hdu.h:192
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
FitsArray< DComplex > DComplexFitsArray
Definition: hdu.h:1030
static functions and enumerations
Definition: fits.h:161
base class that defines a HDU
Definition: hdu.h:71
FitsArray< float > FloatFitsArray
Definition: hdu.h:1026
const FitsKeyword * nextkw(FITS::ReservedName &n)
Definition: hdu.h:133
const FitsKeyword * kw(const FITS::ReservedName &n)
Definition: hdu.h:131
PrimaryGroup< float > FloatPrimaryGroup
Definition: hdu.h:693
double * pscal_x
Definition: hdu.h:646
Random Group datastructure.
Definition: hdu.h:594
Int dim(int n) const
Definition: hdu.h:77
char * datemap_x
Definition: hdu.h:742
PrimaryTable< float > FloatPrimaryTable
Definition: hdu.h:792
FitsField< unsigned char > ByteFitsField
Definition: hdu.h:960
unsigned char mask
Definition: hdu.h:952
PrimaryTable< unsigned char > BytePrimaryTable
Definition: hdu.h:789
virtual int readrow()
read and write the next FITS data row
FitsField< Complex > ComplexFitsField
Definition: hdu.h:965
double crval(int n) const
Definition: hdu.h:365
int write_all_data(FitsOutput &, char *)
Int blank() const
Definition: hdu.h:361
FitsField< IComplex > IComplexFitsField
Definition: hdu.h:966
int get_hdr(FITS::HDUType, FitsKeywordList &)
int offset(int, int) const
compute a linear offset from array indicies
void errmsg(HDUErrs, const char *)
helper class Note: Note that FitsField does not allocate space for the data; Space is external to Fi...
Definition: hdu.h:882
int write(FitsOutput &)
friend std::ostream & operator<<(std::ostream &, HeaderDataUnit &)
Definition: hdu.h:223
FITS::ValueType datatype() const
Definition: hdu.h:79
int dim(int n) const
void(* FITSErrorHandler)(const char *errMessage, FITSError::ErrorLevel severity)
Define a typedef for the handler function signature for convenience.
Definition: FITSError.h:111
double pzero(int n) const
Definition: hdu.h:611
helper class for FITS Binary Tables
Definition: fits.h:116
HDUType
Types of FITS Header-Data Units.
Definition: fits.h:263
FitsKeyword * curr()
Definition: fits.h:876
char * assign(FITS::ReservedName)
Int tnull(int n) const
Definition: hdu.h:1057
ExtensionHeaderDataUnit(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
double tzero(int n) const
Definition: hdu.h:1055
PrimaryGroup< short > ShortPrimaryGroup
Definition: hdu.h:691
int read()
read, or write the next group
ValueType
FITS I/O Error message types.
Definition: fits.h:167
FitsField< char > CharFitsField
Definition: hdu.h:959
FitsArray< short > ShortFitsArray
Definition: hdu.h:1024
double * crpix_x
Definition: hdu.h:472
FitsField(int n=1)
Definition: hdu.h:884
void setaddr(void **addr)
void show(std::ostream &)
const FitsKeyword * nextkw()
Definition: hdu.h:126
PrimaryGroup< FitsLong > LongPrimaryGroup
Definition: hdu.h:692
OFF_T fits_data_size
uInt fits_data_size; // size in bytes of total amount of data
Definition: hdu.h:198
char * ctype(int n) const
Definition: hdu.h:362
Bool notnull(double x) const
Definition: hdu.h:162
PrimaryArray< FitsLong > LongPrimaryArray
Definition: hdu.h:500
Bool isablank() const
Definition: hdu.h:360
int read()
read entire table into memory
virtual void * data()=0
char * xtension()
Definition: hdu.h:527
OFF_T read_all_data(char *)
void copy(double *target, FITS::FitsArrayOption=FITS::NoOpt) const
char * telescop_x
Definition: hdu.h:739
const char * tdim(int n) const
Definition: hdu.h:1061
const char * ttype(int n) const
Definition: hdu.h:1058
PrimaryTable< FitsLong > LongPrimaryTable
Definition: hdu.h:791
unsigned char * table
Definition: hdu.h:1142
char * telescop() const
Definition: hdu.h:727
virtual int dims() const
PrimaryGroup< unsigned char > BytePrimaryGroup
Definition: hdu.h:690
int read(int)
Definition: hdu.h:639
int bind(int, FitsBase &)
binds a FitsField to a column
PrimaryArray< float > FloatPrimaryArray
Definition: hdu.h:501
ImageExtension< float > FloatImageExtension
Definition: hdu.h:567
virtual void show(std::ostream &)=0
Int dims() const
Definition: hdu.h:76
int read(int)
Definition: hdu.h:723
double bzero() const
Definition: hdu.h:358
double * crota_x
Definition: hdu.h:473
void move(TYPE *target, FITS::FitsArrayOption=FITS::NoOpt) const
void comment(const char *n=0, const char *c=0)
Definition: hdu.h:259
FitsField< FitsLong > LongFitsField
Definition: hdu.h:962
virtual void setaddr(void **)=0
void moveparm(TYPE *target) const
FitsArray< FitsLogical > LogicalFitsArray
Definition: hdu.h:1020
FITS::HDUType hdutype() const
Definition: hdu.h:82
OFF_T nelements() const
Definition: hdu.h:369
FitsArray(int, const int *)
int store(const TYPE *source, FITS::FitsArrayOption=FITS::NoOpt)
The `store()&#39;, `move()&#39; and `copy()&#39; functions allow bulk data transfer between the internal FITS arr...
ImageExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
FITS::ValueType fieldtype() const
Definition: hdu.h:855
double cdelt(int n) const
Definition: hdu.h:1066
const char * ctype(int n) const
Definition: hdu.h:1062
int localfieldsize() const
PrimaryTable(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
int write_priArr_hdr(FitsOutput &fout, int simple, int bitpix, int naxis, long naxes[], int extend)
FitsField< DComplex > DComplexFitsField
Definition: hdu.h:967
Int localitemsize() const
Definition: hdu.h:81
const FitsKeyword * nextkw(FITS::ReservedName &n, int i)
Definition: hdu.h:137
Bool notnull(char *s) const
Definition: hdu.h:163
(ascii) TABLE extension
Definition: hdu.h:1160
FitsField< FitsLogical > LogicalFitsField
Definition: hdu.h:957
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
FitsField< FitsBit > BitFitsField
Definition: hdu.h:958
PrimaryTable< double > DoublePrimaryTable
Definition: hdu.h:793
int no_elements
Definition: hdu.h:865
list of read-only FITS keywords
Definition: fits.h:951
int write(FitsOutput &)
Definition: hdu.h:724
FitsBase & field(int i) const
select a field
Definition: hdu.h:1095
ImageExtension< unsigned char > ByteImageExtension
Definition: hdu.h:564
float Float
Definition: aipstype.h:54
IMAGE extension of given type.
Definition: hdu.h:515
ConstFitsKeywordList & kwlist()
Operations on the HDU&#39;s keyword list.
Definition: hdu.h:120
const FitsKeyword * nextkw(const char *n)
Definition: hdu.h:140
FITS::HDUType hdu_type
Definition: hdu.h:202
FitsArray< Complex > ComplexFitsArray
Definition: hdu.h:1028
FitsArray< FitsLong > LongFitsArray
Definition: hdu.h:1025
const char * referenc() const
Definition: hdu.h:1069
const Bool False
Definition: aipstype.h:44
void history(const char *c=0)
add a history card
Definition: fits.h:942
helper class
Definition: hdu.h:840
virtual ~PrimaryArray()
destructor
FitsField< TYPE > & operator=(const TYPE &x)
Definition: hdu.h:890
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...
BinaryTableExtension & operator()(int)
uInt rowsize() const
Definition: hdu.h:1051
ImageExtension< double > DoubleImageExtension
Definition: hdu.h:568
void mk(FITS::ReservedName k, Bool v, const char *c=0)
Definition: hdu.h:225
int fitsfieldsize() const
FitsArray< FitsBit > BitFitsArray
Definition: hdu.h:1021
PrimaryGroup< double > DoublePrimaryGroup
Definition: hdu.h:694
PrimaryGroup(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
unsigned char * fitsrow
Definition: hdu.h:1134
int write_ascTbl_hdr(FitsOutput &, long, long, int, const char **, long *, const char **, const char **, const char *e)
write the required keywords for ASCIITableExtension
char ** ptype_x
Definition: hdu.h:645
int dims() const
const char * tdisp(int n) const
Definition: hdu.h:1060
char * object() const
Definition: hdu.h:726
void ** data_addr
data addresses of fields of current row
Definition: hdu.h:1151
virtual int read()
The `read()&#39; and `write()&#39; functions control reading and writing data from the external FITS I/O medi...
fixed-length sequential blocked FITS output
Definition: fitsio.h:228
Int currrow() const
get current row
Definition: hdu.h:1097
fixed-length sequential blocked FITS input
Definition: fitsio.h:156
int read(char *addr, int nbytes)
read next N bytes into addr
Definition: hdu.h:812
const char * author() const
Definition: hdu.h:1068
FitsArray< char > CharFitsArray
Definition: hdu.h:1022
TYPE & data(int, int, int, int, int)
The various `data()&#39; functions allow one to access and set the raw data itself.
HDUErrs
error handling and error codes that can be returned
Definition: hdu.h:86
FitsArray< IComplex > IComplexFitsArray
Definition: hdu.h:1029
const Double e
e and functions thereof:
PrimaryArray< unsigned char > BytePrimaryArray
Definition: hdu.h:498
FitsField< float > FloatFitsField
Definition: hdu.h:963
char * dateobs() const
Definition: hdu.h:729
virtual int writerow(FitsOutput &)
PrimaryTable< short > ShortPrimaryTable
Definition: hdu.h:790
int write_priGrp_hdr(FitsOutput &fout, int simple, int bitpix, int naxis, long naxes[], long pcount, long gcount)
write the required keywords for PrimaryGroup
int err() const
Definition: hdu.h:90
linked list of FITS keywords
Definition: fits.h:737
char * bunit() const
Definition: hdu.h:359
FITS::ValueType data_type
Definition: hdu.h:866
int read_data(char *, Int)
FITS keyword.
Definition: fits.h:515
FitsArrayOption
Options on FITS array manipulations.
Definition: fits.h:270
OFF_T set_next(OFF_T)
disable these functions, since they are inherited from PrimaryArray
Definition: hdu.h:638
const Double c
Fundamental physical constants (SI units):
ConstFitsKeywordList constkwlist_
Definition: hdu.h:187
FITS array of given type.
Definition: hdu.h:973
PrimaryArray< double > DoublePrimaryArray
Definition: hdu.h:502
Int tbcol(int n)
position in which column starts
Definition: hdu.h:1172
double crpix(int n) const
Definition: hdu.h:1063
Bool notnull(Int l) const
Definition: hdu.h:164
double crpix(int n) const
Definition: hdu.h:363
void set_fitsrow(Int)
sets field addresses in the current row
void storeparm(const TYPE *source)
void copyparm(double *target) const
FitsArray< FitsVADesc > VADescFitsArray
Definition: hdu.h:1031
float equinox() const
Definition: hdu.h:734
double tscal(int n) const
Definition: hdu.h:1054
int write(FitsOutput &fout, char *addr, int nbytes)
write next N bytes from addr to the FITS output fout
Definition: hdu.h:815
float bzero() const
Definition: hdu.h:733
OFF_T fitsdatasize() const
Definition: hdu.h:78
ImageExtension< short > ShortImageExtension
Definition: hdu.h:565
FITSErrorHandler errfn
Definition: hdu.h:191
BinaryTableExtension & operator--()
const FitsKeyword * kw(FITS::ReservedName &n, int i)
Definition: hdu.h:135
TYPE * array
the allocated array
Definition: hdu.h:493
double datamin_x
Definition: hdu.h:477
int write_data(FitsOutput &, char *, Int)
Int gcount() const
Return basic parameters of a random group.
Definition: hdu.h:607
double datamax() const
Definition: hdu.h:367
int set_next(int)
prepare to write the next N rows
double crota(int n) const
Definition: hdu.h:1064
virtual int * vdim()
double crval(int n) const
Definition: hdu.h:1065
double pscal(int n) const
Definition: hdu.h:610
bool init_data_unit(FITS::HDUType t)
for write required keywords only to use.
FitsField< double > DoubleFitsField
Definition: hdu.h:964
double datamax_x
Definition: hdu.h:476
const Bool True
Definition: aipstype.h:43
char * dateobs_x
Definition: hdu.h:741
AsciiTableExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
double * pzero_x
Definition: hdu.h:647
const char * tunit(int n) const
Definition: hdu.h:1059
Bool isatnull(int n) const
Definition: hdu.h:1056
void spaces(const char *n=0, const char *c=0)
Definition: hdu.h:257
PrimaryArray(FitsInput &, FITSErrorHandler=FITSError::defaultHandler)
constructor from a FitsInput
double operator()(int, int, int, int, int) const
The overloaded operator functions `()&#39; all return physical data, i.
int write_hdr(FitsOutput &)
write the current header
int write_binTbl_hdr(FitsOutput &, long, int, const char **, const char **, const char **, const char *, long)
create a binary table header without using FitsKeywordList objet.
int readrow()
read and write the next FITS data row
unsigned int uInt
Definition: aipstype.h:51
void spaces(const char *n=0, const char *c=0)
add a spaces line
Definition: fits.h:934
ReservedName
FITS Reserved Names.
Definition: fits.h:238
static void defaultHandler(const char *errMessage, ErrorLevel severity)
The default error handler.
FitsInput * fin
Definition: hdu.h:190
FITS array of FitsBit type Note: We must specify a FitsArray&lt;FitsBit&gt; as a specialization; ...
Definition: hdu.h:1000
double asgdbl(FITS::ReservedName, double)
FitsField< short > ShortFitsField
Definition: hdu.h:961