Exemple #1
0
def test_segyiotests_writer_from_seisnc(temp_dir, segyio3d_test_files):
    file, segyio_kwargs = segyio3d_test_files
    seisnc = temp_dir / file.with_suffix(".siesnc").name
    segy_converter(str(file), ncfile=seisnc, silent=True, **segyio_kwargs)
    outfile = temp_dir / file.name
    segy_writer(seisnc, outfile)
    ds = segy_loader(str(outfile), silent=True, **well_known_byte_locs("standard_3d"))
    assert isinstance(ds, xr.Dataset)
Exemple #2
0
def convert(output_file, input_file, iline, xline, cdpx, cdpy, crop,
            output_type, dimension):
    input_file = pathlib.Path(input_file)
    if output_type is None and output_file is not None:
        output_type = guess_file_type(output_file)
    elif output_type is None and output_file is None:
        """Because currently only one conversion exists we can guess the output from the input"""
        input_type = guess_file_type(input_file)
        if input_type:
            output_type = "SEGY" if input_type == "NETCDF" else "NETCDF"

    if output_type is None:
        click.echo(
            "Output type not recognised! Please provide the desired output file type explicitly using the --output-type option"
        )
        raise SystemExit

    click.echo(f"Converting file {input_file.name} to {output_type}")

    if len(crop) == 0:
        crop = None

    if output_type == "NETCDF":
        if output_file is None:
            output_file = input_file.stem + ".SEISNC"
        segy_converter(
            input_file,
            ncfile=output_file,
            iline=iline,
            xline=xline,
            ix_crop=crop,
            cdpx=cdpx,
            cdpy=cdpy,
        )
        click.echo(f"Converted file saved as {output_file}")
        LOGGER.info(f"NetCDF output written to {output_file}")
    elif output_type == "SEGY":
        if output_file is None:
            output_file = input_file.stem + ".segy"
        segy_writer(input_file,
                    output_file,
                    iline=iline,
                    xline=xline,
                    dimension=dimension)
        click.echo(f"Converted file saved as {output_file}")
        LOGGER.info(f"SEGY output written to {output_file}")
    else:
        click.echo(
            f"Conversion to output-type {output_type} is not implemented yet")
        raise SystemExit
Exemple #3
0
def test_segyiotests_nohead_2ncdf(temp_dir, segyio_nohead_test_files):
    file, segyio_kwargs = segyio_nohead_test_files
    seisnc = temp_dir / file.with_suffix(".siesnc").name
    segy_converter(str(file), ncfile=seisnc, silent=True, **segyio_kwargs)
    ds = open_seisnc(seisnc)
    assert isinstance(ds, xr.Dataset)