OpenZGY/C++ Public API (ALPHA)
Access seismic data stored in ZGY format.
Public Member Functions | Static Public Member Functions | List of all members
OpenZGY::IZgyReader Class Referenceabstract

Main API for reading ZGY files. More...

#include <api.h>

Inheritance diagram for OpenZGY::IZgyReader:
OpenZGY::IZgyTools OpenZGY::IZgyMeta OpenZGY::Impl::ZgyReader

Public Member Functions

virtual void read (const size3i_t &start, const size3i_t &size, float *data, int lod=0) const =0
 Read an arbitrary region. More...
 
virtual void read (const size3i_t &start, const size3i_t &size, std::int16_t *data, int lod=0) const =0
 Read an arbitrary region with no conversion. More...
 
virtual void read (const size3i_t &start, const size3i_t &size, std::int8_t *data, int lod=0) const =0
 Read an arbitrary region with no conversion. More...
 
virtual std::pair< bool, double > readconst (const size3i_t &start, const size3i_t &size, int lod=0, bool as_float=true) const =0
 Get hint about all constant region. More...
 
virtual void close ()=0
 Close the file and release resources. More...
 
- Public Member Functions inherited from OpenZGY::IZgyTools
virtual void transform (const corners_t &from, const corners_t &to, std::vector< std::array< float64_t, 2 >> &) const =0
 General coordinate conversion of an array of points. (NOT IMPLEMENTED YET) More...
 
virtual std::array< float64_t, 2 > transform1 (const corners_t &from, const corners_t &to, const std::array< float64_t, 2 > &) const =0
 General coordinate conversion of a single coordinate pair. More...
 
virtual std::array< float64_t, 2 > annotToIndex (const std::array< float64_t, 2 > &) const =0
 Convert a single coordinate pair.
 
virtual std::array< float64_t, 2 > annotToWorld (const std::array< float64_t, 2 > &) const =0
 Convert a single coordinate pair.
 
virtual std::array< float64_t, 2 > indexToAnnot (const std::array< float64_t, 2 > &) const =0
 Convert a single coordinate pair.
 
virtual std::array< float64_t, 2 > indexToWorld (const std::array< float64_t, 2 > &) const =0
 Convert a single coordinate pair.
 
virtual std::array< float64_t, 2 > worldToAnnot (const std::array< float64_t, 2 > &) const =0
 Convert a single coordinate pair.
 
virtual std::array< float64_t, 2 > worldToIndex (const std::array< float64_t, 2 > &) const =0
 Convert a single coordinate pair.
 
- Public Member Functions inherited from OpenZGY::IZgyMeta
virtual size3i_t size () const =0
 Size in inline, crossline, vertical directions.
 
virtual SampleDataType datatype () const =0
 Type of samples in each brick.
 
virtual std::array< float32_t, 2 > datarange () const =0
 Used for float to int scaling.
 
virtual UnitDimension zunitdim () const =0
 Vertical dimension.
 
virtual UnitDimension hunitdim () const =0
 Horizontal dimension.
 
virtual std::string zunitname () const =0
 For annotation only. Use hunitfactor, not the name, to convert to or from SI.
 
virtual std::string hunitname () const =0
 For annotation only. Use hunitfactor, not the name, to convert to or from SI.
 
virtual float64_t zunitfactor () const =0
 Multiply by this factor to convert from storage units to SI units.
 
virtual float64_t hunitfactor () const =0
 Multiply by this factor to convert from storage units to SI units.
 
virtual float32_t zstart () const =0
 First time/depth.
 
virtual float32_t zinc () const =0
 Increment in vertical direction.
 
virtual std::array< float32_t, 2 > annotstart () const =0
 First inline, crossline.
 
virtual std::array< float32_t, 2 > annotinc () const =0
 Increment in inline, crossline directions.
 
virtual const corners_t & corners () const =0
 Survey corner points in world coordinates.
 
virtual const corners_t & indexcorners () const =0
 Survey corner points in ordinal (i,j) coordinates.
 
virtual const corners_t & annotcorners () const =0
 Survey corner points in inline, crossline coordinates.
 
virtual size3i_t bricksize () const =0
 Size of one brick. Almost always (64,64,64), change at your own peril.
 
virtual std::vector< size3i_t > brickcount () const =0
 Number of bricks at each resolution (LOD) level.
 
virtual int32_t nlods () const =0
 Number of resolution (LOD) levels.
 
