FITSFile.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2008 by Jonathan Khoo
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __FITSFile_h
10 #define __FITSFile_h
11 
12 #include "fitsio.h"
13 
14 #include "Pulsar/Archive.h"
15 
16 #include "dsp/File.h"
17 #include "dsp/BitSeries.h"
18 
19 namespace dsp
20 {
21 
22  class FITSUnpacker;
23 
25  class FITSFile : public File
26  {
27  public:
29  FITSFile(const char* filename = 0);
30 
32  bool is_valid(const char* filename) const;
33 
35  void close ();
36 
38  void reopen ();
39 
40  void add_extensions (Extensions*);
41 
42  unsigned get_samples_in_row() const { return samples_in_row; }
43 
44  unsigned get_bytes_per_row() { return bytes_per_row; }
45 
46  class Extension;
47 
48  protected:
49  friend class FITSUnpacker;
50 
52  virtual void open_file(const char* filename);
53 
55  virtual int64_t load_bytes(unsigned char* buffer, uint64_t bytes);
56 
58  int64_t seek_bytes (uint64_t bytes);
59 
60  void set_samples_in_row (unsigned n) { samples_in_row = n; }
61 
62  void set_bytes_per_row(const unsigned bytes) { bytes_per_row = bytes; }
63 
64  void set_data_colnum(const int colnum) { data_colnum = colnum; }
65 
66  int get_data_colnum() const { return data_colnum; }
67 
69 
71  int data_colnum;
72 
74  int scl_colnum;
75 
77  int offs_colnum;
78 
80  fitsfile* fp;
81 
83  unsigned samples_in_row;
84 
86  unsigned bytes_per_row;
87 
89  uint64_t current_byte;
90 
92  unsigned current_row;
93 
95  std::vector<float> dat_scl;
96 
98  std::vector<float> dat_offs;
99 
101  unsigned number_of_rows;
102  void set_number_of_rows (unsigned N) { number_of_rows = N; }
103  unsigned get_number_of_rows () const { return number_of_rows; }
104 
106  int signint;
107 
109  float zero_off;
110  };
111 
112  class FITSFile::Extension : public BitSeries::Extension
113  {
114  public:
115 
116  class Row
117  {
118  public:
119 
121  std::vector<float> dat_scl;
122 
124  std::vector<float> dat_offs;
125 
127  uint64_t nsamp;
128  };
129 
131  Extension () { zero_off = 0.0; }
132 
134  float zero_off;
135 
137  std::vector<Row> rows;
138  };
139 
140 }
141 
142 #endif
143 
std::vector< float > dat_offs
Store reference offset.
Definition: FITSFile.h:103
Warning warning
unsigned number_of_rows
Number of rows in the SUBINT table.
Definition: FITSFile.h:106
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
unsigned bytes_per_row
Number of bytes per row in the SUBINT table.
Definition: FITSFile.h:91
unsigned current_row
The last row of data read.
Definition: FITSFile.h:97
static Archive * load(const std::string &name)
virtual int64_t load_bytes(unsigned char *buffer, uint64_t bytes)
Load nbyte bytes of sampled data from the device into buffer.
Definition: FITSFile.C:243
Loads BitSeries data from file.
Definition: File.h:38
bool is_valid(const char *filename) const
Returns true if filename appears to name a valid FITS file.
Definition: FITSFile.C:44
uint64_t current_byte
Current byte offset in the file.
Definition: FITSFile.h:94
Type * get() const
Creates a cloned instance of Pulsar::Archive to be used for output.
Definition: CloneArchive.h:22
fitsfile * fp
Store the instance of fitsfile, so it is only opened once.
Definition: FITSFile.h:85
int offs_colnum
Column number of the DAT_OFFS column in the SUBINT table.
Definition: FITSFile.h:82
float zero_off
Offset to conver unsigned integers to signed integers.
Definition: FITSFile.h:114
A container for storing digitized (generally not floating point) data
Definition: BitSeries.h:35
int64_t seek_bytes(uint64_t bytes)
Set the current byte offset in the file.
Definition: FITSFile.C:236
void close()
Close the file.
Definition: FITSFile.C:203
int signint
Using signed ingegers?
Definition: FITSFile.h:111
int data_colnum
Column number of the DATA column in the SUBINT table.
Definition: FITSFile.h:76
void add_extensions(Extensions *)
Add any extensions.
Definition: FITSFile.C:120
virtual void open_file(const char *filename)
Open the file.
Definition: FITSFile.C:125
void reopen()
Reopen the file.
Definition: FITSFile.C:221
const std::string get_message() const
unsigned samples_in_row
Number of samples per row.
Definition: FITSFile.h:88
int scl_colnum
Column number of the DAT_SCL column in the SUBINT table.
Definition: FITSFile.h:79
FITSFile(const char *filename=0)
Construct and open file.
Definition: FITSFile.C:35
Any additional information required to describe the data.
Definition: BitSeries.h:112
std::vector< float > dat_scl
Store reference spectrum.
Definition: FITSFile.h:100

Generated using doxygen 1.8.17