VAPOR3 3.9.4
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
VAPoR::WaveCodecIO Class Reference

A sub-region reader for VDF files. More...

#include <WaveCodecIO.h>

Inheritance diagram for VAPoR::WaveCodecIO:
Wasp::EasyThreads Wasp::MyBase

Public Member Functions

 WaveCodecIO (const MetadataVDC &metadata, int nthreads=0)
 
 WaveCodecIO (const string &metafile, int nthreads=0)
 
virtual ~WaveCodecIO ()
 
virtual int OpenVariableRead (size_t timestep, const char *varname, int reflevel=0, int lod=0)
 
virtual int OpenVariableWrite (size_t timestep, const char *varname, int reflevel=-1, int lod=-1)
 
virtual int CloseVariable ()
 
virtual int BlockReadRegion (const size_t bmin[3], const size_t bmax[3], float *region, bool unblock=true)
 
virtual int ReadRegion (const size_t min[3], const size_t max[3], float *region)
 
virtual int ReadRegion (float *region)
 
virtual int ReadSlice (float *slice)
 
virtual int BlockWriteRegion (const float *region, const size_t bmin[3], const size_t bmax[3], bool block=true)
 
virtual int WriteRegion (const float *region, const size_t min[3], const size_t max[3])
 
virtual int WriteRegion (const float *region)
 
virtual int WriteSlice (const float *slice)
 
virtual void SetBoundaryPadOnOff (bool pad)
 
const float * GetDataRange () const
 
void GetValidRegion (size_t min[3], size_t max[3], int reflevel) const
 
virtual int VariableExists (size_t ts, const char *varname, int reflevel=0, int lod=0) const
 
virtual int GetNumTransforms () const
 
virtual void GetBlockSize (size_t bs[3], int reflevel) const
 
void SetCollectiveIO (bool newCollectiveIO)
 
int getNumThread ()
 
void EnableBuffering (size_t count[3], size_t divisor, int rank)
 

Static Public Member Functions

static size_t GetMaxCRatio (const size_t bs[3], string wavename, string wmode)
 

Public Attributes

int _nthreads
 

Friends

void * RunBlockReadRegionThread (void *object)
 
void * RunBlockWriteRegionThread (void *object)
 

Additional Inherited Members

- Protected Types inherited from Wasp::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- Protected Member Functions inherited from Wasp::EasyThreads
 EasyThreads (int nthreads)
 
 ~EasyThreads ()
 
int ParRun (void *(*start)(void *), std::vector< void * > arg)
 
int ParRun (void *(*start)(void *), void **arg)
 
int Barrier ()
 
int MutexLock ()
 
int MutexUnlock ()
 
int GetNumThreads () const
 
- Protected Member Functions inherited from Wasp::MyBase
void SetClassName (const string &name)
 
 MyBase ()
 
const string & getClassName () const
 
- Static Protected Member Functions inherited from Wasp::EasyThreads
static void Decompose (int n, int size, int rank, int *offset, int *length)
 
static int NProc ()
 
- Static Protected Member Functions inherited from Wasp::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message.
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code.
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code.
 
static int GetErrCode ()
 Retrieve the current error code.
 
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.
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 
static bool GetEnableErrMsg ()
 
- Static Protected Attributes inherited from Wasp::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
 

Detailed Description

A sub-region reader for VDF files.

Author
John Clyne
Version
$Revision$
Date
$Date$

This class provides an API for reading and writing VDC2 data. VDC2 data may be accessed with two forms of wavelet based progressive refinement, : hierarchical or level-of-detail. The former supports coarsening and refinement of the sampling grid resolution (the dimensions of the sampling grid) at varying powers-of-two, and is controled by the reflevel parameter. The latter allows for arbitrary approximations by restricting the number of wavelet basis coefficients used when reconstructing the data from their wavelet representation. The level-of-detail is controled with the lod parameter.

Definition at line 38 of file WaveCodecIO.h.

Constructor & Destructor Documentation

◆ WaveCodecIO() [1/2]

VAPoR::WaveCodecIO::WaveCodecIO ( const MetadataVDC &  metadata,
int  nthreads = 0 
)

Parameters
[in]nthreadsNumber of execution threads that may be used by the class for parallel execution. If zero, the system hardware will be queried via sysconf to determine the number of processors available and this value will be used.

◆ WaveCodecIO() [2/2]

