OpenZGY/Python API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Public Member Functions | Static Public Member Functions | List of all members
openzgy.impl.compress.CompressFactoryImpl Class Reference

Public Member Functions

def knownCompressors ()
 
def knownDecompressors ()
 

Static Public Member Functions

def registerCompressor (name, fn)
 
def registerDecompressor (name, fn)
 
def factory (name, *args, **kwargs)
 
def decompress (cdata, status, shape, file_dtype, user_dtype)
 

Detailed Description

Registry of known compress and decompress algorithms.
Those two are completely separate but we might as well
handle both in the same class.

Member Function Documentation

◆ decompress()

def openzgy.impl.compress.CompressFactoryImpl.decompress (   cdata,
  status,
  shape,
  file_dtype,
  user_dtype 
)
static
Loop over all registered decompressors and try to find one that
can handle this particular brick. Raises an error if none found.
See CompressPlugin.decompress() for parameter descriptions.

◆ knownCompressors()

def openzgy.impl.compress.CompressFactoryImpl.knownCompressors ( )
Return the names of all compressors known to the system.
This is primarily for logging, but might in principle be used
in a GUI to present a list of compressors to choose from.
The problem with that is how to handle the argument list.

◆ knownDecompressors()

def openzgy.impl.compress.CompressFactoryImpl.knownDecompressors ( )
Return the names of all compressors known to the system.
This is primarily for logging.

◆ registerCompressor()

def openzgy.impl.compress.CompressFactoryImpl.registerCompressor (   name,
  fn 
)
static
Register a factory function that will be called to create
a function that in turn can be used to compress a data block.
Pass fn = None if you for some reason need to remove a registration.

The registered function can have any signature; the signature
needs to include whatever parameters the actual compressor wants.

The function that is created by the factory must have the signature:
    raw:          bytes.
    brickstatus:  impl.enum.BrickStatus,
    bricksize:    tuple(int,int,int),
    file_dtype:   np.dtype,
    result_dtype: np.dtype

The function's return value:
    np.ndarray with rank 3, shape bricksize, and dtype result_dtype.

Example usage of the factory:
    old: with ZgyWriter(snr=snr)
    new: with ZgyWriter(compressor = ZgyCompressFactory("ZFP", snr=30),

The example shows that this is a bit more inconvenient for the end
user. But it allows for using different compression plug-ins with
arbitrary parameters.

Note that user code doesn't need to use ZgyCompressFactory() and
its list of known compressors. Instead a compression function
can be provided directly. But most likely the factory method will
be simpler to maintain.

fn() is allowed to return None, which will have the same effect
as if the user did not specify any compression. E.g. there might be
a convention that snr<0 means store uncompressed. Allowing the
factory to return None in that case means the example above would
still work. Otherwise the snr<0 test would be included in the
client code. Which is messy.

◆ registerDecompressor()

def openzgy.impl.compress.CompressFactoryImpl.registerDecompressor (   name,
  fn 
)
static
Register a factory function that is able to decompress one or more
types of compressed data. The registered functions will be called
in reverse order of registration until one of them indicates that
it has decompressed the data. You cannot remove a registration
but you can effectively disable it by registering another one
that recognizes the same input data.
The supplied name is only for information.

The function that is created by the factory must have the signature:
    raw:          bytes.
    brickstatus:  impl.enum.BrickStatus,
    bricksize:    tuple(int,int,int),
    file_dtype:   np.dtype,
    result_dtype: np.dtype

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