/usr/include/CCfits/PHDU.h is in libccfits-dev 2.4+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | // Astrophysics Science Division,
// NASA/ Goddard Space Flight Center
// HEASARC
// http://heasarc.gsfc.nasa.gov
// e-mail: ccfits@legacy.gsfc.nasa.gov
//
// Original author: Ben Dorman
#ifndef PHDU_H
#define PHDU_H 1
// valarray
#include <valarray>
// HDU
#include "HDU.h"
// FITS
#include "FITS.h"
// FITSUtil
#include "FITSUtil.h"
namespace CCfits {
class FITSBase;
} // namespace CCfits
// for CLONE_DEFECT
#ifdef _MSC_VER
#include "MSconfig.h"
#endif
namespace CCfits {
/*! \class PHDU
\brief class representing the primary HDU for a FITS file.
A PHDU object is automatically instantiated and added to a FITS
object when a FITS file is accessed in any way. If a new file
is created without specifying the data type for the header, CCfits
assumes that the file is to be used for table extensions and creates
a dummy header. PHDU instances are <i>only</i> created by FITS
ctors. In the first release of CCfits, the Primary cannot be changed once
declared.
PHDU and ExtHDU provide the same interface to writing images: multiple
overloads of the templated PHDU::read and PHDU::write operations provide
for (a) writing image data specified in a number of ways [C-array, std::vector,
std::valarray] and with input location specified by
initial pixel, by n-tuple, and by rectangular subset [generalized slice];
(b) reading image data specified similarly to the write options into a std::valarray.
\todo Implement functions that allow replacement of the primary image
*/
/*! \fn PHDU::PHDU (FITSBase* p, int bpix, int naxis, const std::vector<long>& axes)
\brief Writing Primary HDU constructor, called by PrimaryHDU<T> class
Constructor used for creating new PHDU (i.e. for writing data to FITS).
also doubles as default constructor since all arguments have default values,
which are passed to the HDU constructor
*/
/* !\fn PHDU::PHDU (FITSBase* p)
\brief Reading Primary HDU constructor.
Constructor used when reading the primary HDU from an existing file.
Does nothing except initialize, with the real work done by the subclass
PrimaryHDU<T>.
*/
/*! \fn PHDU::~PHDU ()
\brief destructor
*/
/*! \fn virtual void PHDU::readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()) = 0;
\brief read primary HDU data
Called by FITS ctor, not intended for general use.
parameters control how much gets read on initialization. An abstract function,
implemented in the subclasses.
\param readFlag read the image data if true
\param key a vector of strings of keyword names to be read from the primary HDU
*/
/*! \fn virtual PHDU::clone(FITSbase* p) const = 0;
\brief virtual copy constructor for Primary HDUs.
The operation is used when creating a copy of a FITS object.
*/
/*! \fn bool PHDU::simple () const;
\brief Returns the value of the Primary's SIMPLE keyword.
*/
/*! \fn bool PHDU::extend () const;
\brief Returns the value of the Primary's EXTEND keyword.
*/
/*! \fn template<typename S> void PHDU::read (std::valarray<S>& image,
long first,
long nElements,
S* nullValue) ;
\brief read part of an image array, processing null values.
Implicit data conversion is supported (i.e. user does not need to know the
type of the data stored. A WrongExtensionType extension is thrown
if *this is not an image.
\param image The receiving container, a std::valarray reference
\param first The first pixel from the array to read [a long value]
\param nElements The number of values to read
\param nullValue A pointer containing the value in the table to be
considered as undefined. See cfitsio for details
*/
/*! \fn template<typename S> void PHDU::read (std::valarray<S>& image,
const std::vector<long>& first,
long nElements,
S* nullValue) ;
\brief read part of an image array, processing null values.
As above except for
\param first a vector<long> representing an n-tuple giving the
coordinates in the image of the first pixel.
*/
/*! \fn template<typename S> void PHDU::read (std::valarray<S>& image,
const std::vector<long>& firstVertex,
const std::vector<long>& lastVertex,
const std::vector<long>& stride,
S* nullValue) ;
\brief read an image subset into valarray image, processing null values
The image subset is defined by two vertices and a stride
indicating the 'denseness' of the values to be picked in each
dimension (a stride = (1,1,1,...) means picking every
pixel in every dimension, whereas stride = (2,2,2,...)
means picking every other value in each dimension.
*/
/*! \fn template<typename S> void PHDU::read (std::valarray<S>& image,
long first,
long nElements);
\brief read an image section starting at a specified pixel
*/
/*! \fn template<typename S> void PHDU::read (std::valarray<S>& image,
const std::vector<long>& first,
long nElements);
\brief read an image section starting at a location specified by an n-tuple
*/
/*! \fn template<typename S> void PHDU::read (std::valarray<S>& image,
const std::vector<long>& firstVertex,
const std::vector<long>& lastVertex,
const std::vector<long>& stride);
\brief read an image subset
*/
/*! \fn template <typename S> void PHDU::write(const std::vector<long>& first,
long nElements,
const std::valarray<S>& data,
S* nullValue);
\brief Write a set of pixels to an image extension with the first pixel specified by an n-tuple, processing undefined data
All the overloaded versions of PHDU::write perform operations on *this if
it is an image and throw a WrongExtensionType exception if not.
Where appropriate, alternate versions allow undefined data to be processed
\param first an n-tuple of dimension equal to the image dimension specifying the
first pixel in the range to be written
\param nElements number of pixels to be written
\param data array of data to be written
\param nullValue pointer to null value (data with this value written as undefined; needs
the BLANK keyword to have been specified).
*/
/*! \fn template <typename S> void PHDU::write(long first,
long nElements, const std::valarray<S>& data, S* nullValue);
\brief write array to image starting with a specified pixel and allowing undefined data to be processed
parameters after the first are as for version with n-tuple specifying first element.
these two version are equivalent, except that it is possible for the
first pixel number to exceed the range of 32-bit integers, which is
how long datatype is commonly implemented.
*/
/*! \fn template <typename S> void PHDU::write(const std::vector<long>& first,
long nElements, const std::valarray<S>& data);
\brief write array starting from specified n-tuple, without undefined data processing
*/
/*! \fn template <typename S> void PHDU::write(long first, long nElements,
const std::valarray<S>& data);
\brief write array starting from specified pixel number, without undefined data processing
*/
/*! \fn template <typename S> void PHDU::write(const std::vector<long>& firstVertex,
const std::vector<long>& lastVertex,
const std::vector<long>& stride,
const std::valarray<S>& data);
\brief write a subset (generalize slice) of data to the image
A generalized slice/subset is a subset of the image (e.g. one plane
of a data cube of size <= the dimension of the cube). It is specified
by two opposite vertices. The equivalent cfitsio call does not support
undefined data processing so there is no version that allows a null
value to be specified.
\param firstVertex The coordinates specifying lower and upper vertices of the n-dimensional slice
\param lastVertex
\param stride Pixels to skip in each to dimension, e.g. stride = (1,1,1,...)
means picking every pixel in every dimension, whearas stride = (2,2,2,...)
means picking every other value in each dimension.
\param data The data to be written
*/
/*! \fn PHDU::PHDU(const PHDU& right)
\brief copy constructor
required for cloning primary HDUs when copying FITS files.
*/
class PHDU : public HDU //## Inherits: <unnamed>%394E6F9800C3
{
public:
virtual ~PHDU();
// Read data reads the image if readFlag is true and
// optional keywords if supplied. Thus, with no arguments,
// readData() does nothing.
virtual void readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()) = 0;
virtual PHDU * clone (FITSBase* p) const = 0;
virtual void zero (double value);
virtual void scale (double value);
virtual double zero () const;
virtual double scale () const;
bool simple () const;
bool extend () const;
public:
// Additional Public Declarations
// image reading/writing interface.
// The S template parameter, like for Column, denotes the fact that
// the type of the input array and the object to be read may not match.
// the rw interface for images consists of equivalents for fits_read_img,
// fits_read_pix, and fits_read_subset.
// the paradigm for reading is that the image object (a valarray<T> type)
// is the size of the data already read.
// write_subset has no null value aware analogue.
template <typename S>
void write(const std::vector<long>& first,
long nElements,
const std::valarray<S>& data,
S* nullValue);
template <typename S>
void write(long first,
long nElements,
const std::valarray<S>& data,
S* nullValue);
template <typename S>
void write(const std::vector<long>& first,
long nElements,
const std::valarray<S>& data);
template <typename S>
void write(long first,
long nElements,
const std::valarray<S>& data);
template <typename S>
void write(const std::vector<long>& firstVertex,
const std::vector<long>& lastVertex,
const std::vector<long>& stride,
const std::valarray<S>& data);
// read image data and return an array. Can't return a reference
// because the type conversion needs to allocate a new object in general.
template<typename S>
void read(std::valarray<S>& image) ;
template<typename S>
void read (std::valarray<S>& image, long first,long nElements);
template<typename S>
void read (std::valarray<S>& image, long first,long nElements, S* nullValue) ;
template<typename S>
void read (std::valarray<S>& image, const std::vector<long>& first,long nElements) ;
template<typename S>
void read (std::valarray<S>& image, const std::vector<long>& first, long nElements,
S* nullValue);
template<typename S>
void read (std::valarray<S>& image, const std::vector<long>& firstVertex,
const std::vector<long>& lastVertex,
const std::vector<long>& stride) ;
template<typename S>
void read (std::valarray<S>& image, const std::vector<long>& firstVertex,
const std::vector<long>& lastVertex,
const std::vector<long>& stride,
S* nullValue) ;
protected:
PHDU(const PHDU &right);
// Constructor for new FITS objects, takes as arguments
// the required keywords for a primary HDU.
PHDU (FITSBase* p, int bpix, int naxis, const std::vector<long>& axes);
// Custom constructor. Allows specification of data to be read and whether to read data at
// construction or wait until the image data are requested. The default is 'lazy initialization:'
// wait until asked.
PHDU (FITSBase* p = 0);
virtual void initRead ();
void simple (bool value);
void extend (bool value);
// Additional Protected Declarations
private:
// Additional Private Declarations
private: //## implementation
// Data Members for Class Attributes
bool m_simple;
bool m_extend;
// Additional Implementation Declarations
};
// Class CCfits::PHDU
inline bool PHDU::simple () const
{
return m_simple;
}
inline void PHDU::simple (bool value)
{
m_simple = value;
}
inline bool PHDU::extend () const
{
return m_extend;
}
inline void PHDU::extend (bool value)
{
m_extend = value;
}
} // namespace CCfits
#endif
|