VAPoR::WaveCodecIO::WaveCodecIO ( const string &  metafile,
int  nthreads = 0 
)

Parameters
[in]nthreadsNumber of execution threads that may be used by the class for parallel execution. If zero, the system hardware will be queried via sysconf to determine the number of processors available and this value will be used.

◆ ~WaveCodecIO()

virtual VAPoR::WaveCodecIO::~WaveCodecIO ( )
virtual

Member Function Documentation

◆ BlockReadRegion()

virtual int VAPoR::WaveCodecIO::BlockReadRegion ( const size_t  bmin[3],
const size_t  bmax[3],
float *  region,
bool  unblock = true 
)
virtual

Read in and return a subregion from the currently opened data volume.

The bmin and bmax vectors identify the minimum and maximum extents, in block coordinates, of the subregion of interest. The minimum valid value of 'bmin' is (0,0,0), the maximum valid value of bmax is (nbx-1,nby-1,nbz-1), where nx, ny, and nz are the block dimensions of the volume at the currently opened refinement level as retuned by GetDimBlk(). The volume returned is stored in the memory region pointed to by region. It is the caller's responsbility to ensure adequate space is available.

Parameters
[in]bminMinimum region extents in block coordinates
[in]bmaxMaximum region extents in block coordinates
[out]regionThe requested volume subregion
[in]unblockIf true, unblock the data before copying to region
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead(), GetBlockSize(), MapVoxToBlk()

◆ BlockWriteRegion()

virtual int VAPoR::WaveCodecIO::BlockWriteRegion ( const float *  region,
const size_t  bmin[3],
const size_t  bmax[3],
bool  block = true 
)
virtual

Write a volume subregion to the currently opened progressive access data volume.

This method is identical to the WriteRegion() method with the exception that the region boundaries are defined in block, not voxel, coordinates. Secondly, unless the 'block' parameter is set, the internal blocking of the data will be preserved. I.e. the data are assumed to already be blocked.

The number of voxels contained in region must be the product over i :

(bmax[i] - bmin[i] + 1) * bs[i]

where bs[i] is the ith dimension of the block size.

Parameters
[in]bminMinimum region extents in block coordinates
[in]bmaxMaximum region extents in block coordinates
[in]regionThe volume subregion to write
[in]blockIf true, block the data before writing/transforming
Return values
statusReturns a non-negative value on success
See also
OpenVariableWrite() SetBoundarPadOnOff()

◆ CloseVariable()

virtual int VAPoR::WaveCodecIO::CloseVariable ( )
virtual

Close the currently opened variable.

See also
OpenVariableWrite(), OpenVariableRead()

◆ EnableBuffering()

void VAPoR::WaveCodecIO::EnableBuffering ( size_t  count[3],
size_t  divisor,
int  rank 
)

◆ GetBlockSize()

virtual void VAPoR::WaveCodecIO::GetBlockSize ( size_t  bs[3],
int  reflevel 
) const
virtual

◆ GetDataRange()

const float * VAPoR::WaveCodecIO::GetDataRange ( ) const
inline

Return the data range of the currently opened volume as a two-element array

This method returns the minimum and maximum data values of the currently opened variable within the valid domain bounds. See GetValidRegion().

Note
The range values returned are valid for the native data only. Data approximations produced by level-of-detail or through multi-resolution may have values outside of this range.
Return values
[out]range A two-element vector containing the current minimum and maximum.

Definition at line 308 of file WaveCodecIO.h.

◆ GetMaxCRatio()

static size_t VAPoR::WaveCodecIO::GetMaxCRatio ( const size_t  bs[3],
string  wavename,
string  wmode 
)
static

Return the maximimum compression ratio possible

This static methods returns the maximum possible compression ratio possible for a given combination of blocksize, ps, wavele name, wname, and wavelet boundary handling mode, wmode.

Parameters
[in]bsA three-element vector providing the dimensions of a block
[in]wavenameThe name of the wavelet
[in]wmodeThe wavelet boundary handling mode
Return values
ratioA value of zero is returned if the wavename or wmode are invalid, otherwise the maximum possible data compression ratio is returned.
See also
Metadata::GetCRatios()

◆ getNumThread()

int VAPoR::WaveCodecIO::getNumThread ( )
inline

Definition at line 416 of file WaveCodecIO.h.

◆ GetNumTransforms()

virtual int VAPoR::WaveCodecIO::GetNumTransforms ( ) const
virtual

