VAPoR  0.1
Public Member Functions | Static Public Member Functions | Friends | List of all members
VAPoR::Compressor Class Reference

A class for managing data set metadata. More...

#include <Compressor.h>

Inheritance diagram for VAPoR::Compressor:
VAPoR::MatWaveWavedec VAPoR::MatWaveDwt VAPoR::MatWaveBase VetsUtil::MyBase

Public Member Functions

 Compressor (std::vector< size_t > dims, const string &wname, const string &mode)
 
 Compressor (std::vector< size_t > dims, const string &wname)
 
 ~Compressor ()
 
int Compress (const float *src_arr, float *dst_arr, size_t dst_arr_len, SignificanceMap *sigmap)
 
int Compress (const double *src_arr, double *dst_arr, size_t dst_arr_len, SignificanceMap *sigmap)
 
int Decompress (const float *src_arr, float *dst_arr, SignificanceMap *sigmap)
 
int Decompress (const double *src_arr, double *dst_arr, SignificanceMap *sigmap)
 
int Decompose (const float *src_arr, float *dst_arr, const vector< size_t > &dst_arr_lens, vector< SignificanceMap > &sigmaps)
 
int Decompose (const double *src_arr, double *dst_arr, const vector< size_t > &dst_arr_lens, vector< SignificanceMap > &sigmaps)
 
int Reconstruct (const float *src_arr, float *dst_arr, vector< SignificanceMap > &sigmaps, int l)
 
int Reconstruct (const double *src_arr, double *dst_arr, vector< SignificanceMap > &sigmaps, int l)
 
void GetSigMapShape (std::vector< size_t > &dims) const
 
size_t GetNumWaveCoeffs () const
 
size_t GetSigMapSize (size_t num_entries) const
 
void GetDimension (vector< size_t > &dims, int l) const
 
int GetNumLevels () const
 
size_t GetMinCompression () const
 
bool & KeepAppOnOff ()
 
bool & ClampMinOnOff ()
 
double & ClampMin ()
 
bool & ClampMaxOnOff ()
 
double & ClampMax ()
 
bool & EpsilonOnOff ()
 
double & Epsilon ()
 
- Public Member Functions inherited from VAPoR::MatWaveWavedec
 MatWaveWavedec (const string &wname, const string &mode)
 
 MatWaveWavedec (const string &wname)
 
virtual ~MatWaveWavedec ()
 
int wavedec (const double *sigIn, size_t sigInLength, int n, double *C, size_t *L)
 
int wavedec (const float *sigIn, size_t sigInLength, int n, float *C, size_t *L)
 
int waverec (const double *C, const size_t *L, int n, double *sigOut)
 
int waverec (const float *C, const size_t *L, int n, float *sigOut)
 
int wavedec2 (const double *sigIn, size_t sigInX, size_t sigInY, int n, double *C, size_t *L)
 
int wavedec2 (const float *sigIn, size_t sigInX, size_t sigInY, int n, float *C, size_t *L)
 
int waverec2 (const double *C, const size_t *L, int n, double *sigOut)
 
int waverec2 (const float *C, const size_t *L, int n, float *sigOut)
 
int wavedec3 (const double *sigIn, size_t sigInX, size_t sigInY, size_t sigInZ, int n, double *C, size_t *L)
 
int wavedec3 (const float *sigIn, size_t sigInX, size_t sigInY, size_t sigInZ, int n, float *C, size_t *L)
 
int waverec3 (const double *C, const size_t *L, int n, double *sigOut)
 
int waverec3 (const float *C, const size_t *L, int n, float *sigOut)
 
int appcoef (const double *C, const size_t *L, int n, int l, bool normal, double *sigOut)
 
int appcoef (const float *C, const size_t *L, int n, int l, bool normal, float *sigOut)
 
int appcoef2 (const double *C, const size_t *L, int n, int l, bool normal, double *sigOut)
 
int appcoef2 (const float *C, const size_t *L, int n, int l, bool normal, float *sigOut)
 
int appcoef3 (const double *C, const size_t *L, int n, int l, bool normal, double *sigOut)
 
int appcoef3 (const float *C, const size_t *L, int n, int l, bool normal, float *sigOut)
 
size_t coefflength (size_t sigInLen, int n) const
 
size_t coefflength (const size_t *L, int n) const
 
size_t approxlength (size_t sigInLen, int n) const
 
void approxlength (const size_t *L, int n, int l, size_t *len) const
 
size_t coefflength2 (size_t sigInX, size_t sigInY, int n) const
 
