summaryrefslogtreecommitdiffstats
path: root/tksao/fitsy++/hdu.h
blob: 818f6816b1de9fc9ddd36c69ef214dc3663527df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (C) 1999-2018
// Smithsonian Astrophysical Observatory, Cambridge, MA, USA
// For conditions of distribution and use, see copyright notice in "copyright"

#ifndef __fitshdu_h__
#define __fitshdu_h__

#include <stdlib.h>

#include "column.h"

#define FTY_MAXAXES 10

class FitsHead;

class FitsHDU {
 protected:
  char* extname_;             // EXTNAME keyword
  int extver_;                // EXTVER keyword
  int extlevel_;              // EXTLEVEL keyword

  int bitpix_;                // BITPIX keyword
  int naxes_;                 // NAXIS keyword
  int naxis_[FTY_MAXAXES];    // NAXIS[i] keywords

  size_t realbytes_;      // Number of real bytes
  size_t heapbytes_;      // Number of heap bytes
  size_t allbytes_;       // Number of real bytes + heap bytes
  size_t padbytes_;       // Number of pad bytes
  size_t databytes_;      // Number of total bytes (padded)
  size_t datablocks_;     // Number of total blocks

  char keybuf[9];
  char* keycat(const char*, int);

public:
  FitsHDU(FitsHead*);
  virtual ~FitsHDU();

  virtual void updateCards(FitsHead*);

  const char* extname() {return extname_;}
  int extver() {return extver_;}
  int extlevel() {return extlevel_;}
  int bitpix() {return bitpix_;}
  int naxes() {return naxes_;}
  int naxis(int ii) {return naxis_[ii];}

  size_t realbytes() {return realbytes_;}
  size_t heapbytes() {return heapbytes_;}
  size_t allbytes() {return allbytes_;}
  size_t padbytes() {return padbytes_;}
  size_t databytes() {return databytes_;}
  size_t datablocks() {return datablocks_;}
};

class FitsImageHDU : public FitsHDU {
private:
  size_t imgbytes_;    // number of image bytes

  double bscale_;
  double bzero_;
  int hasblank_;
  int blank_;

public:
  FitsImageHDU(FitsHead*);

  void updateCards(FitsHead*);

  size_t imgbytes() {return imgbytes_;}
  void setScaling(double t,double z) {bscale_=t; bzero_=z;}
  double bscale() {return bscale_;}
  double bzero() {return bzero_;}
  int hasscaling() {return bscale_ != 1 || bzero_ != 0;}
  int hasblank() {return hasblank_;}
  int blank() {return blank_;}
};

class FitsTableHDU : public FitsHDU {
protected:
  int tfields_;
  FitsColumn** cols_;

public:
  FitsTableHDU(FitsHead*);
  virtual ~FitsTableHDU();

  int tfields() {return tfields_;}
  int rows() {return naxis_[1];}
  int cols() {return tfields_;}
  int width() {return naxis_[0];}
  char* list();
  FitsColumn* find(const char*);
  FitsColumn* find(int);
  Vector dimension(const char*);
};

class FitsBinTableHDU : public FitsTableHDU {
public:
  FitsBinTableHDU(FitsHead*);
};

class FitsAsciiTableHDU : public FitsTableHDU {
public:
  FitsAsciiTableHDU(FitsHead*);
};

#endif