◆ GetValidRegion()

void VAPoR::WaveCodecIO::GetValidRegion ( size_t  min[3],
size_t  max[3],
int  reflevel 
) const

Return the valid region bounds for the currently opened variable

This method returns the minimum and maximum valid coordinate bounds (in voxels) of the currently opened variable. In general, the minimum bounds are (0,0,0) and the maximum bounds are (nx-1, ny-1, nz-1), where nx, ny, and nz are the volume dimensions returned by GetDim(). However, partial regions (sub-volumes) may be written to the VDC as well.

Parameters
[in]reflevelRefinement level of the variable
[out]minMinimum coordinate bounds (in voxels) of volume
[out]maxMaximum coordinate bounds (in voxels) of volume
Return values
statusA non-negative int is returned on success

◆ OpenVariableRead()

virtual int VAPoR::WaveCodecIO::OpenVariableRead ( size_t  timestep,
const char *  varname,
int  reflevel = 0,
int  lod = 0 
)
virtual

Open the named variable for reading

This method prepares a data volume (slice), indicated by a variable name and time step pair, for subsequent read operations by methods of this class. The number of the refinement levels parameter, reflevel, indicates the resolution of the volume in the multiresolution hierarchy. The valid range of values for reflevel is [0..max_refinement], where max_refinement is the maximum refinement level of the data set: Metadata::GetNumTransforms(). A value of zero indicates the coarsest resolution data, a value of max_refinement (or -1) indicates the finest resolution data. The level-of-detail parameter, lod, selects the approximation level. Valid values for lod are integers in the range 0..GetCRatios().size()-1, or the value -1 may be used to select the best approximation available: GetCRatios().size()-1.

An error occurs, indicated by a negative return value, if the volume identified by the {varname, timestep, reflevel, lod} tupple is not available. Note the availability of a volume can be tested with the VariableExists() method.

Parameters
[in]timestepTime step of the variable to read
[in]varnameName of the variable to read
[in]reflevelRefinement level of the variable. A value of -1 indicates the maximum refinment level defined for the VDC
[in]lodApproximation level of the variable. A value of -1 indicates the maximum approximation level defined for the VDC
Return values
statusReturns a non-negative value on success
See also
Metadata::GetVariableNames(), Metadata::GetNumTransforms(), GetNumTimeSteps(), GetCRatios()

◆ OpenVariableWrite()

virtual int VAPoR::WaveCodecIO::OpenVariableWrite ( size_t  timestep,
const char *  varname,
int  reflevel = -1,
int  lod = -1 
)
virtual

Open the named variable for writing

Prepare a VDC for writing a data volume (slice). The data volume is identified by the specfied time step and variable name. The number of resulting approximations for the data volume is determined by the Metadata object used to initialize the class. Moreover, the number of levels-of-detail actually saved to the data collection are determined by lod. If lod is maximum level of detail (or the special value -1, the default) all of the wavelet coefficients are saved, and it is possible to fully reconstruct the volume later without loss of information (beyond floating point round off).

Parameters
[in]timestepTime step of the variable to read
[in]varnameName of the variable to read
[in]lodLevel of detail saved. A value of -1 indicates the maximum level of detail.
Return values
statusReturns a non-negative value on success
See also
Metadata::GetVariableNames(), Metadata::GetNumTransforms()

◆ ReadRegion() [1/2]

virtual int VAPoR::WaveCodecIO::ReadRegion ( const size_t  min[3],
const size_t  max[3],
float *  region 
)
virtual

Read in and return a subregion from the currently opened data volume.

This method is similar to BlockReadRegion() with the exception that the region bounds are specified in voxel coordinates. The min and max vectors identify the minimum and maximum extents, in voxel coordinates, of the subregion of interest. The minimum valid value of 'min' is (0,0,0), the maximum valid value of max is (nx-1,ny-1,nz-1), where nx, ny, and nz are the voxel dimensions of the volume at the currently opened refinement level as returned by GetDim().

The volume returned is stored in the memory region pointed to by region. It is the caller's responsbility to ensure adequate space is available.

Parameters
[in]minMinimum region extents in voxel coordinates
[in]maxMaximum region extents in voxel coordinates
[out]regionThe requested volume subregion
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead(), GetDim(), MapVoxToBlk()

◆ ReadRegion() [2/2]

virtual int VAPoR::WaveCodecIO::ReadRegion ( float *  region)
virtual

