def run_action():
    try:
        t0 = time.time()
        if compress.get():
            update_messages('Running compression...')
            if adv_layout.get():
                with SegyConverter(infile.get()) as converter:
                    converter.run(outfile.get(),
                                  bits_per_voxel=2,
                                  blockshape=(64, 64, 4),
                                  method="Stream",
                                  reduce_iops=True)
            else:
                with SegyConverter(infile.get()) as converter:
                    converter.run(outfile.get(),
                                  bits_per_voxel=bitrate.get(),
                                  method='Stream',
                                  reduce_iops=True)
        else:
            update_messages('Running decompression...')
            with SgzConverter(infile.get()) as converter:
                converter.convert_to_segy(outfile.get())
        tt = time.time() - t0

        outfile_size_bytes = os.path.getsize(outfile.get())
        outfile_size_gb = (outfile_size_bytes) / (1024 * 1024 * 1024)

        update_messages('...complete.')
        update_messages(
            'Actual output file size: {:8.2f}GB'.format(outfile_size_gb))
        update_messages('Time taken: {}'.format(str(timedelta(seconds=tt))))

    except FileNotFoundError:
        update_messages('File not found: ' + infile.get())
예제 #2
0
def main():
    if len(sys.argv) != 3:
        raise RuntimeError(
            "This example accepts exactly 2 arguments: input_file & output_file"
        )

    with SgzConverter(sys.argv[1]) as converter:
        converter.convert_to_adv_sgz(sys.argv[2])
예제 #3
0
def test_decompress_data(tmp_path):
    out_sgy = os.path.join(str(tmp_path), 'small_test_data.sgy')

    with SgzConverter(SGZ_FILE) as converter:
        converter.convert_to_segy(out_sgy)

    assert np.allclose(segyio.tools.cube(out_sgy),
                       segyio.tools.cube(SGY_FILE),
                       rtol=1e-8)
예제 #4
0
def test_decompress_unstructured(tmp_path):
    out_sgy = os.path.join(str(tmp_path), 'small_test-irregular_data.sgy')

    with SgzConverter(SGZ_FILE_IRREG) as converter:
        converter.convert_to_segy(out_sgy)

    segy_cube = segyio.tools.cube(SGY_FILE)
    segy_cube[4, 4, :] = 0

    assert np.allclose(segyio.tools.cube(out_sgy), segy_cube, rtol=1e-2)
예제 #5
0
def test_decompress_headers(tmp_path):
    out_sgy = os.path.join(str(tmp_path), 'small_test_headers.sgy')

    with SgzConverter(SGZ_FILE) as converter:
        converter.convert_to_segy(out_sgy)

    with segyio.open(out_sgy) as recovered_sgy_file:
        with segyio.open(SGY_FILE) as original_sgy_file:
            for sgz_header, sgy_header in zip(recovered_sgy_file.header,
                                              original_sgy_file.header):
                assert sgz_header == sgy_header
예제 #6
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)