|
OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
|
Concrete implementation of IZgyWriter. More...
Public Member Functions | |
| ZgyWriter (const ZgyWriterArgs &args) | |
| Create a ZGY file and open it for writing. More... | |
| virtual | ~ZgyWriter () |
| Automatically close the file when it goes out of scope. More... | |
| void | write (const size3i_t &start, const size3i_t &size, const float *data) const override |
| Write an arbitrary region. More... | |
| void | write (const size3i_t &start, const size3i_t &size, const std::int16_t *data) const override |
| Write an arbitrary region with no conversion. More... | |
| void | write (const size3i_t &start, const size3i_t &size, const std::int8_t *data) const override |
| Write an arbitrary region with no conversion. More... | |
| void | writeconst (const size3i_t &start, const size3i_t &size, const float *data) const override |
| Write all-constant data. More... | |
| void | writeconst (const size3i_t &start, const size3i_t &size, const std::int16_t *data) const override |
| Write an arbitrary region with no conversion. More... | |
| void | writeconst (const size3i_t &start, const size3i_t &size, const std::int8_t *data) const override |
| Write an arbitrary region with no conversion. More... | |
| void | finalize (const std::vector< DecimationType > &decimation, const std::function< bool(std::int64_t, std::int64_t)> &progress, bool force=false) |
| Generate low resolution data, statistics, and histogram. More... | |
| void | close_incomplete () |
| Flush the file to disk and close it. More... | |
| void | close () |
| Flush the file to disk and close it. More... | |
| bool | errorflag () const override |
| void | set_errorflag (bool value) override |
Public Member Functions inherited from OpenZGY::Impl::ZgyMetaAndTools | |
| virtual void | transform (const corners_t &A, const corners_t &B, std::vector< std::array< float64_t, 2 >> &data) const override |
| General coordinate conversion of an array of points. (NOT IMPLEMENTED YET) More... | |
| virtual std::array< float64_t, 2 > | transform1 (const corners_t &A, const corners_t &B, const std::array< float64_t, 2 > &point) const override |
| General coordinate conversion of a single coordinate pair. More... | |
| virtual std::array< float64_t, 2 > | annotToIndex (const std::array< float64_t, 2 > &point) const override |
| Convert a single coordinate pair. | |
| virtual std::array< float64_t, 2 > | annotToWorld (const std::array< float64_t, 2 > &point) const override |
| Convert a single coordinate pair. | |
| virtual std::array< float64_t, 2 > | indexToAnnot (const std::array< float64_t, 2 > &point) const override |
| Convert a single coordinate pair. | |
| virtual std::array< float64_t, 2 > | indexToWorld (const std::array< float64_t, 2 > &point) const override |
| Convert a single coordinate pair. | |
| virtual std::array< float64_t, 2 > | worldToAnnot (const std::array< float64_t, 2 > &point) const override |
| Convert a single coordinate pair. | |
| virtual std::array< float64_t, 2 > | worldToIndex (const std::array< float64_t, 2 > &point) const override |
| Convert a single coordinate pair. | |
Public Member Functions inherited from OpenZGY::Impl::ZgyMeta | |
| virtual std::array< int64_t, 3 > | size () const override |
| Size in inline, crossline, vertical directions. | |
| virtual SampleDataType | datatype () const override |
| Type of samples in each brick. | |
| virtual std::array< float32_t, 2 > | datarange () const override |
| Used for float to int scaling. | |
| virtual UnitDimension | zunitdim () const override |
| Vertical dimension. | |
| virtual UnitDimension | hunitdim () const override |
| Horizontal dimension. | |
| virtual std::string | zunitname () const override |
| For annotation only. Use hunitfactor, not the name, to convert to or from SI. | |
| virtual std::string | hunitname () const override |
| For annotation only. Use hunitfactor, not the name, to convert to or from SI. | |
| virtual float64_t | zunitfactor () const override |
| Multiply by this factor to convert from storage units to SI units. | |
| virtual float64_t | hunitfactor () const override |
| Multiply by this factor to convert from storage units to SI units. | |
| virtual float32_t | zstart () const override |
| First time/depth. | |
| virtual float32_t | zinc () const override |
| Increment in vertical direction. | |
| virtual std::array< float32_t, 2 > | annotstart () const override |
| First inline, crossline. | |
| virtual std::array< float32_t, 2 > | annotinc () const override |
| Increment in inline, crossline directions. | |
| virtual const corners_t & | corners () const |
| Survey corner points in world coordinates. | |
| virtual const corners_t & | indexcorners () const |
| Survey corner points in ordinal (i,j) coordinates. | |
| virtual const corners_t & | annotcorners () const |
| Survey corner points in inline, crossline coordinates. | |
| virtual std::array< int64_t, 3 > | bricksize () const override |
| Size of one brick. Almost always (64,64,64), change at your own peril. | |
| virtual std::vector< std::array< int64_t, 3 > > | brickcount () const override |
| Number of bricks at each resolution (LOD) level. | |
| virtual int32_t | nlods () const override |
| Number of resolution (LOD) levels. | |
| virtual void | meta () const override |
| Dictionary of meta data. NOT IMPLEMENTED. | |
| virtual int32_t | numthreads () const override |
| Number of threads to use. NOT IMPLEMENTED. | |
| virtual void | set_numthreads (int32_t) override |
| Number of threads to use. NOT IMPLEMENTED. | |
| virtual void | dump (std::ostream &os) const override |
| Output in human readable form for debugging. | |
| virtual SampleStatistics | statistics () const override |
| Statistics of all sample values on the file. | |
| virtual SampleHistogram | histogram () const override |
| Histogram of all sample values on the file. | |
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 |
Static Public Member Functions inherited from OpenZGY::IZgyWriter | |
| static std::shared_ptr< IZgyWriter > | open (const ZgyWriterArgs &args) |
| Create a ZGY file and open it for writing. | |
Protected Attributes inherited from OpenZGY::Impl::ZgyMeta | |
| std::shared_ptr< InternalZGY::ZgyInternalMeta > | _meta |
| Handle to the internal metadata layer which this class wraps. | |
Concrete implementation of IZgyWriter.
| OpenZGY::Impl::ZgyWriter::ZgyWriter | ( | const ZgyWriterArgs & | args | ) |
Create a ZGY file and open it for writing.
|
virtual |
Automatically close the file when it goes out of scope.
Application code is encouraged to close the file explicitly. The destructor is just there as a fallback. Errors caught in the fallback will be logged to stderr and otherwise ignored.
|
virtual |
Flush the file to disk and close it.
If the file has been written to, the application is encouraged to call finalize() before close(). This gives more control over the process and allows using a progress callback to track generation of low resolution data.
The function won't bother with statistics, histogram, lowres if there has been an unrecoverable error. The headers might still be written out in case somebody wants to try some forensics.
The ZgyWriter destructor will call close() if not done already, but that will catch and swallow any exception. Relying on the destructor to close the file is strongly discouraged.
Implements OpenZGY::IZgyWriter.
|
virtual |
Flush the file to disk and close it.
This version of close() will not calculate statistics and low resolution bricks. Currently this makes the file useless in most cases. The function may be useful for performance measurements.
In the future it might be possible to re-open the file at some later date and continue writing data to it. Calling the regular close() only when all data has been output.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Return true if this open file has encountered an unrecoverable error. The error should previously have caused an exception to be thrown. If this flag is set, no further writes will be allowed.
Application code might check this flag if they are considering trying to recover from an error. Internally the flag is also checked and if set it will (mostly) prevent other writes from being done.
Implementation note: Currently the ZgyInternalMeta and ZgyInternalBulk instances each contains an _is_bad member. The reader or writer is considered bad if either of those are set. This scheme improves isolation somewhat, but TODO-Low it might backfire. If writing metadata to file failed, the bulk accessor should probably behave as if it also has seen an error.
Currently only the ZgyWriter uses this mechanism. It might not make that much sense in ZgyReader, because as long as opening the file succeded no operation should manage to corrupt it.
Implements OpenZGY::IZgyWriter.
|
virtual |
Generate low resolution data, statistics, and histogram.
This method will be called automatically from close(), but in that case it is not possible to request a progress callback.
If the processing raises an exception the data is still marked as clean. Called can force a retry by passing force=True.
The C++ code is very different from Python because it needs an entirely different approach to be performant.
| decimation | Optionally override the decimation algorithms by passing an array of DecimationType with one entry for each level of detail. If the array is too short then the last entry is used for subsequent levels. |
| progress | Function(done, total) called to report progress. If it returns False the computation is aborted. Will be called at least one, even if there is no work. |
| force | If true, generate the low resolution data even if it appears to not be needed. Use with caution. Especially if writing to the cloud, where data should only be written once. |
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Force the error flag for this open file to true or false. This should normally be done only for testing.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Write an arbitrary region.
This will apply conversion float -> storage if needed.
A read/modify/write will be done if the region's start and size doesn't align with bricksize. When writing to the cloud this read/modify/write may incur performance and size penalties. So do write brick aligned data if possible. The same applies to writing compressed data where r/m/w can cause a severe loss of quality.
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.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Write an arbitrary region with no conversion.
As the write overload with a float buffer but only works for files with SampleDataType::int16 and does not scale the samples.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Write an arbitrary region with no conversion.
As the write overload with a float buffer but only works for files with SampleDataType::int8 and does not scale the samples.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Write all-constant data.
Works as the corresponding write but the entire region is set to the same value. So the provided data buffer needs just one value, or alternatively can be passed as &scalar_value.
Calling this method is faster than filling a buffer with constant values and calling write. But it produces the exact same result. This is because write will automatically detect whether the input buffer is all constant.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Write an arbitrary region with no conversion.
As the writeconst overload with a float buffer but only works for files with SampleDataType::int16 and does not scale the samples.
Implements OpenZGY::IZgyWriter.
|
overridevirtual |
Write an arbitrary region with no conversion.
As the write overload with a float buffer but only works for files with SampleDataType::int8 and does not scale the samples.
Implements OpenZGY::IZgyWriter.
1.8.17