◆ ReadSlice()

virtual int VAPoR::WaveCodecIO::ReadSlice ( float *  slice)
virtual

Read the next volume slice from the currently opened file

Read in and return a slice (2D array) of voxels from the currently opened data volume at the current refinement level. Subsequent calls will read successive slices until the entire volume has been read. It is the caller's responsibility to ensure that the array pointed to by slice contains enough space to accomodate an NX by NY dimensioned slice, where NX is the dimesion of the volume along the X axis, specified in voxels, and NY is the Y axis dimension, as returned by GetDim().

Note
ReadSlice returns 0 if the entire volume has been read.
Parameters
[out]sliceThe requested volume slice
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead(), Metadata::GetDim()

◆ SetBoundaryPadOnOff()

virtual void VAPoR::WaveCodecIO::SetBoundaryPadOnOff ( bool  pad)
inlinevirtual

Toggle padding of data on writes

If true, incomplete data blocks will be padded prior to transformation and storage to disk. A block is incomplete iff it is a boundary block (a block that contains a volume region boundary) and the extents of the region do not coincide with block boundaries

Parameters
[in]padBoolean indicating whether padding should (true) or should not (false) take place
See also
GetBoundaryMode()

Definition at line 292 of file WaveCodecIO.h.

◆ SetCollectiveIO()

void VAPoR::WaveCodecIO::SetCollectiveIO ( bool  newCollectiveIO)
inline

Definition at line 373 of file WaveCodecIO.h.

◆ VariableExists()

virtual int VAPoR::WaveCodecIO::VariableExists ( size_t  ts,
const char *  varname,
int  reflevel = 0,
int  lod = 0 
) const
virtual

Returns true if the indicated data volume exists on disk

Returns true if the variable identified by the timestep, variable name, refinement level, and level-of-detail is present on disk. Returns 0 if the variable is not present.

Parameters
[in]tsA valid time step from the Metadata object used to initialize the class
[in]varnameA valid variable name
[in]reflevelIgnored
[in]lodCompression level of detail requested. The coarsest approximation level is 0 (zero). A value of -1 indicates the finest refinement level contained in the VDC.

◆ WriteRegion() [1/2]

virtual int VAPoR::WaveCodecIO::WriteRegion ( const float *  region)
virtual

◆ WriteRegion() [2/2]

virtual int VAPoR::WaveCodecIO::WriteRegion ( const float *  region,
const size_t  min[3],
const size_t  max[3] 
)
virtual

Write a volume subregion to the currently opened progressive access data volume.

This method is identical to the WriteRegion() method with the exception that the region boundaries are defined in block, not voxel, coordinates. Secondly, unless the 'block' parameter is set, the internal blocking of the data will be preserved. I.e. the data are assumed to already be blocked.

The number of voxels contained in region must be the product over i :

(max[i] - min[i] + 1)

Parameters
[in]minMinimum region extents in voxel coordinates
[in]maxMaximum region extents in voxel coordinates
[in]regionThe volume subregion to write
Return values
statusReturns a non-negative value on success
See also
OpenVariableWrite(), GetBlockSize(), MapVoxToBlk()
SetBoundarPadOnOff()
Note
Unexpected results may be obtained if this method is invoked multiple times for adjacent regions if the region boundaries do not coincide with block boundaries.

◆ WriteSlice()

virtual int VAPoR::WaveCodecIO::WriteSlice ( const float *  slice)
virtual

Write a single slice of voxels to the currently opened variable

Transform and write a single slice (2D array) of voxels to the variable indicated by the most recent call to OpenVariableWrite(). The dimensions of a slices is NX by NY, where NX is the dimesion of the volume along the X axis, specified in voxels, and NY is the Y axis dimension.

This method should be called exactly NZ times for each opened variable, where NZ is the dimension of the volume in voxels along the Z axis. Each invocation should pass a successive slice of volume data.

Parameters
[in]sliceA slices of volume data
Return values
statusReturns a non-negative value on success
See also
OpenVariableRead()

Friends And Related Function Documentation

◆ RunBlockReadRegionThread

void * RunBlockReadRegionThread ( void *  object)
friend

◆ RunBlockWriteRegionThread

void * RunBlockWriteRegionThread ( void *  object)
friend

Member Data Documentation

◆ _nthreads

int VAPoR::WaveCodecIO::_nthreads

Definition at line 415 of file WaveCodecIO.h.


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