30     _fitsFile(new 
fits::Fits(fileName, 
"r", 
fits::Fits::AUTO_CLOSE | 
fits::Fits::AUTO_CHECK))
 
   34     _hdu = _fitsFile->
getHdu();
 
   40     _fitsFile(new 
fits::Fits(manager, 
"r", 
fits::Fits::AUTO_CLOSE | 
fits::Fits::AUTO_CHECK))
 
   44     _hdu = _fitsFile->
getHdu();
 
   73             "FitsReader not initialized; desired HDU is probably missing." 
   81     checkFitsFile(_fitsFile);
 
   88     if (origin == 
LOCAL) {
 
   97     } 
else if (origin == 
PARENT) {
 
  106     checkFitsFile(_fitsFile);
 
  107     if (_metadata == 
nullptr) {
 
  111         auto computeShape = [
this](){
 
  117                 ndarray::Vector<ndarray::Size, 3> shape3 = _fitsFile->
getImageShape<3>();
 
  118                 if (shape3[0] != 1) {
 
  121                         str(
boost::format(
"Error reading %s: HDU %d has 3rd dimension %d != 1") %
 
  124                 return shape3.last<2>();
 
  128                 str(
boost::format(
"Error reading %s: HDU %d has %d dimensions") %
 
  135         ndarray::Vector<ndarray::Size, 2> shape = computeShape();
 
  146 template <
typename T>
 
  149     static_assert(L::is_specialized, 
"makeDTypeString requires a primitive numeric template parameter.");
 
  170 template <
typename T>
 
  173     checkFitsFile(_fitsFile);
 
  176     if (subBBox.isEmpty()) {
 
  178     } 
else if (!fullBBox.contains(subBBox)) {
 
  181             str(
boost::format(
"Subimage box (%d,%d) %dx%d doesn't fit in image (%d,%d) %dx%d in HDU %d") %
 
  182                 subBBox.getMinX() % subBBox.getMinY() % subBBox.getWidth() % subBBox.getHeight() %
 
  183                 fullBBox.getMinX() % fullBBox.getMinY() % fullBBox.getWidth() % fullBBox.getHeight() % _hdu)
 
  190             str(
boost::format(
"Incompatible type for FITS image: on disk is %s (HDU %d), in-memory is %s. " 
  191                               "Read with allowUnsafe=True to permit conversions that may overflow.") %
 
  195     ndarray::Array<T, 2, 2> 
result = ndarray::allocate(subBBox.getHeight(), subBBox.getWidth());
 
  196     ndarray::Vector<int, 2> offset = ndarray::makeVector(subBBox.getMinY() - fullBBox.getMinY(),
 
  197                                                          subBBox.getMinX() - fullBBox.getMinX());
 
  203 #define INSTANTIATE(T) \ 
  204     template ndarray::Array<T, 2, 2> ImageBaseFitsReader::readArray( \ 
  205         lsst::geom::Box2I const & bbox, \ 
  206         ImageOrigin origin, \ 
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
 
An exception thrown when problems are found when reading or writing FITS files.
 
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
 
void readImage(ndarray::Array< T, N, N > const &array, ndarray::Vector< int, N > const &offset)
Read an array from a FITS image.
 
int getImageDim()
Return the number of dimensions in the current HDU.
 
void setHdu(int hdu, bool relative=false)
Set the current HDU.
 
bool checkCompressedImagePhu()
Go to the first image header in the FITS file.
 
ndarray::Vector< ndarray::Size, N > getImageShape()
Return the shape of the current (image) HDU.
 
std::string getImageDType()
Return the numpy dtype equivalent of the image pixel type (e.g.
 
int getHdu()
Return the current HDU (0-indexed; 0 is the Primary HDU).
 
bool checkImageType()
Return true if the current HDU is compatible with the given pixel type.
 
An exception thrown when a FITS file has the wrong type.
 
RAII scoped guard for moving the HDU in a Fits object.
 
Lifetime-management for memory that goes into FITS memory files.
 
lsst::geom::Point2I readXY0(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT)
Read the image origin from the on-disk image or a subimage thereof.
 
std::shared_ptr< daf::base::PropertyList > readMetadata()
Read the image's FITS header.
 
ndarray::Array< T, 2, 2 > readArray(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT, bool allowUnsafe=false)
Read the image's data array.
 
std::string getFileName() const
Return the name of the file this reader targets.
 
lsst::geom::Box2I readBBox(ImageOrigin origin=PARENT)
Read the bounding box of the on-disk image.
 
~ImageBaseFitsReader() noexcept
 
std::string readDType() const
Read a string describing the pixel type of the on-disk image.
 
ImageBaseFitsReader(std::string const &fileName, int hdu=fits::DEFAULT_HDU)
Construct a FITS reader object.
 
An integer coordinate rectangle.
 
Point2I const getMin() const noexcept
 
Extent2I const getDimensions() const noexcept
 
Reports attempts to exceed implementation-defined length limits for some classes.
 
#define LSST_FITS_EXCEPT(type, fitsObj,...)
A FITS-related replacement for LSST_EXCEPT that takes an additional Fits object and uses makeErrorMes...
 
const int DEFAULT_HDU
Specify that the default HDU should be read.
 
std::shared_ptr< daf::base::PropertyList > readMetadata(std::string const &fileName, int hdu=DEFAULT_HDU, bool strip=false)
Read FITS header.
 
lsst::geom::Point2I getImageXY0FromMetadata(daf::base::PropertySet &metadata, std::string const &wcsName, bool strip=false)
 
std::string const wcsNameForXY0
 
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
 
Extent< int, 2 > Extent2I
 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
 
A base class for image defects.