Example #1
0
def scrape(filename, ebcidc=False, trace_headers=False):
    """Scrape the file meta information and output it to text file.

    If no options are specified both will be output. The output file will be
    <filename>.txt for the EBCIDC and <filename>.csv for
    trace headers.

    The trace headers can be read back into Python using
    pandas.read_csv(<filename>.csv, index_col=0)
    """
    for file in tqdm(filename, desc="File"):
        file = pathlib.Path(file)
        ebcidc_name = file.with_suffix(".txt")
        header_name = file.with_suffix(".csv")

        if ebcidc == False and trace_headers == False:
            ebcidc = True
            trace_headers = True

        if ebcidc:
            txt = get_segy_texthead(file)
            with open(ebcidc_name, "w") as txtfile:
                txtfile.writelines(txt)

        if trace_headers:
            head_df = segy_header_scrape(file)
            head_df.to_csv(header_name)
Example #2
0
def test_segyiotests_2ds_wheaderscrap(segyio3d_test_files):
    file, segyio_kwargs = segyio3d_test_files
    scrape_args = dict()
    try:
        scrape_args["endian"] = segyio_kwargs["endian"]
    except KeyError:
        pass
    header = segy_header_scrape(str(file), silent=True, **scrape_args)
    ds = segy_loader(str(file), silent=True, **segyio_kwargs, head_df=header)
    assert isinstance(ds, xr.Dataset)
Example #3
0
def test_segy_header_scrape(temp_dir, temp_segy):
    header = segy_header_scrape(temp_segy, silent=True)
    assert isinstance(header, pd.DataFrame)
    assert header.shape == (TEST_SEGY_SIZE**2, 89)
Example #4
0
# to filter away blank values which can help us to understand the composition of the data.
#
# For instance, key values like **trace UTM coordinates** are located in bytes *73* for X & *77* for Y. We
# can also see the byte positions of the **local grid** for INLINE_3D in byte *189* and for CROSSLINE_3D in byte *193*.

# %%
scan[scan["std"] > 0]

# %% [markdown]
# To retreive the raw header content use `segy_header_scrape`. Setting `partial_scan=None` will return the
# full dataframe of trace header information.

# %%
from segysak.segy import segy_header_scrape

scrape = segy_header_scrape(V3D_path, partial_scan=1000)
scrape

# %% [markdown]
# ## Load SEG-Y data

# %% [markdown]
# All SEGY (2D, 2D gathers, 3D & 3D gathers) are ingested into `xarray.Dataset` objects through the
# `segy_loader` function. It is best to be explicit about the byte locations of key information but
# `segy_loader` can attempt to guess the shape of your dataset. Some standard byte positions are
# defined in the `well_known_bytes` function and others can be added via pull requests to the Github
# repository if desired.

# %%
from segysak.segy import segy_loader, well_known_byte_locs