size_t coefflength2 (const size_t *L, int n) const
 
void approxlength2 (const size_t *L, int n, int l, size_t *lenx, size_t *leny) const
 
size_t coefflength3 (size_t sigInX, size_t sigInY, size_t sigInZ, int n) const
 
size_t coefflength3 (const size_t *L, int n) const
 
void approxlength3 (const size_t *L, int n, int l, size_t *lenx, size_t *leny, size_t *lenz) const
 
void computeL (size_t sigInLen, int n, size_t *L) const
 
void computeL2 (size_t sigInX, size_t sigInY, int n, size_t *L) const
 
void computeL3 (size_t sigInX, size_t sigInY, size_t sigInZ, int n, size_t *L) const
 
- Public Member Functions inherited from VAPoR::MatWaveDwt
 MatWaveDwt (const string &wname, const string &mode)
 
 MatWaveDwt (const string &wname)
 
virtual ~MatWaveDwt ()
 
int dwt (const double *sigIn, size_t sigInLength, double *C, size_t L[3])
 
int dwt (const float *sigIn, size_t sigInLength, float *C, size_t L[3])
 
int dwt (const double *sigIn, size_t sigInLength, double *cA, double *cD, size_t L[3])
 
int dwt (const float *sigIn, size_t sigInLength, float *cA, float *cD, size_t L[3])
 
int idwt (const double *C, const size_t L[3], double *sigOut)
 
int idwt (const float *C, const size_t L[3], float *sigOut)
 
int idwt (const double *cA, const double *cD, const size_t L[3], double *sigOut)
 
int idwt (const float *cA, const float *cD, const size_t L[3], float *sigOut)
 
int dwt2d (const double *sigIn, size_t sigInX, size_t sigInY, double *C, size_t L[10])
 
int dwt2d (const float *sigIn, size_t sigInX, size_t sigInY, float *C, size_t L[10])
 
int dwt2d (const double *sigIn, size_t sigInX, size_t sigInY, double *cA, double *cDh, double *cDv, double *cDd, size_t L[10])
 
int dwt2d (const float *sigIn, size_t sigInX, size_t sigInY, float *cA, float *cDh, float *cDv, float *cDd, size_t L[10])
 
int idwt2d (const double *C, const size_t L[10], double *sigOut)
 
int idwt2d (const float *C, const size_t L[10], float *sigOut)
 
int idwt2d (const double *cA, const double *cDh, const double *cDv, const double *cDd, const size_t L[10], double *sigOut)
 
int idwt2d (const float *cA, const float *cDh, const float *cDv, const float *cDd, const size_t L[10], float *sigOut)
 
int dwt3d (const double *sigIn, size_t sigInX, size_t sigInY, size_t sigInZ, double *C, size_t L[27])
 
int dwt3d (const float *sigIn, size_t sigInX, size_t sigInY, size_t sigInZ, float *C, size_t L[27])
 
int idwt3d (const double *C, const size_t L[27], double *sigOut)
 Single-level inverse discrete 3D wavelet transform. More...
 
int idwt3d (const float *C, const size_t L[27], float *sigOut)
 
int idwt3d (const double *cLLL, const double *cLLH, const double *cLHL, const double *cLHH, const double *cHLL, const double *cHLH, const double *cHHL, const double *cHHH, const size_t L[27], double *sigOut)
 
int idwt3d (const float *cLLL, const float *cLLH, const float *cLHL, const float *cLHH, const float *cHLL, const float *cHLH, const float *cHHL, const float *cHHH, const size_t L[27], float *sigOut)
 
- Public Member Functions inherited from VAPoR::MatWaveBase
 MatWaveBase (const string &wname, const string &mode)
 
 MatWaveBase (const string &wname)
 
virtual ~MatWaveBase ()
 
int dwtmode (const string &mode)
 
int dwtmode (dwtmode_t mode)
 
const string dwtmode () const
 
dwtmode_t dwtmodeenum () const
 
int wavelet (const string &wname)
 
string wavelet_name () const
 
const WaveFiltBasewavelet () const
 
size_t approxlength (size_t sigInLen) const
 
size_t detaillength (size_t sigInLen) const
 
size_t coefflength (size_t sigInLen) const
 
size_t coefflength2 (size_t sigInX, size_t sigInY) const
 
size_t coefflength3 (size_t sigInX, size_t sigInY, size_t sigInZ) const
 
size_t wmaxlev (size_t s) const
 
bool & InvalidFloatAbortOnOff ()
 
