RTC Toolkit  0.1.0-alpha
fitsIoFunctions.hpp
Go to the documentation of this file.
1 
9 #ifndef RTCTK_COMPONENTFRAMEWORK_FITSIOFUNCTIONS_HPP
10 #define RTCTK_COMPONENTFRAMEWORK_FITSIOFUNCTIONS_HPP
11 
12 #include <cassert>
13 #include <type_traits>
14 #include <limits>
15 #include <string>
16 #include <boost/filesystem.hpp>
17 #include <unistd.h>
18 #include <fitsio.h>
22 
23 namespace {
24 
31 template <typename T>
32 void IdentifyCfitsioTypes(int& bitpix, int& datatype) {
33  if constexpr (std::is_integral_v<T>) {
34  if constexpr (std::is_same_v<T, bool>) {
35  bitpix = BYTE_IMG;
36  datatype = TBYTE;
37  } else if constexpr (sizeof(T) == 1) {
38  if constexpr (std::is_signed_v<T>) {
39  bitpix = SBYTE_IMG;
40  datatype = TSBYTE;
41  } else {
42  bitpix = BYTE_IMG;
43  datatype = TBYTE;
44  }
45  } else if constexpr (sizeof(T) == 2) {
46  if constexpr (std::is_signed_v<T>) {
47  bitpix = SHORT_IMG;
48  datatype = TSHORT;
49  } else {
50  bitpix = USHORT_IMG;
51  datatype = TUSHORT;
52  }
53  } else if constexpr (sizeof(T) == 4) {
54  if constexpr (std::is_signed_v<T>) {
55  bitpix = LONG_IMG;
56  if constexpr (sizeof(int) == 4) {
57  datatype = TINT;
58  } else if constexpr (sizeof(long) == 4) {
59  datatype = TLONG;
60  } else {
61  static_assert(sizeof(int) == 4 or sizeof(long) == 4,
62  "Require either int or long type to be 32 bits wide.");
63  }
64  } else {
65  bitpix = ULONG_IMG;
66  if constexpr (sizeof(unsigned int) == 4) {
67  datatype = TUINT;
68  } else if constexpr (sizeof(unsigned long) == 4) {
69  datatype = TULONG;
70  } else {
71  static_assert(sizeof(unsigned int) == 4 or sizeof(unsigned long) == 4,
72  "Require either unsigned int or unsigned long type to be 32 bits wide.");
73  }
74  }
75  } else if constexpr (sizeof(T) == 8) {
76  if constexpr (std::is_signed_v<T>) {
77  bitpix = LONGLONG_IMG;
78  datatype = TLONGLONG;
79  } else {
80 #ifdef ULONGLONG_IMG
81  bitpix = ULONGLONG_IMG;
82  datatype = TULONGLONG;
83 #else
84  // If we are using an older Cfitsio library that does not have ULONGLONG_IMG defined
85  // then simply alias to using the signed version for the image code and data type.
86  bitpix = LONGLONG_IMG;
87  datatype = TLONGLONG;
88 #endif
89  }
90  } else {
91  static_assert(sizeof(T) == 1 or sizeof(T) == 2 or sizeof(T) == 4 or sizeof(T) == 8,
92  "The integer type used as the template parameter must be one of 8, 16, 32, or 64"
93  " bits wide.");
94  }
95  } if constexpr (std::is_floating_point_v<T>) {
96  if constexpr (sizeof(T) == 4) {
97  bitpix = FLOAT_IMG;
98  datatype = TFLOAT;
99  } else if constexpr (sizeof(T) == 8) {
100  bitpix = DOUBLE_IMG;
101  datatype = TDOUBLE;
102  } else {
103  static_assert(sizeof(T) == 4 or sizeof(T) == 8,
104  "The floating-point type used as the template parameter must be float or double.");
105  }
106  } else {
107  static_assert(std::is_arithmetic_v<T>,
108  "The template parameter used must be an integer or floating-point type.");
109  }
110 }
111 
112 } // namespace anonymous
113 
114 namespace rtctk::componentFramework {
115 
116 std::string GetCfitsioErrorMsg(int status);
117 std::string CfitsioImageTypeToString(int bitpix);
118 std::string CfitsioDataTypeToString(int datatype);
119 
125 template <typename T, typename A>
126 void WriteMatrixToFits(const std::string& filename, const MatrixBuffer<T, A>& matrix) {
127  assert(int64_t(matrix.get_nrows()) <= int64_t(std::numeric_limits<long>::max()));
128  assert(int64_t(matrix.get_ncols()) <= int64_t(std::numeric_limits<long>::max()));
129 
130  // Workout the appropriate Cfitsio image type code and data type code to use, based on the type
131  // used with MatrixBuffer, i.e. the type of T.
132  int bitpix = 0;
133  int datatype = 0;
134  IdentifyCfitsioTypes<T>(bitpix, datatype);
135 
136  std::string tmpfilename = filename + ".new-" + std::to_string(getpid());
137 
138  // Create the new FITS file and open it for modifications.
139  fitsfile* fptr = nullptr;
140  int status = 0; // It is important to initialise this to zero before each Cfitsio API call.
141  if (fits_create_file(&fptr, tmpfilename.c_str(), &status) != 0) {
142  std::string msg = "Failed to create FITS file '" + tmpfilename + "'. "
143  + GetCfitsioErrorMsg(status);
144  CII_THROW(std::runtime_error, msg);
145  }
146 
147  try {
148  // Create the image header in the HDU.
149  long nrows = long(matrix.get_nrows());
150  long ncols = long(matrix.get_ncols());
151  long size[2] = {ncols, nrows};
152  status = 0;
153  if (fits_create_img(fptr, bitpix, 2, size, &status) != 0) {
154  std::string msg = "Failed to create the image type from FITS file '" + tmpfilename
155  + "'. " + GetCfitsioErrorMsg(status);
156  CII_THROW(std::runtime_error, msg);
157  }
158 
159  // Write the matrix data as pixels.
160  long fpixel[2] = {1, 1}; // Pixel start location. Cfitsio counts from 1, not 0.
161  long nelements = matrix.size();
162  // We are forced to use const_cast, since the fits_write_pix function does not accept
163  // const void*.
164  void* array = const_cast<void*>(reinterpret_cast<const void*>(matrix.data()));
165  status = 0;
166  if (fits_write_pix(fptr, datatype, fpixel, nelements, array, &status) != 0) {
167  std::string msg = "Failed to write the matrix to FITS file '" + tmpfilename + "'. "
168  + GetCfitsioErrorMsg(status);
169  CII_THROW(std::runtime_error, msg);
170  }
171  } catch (...) {
172  // Attempt to close the FITS file if an exception was thrown. But do not throw an additional
173  // exception if closing the file failed. Just log this error and rethrow the original
174  // exception.
175  status = 0;
176  if (fits_close_file(fptr, &status) != 0) {
177  LOG4CPLUS_ERROR(GetLogger(), "Failed to close file '" + tmpfilename
178  + "' while handling an exception. " + GetCfitsioErrorMsg(status));
179  }
180  throw;
181  }
182 
183  status = 0;
184  if (fits_close_file(fptr, &status) != 0) {
185  std::string msg = "Failed to close the FITS file '" + tmpfilename + "'. "
186  + GetCfitsioErrorMsg(status);
187  CII_THROW(std::runtime_error, msg);
188  }
189 
190  // Rename the temporary file to its final value. Updating the file in this manner will make sure
191  // that different processes or threads will see changes to the file in an atomic manner. Either
192  // the old file will be visible, or the new file, but not a partially modified file.
193  try {
194  boost::filesystem::rename(tmpfilename, filename);
195  } catch (const std::exception& error) {
196  CII_THROW_WITH_NESTED(std::runtime_error, error,
197  "Failed to rename FITS file '" + tmpfilename + "' to '" + filename + "'.")
198  }
199 }
200 
206 template <typename T, typename A>
207 void ReadMatrixFromFits(const std::string& filename, MatrixBuffer<T, A>& matrix) {
208  // Identify the Cfitsio data type code to be used and the expected Cfitsio image type code,
209  // based on the type used with MatrixBuffer, i.e. type of T.
210  int expected_bitpix = 0;
211  int datatype = 0;
212  IdentifyCfitsioTypes<T>(expected_bitpix, datatype);
213 
214  fitsfile* fptr = nullptr;
215  int status = 0; // It is important to initialise this to zero before every Cfitsio API call.
216  if (fits_open_image(&fptr, filename.c_str(), READONLY, &status) != 0) {
217  std::string msg = "Failed to open FITS file '" + filename + "'. "
218  + GetCfitsioErrorMsg(status);
219  CII_THROW(std::runtime_error, msg);
220  }
221 
222  try {
223  // Read and check that the pixel format used in the FITS file corresponds to the type used
224  // for the matrix object passed to this function.
225  int bitpix = -1;
226  status = 0;
227  if (fits_get_img_equivtype(fptr, &bitpix, &status) != 0) {
228  std::string msg = "Failed to read the image type from FITS file '" + filename + "'. "
229  + GetCfitsioErrorMsg(status);
230  CII_THROW(std::runtime_error, msg);
231  }
232  if (bitpix == LONGLONG_IMG) {
233  // NOTE: Correcting the bitpix for ULONGLONG_IMG. There is a bug in Cfitsio that returns
234  // LONGLONG_IMG instead of ULONGLONG_IMG.
235  char value[80]; // Use maximum possible FITS card size of 80 bytes.
236  status = 0;
237  int result = fits_read_keyword(fptr, "BZERO", value, nullptr, &status);
238  if (result != 0 and status != KEY_NO_EXIST) {
239  std::string msg = "Failed to read keyword BZERO from '" + filename + "'. "
240  + GetCfitsioErrorMsg(status);
241  CII_THROW(std::runtime_error, msg);
242  }
243  if (std::string(value) == std::to_string(std::numeric_limits<uint64_t>::max()/2+1)) {
244 #ifdef ULONGLONG_IMG
245  bitpix = ULONGLONG_IMG;
246 #else
247  // If we are dealing with an older Cfitsio library that does not have ULONGLONG_IMG
248  // defined, then simply alias to using the signed version instead.
249  bitpix = LONGLONG_IMG;
250 #endif
251  }
252  }
253  if (bitpix != expected_bitpix) {
254  std::string msg = "The FITS file '" + filename + "' has the wrong image format of " +
255  CfitsioImageTypeToString(bitpix) + ". Expected a"
256  " FITS image of type " + CfitsioImageTypeToString(expected_bitpix) + ".";
257  CII_THROW(std::runtime_error, msg);
258  }
259 
260  // Read and check that the number of image axes is 2.
261  int naxis = -1;
262  status = 0;
263  if (fits_get_img_dim(fptr, &naxis, &status) != 0) {
264  std::string msg = "Failed to read the number of image axes from FITS file '"
265  + filename + "'. " + GetCfitsioErrorMsg(status);
266  CII_THROW(std::runtime_error, msg);
267  }
268  if (naxis != 2) {
269  std::string msg = "The FITS file '" + filename + "' has image dimensions that we cannot"
270  " handle. Expect a 2D image when loading as a matrix.";
271  CII_THROW(std::runtime_error, msg);
272  }
273 
274  long size[2] = {-1, -1};
275  status = 0;
276  if (fits_get_img_size(fptr, 2, size, &status) != 0) {
277  std::string msg = "Failed to read the image size from FITS file '" + filename + "'. "
278  + GetCfitsioErrorMsg(status);
279  CII_THROW(std::runtime_error, msg);
280  }
281 
282  using size_type = typename MatrixBuffer<T, A>::size_type;
283  auto nrows = size_type(size[1]);
284  auto ncols = size_type(size[0]);
285  long nelements = size[0] * size[1]; // Total number of pixels, i.e. rows * columns.
286 
287  long fpixel[2] = {1, 1}; // Pixel start location. Cfitsio counts from 1, not 0.
288  int anynull = 0; // Boolean flag indicating if there were any null/nil pixel values.
289  matrix.resize(nrows, ncols);
290  void* array = matrix.data();
291  status = 0;
292  if (fits_read_pix(fptr, datatype, fpixel, nelements, nullptr, array, &anynull,
293  &status) != 0) {
294  std::string msg = "Failed to read the image from FITS file '" + filename + "'. "
295  + GetCfitsioErrorMsg(status);
296  CII_THROW(std::runtime_error, msg);
297  }
298  } catch (...) {
299  // Attempt to close the FITS file if an exception was thrown. But do not throw an additional
300  // exception if closing the file failed. Just log this error and rethrow the original
301  // exception.
302  status = 0;
303  if (fits_close_file(fptr, &status) != 0) {
304  LOG4CPLUS_ERROR(GetLogger(), "Failed to close file '" + filename
305  + "' while handling an exception. "+ GetCfitsioErrorMsg(status));
306  }
307  throw;
308  }
309 
310  status = 0;
311  if (fits_close_file(fptr, &status) != 0) {
312  std::string msg = "Failed to close the FITS file '" + filename + "'. "
313  + GetCfitsioErrorMsg(status);
314  CII_THROW(std::runtime_error, msg);
315  }
316 }
317 
323 template <typename T, typename A>
324 void WriteVectorToFits(const std::string& filename, const std::vector<T, A>& vector) {
325  assert(int64_t(vector.size()) <= int64_t(std::numeric_limits<long>::max()));
326 
327  // Workout the appropriate Cfitsio image type code and data type code to use, based on the type
328  // used with std::vector, i.e. the type of T.
329  int bitpix = 0;
330  int datatype = 0;
331  IdentifyCfitsioTypes<T>(bitpix, datatype);
332 
333  std::string tmpfilename = filename + ".new-" + std::to_string(getpid());
334 
335  // Create the new FITS file and open it for modifications.
336  fitsfile* fptr = nullptr;
337  int status = 0; // It is important to initialise this to zero before each Cfitsio API call.
338  if (fits_create_file(&fptr, tmpfilename.c_str(), &status) != 0) {
339  std::string msg = "Failed to create FITS file '" + tmpfilename + "'. "
340  + GetCfitsioErrorMsg(status);
341  CII_THROW(std::runtime_error, msg);
342  }
343 
344  try {
345  // Create the image header in the HDU.
346  long size = long(vector.size());
347  status = 0;
348  if (fits_create_img(fptr, bitpix, 1, &size, &status) != 0) {
349  std::string msg = "Failed to create the image type from FITS file '" + tmpfilename
350  + "'. " + GetCfitsioErrorMsg(status);
351  CII_THROW(std::runtime_error, msg);
352  }
353 
354  // Write the vector data as pixels.
355  long fpixel = 1; // Pixel start location. Cfitsio counts from 1, not 0.
356  long nelements = vector.size();
357  // We are forced to use const_cast, since the fits_write_pix function does not accept
358  // const void*.
359  void* array = const_cast<void*>(reinterpret_cast<const void*>(vector.data()));
360  status = 0;
361  if (fits_write_pix(fptr, datatype, &fpixel, nelements, array, &status) != 0) {
362  std::string msg = "Failed to write the vector to FITS file '" + tmpfilename + "'. "
363  + GetCfitsioErrorMsg(status);
364  CII_THROW(std::runtime_error, msg);
365  }
366  } catch (...) {
367  // Attempt to close the FITS file if an exception was thrown. But do not throw an additional
368  // exception if closing the file failed. Just log this error and rethrow the original
369  // exception.
370  status = 0;
371  if (fits_close_file(fptr, &status) != 0) {
372  LOG4CPLUS_ERROR(GetLogger(), "Failed to close file '" + tmpfilename
373  + "' while handling an exception. " + GetCfitsioErrorMsg(status));
374  }
375  throw;
376  }
377 
378  status = 0;
379  if (fits_close_file(fptr, &status) != 0) {
380  std::string msg = "Failed to close the FITS file '" + tmpfilename + "'. "
381  + GetCfitsioErrorMsg(status);
382  CII_THROW(std::runtime_error, msg);
383  }
384 
385  // Rename the temporary file to its final value. Updating the file in this manner will make sure
386  // that different processes or threads will see changes to the file in an atomic manner. Either
387  // the old file will be visible, or the new file, but not a partially modified file.
388  try {
389  boost::filesystem::rename(tmpfilename, filename);
390  } catch (const std::exception& error) {
391  CII_THROW_WITH_NESTED(std::runtime_error, error,
392  "Failed to rename FITS file '" + tmpfilename + "' to '" + filename + "'.")
393  }
394 }
395 
401 template <typename T, typename A>
402 void ReadVectorFromFits(const std::string& filename, std::vector<T, A>& vector) {
403  // Identify the Cfitsio data type code to be used and the expected Cfitsio image type code,
404  // based on the type used with std::vector, i.e. type of T.
405  int expected_bitpix = 0;
406  int datatype = 0;
407  IdentifyCfitsioTypes<T>(expected_bitpix, datatype);
408 
409  fitsfile* fptr = nullptr;
410  int status = 0; // It is important to initialise this to zero before every Cfitsio API call.
411  if (fits_open_image(&fptr, filename.c_str(), READONLY, &status) != 0) {
412  std::string msg = "Failed to open FITS file '" + filename + "'. "
413  + GetCfitsioErrorMsg(status);
414  CII_THROW(std::runtime_error, msg);
415  }
416 
417  try {
418  // Read and check that the pixel format used in the FITS file corresponds to the type used
419  // for the vector object passed to this function.
420  int bitpix = -1;
421  status = 0;
422  if (fits_get_img_equivtype(fptr, &bitpix, &status) != 0) {
423  std::string msg = "Failed to read the image type from FITS file '" + filename + "'. "
424  + GetCfitsioErrorMsg(status);
425  CII_THROW(std::runtime_error, msg);
426  }
427  if (bitpix == LONGLONG_IMG) {
428  // NOTE: Correcting the bitpix for ULONGLONG_IMG. There is a bug in Cfitsio that returns
429  // LONGLONG_IMG instead of ULONGLONG_IMG.
430  char value[80]; // Use maximum possible FITS card size of 80 bytes.
431  status = 0;
432  int result = fits_read_keyword(fptr, "BZERO", value, nullptr, &status);
433  if (result != 0 and status != KEY_NO_EXIST) {
434  std::string msg = "Failed to read keyword BZERO from '" + filename + "'. "
435  + GetCfitsioErrorMsg(status);
436  CII_THROW(std::runtime_error, msg);
437  }
438  if (std::string(value) == std::to_string(std::numeric_limits<uint64_t>::max()/2+1)) {
439 #ifdef ULONGLONG_IMG
440  bitpix = ULONGLONG_IMG;
441 #else
442  // If we are dealing with an older Cfitsio library that does not have ULONGLONG_IMG
443  // defined, then simply alias to using the signed version instead.
444  bitpix = LONGLONG_IMG;
445 #endif
446  }
447  }
448  if (bitpix != expected_bitpix) {
449  std::string msg = "The FITS file '" + filename + "' has the wrong image format of " +
450  CfitsioImageTypeToString(bitpix) + ". Expected a"
451  " FITS image of type " + CfitsioImageTypeToString(expected_bitpix) + ".";
452  CII_THROW(std::runtime_error, msg);
453  }
454 
455  // Read and check that the number of image axes is 2.
456  int naxis = -1;
457  status = 0;
458  if (fits_get_img_dim(fptr, &naxis, &status) != 0) {
459  std::string msg = "Failed to read the number of image axes from FITS file '"
460  + filename + "'. " + GetCfitsioErrorMsg(status);
461  CII_THROW(std::runtime_error, msg);
462  }
463  if (naxis != 1) {
464  std::string msg = "The FITS file '" + filename + "' has image dimensions that we cannot"
465  " handle. Expect a 1D image when loading as a vector.";
466  CII_THROW(std::runtime_error, msg);
467  }
468 
469  long nelements = -1;
470  status = 0;
471  if (fits_get_img_size(fptr, 1, &nelements, &status) != 0) {
472  std::string msg = "Failed to read the 1D image size from FITS file '" + filename + "'. "
473  + GetCfitsioErrorMsg(status);
474  CII_THROW(std::runtime_error, msg);
475  }
476 
477  using size_type = typename std::vector<T, A>::size_type;
478  long fpixel = 1; // Pixel start location. Cfitsio counts from 1, not 0.
479  int anynull = 0; // Boolean flag indicating if there were any null/nil pixel values.
480  vector.resize(size_type(nelements));
481  void* array = vector.data();
482  status = 0;
483  if (fits_read_pix(fptr, datatype, &fpixel, nelements, nullptr, array, &anynull,
484  &status) != 0) {
485  std::string msg = "Failed to read the image from FITS file '" + filename + "'. "
486  + GetCfitsioErrorMsg(status);
487  CII_THROW(std::runtime_error, msg);
488  }
489  } catch (...) {
490  // Attempt to close the FITS file if an exception was thrown. But do not throw an additional
491  // exception if closing the file failed. Just log this error and rethrow the original
492  // exception.
493  status = 0;
494  if (fits_close_file(fptr, &status) != 0) {
495  LOG4CPLUS_ERROR(GetLogger(), "Failed to close file '" + filename
496  + "' while handling an exception. "+ GetCfitsioErrorMsg(status));
497  }
498  throw;
499  }
500 
501  status = 0;
502  if (fits_close_file(fptr, &status) != 0) {
503  std::string msg = "Failed to close the FITS file '" + filename + "'. "
504  + GetCfitsioErrorMsg(status);
505  CII_THROW(std::runtime_error, msg);
506  }
507 }
508 
509 // The following are template specialisations for vectors and matrices of boolean values.
510 
514 template <typename A>
515 void WriteMatrixToFits(const std::string& filename, const MatrixBuffer<bool, A>& matrix) {
516  // Concert the boolean matrix to a matrix of 8 bit integers and write that to file instead.
517  MatrixBuffer<int8_t> int_matrix;
518  int_matrix.resize(matrix.get_nrows(), matrix.get_ncols());
519  for (MatrixBuffer<int8_t>::size_type n = 0; n < int_matrix.get_nrows(); ++n) {
520  for (MatrixBuffer<int8_t>::size_type m = 0; m < int_matrix.get_ncols(); ++m) {
521  int_matrix(n, m) = matrix(n, m) ? 1 : 0;
522  }
523  }
524  WriteMatrixToFits(filename, int_matrix);
525 }
526 
530 template <typename A>
531 void ReadMatrixFromFits(const std::string& filename, MatrixBuffer<bool, A>& matrix) {
532  // Load the matrix from file as 8 bit integers and convert it to a boolean matrix.
533  MatrixBuffer<int8_t> int_matrix;
534  ReadMatrixFromFits(filename, int_matrix);
535  matrix.resize(int_matrix.get_nrows(), int_matrix.get_ncols());
536  for (MatrixBuffer<int8_t>::size_type n = 0; n < int_matrix.get_nrows(); ++n) {
537  for (MatrixBuffer<int8_t>::size_type m = 0; m < int_matrix.get_ncols(); ++m) {
538  matrix(n, m) = int_matrix(n, m) == 1 ? true : false;
539  }
540  }
541 }
542 
546 template <typename A>
547 void WriteVectorToFits(const std::string& filename, const std::vector<bool, A>& vector) {
548  // Concert the boolean vector to a vector of 8 bit integers and write that to file instead.
549  std::vector<int8_t> int_vector;
550  int_vector.resize(vector.size());
551  for (std::vector<int8_t>::size_type n = 0; n < int_vector.size(); ++n) {
552  int_vector[n] = vector[n] ? 1 : 0;
553  }
554  WriteVectorToFits(filename, int_vector);
555 }
556 
560 template <typename A>
561 void ReadVectorFromFits(const std::string& filename, std::vector<bool, A>& vector) {
562  // Load the vector from file as 8 bit integers and convert it to a boolean vector.
563  std::vector<int8_t> int_vector;
564  ReadVectorFromFits(filename, int_vector);
565  vector.resize(int_vector.size());
566  for (std::vector<int8_t>::size_type n = 0; n < int_vector.size(); ++n) {
567  vector[n] = int_vector[n] == 1 ? true : false;
568  }
569 }
570 
571 } // namespace rtctk::componentFramework
572 
573 #endif // RTCTK_COMPONENTFRAMEWORK_FITSIOFUNCTIONS_HPP
rtctk::componentFramework::CfitsioDataTypeToString
std::string CfitsioDataTypeToString(int datatype)
Definition: fitsIoFunctions.cpp:57
exceptions.hpp
Provides macros and utilities for exception handling.
rtctk::componentFramework::ReadVectorFromFits
void ReadVectorFromFits(const std::string &filename, std::vector< T, A > &vector)
Definition: fitsIoFunctions.hpp:402
rtctk::componentFramework::MatrixBuffer::resize
constexpr void resize(size_type n, size_type m)
Definition: matrixBuffer.hpp:63
rtctk::componentFramework
Definition: rtcComponent.hpp:17
rtctk::componentFramework::WriteVectorToFits
void WriteVectorToFits(const std::string &filename, const std::vector< T, A > &vector)
Definition: fitsIoFunctions.hpp:324
matrixBuffer.hpp
Declaration of the MatrixBuffer template class used in APIs.
rtctk::componentFramework::ReadMatrixFromFits
void ReadMatrixFromFits(const std::string &filename, MatrixBuffer< T, A > &matrix)
Definition: fitsIoFunctions.hpp:207
rtctk::componentFramework::WriteMatrixToFits
void WriteMatrixToFits(const std::string &filename, const MatrixBuffer< T, A > &matrix)
Definition: fitsIoFunctions.hpp:126
CII_THROW_WITH_NESTED
#define CII_THROW_WITH_NESTED(exceptionType_t, nested_exception,...)
Throw exception with information about the throw location.
Definition: exceptions.hpp:433
rtctk::componentFramework::GetLogger
log4cplus::Logger & GetLogger(const std::string &name="")
CII_THROW
#define CII_THROW(exceptionType_t,...)
Throw exception with information about the throw location.
Definition: exceptions.hpp:422
rtctk::componentFramework::MatrixBuffer::get_nrows
size_type get_nrows() const
Definition: matrixBuffer.hpp:87
logger.hpp
Logging Support Library based on log4cplus.
rtctk::componentFramework::CfitsioImageTypeToString
std::string CfitsioImageTypeToString(int bitpix)
Definition: fitsIoFunctions.cpp:33
rtctk::componentFramework::MatrixBuffer::get_ncols
size_type get_ncols() const
Definition: matrixBuffer.hpp:91
error
void error(const char *msg)
Definition: main.cpp:29
rtctk::componentFramework::MatrixBuffer
Definition: matrixBuffer.hpp:19
rtctkExampleDataTaskGenFitsData.filename
filename
Definition: rtctkExampleDataTaskGenFitsData.py:13
rtctk::componentFramework::GetCfitsioErrorMsg
std::string GetCfitsioErrorMsg(int status)
Definition: fitsIoFunctions.cpp:18