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