casacore
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>
33# include <casacore/fits/FITS/blockio.h>
34# include <casacore/casa/BasicSL/String.h>
35# include <casacore/casa/Arrays/Vector.h>
36
37//# # include <stdarg.h> // If we ever wan to put varargs support back
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41class FitsInput;
42class 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; }
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
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:
132 return kwlist_(n); }
134 return kwlist_.next(n); }
135 const FitsKeyword *kw(FITS::ReservedName &n, int i) {
136 return kwlist_(n,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.
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>
208 double asgdbl(FITS::ReservedName, double);
209 double asgdbl(FITS::ReservedName, int, double);
210 //</group>
214
215 public:
217 int read_data(char *, Int);
218 int write_data(FitsOutput &, char *, Int);
219 OFF_T read_all_data(char *);
221};
222
223inline std::ostream & operator << (std::ostream &o, HeaderDataUnit &h) {
224 return o << h.kwlist_; }
225inline void HeaderDataUnit::mk(FITS::ReservedName k, Bool v, const char *c) {
226 posEnd(); kwlist_.mk(k,v,c); }
227inline void HeaderDataUnit::mk(FITS::ReservedName k, const char *v,
228 const char *c) { posEnd(); kwlist_.mk(k,v,c); }
229inline void HeaderDataUnit::mk(FITS::ReservedName k, Int v, const char *c) {
230 posEnd(); kwlist_.mk(k,v,c); }
231inline void HeaderDataUnit::mk(FITS::ReservedName k, double v, const char *c) {
232 posEnd(); kwlist_.mk(k,v,c); }
234 const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
235inline void HeaderDataUnit::mk(int n, FITS::ReservedName k, const char *v,
236 const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
238 const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
239inline void HeaderDataUnit::mk(int n, FITS::ReservedName k, double v,
240 const char *c) { posEnd(); kwlist_.mk(n,k,v,c); }
241inline void HeaderDataUnit::mk(const char *n, Bool v, const char *c) {
242 posEnd(); kwlist_.mk(n,v,c); }
243inline void HeaderDataUnit::mk(const char *n, const char *v, const char *c) {
244 posEnd(); kwlist_.mk(n,v,c); }
245inline void HeaderDataUnit::mk(const char *n, Int v, const char *c) {
246 posEnd(); kwlist_.mk(n,v,c); }
247inline void HeaderDataUnit::mk(const char *n, float v, const char *c) {
248 posEnd(); kwlist_.mk(n,v,c); }
249inline void HeaderDataUnit::mk(const char *n, double v, const char *c) {
250 posEnd(); kwlist_.mk(n,v,c); }
251inline void HeaderDataUnit::mk(const char *n, Int r, Int i, const char *c) {
252 posEnd(); kwlist_.mk(n,r,i,c); }
253inline void HeaderDataUnit::mk(const char *n, float r, float i, const char *c) {
254 posEnd(); kwlist_.mk(n,r,i,c); }
255inline void HeaderDataUnit::mk(const char *n, double r, double i,
256 const char *c) { posEnd(); kwlist_.mk(n,r,i,c); }
257inline void HeaderDataUnit::spaces(const char *n, const char *c) {
258 posEnd(); kwlist_.spaces(n,c); }
259inline void HeaderDataUnit::comment(const char *n, const char *c) {
260 posEnd(); kwlist_.comment(n,c); }
261inline 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
339template <class TYPE>
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
514template <class TYPE>
515class ImageExtension : public PrimaryArray<TYPE> {
516 public:
517 typedef TYPE ElementType;
518
523 // constructor for header consisted required keywords only
525
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
535 int bitpix, int naxis, long *naxes);
536 protected:
543
544 private:
545 void ie_assign();
546
547 //# Make members in parent known
548 protected:
549 using PrimaryArray<TYPE>::assign;
550 using PrimaryArray<TYPE>::errmsg;
552 using PrimaryArray<TYPE>::pa_assign;
553 using PrimaryArray<TYPE>::char_null;
554 using PrimaryArray<TYPE>::kwlist_;
555 using PrimaryArray<TYPE>::errfn;
556 using PrimaryArray<TYPE>::hdu_type;
557 using PrimaryArray<TYPE>::data_type;
560 using PrimaryArray<TYPE>::array;
561 using PrimaryArray<TYPE>::BADOPER;
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>
593template <class TYPE>
594class PrimaryGroup : public PrimaryArray<TYPE> {
595 public:
600 // constructor for header consisted required keywords only
602
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();
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;
650
651 private:
652 void pg_assign();
653
654 //# Make members in parent known
655 protected:
656 using PrimaryArray<TYPE>::assign;
657 using PrimaryArray<TYPE>::errmsg;
659 using PrimaryArray<TYPE>::pa_assign;
660 using PrimaryArray<TYPE>::asgdbl;
661 using PrimaryArray<TYPE>::nelements;
662 using PrimaryArray<TYPE>::localitemsize;
663 using PrimaryArray<TYPE>::fitsitemsize;
664 using PrimaryArray<TYPE>::read_data;
665 using PrimaryArray<TYPE>::write_data;
666 using PrimaryArray<TYPE>::char_null;
667 using PrimaryArray<TYPE>::kwlist_;
668 using PrimaryArray<TYPE>::errfn;
669 using PrimaryArray<TYPE>::err_status;
670 using PrimaryArray<TYPE>::hdu_type;
671 using PrimaryArray<TYPE>::data_type;
674 using PrimaryArray<TYPE>::array;
675 using PrimaryArray<TYPE>::totsize;
676 using PrimaryArray<TYPE>::dimn;
677 using PrimaryArray<TYPE>::no_dims;
678 using PrimaryArray<TYPE>::factor;
679 using PrimaryArray<TYPE>::ctype_x;
680 using PrimaryArray<TYPE>::crpix_x;
681 using PrimaryArray<TYPE>::crota_x;
682 using PrimaryArray<TYPE>::crval_x;
683 using PrimaryArray<TYPE>::cdelt_x;
684 using PrimaryArray<TYPE>::BADOPER;
685 using PrimaryArray<TYPE>::OK;
686 using PrimaryArray<TYPE>::NOMEM;
687 using PrimaryArray<TYPE>::BADIO;
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
705template <class TYPE>
706class PrimaryTable : public PrimaryArray<TYPE> {
707 public:
708 typedef TYPE ElementType;
709
714 // constructor for header consisted required keywords only
716
718 // write required keywords for PrimaryTable
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:
755 using PrimaryArray<TYPE>::assign;
756 using PrimaryArray<TYPE>::errmsg;
758 using PrimaryArray<TYPE>::pa_assign;
759 using PrimaryArray<TYPE>::asgdbl;
760 using PrimaryArray<TYPE>::nelements;
761 using PrimaryArray<TYPE>::localitemsize;
762 using PrimaryArray<TYPE>::fitsitemsize;
763 using PrimaryArray<TYPE>::read_data;
764 using PrimaryArray<TYPE>::write_data;
765 using PrimaryArray<TYPE>::char_null;
766 using PrimaryArray<TYPE>::kwlist_;
767 using PrimaryArray<TYPE>::errfn;
768 using PrimaryArray<TYPE>::err_status;
769 using PrimaryArray<TYPE>::hdu_type;
770 using PrimaryArray<TYPE>::data_type;
773 using PrimaryArray<TYPE>::array;
774 using PrimaryArray<TYPE>::totsize;
775 using PrimaryArray<TYPE>::dimn;
776 using PrimaryArray<TYPE>::no_dims;
777 using PrimaryArray<TYPE>::factor;
778 using PrimaryArray<TYPE>::ctype_x;
779 using PrimaryArray<TYPE>::crpix_x;
780 using PrimaryArray<TYPE>::crota_x;
781 using PrimaryArray<TYPE>::crval_x;
782 using PrimaryArray<TYPE>::cdelt_x;
783 using PrimaryArray<TYPE>::BADOPER;
784 using PrimaryArray<TYPE>::OK;
785 using PrimaryArray<TYPE>::NOMEM;
786 using PrimaryArray<TYPE>::BADIO;
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
833
834 private:
835 void ex_assign();
836};
837
838//<summary> helper class </summary>
839
840class FitsBase {
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();
856
857 static FitsBase *make(const FITS::ValueType &, int = 1);
858 static FitsBase *make(const FITS::ValueType &, int, int *);
860
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
870inline 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
881template <class TYPE>
882class FitsField : public FitsBase {
883 public:
884 FitsField(int n = 1) :
885 FitsBase(FITS::getfitstype(NoConvert<TYPE>()),n), field(0) { }
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
925template <> class FitsField<FitsBit> : public FitsBase {
926 public:
927 FitsField(int n = 1);
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>
971template <class TYPE>
972class FitsArray : public FitsField<TYPE> {
973 public:
974 FitsArray(int, const int *);
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:
990 using FitsField<TYPE>::no_elements;
991 using FitsField<TYPE>::field;
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
1000template <> class FitsArray<FitsBit> : public FitsField<FitsBit> {
1001 public:
1002 FitsArray(int, const 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:
1016 int *dimn;
1018};
1019
1032
1033//<summary> BINTABLE extension </summary>
1034
1036 public:
1039
1042 // constructor to match write_bintbl_hdr()
1044
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
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;
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
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:
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
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();
1190 //</group>
1191
1192 private:
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
(ascii) TABLE extension
Definition: hdu.h:1160
AsciiTableExtension(FitsKeywordList &, FITSErrorHandler errhandler=FITSError::defaultHandler)
int readrow()
read and write the next FITS data row
Int tbcol(int n)
position in which column starts
Definition: hdu.h:1172
int writerow(FitsOutput &)
char * tnull(int n)
ascii string that represents the NULL value
Definition: hdu.h:1174
int write_ascTbl_hdr(FitsOutput &, long, long, int, const char **, long *, const char **, const char **, const char *e)
write the required keywords for ASCIITableExtension
AsciiTableExtension(FITSErrorHandler errhandler=FITSError::defaultHandler)
AsciiTableExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
BINTABLE extension
Definition: hdu.h:1035
const char * tdim(int n) const
Definition: hdu.h:1061
Int nrows() const
return basic elements of a table
Definition: hdu.h:1049
Bool isatnull(int n) const
Definition: hdu.h:1056
double tscal(int n) const
Definition: hdu.h:1054
const char * tdisp(int n) const
Definition: hdu.h:1060
BinaryTableExtension(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
FitsBase & field(int i) const
select a field
Definition: hdu.h:1095
int bind(int, FitsBase &)
binds a FitsField to a column
const char * ttype(int n) const
Definition: hdu.h:1058
double crval(int n) const
Definition: hdu.h:1065
BinaryTableExtension(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
sets field addresses in the current row void set_fitsrow(Int);
virtual int writerow(FitsOutput &)
Int currrow() const
get current row
Definition: hdu.h:1097
BinaryTableExtension(FITSErrorHandler errhandler=FITSError::defaultHandler)
constructor to match write_bintbl_hdr()
BinaryTableExtension(FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
BinaryTableExtension(FitsKeywordList &, FITSErrorHandler errhandler=FITSError::defaultHandler)
int write(FitsOutput &)
write current rows
unsigned char * table
Definition: hdu.h:1142
BinaryTableExtension & operator()(int)
int read()
read entire table into memory
Int tnull(int n) const
Definition: hdu.h:1057
double crota(int n) const
Definition: hdu.h:1064
const char * author() const
Definition: hdu.h:1068
unsigned char * fitsrow
Definition: hdu.h:1134
int set_next(int)
prepare to write the next N rows
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.
void ** data_addr
data addresses of fields of current row
Definition: hdu.h:1151
BinaryTableExtension & operator--()
double cdelt(int n) const
Definition: hdu.h:1066
const char * tform(int n) const
Definition: hdu.h:1053
int read(int)
read next N rows into memory
double crpix(int n) const
Definition: hdu.h:1063
void set_fitsrow(Int)
sets field addresses in the current row
const char * tunit(int n) const
Definition: hdu.h:1059
const char * ctype(int n) const
Definition: hdu.h:1062
const char * referenc() const
Definition: hdu.h:1069
BinaryTableExtension & operator++()
row selector functions
virtual int readrow()
read and write the next FITS data row
BinaryTableExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
double tzero(int n) const
Definition: hdu.h:1055
list of read-only FITS keywords
Definition: fits.h:951
base class for generalized exentensions HDU
Definition: hdu.h:797
ExtensionHeaderDataUnit(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
ExtensionHeaderDataUnit(FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
This constructor is used for writing only required keywords.
int write(FitsOutput &fout, char *addr, int nbytes)
write next N bytes from addr to the FITS output fout
Definition: hdu.h:815
ExtensionHeaderDataUnit(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
ExtensionHeaderDataUnit(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
ExtensionHeaderDataUnit(FitsKeywordList &, FITSErrorHandler errhandler=FITSError::defaultHandler)
int read(char *addr, int nbytes)
read next N bytes into addr
Definition: hdu.h:812
static void defaultHandler(const char *errMessage, ErrorLevel severity)
The default error handler.
static functions and enumerations
Definition: fits.h:161
ReservedName
FITS Reserved Names.
Definition: fits.h:238
ValueType
FITS I/O Error message types.
Definition: fits.h:167
FitsArrayOption
Options on FITS array manipulations.
Definition: fits.h:270
HDUType
Types of FITS Header-Data Units.
Definition: fits.h:263
FITS array of FitsBit type Note: We must specify a FitsArray<FitsBit> as a specialization;
Definition: hdu.h:1000
FITS array of given type
Definition: hdu.h:973
FitsArray(int, const int *)
int dim(int n) const
int * factor
Definition: hdu.h:987
helper class
Definition: hdu.h:840
static FitsBase * make(FitsBase &)
virtual void setaddr(void **)=0
virtual int dims() const
FitsBase(const FITS::ValueType &t, int n)
Definition: hdu.h:844
unsigned int nelements() const
Definition: hdu.h:848
virtual void show(std::ostream &)=0
virtual int * vdim()
FITS::ValueType data_type
Definition: hdu.h:866
static FitsBase * make(const FITS::ValueType &, int, int *)
FitsBase & operator=(FitsBase &)=delete
virtual int fitsfieldsize() const =0
virtual int localfieldsize() const =0
int no_elements
Definition: hdu.h:865
static FitsBase * make(const FITS::ValueType &, int=1)
virtual int dim(int n) const
virtual void * data()=0
FITS::ValueType fieldtype() const
Definition: hdu.h:855
helper class for FITS Binary Tables
Definition: fits.h:116
void show(std::ostream &)
unsigned char mask
Definition: hdu.h:952
helper class Note: Note that FitsField does not allocate space for the data; Space is external to Fi...
Definition: hdu.h:882
FitsField< TYPE > & operator=(const TYPE &x)
Definition: hdu.h:890
TYPE & operator()()
Definition: hdu.h:888
FitsField(int n=1)
Definition: hdu.h:884
int fitsfieldsize() const
void show(std::ostream &)
int localfieldsize() const
TYPE ** field
Definition: hdu.h:901
void setaddr(void **addr)
fixed-length sequential blocked FITS input
Definition: fitsio.h:156
linked list of FITS keywords
Definition: fits.h:737
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
FitsKeyword * next(const FITS::ReservedName &)
FitsKeyword * curr()
Definition: fits.h:876
void spaces(const char *n=0, const char *c=0)
add a spaces line
Definition: fits.h:934
void comment(const char *n=0, const char *c=0)
add a comment card
Definition: fits.h:938
void history(const char *c=0)
add a history card
Definition: fits.h:942
FITS keyword.
Definition: fits.h:515
fixed-length sequential blocked FITS output
Definition: fitsio.h:228
FitsInput * fin
Definition: hdu.h:190
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.
OFF_T read_all_data(char *)
FITSErrorHandler errfn
Definition: hdu.h:191
FITS::ValueType datatype() const
Definition: hdu.h:79
HDUErrs
error handling and error codes that can be returned
Definition: hdu.h:86
Bool notnull(Int l) const
Definition: hdu.h:164
OFF_T fits_data_size
uInt fits_data_size; // size in bytes of total amount of data
Definition: hdu.h:198
HDUErrs err_status
Definition: hdu.h:192
const FitsKeyword * kw(int n)
Definition: hdu.h:129
const FitsKeyword * kw(FITS::ReservedName &n, int i)
Definition: hdu.h:135
bool init_data_unit(FITS::HDUType t)
for write required keywords only to use.
void spaces(const char *n=0, const char *c=0)
Definition: hdu.h:257
double asgdbl(FITS::ReservedName, int, double)
void history(const char *c=0)
Definition: hdu.h:261
int skip(uInt n)
skipping one or more HDU's
const FitsKeyword * nextkw(FITS::ReservedName &n)
Definition: hdu.h:133
const FitsKeyword * kw(const char *n)
Definition: hdu.h:139
void comment(const char *n=0, const char *c=0)
Definition: hdu.h:259
void mk(FITS::ReservedName k, Bool v, const char *c=0)
Definition: hdu.h:225
const FitsKeyword * kw(const FITS::ReservedName &n)
Definition: hdu.h:131
char * assign(FITS::ReservedName)
int err() const
Definition: hdu.h:90
ConstFitsKeywordList & kwlist()
Operations on the HDU's keyword list.
Definition: hdu.h:120
FITS::HDUType hdutype() const
Definition: hdu.h:82
double asgdbl(FITS::ReservedName, double)
Int dims() const
Definition: hdu.h:76
const FitsKeyword * currkw()
Definition: hdu.h:128
HeaderDataUnit(FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler, FitsInput *=0)
constructor for objects that write only required keyword to fits file.
const FitsKeyword * nextkw(const char *n)
Definition: hdu.h:140
int read_data(char *, Int)
Int dim(int n) const
Definition: hdu.h:77
HeaderDataUnit(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
For input – ~ should delete the keyword list: kwflag = 1.
Vector< String > kwlist_str(Bool length80=False)
return the header of the chdu as a vector of String.
Int fitsitemsize() const
Definition: hdu.h:80
FitsKeywordList & kwlist_
Definition: hdu.h:186
const FitsKeyword * nextkw()
Definition: hdu.h:126
int write_data(FitsOutput &, char *, Int)
FITS::HDUType hdu_type
Definition: hdu.h:202
int write_all_data(FitsOutput &, char *)
Bool notnull(char *s) const
Definition: hdu.h:163
friend std::ostream & operator<<(std::ostream &, HeaderDataUnit &)
Definition: hdu.h:223
const FitsKeyword * nextkw(FITS::ReservedName &n, int i)
Definition: hdu.h:137
int get_hdr(FITS::HDUType, FitsKeywordList &)
char * assign(FITS::ReservedName, int)
Bool notnull(double x) const
Definition: hdu.h:162
OFF_T fitsdatasize() const
Definition: hdu.h:78
Int localitemsize() const
Definition: hdu.h:81
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 ...
ConstFitsKeywordList constkwlist_
Definition: hdu.h:187
int write_hdr(FitsOutput &)
write the current header
const FitsKeyword * prevkw()
Definition: hdu.h:127
FITS::ValueType data_type
Definition: hdu.h:199
void errmsg(HDUErrs, const char *)
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,...
IMAGE extension of given type.
Definition: hdu.h:515
ImageExtension(FITSErrorHandler errhandler=FITSError::defaultHandler)
constructor for header consisted required keywords only
ImageExtension(FitsKeywordList &, FITSErrorHandler errhandler=FITSError::defaultHandler)
int write_imgExt_hdr(FitsOutput &fout, int bitpix, int naxis, long *naxes)
write required keywords for ImageExtension
ImageExtension(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
char * xtension()
Definition: hdu.h:527
char * extname()
Definition: hdu.h:528
templated primary array base class of given type
Definition: hdu.h:340
double bscale() const
General access routines for a primary array.
Definition: hdu.h:357
void move(TYPE *target, FITS::FitsArrayOption=FITS::NoOpt) const
OFF_T nelements() const
Definition: hdu.h:369
double datamax() const
Definition: hdu.h:367
PrimaryArray(FitsInput &, FITSErrorHandler=FITSError::defaultHandler)
constructor from a FitsInput
double datamax_x
Definition: hdu.h:476
int offset(int, int) const
compute a linear offset from array indicies
virtual int read(int)
double * crota_x
Definition: hdu.h:473
void copy(double *target, FITS::FitsArrayOption=FITS::NoOpt) const
double datamin() const
Definition: hdu.h:368
char * bunit() const
Definition: hdu.h:359
int store(const TYPE *source, FITS::FitsArrayOption=FITS::NoOpt)
The ‘store()’, ‘move()’ and ‘copy()’ functions allow bulk data transfer between the internal FITS arr...
double cdelt(int n) const
Definition: hdu.h:366
PrimaryArray(FitsKeywordList &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
construct from a FitsKeywordList with given HDU type
virtual int write(FitsOutput &)
PrimaryArray(FitsKeywordList &, FITSErrorHandler=FITSError::defaultHandler)
constructor from a FitsKeywordList
double crota(int n) const
Definition: hdu.h:364
double bzero() const
Definition: hdu.h:358
double * crval_x
Definition: hdu.h:474
void copy(float *target, FITS::FitsArrayOption=FITS::NoOpt) const
TYPE & data(int, int, int, int)
char ** ctype_x
Definition: hdu.h:471
virtual int read()
The ‘read()’ and ‘write()’ functions control reading and writing data from the external FITS I/O medi...
TYPE * array
the allocated array
Definition: hdu.h:493
int offset(int, int, int) const
double crpix(int n) const
Definition: hdu.h:363
int store(const TYPE *source, int npixels)
Use these versions if you are reading/writing "chunk by chunk.
TYPE & data(int, int, int)
double operator()(int, int, int, int, int) const
The overloaded operator functions ‘()’ all return physical data, i.
double crval(int n) const
Definition: hdu.h:365
int offset(int, int, int, int, int) const
double datamin_x
Definition: hdu.h:477
PrimaryArray(FitsInput &, FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
construct from a FitsInput with given HDU type
int offset(int, int, int, int) const
virtual OFF_T set_next(OFF_T)
PrimaryArray(FITSErrorHandler=FITSError::defaultHandler)
constructor does not require a FitsKeywordList.
void copy(float *target, int npixels) const
PrimaryArray(FITS::HDUType, FITSErrorHandler errhandler=FITSError::defaultHandler)
construct witout FitsKeywordList for given HDU type(for ImageExtension and PrimaryGroup)
void copy(double *target, int npixels) const
double * cdelt_x
Definition: hdu.h:475
double * crpix_x
Definition: hdu.h:472
Int blank() const
Definition: hdu.h:361
char * ctype(int n) const
Definition: hdu.h:362
void move(TYPE *target, int npixels) const
int write_priArr_hdr(FitsOutput &fout, int simple, int bitpix, int naxis, long naxes[], int extend)
TYPE & data(int, int)
Bool isablank() const
Definition: hdu.h:360
virtual ~PrimaryArray()
destructor
TYPE & data(int, int, int, int, int)
The various ‘data()’ functions allow one to access and set the raw data itself.
Random Group datastructure.
Definition: hdu.h:594
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 read(int)
Definition: hdu.h:639
double * pscal_x
Definition: hdu.h:646
double pscal(int n) const
Definition: hdu.h:610
Int pcount() const
Definition: hdu.h:608
int read()
read, or write the next group
Int gcount() const
Return basic parameters of a random group.
Definition: hdu.h:607
PrimaryGroup(FitsKeywordList &, FITSErrorHandler errhandler=FITSError::defaultHandler)
TYPE * group_parm
Definition: hdu.h:648
void moveparm(TYPE *target) const
PrimaryGroup(FITSErrorHandler errhandler=FITSError::defaultHandler)
constructor for header consisted required keywords only
double pzero(int n) const
Definition: hdu.h:611
void copyparm(double *target) const
double * pzero_x
Definition: hdu.h:647
int write(FitsOutput &)
OFF_T set_next(OFF_T)
disable these functions, since they are inherited from PrimaryArray
Definition: hdu.h:638
PrimaryGroup(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
void copyparm(float *target) const
void storeparm(const TYPE *source)
Int currgroup() const
Definition: hdu.h:614
char * ptype(int n) const
Definition: hdu.h:609
char ** ptype_x
Definition: hdu.h:645
Primary Table structure.
Definition: hdu.h:706
int write_priTable_hdr(FitsOutput &fout, int bitpix, int naxis, long *naxes)
write required keywords for PrimaryTable
int read()
The ‘read()’ and ‘write()’ functions control reading and writing data from the external FITS I/O medi...
float altrpix() const
Definition: hdu.h:735
int write(FitsOutput &)
Definition: hdu.h:724
int read(int)
Definition: hdu.h:723
float bscal() const
Definition: hdu.h:732
char * dateobs_x
Definition: hdu.h:741
char * object() const
Definition: hdu.h:726
PrimaryTable(FITSErrorHandler errhandler=FITSError::defaultHandler)
constructor for header consisted required keywords only
PrimaryTable(FitsKeywordList &, FITSErrorHandler errhandler=FITSError::defaultHandler)
char * bunit() const
Definition: hdu.h:731
float equinox() const
Definition: hdu.h:734
char * dateobs() const
Definition: hdu.h:729
char * instrume_x
Definition: hdu.h:740
char * instrume() const
Definition: hdu.h:728
float bzero() const
Definition: hdu.h:733
char * datemap() const
Definition: hdu.h:730
PrimaryTable(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler)
char * telescop() const
Definition: hdu.h:727
char * telescop_x
Definition: hdu.h:739
char * datemap_x
Definition: hdu.h:742
void(* FITSErrorHandler)(const char *errMessage, FITSError::ErrorLevel severity)
Define a typedef for the handler function signature for convenience.
Definition: FITSError.h:111
const Double c
Fundamental physical constants (SI units):
const Double e
e and functions thereof:
this file contains all the compiler specific defines
Definition: mainpage.dox:28
FitsArray< FitsLong > LongFitsArray
Definition: hdu.h:1025
FitsArray< DComplex > DComplexFitsArray
Definition: hdu.h:1030
PrimaryGroup< short > ShortPrimaryGroup
Definition: hdu.h:691
const Bool False
Definition: aipstype.h:44
FitsArray< short > ShortFitsArray
Definition: hdu.h:1024
ostream & operator<<(ostream &os, const IComplex &)
Show on ostream.
FitsField< FitsVADesc > VADescFitsField
Definition: hdu.h:968
FitsField< FitsBit > BitFitsField
Definition: hdu.h:958
FitsField< Complex > ComplexFitsField
Definition: hdu.h:965
FitsArray< float > FloatFitsArray
Definition: hdu.h:1026
unsigned int uInt
Definition: aipstype.h:51
PrimaryArray< unsigned char > BytePrimaryArray
Definition: hdu.h:498
PrimaryArray< float > FloatPrimaryArray
Definition: hdu.h:501
PrimaryTable< FitsLong > LongPrimaryTable
Definition: hdu.h:791
FitsField< short > ShortFitsField
Definition: hdu.h:961
ImageExtension< unsigned char > ByteImageExtension
Definition: hdu.h:564
PrimaryTable< double > DoublePrimaryTable
Definition: hdu.h:793
PrimaryArray< FitsLong > LongPrimaryArray
Definition: hdu.h:500
FitsField< float > FloatFitsField
Definition: hdu.h:963
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
ImageExtension< float > FloatImageExtension
Definition: hdu.h:567
FitsField< unsigned char > ByteFitsField
Definition: hdu.h:960
float Float
Definition: aipstype.h:54
FitsField< FitsLong > LongFitsField
Definition: hdu.h:962
PrimaryGroup< double > DoublePrimaryGroup
Definition: hdu.h:694
FitsField< char > CharFitsField
Definition: hdu.h:959
FitsArray< Complex > ComplexFitsArray
Definition: hdu.h:1028
FitsArray< unsigned char > ByteFitsArray
Definition: hdu.h:1023
ImageExtension< short > ShortImageExtension
Definition: hdu.h:565
PrimaryTable< float > FloatPrimaryTable
Definition: hdu.h:792
FitsArray< FitsVADesc > VADescFitsArray
Definition: hdu.h:1031
FitsArray< char > CharFitsArray
Definition: hdu.h:1022
PrimaryArray< double > DoublePrimaryArray
Definition: hdu.h:502
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
ImageExtension< FitsLong > LongImageExtension
Definition: hdu.h:566
FitsArray< FitsLogical > LogicalFitsArray
Definition: hdu.h:1020
PrimaryTable< short > ShortPrimaryTable
Definition: hdu.h:790
FitsField< double > DoubleFitsField
Definition: hdu.h:964
FitsArray< IComplex > IComplexFitsArray
Definition: hdu.h:1029
PrimaryGroup< unsigned char > BytePrimaryGroup
Definition: hdu.h:690
FitsField< DComplex > DComplexFitsField
Definition: hdu.h:967
const Bool True
Definition: aipstype.h:43
PrimaryGroup< FitsLong > LongPrimaryGroup
Definition: hdu.h:692
FitsField< FitsLogical > LogicalFitsField
Definition: hdu.h:957
PrimaryArray< short > ShortPrimaryArray
Definition: hdu.h:499
FitsField< IComplex > IComplexFitsField
Definition: hdu.h:966
PrimaryTable< unsigned char > BytePrimaryTable
Definition: hdu.h:789
FitsArray< double > DoubleFitsArray
Definition: hdu.h:1027
PrimaryGroup< float > FloatPrimaryGroup
Definition: hdu.h:693
FitsArray< FitsBit > BitFitsArray
Definition: hdu.h:1021
ImageExtension< double > DoubleImageExtension
Definition: hdu.h:568