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