virtual void meta () const =0
 Dictionary of meta data. NOT IMPLEMENTED.
 
virtual int32_t numthreads () const =0
 Number of threads to use. NOT IMPLEMENTED.
 
virtual void set_numthreads (int32_t)=0
 Number of threads to use. NOT IMPLEMENTED.
 
virtual void dump (std::ostream &) const =0
 Output in human readable form for debugging.
 
virtual SampleStatistics statistics () const =0
 Statistics of all sample values on the file.
 
virtual SampleHistogram histogram () const =0
 Histogram of all sample values on the file.
 

Static Public Member Functions

static std::shared_ptr< IZgyReaderopen (const std::string &filename, const IOContext *iocontext=nullptr)
 Open a ZGY file for reading.
 

Additional Inherited Members

- Public Types inherited from OpenZGY::IZgyMeta
typedef std::int8_t int8_t
 
typedef std::int16_t int16_t
 
typedef std::int32_t int32_t
 
typedef std::int64_t int64_t
 
typedef float float32_t
 
typedef double float64_t
 
typedef std::array< int64_t, 3 > size3i_t
 
typedef std::array< std::array< float64_t, 2 >, 4 > corners_t
 
typedef std::pair< std::shared_ptr< const void >, std::int64_t > rawdata_t
 
typedef std::function< rawdata_t(const rawdata_t &, const std::array< int64_t, 3 > &)> compressor_t
 

Detailed Description

Main API for reading ZGY files.

Obtain a concrete instance by calling the factory method IZgyReader::open(). You can then use the instance to read both meta data and bulk data. It is recommended to explicitly close the file when done with it.

Note: Yes, I understand that the open() factory method should not have been lexically scoped inside the ostensibly pure IZgyReader interface. But this reduces the number of classes a library user needs to relate to.

Member Function Documentation

◆ close()

virtual void OpenZGY::IZgyReader::close ( )
pure virtual

Close the file and release resources.

The ZgyReader destructor will call close() if not done already, catching and swallowing any exception. Unlike ZgyWriter::close() forgetting to close a file that was only open for read is not a major faux pas. It is still recommended to explicitly close, though.

Implemented in OpenZGY::Impl::ZgyReader.

◆ read() [1/3]

virtual void OpenZGY::IZgyReader::read ( const size3i_t &  start,
const size3i_t &  size,
float *  data,
int  lod = 0 
) const
pure virtual

Read an arbitrary region.

The data is read into a buffer provided by the caller. The method will apply conversion storage -> float if needed.

The start position refers to the specified lod level. At lod 0 start + data.size can be up to the survey size. At lod 1 the maximum is just half that, rounded up.

It is valid to pass a size that includes the padding area between the survey and the end of the current brick. But not more. In other words, the limit for lod 0 is actually reader()->size() rounded up to a multiple of reader->bricksize().

Implemented in OpenZGY::Impl::ZgyReader.

◆ read() [2/3]

virtual void OpenZGY::IZgyReader::read ( const size3i_t &  start,
const size3i_t &  size,
std::int16_t *  data,
int  lod = 0 
) const
pure virtual

Read an arbitrary region with no conversion.

As the read overload with a float buffer but only works for files with SampleDataType::int16 and does not scale the samples.

Implemented in OpenZGY::Impl::ZgyReader.

◆ read() [3/3]

virtual void OpenZGY::IZgyReader::read ( const size3i_t &  start,
const size3i_t &  size,
std::int8_t *  data,
int  lod = 0 
) const
pure virtual

Read an arbitrary region with no conversion.

As the read overload with a float buffer but only works for files with SampleDataType::int8 and does not scale the samples.

Implemented in OpenZGY::Impl::ZgyReader.

◆ readconst()

virtual std::pair<bool,double> OpenZGY::IZgyReader::readconst ( const size3i_t &  start,
const size3i_t &  size,
int  lod = 0,
bool  as_float = true 
) const
pure virtual

Get hint about all constant region.

Check to see if the specified region is known to have all samples set to the same value. Returns a pair of (is_const, const_value).

The function only makes inexpensive checks so it might return is_const=false even if the region was in fact constant. It will not make the opposite mistake. This method is only intended as a hint to improve performance.

For int8 and int16 files the caller may specify whether to scale the values or not. Even if unscaled the function returns the value as a double.

Implemented in OpenZGY::Impl::ZgyReader.


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