- Public Member Functions inherited from VetsUtil::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Member Functions

static bool CompressionInfo (vector< size_t > dims, const string wavename, bool keepapp, size_t &nlevels, size_t &maxcratio)
 
- Static Public Member Functions inherited from VetsUtil::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message. More...
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code. More...
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code. More...
 
static int GetErrCode ()
 Retrieve the current error code. More...
 
static void SetErrMsgCB (ErrMsgCB_T cb)
 
static ErrMsgCB_T GetErrMsgCB ()
 
static void SetErrMsgFilePtr (FILE *fp)
 
static const FILE * SetErrMsgFilePtr ()
 
static void SetDiagMsg (const char *format,...)
 Record a formatted diagnostic message. More...
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 

Friends

std::ostream & operator<< (std::ostream &o, const Compressor &rhs)
 

Additional Inherited Members

- Public Types inherited from VAPoR::MatWaveBase
enum  dwtmode_t {
  INVALID = -1, ZPD, SYMH, SYMW,
  ASYMH, ASYMW, SP0, SP1,
  PPD, PER
}
 
- Public Types inherited from VetsUtil::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- Static Public Attributes inherited from VetsUtil::MyBase
static char * ErrMsg
 
static int ErrCode
 
static int ErrMsgSize
 
static FILE * ErrMsgFilePtr
 
static ErrMsgCB_T ErrMsgCB
 
static char * DiagMsg
 
static int DiagMsgSize
 
static FILE * DiagMsgFilePtr
 
static DiagMsgCB_T DiagMsgCB
 
static bool Enabled
 
- Protected Member Functions inherited from VetsUtil::MyBase
void SetClassName (const string &name)
 

Detailed Description

A class for managing data set metadata.

Author
John Clyne
Version
$Revision$
Date
$Date$

This class performs either lossy compression decomposition on an array with an arbitrary number of dimensions (up to 3 presently). Compression is performed by transforming data with a wavelet transform, sorting the resulting coefficients, and returning the n largest magnitude coefficients.

Definition at line 29 of file Compressor.h.

Constructor & Destructor Documentation

VAPoR::Compressor::Compressor ( std::vector< size_t >  dims,
const string &  wname,
const string &  mode 
)

Constructor for compressor class

This construct initializes a Compressor class object for use in compression or decomposition. The parameter wname specifies the name of the wavelet to use for subsequent wavelet transforms. The parameter wmode specifies the boundary extention mode to employ for transforms. For non-periodic data the biorthogonal wavelets with a with an appropriate symetric extension are recommended.

Parameters
[in]dimsVector specifying dimensions of arrays to be compressed
[in]wnameName of wavelet to use in transform
[in]wmodeBoundary extention mode
See also
MatWaveBase, WaveFiltBase
VAPoR::Compressor::Compressor ( std::vector< size_t >  dims,
const string &  wname 
)
VAPoR::Compressor::~Compressor ( )

Member Function Documentation

double& VAPoR::Compressor::ClampMax ( )
inline

Set or get the maximum range clamp value

See also
ClampMaxOnOff(), Decompress(), Reconstruct()

Definition at line 340 of file Compressor.h.

bool& VAPoR::Compressor::ClampMaxOnOff ( )
inline

Set or get the max range clamping attribute

When set, this attribute will clamp the maximum data value reconstructed to the value of ClampMax(). I.e. all data values reconstructed by Decompress() or Reconstruct() will be less than or equal to the value returned by ClampMax(). By default clamping is disabled.

See also
ClampMin(), Decompress(), Reconstruct()

Definition at line 334 of file Compressor.h.

double& VAPoR::Compressor::ClampMin ( )
inline

Set or get the minimum range clamp value

See also
ClampMinOnOff(), Decompress(), Reconstruct()

Definition at line 322 of file Compressor.h.

bool& VAPoR::Compressor::ClampMinOnOff ( )
inline

Set or get the min range clamping attribute

When set, this attribute will clamp the minimum data value reconstructed to the value of ClampMin(). I.e. all data values reconstructed by Decompress() or Reconstruct() will be greater than or equal to the value returned by ClampMin(). By default clamping is disabled.

See also
ClampMin(), Decompress(), Reconstruct()

Definition at line 316 of file Compressor.h.

int VAPoR::Compressor::Compress ( const float *  src_arr,
float *  dst_arr,
size_t  dst_arr_len,
SignificanceMap sigmap 
)

Compress an array

