Пример #1
0
def test_convert_to_adv_from_compressed(tmp_path):
    out_sgz = os.path.join(str(tmp_path), 'small_test_data_convert-adv.sgz')

    with SgzConverter(SGZ_FILE_2) as converter:
        converter.convert_to_adv_sgz(out_sgz)

    with SgzReader(SGZ_FILE_2) as reader:
        sgz_data = reader.read_volume()

    with SgzReader(out_sgz) as reader:
        sgz_adv_data = reader.read_volume()

    assert np.array_equal(sgz_data, sgz_adv_data)
Пример #2
0
def compress_and_compare_axes(sgy_file, unit, tmp_path):
    out_sgz = os.path.join(str(tmp_path),
                           'small_test_axes_{}.sgz'.format(unit))

    with SegyConverter(sgy_file) as converter:
        converter.run(out_sgz)

    with segyio.open(sgy_file) as f:
        with SgzReader(out_sgz) as reader:
            assert np.all(reader.ilines == f.ilines)
            assert np.all(reader.xlines == f.xlines)
            assert np.all(reader.zslices == f.samples)
Пример #3
0
def test_compress_unstructured(tmp_path):
    out_sgz = os.path.join(str(tmp_path), 'small_test-irregular_data.sgz')

    with SegyConverter(SGY_FILE_IRREG) as converter:
        converter.run(out_sgz, bits_per_voxel=8)

    with SgzReader(out_sgz) as reader:
        sgz_data = reader.read_volume()

    segy_cube = segyio.tools.cube(SGY_FILE)
    segy_cube[4, 4, :] = 0
    assert np.allclose(sgz_data, segy_cube, rtol=1e-2)
Пример #4
0
def test_compress_crop(tmp_path):
    out_sgz = os.path.join(str(tmp_path), 'small_test_data.sgz')

    with SegyConverter(SGY_FILE, min_il=1, max_il=4, min_xl=1,
                       max_xl=3) as converter:
        converter.run(out_sgz, bits_per_voxel=16)

    with SgzReader(out_sgz) as reader:
        sgz_data = reader.read_volume()

    assert np.allclose(sgz_data,
                       segyio.tools.cube(SGY_FILE)[1:4, 1:3, :],
                       rtol=1e-8)
Пример #5
0
def compress_and_compare_data(sgy_file, tmp_path, bits_per_voxel, rtol):
    for reduce_iops in [True, False]:
        out_sgz = os.path.join(
            str(tmp_path),
            'small_test_data_{}_{}_.sgz'.format(bits_per_voxel, reduce_iops))

        with SegyConverter(sgy_file) as converter:
            converter.run(out_sgz,
                          bits_per_voxel=bits_per_voxel,
                          reduce_iops=reduce_iops)

        with SgzReader(out_sgz) as reader:
            sgz_data = reader.read_volume()

        assert np.allclose(sgz_data, segyio.tools.cube(sgy_file), rtol=rtol)
Пример #6
0
def compress_and_compare_zgy(zgy_file, sgy_file, tmp_path, bits_per_voxel,
                             rtol):
    out_sgz = os.path.join(
        str(tmp_path), 'test_{}_{}_.sgz'.format(
            os.path.splitext(os.path.basename(zgy_file))[0], bits_per_voxel))

    with ZgyConverter(zgy_file) as converter:
        converter.run(out_sgz, bits_per_voxel=bits_per_voxel)

    with SgzReader(out_sgz) as reader:
        sgz_data = reader.read_volume()
        sgz_ilines = reader.ilines

    with segyio.open(sgy_file) as f:
        ref_ilines = f.ilines

    assert np.allclose(sgz_data, segyio.tools.cube(sgy_file), rtol=rtol)
    assert all([a == b for a, b in zip(sgz_ilines, ref_ilines)])
Пример #7
0
import segyio
import time
import os
import sys

from PIL import Image
import numpy as np
from matplotlib import cm

base_path = sys.argv[1]
LINE_NO = int(sys.argv[2])

CLIP = 0.2
SCALE = 1.0/(2.0*CLIP)

with SgzReader(os.path.join(base_path, '0.sgz')) as reader:
    t0 = time.time()
    slice_sgz = reader.read_anticorrelated_diagonal(LINE_NO)
    print("SgzReader took", time.time() - t0)


im = Image.fromarray(np.uint8(cm.seismic((slice_sgz.T.clip(-CLIP, CLIP) + CLIP) * SCALE)*255))
im.save(os.path.join(base_path, 'out_ad-sgz.png'))


with segyio.open(os.path.join(base_path, '0.sgy')) as segyfile:
    t0 = time.time()
    diagonal_length = get_anticorrelated_diagonal_length(LINE_NO, len(segyfile.ilines), len(segyfile.xlines))
    slice_segy = np.zeros((diagonal_length, len(segyfile.samples)))
    if LINE_NO < len(segyfile.xlines):
        for d in range(diagonal_length):
Пример #8
0
from seismic_zfp.read import SgzReader
import time
import os
import sys

base_path = sys.argv[1]

CLIP = 0.2
SCALE = 1.0 / (2.0 * CLIP)

with SgzReader(os.path.join(base_path, '0.sgz'), preload=True) as reader:
    t0 = time.time()
    for i in range(reader.n_ilines):
        slice_sgz = reader.read_inline(i)
    print("SgzReader (with preloading) took", time.time() - t0)

with SgzReader(os.path.join(base_path, '0.sgz'), preload=False) as reader:
    t0 = time.time()
    for i in range(reader.n_ilines):
        slice_sgz = reader.read_inline(i)
    print("SgzReader (without preloading) took", time.time() - t0)