OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
InternalZGY::GenLodBase Class Reference

#include <genlod.h>

Inheritance diagram for InternalZGY::GenLodBase:
InternalZGY::GenLodImpl InternalZGY::GenLodC

Public Member Functions

 GenLodBase (const index3_t &size, const index3_t &bricksize, RawDataType dtype, const std::array< double, 2 > &histogram_range, std::int32_t nlods_in, const std::vector< LodAlgorithm > &decimation, const std::shared_ptr< HistogramData > &histogram, double defaultvalue, const std::function< bool(std::int64_t, std::int64_t)> &progress, bool verbose)
 

Protected Member Functions

virtual std::shared_ptr< DataBuffer_read (std::int32_t lod, const index3_t &pos, const index3_t &size)
 
virtual void _write (std::int32_t lod, const index3_t &pos, const std::shared_ptr< const DataBuffer > &data)
 
virtual void _savestats ()
 
void _report (const DataBuffer *data)
 
std::string _prefix (std::int32_t lod)
 

Static Protected Member Functions

static std::string _format_result (const std::shared_ptr< DataBuffer > &data)
 

Protected Attributes

std::int32_t _nlods
 
std::int64_t _total
 
std::int64_t _done
 
index3_t _surveysize
 
index3_t _bricksize
 
RawDataType _dtype
 
std::array< double, 2 > _histogram_range
 
std::vector< LodAlgorithm_decimation
 
std::shared_ptr< HistogramData_wa_histogram
 
double _wa_defaultstorage
 
std::function< bool(std::int64_t, std::int64_t)> _progress
 
bool _verbose
 

Detailed Description

Abstract class for generating low resolution bricks, histogram, and statistics. At this level only define virtual methods for I/O. The implementation can be used as-is when mocking the class. The optional nlods parameter is only used as a consistency check.

Constructor & Destructor Documentation

◆ GenLodBase()

InternalZGY::GenLodBase::GenLodBase ( const index3_t size,
const index3_t bricksize,
RawDataType  dtype,
const std::array< double, 2 > &  histogram_range,
std::int32_t  nlods_in,
const std::vector< LodAlgorithm > &  decimation,
const std::shared_ptr< HistogramData > &  histogram,
double  defaultstorage,
const std::function< bool(std::int64_t, std::int64_t)> &  progress,
bool  verbose 
)

Abstract class for generating low resolution bricks, histogram, and statistics. At this level only define virtual methods for I/O. The implementation can be used as-is when mocking the class. The optional nlods parameter is only used as a consistency check.

Note that the WeightedAverage algorithm requires a histogram to work. If no histogram was provided then the current contents of the accumulated histogram will be used. This is unfortunate and might cause brick artifacts. Especially in the first few bricks that are generated. With a non-recursive algorithm (plan C) and with only lod2 and above uses weighted average then this is unproblematic. Because in that case we will be done with the histogram once we need it. TODO-Low consider doing an initial pass with a statistical sampling of the lod0 data, only for use with weighted average. There will be a minor issue with some values appearing to have zero frequency, but this should not cause any trouble. (assume "1").

Note that the WeightedAverage and AverageNon0 algorithms expect a defaultstorage to use when all inputs are inf/nan or (for AverageNon0) zero. Only relevant for integral types, to ensure that the default is whatever will produce the value closest to 0 after conversion. And integral data can neither be inf nor nan, so this is a pretty academic issue. For AverageNon0 that algorithm is currently not used. So it isn't even clear what the desired behavior should be.

Member Function Documentation

◆ _format_result()

std::string InternalZGY::GenLodBase::_format_result ( const std::shared_ptr< DataBuffer > &  data)
staticprotected

For debugging and logging only.

◆ _prefix()

std::string InternalZGY::GenLodBase::_prefix ( std::int32_t  lod)
protected

For debugging and logging only.

◆ _read()

std::shared_ptr< DataBuffer > InternalZGY::GenLodBase::_read ( std::int32_t  lod,
const index3_t pos,
const index3_t size 
)
protectedvirtual

This is a stub that must be redefined except for low level unit tests. Read a block from the ZGY file (plans B and C) or the application (plan D). The lod parameter will always be 0 for plans C and D. Returns a ScalarBuffer if all constant, else a 3D numpy array.

Reimplemented in InternalZGY::GenLodC.

◆ _report()

void InternalZGY::GenLodBase::_report ( const DataBuffer data)
protected

Invoke the user's progress callback if any. Keep track of how many bricks we have processed. Both reads and writes increment the same counter. For plan C the reads will cover all blocks in lod 0 and the writes will cover all blocks in lod > 0. For plan D all blocks are written which means the computation of _total done in init might need to change.

◆ _savestats()

void InternalZGY::GenLodBase::_savestats ( )
protectedvirtual

This is a stub that must be redefined except for low level unit tests. Finalize and write the computed statistics and histogram to the file.

Reimplemented in InternalZGY::GenLodC.

◆ _write()

void InternalZGY::GenLodBase::_write ( std::int32_t  lod,
const index3_t pos,
const std::shared_ptr< const DataBuffer > &  data 
)
protectedvirtual

This is a stub that must be redefined except for low level unit tests. Write a block to the ZGY file. Silently ignore writes of data that is known to have been read directly from the file. For plans B and C this means ignoring all writes to lod 0.

Reimplemented in InternalZGY::GenLodC.


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