This method compresses an input array and returns a compressed version of the data. Compression is performed by wavelet transforming the data and sorting the resulting wavelet coefficients. Only the largest dst_arr_len coefficients are returned.

Parameters
[in]src_arrThe input array. The dimensions are determined by the constructor's dims parameter.
[out]dst_arrThe output array that will contain the largest dst_arr_len coefficients from the transformed input array. dst_arr must point to enough space to contain dst_arr_len elements.
[out]dst_arr_lenLength of dst_arr.
[in,out]Asignficance map that, upon return, will provide the coordinates of the output coefficents returned.
Return values
statusA negative value indicates failure
See also
SignificanceMap, KeepAppOnOff()
int VAPoR::Compressor::Compress ( const double *  src_arr,
double *  dst_arr,
size_t  dst_arr_len,
SignificanceMap sigmap 
)
static bool VAPoR::Compressor::CompressionInfo ( vector< size_t >  dims,
const string  wavename,
bool  keepapp,
size_t &  nlevels,
size_t &  maxcratio 
)
static
int VAPoR::Compressor::Decompose ( const float *  src_arr,
float *  dst_arr,
const vector< size_t > &  dst_arr_lens,
vector< SignificanceMap > &  sigmaps 
)

Decompose an array into a series of approximations of increasingly better fidelity.

This method performs a wavelet decomposition of an array, sorts the resulting coefficients from largest to smallest, and returns the sorted coefficients as a collection of n sets, Si. The absolute value of each element of a set Si will be less than each element of a set Si+1.

Parameters
[in]src_arrThe input array. The dimensions are determined by the constructor's dims parameter.
[out]dst_arrThe output array that will contain all of the sorted coefficients for each collection Si.
[in]dst_arr_lensA vector whose size determines the number of collections Si, and whose elements specify the number of elements in each collection Si. The sum of all elements of dst_arr_lens must be less than or equal the total number of wavelet coefficients generated by the wavelet transform. The total is given by the size of the vector returned by GetSigMapShape().
[out]sigmapsAn array of significance maps, one map for each coefficient collection, Si
Return values
statusA negative value indicates failure
See also
SignificanceMap, KeepAppOnOff(), Compress()
int VAPoR::Compressor::Decompose ( const double *  src_arr,
double *  dst_arr,
const vector< size_t > &  dst_arr_lens,
vector< SignificanceMap > &  sigmaps 
)
int VAPoR::Compressor::Decompress ( const float *  src_arr,
float *  dst_arr,
SignificanceMap sigmap 
)

Decompress an array previously compressed with Compress()

Parameters
[in]src_arrThe input array containing the coefficients previsously computed by Compress().
[out]dst_arrThe output array that will contain uncompressed array. dst_arr must point to enough space to contain The entire uncompressed array
[in]Thesignficance map that returned by Compress() for src_arr
Return values
statusA negative value indicates failure
See also
Compress()
int VAPoR::Compressor::Decompress ( const double *  src_arr,
double *  dst_arr,
SignificanceMap sigmap 
)
double& VAPoR::Compressor::Epsilon ( )
inline

Set or get the epsilon value

See also
EpsilonOnOff(), Decompress(), Reconstruct()

Definition at line 358 of file Compressor.h.

bool& VAPoR::Compressor::EpsilonOnOff ( )
inline

Set or get the epsilon attribute

When set, this attribute will compare the absolute value of reconstructed data with Epsilon(). If abs(v) is less than epsilon the value of v is set to 0.0. By default the epsilon comparison is disabled.

See also
Epsilon(), Decompress(), Reconstruct()

Definition at line 352 of file Compressor.h.

void VAPoR::Compressor::GetDimension ( vector< size_t > &  dims,
int  l 
) const

Returns the dimensions of a reconstructed array

This method returns the dimensions of an array reconstructed with either the Reconstruct() or Decompress() methods. The parameter l specifies the number of inverse transformation passes applied in the range -1 to max, where max is the value returned by GetNumLevels(). A value of -1 corresponds to max levels. A value of zero implies no inverse transformations are performed (the dimensions returned are those of the wavelet approximation coefficients).

Parameters
[out]dimsThe dimensions of the reconstructed array.
[in]lThe number of inverse transforms to apply
See also
Compressor(), GetNumLevels()
size_t VAPoR::Compressor::GetMinCompression ( ) const

Returns the number of coefficients in the smallest allowable compression

Returns the minimum number of wavelet coefficients allowable after compression. The minimum number of of coefficients is determined by a combination of the wavelet, the boundary extension handling method, the dimensions of the array, and the setting of KeepAppOnOff()

