LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
2 #ifndef LSST_AFW_fitsCompression_h_INCLUDED
3 #define LSST_AFW_fitsCompression_h_INCLUDED
8 #include "boost/cstdfloat.hpp"
13 #include "ndarray/eigen.h"
33 static int const value = 8;
37 static int const value = 16;
41 static int const value = 32;
45 static int const value = 64;
49 static int const value = 16;
53 static int const value = 32;
57 static int const value = 64;
61 static int const value = -32;
65 static int const value = -64;
105 _manager(array.getManager()) {}
110 template <
typename U>
113 _manager = mem.first;
114 _pixels = mem.second;
121 void const*
getData()
const override {
return _pixels; }
125 ndarray::Manager::Ptr _manager;
133 template <
typename T>
137 return std::make_shared<PixelArray<T>>(array);
139 return std::make_shared<PixelArray<std::uint8_t>>(array);
141 return std::make_shared<PixelArray<std::int16_t>>(array);
143 return std::make_shared<PixelArray<std::int32_t>>(array);
145 return std::make_shared<PixelArray<std::int64_t>>(array);
147 return std::make_shared<PixelArray<boost::float32_t>>(array);
149 return std::make_shared<PixelArray<boost::float64_t>>(array);
152 os <<
"Unrecognized bitpix: " << bitpix;
194 typedef ndarray::Array<long, 1, 1>
Tiles;
202 float quantizeLevel_ = 0.0)
206 float quantizeLevel_ = 0.0)
217 float quantizeLevel_ = 0.0);
223 template <
typename T>
226 template <
typename T>
292 template <
typename T>
294 ndarray::Array<T const, 2, 2>
const&
image,
bool forceNonfiniteRemoval,
bool fuzz =
true,
295 ndarray::Array<long, 1>
const& tiles = ndarray::Array<long, 1, 1>(),
int seed = 1)
const;
302 template <
typename T>
303 ndarray::Array<T, 2, 2>
fromFits(ndarray::Array<T, 2, 2>
const&
image)
const;
395 float quantizeLevel_ = 4.0,
float quantizePad_ = 5.0,
bool fuzz_ =
true,
396 double bscale_ = 1.0,
double bzero_ = 0.0);
407 template <
typename T>
418 template <
typename T,
int N>
420 ndarray::Array<bool, N, N>
const&
mask)
const;
425 template <
typename T>
429 if (
mask &&
image.getDimensions() !=
mask->getDimensions()) {
431 os <<
"Size mismatch between image and mask: ";
434 os <<
mask->getWidth() <<
"x" <<
mask->getHeight();
437 ndarray::Array<T const, 2, 2> imageArray = ndarray::dynamic_dimension_cast<2>(
image.getArray());
438 if (imageArray.empty()) imageArray = ndarray::copy(
image.getArray());
439 ndarray::Array<bool, 2, 2> maskArray = ndarray::allocate(imageArray.getShape());
443 maskArray.deep() =
false;
454 template <
typename T,
int N>
455 ImageScale determineFromRange(ndarray::Array<T const, N, N>
const&
image,
456 ndarray::Array<bool, N, N>
const&
mask,
bool isUnsigned =
false,
457 bool cfitsioPadding =
true)
const;
465 template <
typename T,
int N>
466 ImageScale determineFromStdev(ndarray::Array<T const, N, N>
const&
image,
467 ndarray::Array<bool, N, N>
const&
mask,
bool isUnsigned =
false,
468 bool cfitsioPadding =
true)
const;
481 #endif // ifndef LSST_AFW_fitsCompression_h_INCLUDED
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
ndarray::Array< long, 1, 1 > Tiles
ScalingAlgorithm algorithm
Scaling algorithm to use.
ImageScale(int bitpix_, double bscale_, double bzero_)
Constructor.
int bitpix
Bits per pixel; negative means floating-point: 8,16,32,64,-32,-64.
Represent a 2-dimensional array of bitmask pixels.
Abstract base class for an array of pixel values.
ImageCompressionOptions(CompressionAlgorithm algorithm_, Tiles tiles_, float quantizeLevel_=0.0)
Custom compression.
int compressionAlgorithmToCfitsio(ImageCompressionOptions::CompressionAlgorithm algorithm)
Convert ImageCompressionOptions::CompressionAlgorithm to cfitsio.
CompressionAlgorithm
Compression algorithms.
int bitpix
Bits per pixel (0, 8,16,32,64,-32,-64)
long blank
Value for integer images indicating non-finite values.
virtual ~PixelArrayBase()
std::shared_ptr< PixelArrayBase > makePixelArray(int bitpix, ndarray::Array< T, 1, 1 > const &array)
Create a PixelArray suitable for an image with the nominated BITPIX.
float quantizeLevel
quantization level: 0.0 = none requires use of GZIP or GZIP_SHUFFLE
CompressionAlgorithm algorithm
Compresion algorithm to use.
std::size_t getNumElements() const
Return the number of pixels.
ImageCompressionOptions(image::Image< std::int64_t > const &image)
float quantizeLevel
Divisor of the standard deviation for STDEV_* scaling.
ImageScale determine(ndarray::Array< T const, N, N > const &image, ndarray::Array< bool, N, N > const &mask) const
int seed
Seed for random number generator when fuzzing.
Options for tile compression of image pixels.
ImageCompressionOptions(CompressionAlgorithm algorithm_, std::vector< long > tiles_, float quantizeLevel_=0.0)
@ MANUAL
Scale set manually.
@ STDEV_NEGATIVE
Scale based on the standard deviation, dynamic range negative.
PixelArray(ndarray::Array< U, 1, 1 > const &array)
Construct from an ndarray::Array of different type.
@ STDEV_POSITIVE
Scale based on the standard deviation. dynamic range positive.
void const * getData() const override
Return a void* array of the pixels.
PixelArray(ndarray::Array< T, 1, 1 > const &array)
Construct from an ndarray::Array of the same type.
Options for scaling image pixels.
@ RANGE
Scale to preserve dynamic range.
ImageCompressionOptions::CompressionAlgorithm compressionAlgorithmFromString(std::string const &name)
Interpret compression algorithm expressed in string.
Typed array of pixel values.
virtual void const * getData() const =0
Return a void* array of the pixels.
ImageScale determine(image::ImageBase< T > const &image, std::shared_ptr< image::Mask< image::MaskPixel > const > mask=nullptr) const
Determine the scaling for a particular image.
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
double bzero
Zero-point to apply when reading from FITS.
PixelArrayBase(std::size_t num)
@ GZIP
Standard GZIP compression.
ImageCompressionOptions(image::Mask< T > const &mask)
ImageCompressionOptions(image::Image< std::uint64_t > const &image)
ImageCompressionOptions(image::Mask< std::int64_t > const &mask)
double bscale
Scale to apply when reading from FITS.
Reports invalid arguments.
std::string scalingAlgorithmToString(ImageScalingOptions::ScalingAlgorithm algorithm)
Provide string version of compression algorithm.
double bscale
Manually specified BSCALE (for MANUAL scaling)
ImageScalingOptions(int bitpix_, double bscale_=1.0, double bzero_=0.0)
Manual scaling Ctor.
PixelArray(PixelArray const &)=delete
ImageScalingOptions()
Default Ctor.
std::string compressionAlgorithmToString(ImageCompressionOptions::CompressionAlgorithm algorithm)
Provide string version of compression algorithm.
bool fuzz
Fuzz the values when quantising floating-point values?
double bzero
Manually specified BZERO (for MANUAL scaling)
ImageCompressionOptions(image::Mask< std::uint64_t > const &mask)
@ STDEV_BOTH
Scale based on the standard deviation, dynamic range positive+negative.
ImageCompressionOptions(image::Image< T > const &image)
Default compression for a particular style of image.
float quantizePad
Number of stdev to allow on the low/high side (for STDEV_POSITIVE/NEGATIVE)
FITS BITPIX header value by C++ type.
ImageCompressionOptions::CompressionAlgorithm compressionAlgorithmFromCfitsio(int cfitsio)
Convert compression algorithm from cfitsio to ImageCompressionOptions::CompressionAlgorithm.
A class to represent a 2-dimensional array of pixels.
Extent< int, N > floor(Extent< double, N > const &input) noexcept
Return the component-wise floor (round towards more negative).
Tiles tiles
Tile size; a dimension with 0 means infinite (e.g., to specify one row: 0,1)
std::shared_ptr< detail::PixelArrayBase > toFits(ndarray::Array< T const, 2, 2 > const &image, bool forceNonfiniteRemoval, bool fuzz=true, ndarray::Array< long, 1 > const &tiles=ndarray::Array< long, 1, 1 >(), int seed=1) const
Convert to an array of pixel values to write to FITS.
std::vector< std::string > maskPlanes
Mask planes to ignore when doing statistics.
The base class for all image classed (Image, Mask, MaskedImage, ...)
ImageScalingOptions::ScalingAlgorithm scalingAlgorithmFromString(std::string const &name)
Interpret scaling algorithm expressed in string.
@ GZIP_SHUFFLE
GZIP compression with shuffle (most-significant byte first)
ndarray::Array< T, 2, 2 > fromFits(ndarray::Array< T, 2, 2 > const &image) const
Convert to an array.