|
OpenZGY/Python Public API (ALPHA)
Access seismic data stored in ZGY format.
|
Main API for creating ZGY files. More...
Public Member Functions | |
| def | __init__ (self, filename, *iocontext=None, compressor=None, lodcompressor=None, **kwargs) |
| def | __enter__ (self) |
| def | __exit__ (self, type, value, traceback) |
| def | write (self, start, data, *verbose=None) |
| Write an arbitrary region. More... | |
| def | writeconst (self, start, value, size, is_storage, *verbose=None) |
| Write a single value to a region of the file. More... | |
| def | finalize (self, *decimation=None, progress=None, force=False, verbose=None) |
| def | close (self) |
Public Member Functions inherited from openzgy.api.ZgyMetaAndTools | |
| def | annotToIndex (self, point) |
| def | annotToWorld (self, point) |
| def | indexToAnnot (self, point) |
| def | indexToWorld (self, point) |
| def | worldToAnnot (self, point) |
| def | worldToIndex (self, point) |
Public Member Functions inherited from openzgy.api.ZgyMeta | |
| def | __init__ (self, meta) |
| def | size (self) |
| def | datatype (self) |
| def | datarange (self) |
| def | zunitdim (self) |
| def | hunitdim (self) |
| def | zunitname (self) |
| def | hunitname (self) |
| def | zunitfactor (self) |
| def | hunitfactor (self) |
| def | zstart (self) |
| def | zinc (self) |
| def | annotstart (self) |
| def | annotinc (self) |
| def | corners (self) |
| def | indexcorners (self) |
| def | annotcorners (self) |
| def | bricksize (self) |
| def | brickcount (self) |
| def | nlods (self) |
| def | meta (self) |
| def | numthreads (self) |
| def | numthreads (self, x) |
| def | dump (self, file=None) |
| def | statistics (self) |
| def | histogram (self) |
Additional Inherited Members | |
Static Public Member Functions inherited from openzgy.api.ZgyMetaAndTools | |
| def | transform (A, B, data) |
| def | transform1 (A, B, point) |
Main API for creating ZGY files.
Main API for creating ZGY files. Obtain a concrete instance by calling the constructor. All meta data is specified in the call to open(), so meta data will appear to be read only. You can use the instance to write bulk data. The file becomes read only once the instance is closed. It is recommended to call finalize() and close() after all bulk has been written. But if you forget then this will be done when the writer goes out of scope, provided of course that you used a "with" block.
| def openzgy.api.ZgyWriter.__init__ | ( | self, | |
| filename, | |||
| * | iocontext = None, |
||
compressor = None, |
|||
lodcompressor = None, |
|||
| ** | kwargs | ||
| ) |
Create a new ZGY file.
Optionally pass templatename = otherfile to create a new file
similar to otherfile. Explicit keyword argumants override
information from otherfile.
Optionally pass templatename = filename to erase all data blocks
from filename but keep the metadata. New data blocks can then
be written to the file. Petrel/BASE might need this feature,
due to the way it writes new files. They tend to get opened
several times to add meta information. Caveat: Behind the
scenes the file is simply deleted and re-created. This is
slightly less efficient than opening the file for read/write.
templatename: string
Optionally create a file similar to this one.
TODO-Low: In the future might also accept a ZgyReader instance.
This is convenient if a file is being copied, so as to not
needing to open it twice.
filename: string
The local or cloud file to create.
size: (int, int, int)
Number of inlines, crosslines, samples.
bricksize: (int, int, int)
Size of a single brick. Defaults to (64, 64, 64).
Please use the default unless you really know what
you are doing. In any case, each size needs to be
a power of 2.
datatype: SampleDataType
Specify int8, int16, or float.
datarange = (float, float)
Used only if datatype is integral, to convert from storage to
actual sample values. The lowest possible storage value, i.e.
-128 or -32768, maps to datarange[0] and the highest possible
storage value maps to datarange[1].
zunitdim: UnitDimension. time, length, or unknown.
zunitname: string
zunitfactor: float
Describe how to convert between storage units and SI units
in the vertical direction. Petrel ignores these settings and
prompts the user.
hunitdim: UnitDimension. length, arcangle, or unknown.
hunitname: string
hunitfactor: float
Describe how to convert between storage units and SI units
in the horizontal direction. Most applications cannot handle
arcangle. Petrel ignores these settings and prompts the user.
zstart: float
The time or depth corresponding to the shallowest sample.
zinc: float
The vertical time or depth distance between neighboring samples.
annotstart: (float, float)
The inline and crossline numbers corresponding to the ordinal
position (0, 0) i.e. the first sample on the file.
annotinc: (float, float)
The inline / crossline step between neighboring samples.
The samples at ordinal (1, 1) will have annotation
annotstart + annotinc.
corners: (float, float)[4]
World coordinates of each corner, order as
First inline / first crossline,
last inline / first crossline,
first inline / last crossline,
last inline / last crossline.
compressor, lodcompressor: callable
If set, attempt to compress each block with this callable.
Typically this should be a lambda or a class, because it
needs to capture the compression parameters.
Example:
compressor = ZgyCompressFactory("ZFP", snr = 30)
If different compression parameters are desired for
full- and low resolution bricks then lodcompressor can
be provided as well. It defaults to compressor. Using
two different instances, even if the parameters match,
may also cause statistics to be reported separately
for fullres and lowres.
| def openzgy.api.ZgyWriter.close | ( | self | ) |
Close the currently open file. Failure to close the file will corrupt it.
| def openzgy.api.ZgyWriter.finalize | ( | self, | |
| * | decimation = None, |
||
progress = None, |
|||
force = False, |
|||
verbose = None |
|||
| ) |
Generate low resolution data, statistics, and histogram.
This 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.
Arguments:
decimation: Optionally override the decimation algorithms by
passing an array of impl.lodalgo.DecimationType
with one entry for each level of detail. If the
array is too short then the last entry is used for
subsequent levels.
TODO-Low: The expected enum type is technically internal
and ought to have been mapped to an enum api.XXX.
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.
verbose: optional function to print diagnostic information.
| def openzgy.api.ZgyWriter.write | ( | self, | |
| start, | |||
| data, | |||
| * | verbose = None |
||
| ) |
Write an arbitrary region.
Write bulk data. Type must be np.float32, np.int16, or np.int8.
np.float32 may be written to any file and will be converted
if needed before storing. Writing an integral type implies that
values are to be written without conversion. In that case the
type of the buffer must match exactly the file's storage type.
You cannot write int8 data to an int16 file or vice versa.
Arguments:
start: tuple(i0,j0,k0) where to start writing.
data: np.ndarray of np.int8, np.int16, or np.float32
| def openzgy.api.ZgyWriter.writeconst | ( | self, | |
| start, | |||
| value, | |||
| size, | |||
| is_storage, | |||
| * | verbose = None |
||
| ) |
Write a single value to a region of the file.
Write a single value to a region of the file.
This is equivalent to creating a constant-value array with np.full()
and write that. But this version might be considerably faster.
If is_storage is false and the input value cannot be converted to
storage values due to being outside range after conversion then
the normal rules (use closest valid value) apply. If
is_storage is True then an error is raised if the supplied value
cannot be represented.
Arguments:
start: tuple(i0,j0,k0) where to start writing.
size: tuple(ni,nj,nk) size of region to write.
value: Scalar to be written.
is_storge: False if the value shall be converted to storage
True if it is already storage and should be written
unchanged. Ignored if the storage type is float.
1.8.17