Return values
nlevelsNumber of transformation levels
int VAPoR::Compressor::GetNumLevels ( ) const
inline

Returns the number of transformation levels

Returns the number of forward or inverse wavelet transformations applied to compress or fully reconstruct an array. The number of of transforms is determined by a combination of the wavelet, the boundary extension handling method, and the dimensions of the array.

Return values
nlevelsNumber of transformation levels

Definition at line 282 of file Compressor.h.

size_t VAPoR::Compressor::GetNumWaveCoeffs ( ) const
inline

Returns the number of wavelet coefficients resulting from a forward wavelet transformation of an array.

Returns the number of wavelet coefficients resulting from a forward wavelet transformation of an array based on the parameters supplied to the class constructor. The number of coefficients resulting from a wavelet transform is a function of the dimensions of the array, the wavlet familiy used, the boundary handling method, and the number of transformation levels.

Note
For periodic boundary handling, or symetric wavelets matched with appropriate symetric boundary handling, the number of coefficients in the transform is guaranteed to match the number of coefficients in the input array.
See also
Compress(), Decompose()

Definition at line 240 of file Compressor.h.

Referenced by GetSigMapSize().

void VAPoR::Compressor::GetSigMapShape ( std::vector< size_t > &  dims) const
inline

Return true if the given grid array is compressible

Return true if the given grid array is compressible based on it's dimension and the requested wavelet. I.e. returns true if at least one dimension is wide enough for a single wavelet transform

Parameters
[in]dimsVector specifying dimensions of arrays to be compressed
[in]wnameName of wavelet to use in transform
[in]wmodeBoundary extention mode
See also
MatWaveBase, WaveFiltBaseReturns the shape of significance maps based on constructor

This method returns the shape of any significance maps configured by the Compress() or Decompose() method based on parameters passed to the class constructor.

Parameters
[out]dimsA vector describing the shap (dimensions) of a significance map
See also
SignificanceMap, Compress(), Decompose()

Definition at line 218 of file Compressor.h.

size_t VAPoR::Compressor::GetSigMapSize ( size_t  num_entries) const
inline

Returns the size of an encoded SignficanceMap()

Returns the size in bytes of an encoded SignificanceMap() used to store num_entries entries.

See also
Compress(), Decompose()

Definition at line 249 of file Compressor.h.

References VAPoR::SignificanceMap::GetMapSize(), and GetNumWaveCoeffs().

bool& VAPoR::Compressor::KeepAppOnOff ( )
inline

Set or get the keep approximations attribute

When set, this attribute ensures that all wavelet approximation coefficients are retained during compression or decomposition. Setting this attribute will decrease the maximum possible compression, but may significantly improve the fidelity of the approximation

Definition at line 304 of file Compressor.h.

int VAPoR::Compressor::Reconstruct ( const float *  src_arr,
float *  dst_arr,
vector< SignificanceMap > &  sigmaps,
int  l 
)

Reconstruct a signal decomposed with Decompose()

This method reconstructs a signal previosly decomposed with Decompose(). Partial reconstructions are possible using one of two methods, both of which may be combined. In the first the a subset of coefficient collections Si may be used for reconstruction. In this case missing coefficients are simply treated as having value zero. Note that arbitrary Si cannot be specified: the collections must be ordered with i less than or equal to the total number of collections returned by Decompose().

The second method of partial reconstruction is to limit the number of inverse wavelet transforms applied to the coefficients. In this case the reconstructed array will be coarsened (contain fewer elements) than the original. The dimensions of the reconstructed array are given by GetDimension().

Parameters
[in]src_arrThe input array containing the coefficients previsously computed by Decompose().
[out]dst_arrThe output array containing reconstructed signal. The dimensions of dst_arr are determined by GetDimension(). If l is -1, the dimensions will be the same as those specified by the class constructor's dims parameter
[in]sigmapsAn array of significance maps previosly returned by Decompose()
[in]lThe refinement level. l must be in the range -1 to max, where max is the value returned by GetNumLevels(). If is -1 its value will be set to max. A value of zero coresponds to the approximation level coefficients.
Return values
statusA negative value indicates failure
See also
SignificanceMap, KeepAppOnOff(), Compress()
int VAPoR::Compressor::Reconstruct ( const double *  src_arr,
double *  dst_arr,
vector< SignificanceMap > &  sigmaps,
int  l 
)

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const Compressor rhs 
)
friend

The documentation for this class was generated from the following file: