Skip to content

Depreciated Writing SEG-Y

Warning

These methods have been depreciated in favour of an Xarray accessor method. Examples in this documentation have been updated to use the new method or consult the accessor reference.

segy_writer(seisnc, segyfile, trace_header_map=None, il_chunks=None, dimension=None, silent=False, use_text=False)

Convert siesnc format (NetCDF4) to SEGY.

Parameters:

Name Type Description Default
seisnc (Dataset, string)

The input SEISNC file either a path or the in memory xarray.Dataset

required
segyfile string

The output SEG-Y file

required
trace_header_map dict

Defaults to None. A dictionary of seisnc variables and byte locations. The variable will be written to the trace headers in the assigned byte location. By default CMP=23, cdp_x=181, cdp_y=185, iline=189, xline=193.

None
il_chunks int

The size of data to work on - if you have memory limitations. Defaults to 10. This is primarily used for large 3D and ignored for 2D data.

None
dimension str

Data dimension to output, defaults to 'twt' or 'depth' whichever is present

None
silent bool

Turn off progress reporting. Defaults to False.

False
use_text bool

Use the seisnc text for the EBCIDC output. This text usally comes from the loaded SEG-Y file and may not match the segysak SEG-Y output. Defaults to False and writes the default segysak EBCIDC

False
Source code in segysak/segy/_segy_writer.py
Python
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
def segy_writer(
    seisnc,
    segyfile,
    trace_header_map=None,
    il_chunks=None,
    dimension=None,
    silent=False,
    use_text=False,
):
    """Convert siesnc format (NetCDF4) to SEGY.

    Args:
        seisnc (xarray.Dataset, string): The input SEISNC file either a path or the in memory xarray.Dataset
        segyfile (string): The output SEG-Y file
        trace_header_map (dict, optional): Defaults to None. A dictionary of seisnc variables
            and byte locations. The variable will be written to the trace headers in the
            assigned byte location. By default CMP=23, cdp_x=181, cdp_y=185, iline=189,
            xline=193.
        il_chunks (int, optional): The size of data to work on - if you have memory
            limitations. Defaults to 10. This is primarily used for large 3D and ignored for 2D data.
        dimension (str): Data dimension to output, defaults to 'twt' or 'depth' whichever is present
        silent (bool, optional): Turn off progress reporting. Defaults to False.
        use_text (bool, optional): Use the seisnc text for the EBCIDC output. This text usally comes from
            the loaded SEG-Y file and may not match the segysak SEG-Y output. Defaults to False and writes
            the default segysak EBCIDC
    """
    warn(
        "segy_writer will be removed in v0.6, please use the accessor ds.seisio.to_segy() method instead.",
        DeprecationWarning,
        stacklevel=2,
    )
    if trace_header_map:
        check_tracefield(trace_header_map.values())

    if isinstance(seisnc, xr.Dataset):
        _segy_writer_input_handler(
            seisnc, segyfile, trace_header_map, dimension, silent, None, use_text
        )
    else:
        ncfile = seisnc
        if isinstance(il_chunks, int):
            chunking = {"iline": il_chunks}
        else:
            chunking = None
        with open_seisnc(ncfile, chunks=chunking) as seisnc:
            _segy_writer_input_handler(
                seisnc,
                segyfile,
                trace_header_map,
                dimension,
                silent,
                il_chunks,
                use_text,
            )

segy_freewriter(seisnc, segyfile, data_array='data', trace_header_map=None, use_text=False, dead_trace_key=None, vert_dimension='twt', chunk_spec=None, silent=False, **dim_kwargs)

Convert siesnc format (NetCDF4) to SEG-Y.

Parameters:

Name Type Description Default
seisnc (Dataset, string)

The input SEISNC file either a path or the in memory xarray.Dataset

required
segyfile string

The output SEG-Y file

required
data_array string

The Dataset variable name for the output volume.

'data'
trace_header_map dict

Defaults to None. A dictionary of seisnc variables and byte locations. The variable will be written to the trace headers in the assigned byte location. By default CMP=23, cdp_x=181, cdp_y=185, iline=189, xline=193.

None
use_text book

Use the seisnc text for the EBCIDC output. This text usally comes from the loaded SEG-Y file and may not match the segysak SEG-Y output. Defaults to False and writes the default segysak EBCIDC

False
dead_trace_key str

The key for the Dataset variable to use for trace output filter.

None
vert_dimension str

Data dimension to output, defaults to 'twt' or 'depth' whichever is present.

'twt'
chunk_spec dict

Xarray open_dataset chunking spec.

None
silent bool

Turn off progress reporting. Defaults to False.

False
dim_kwargs int

The dimension/byte location pairs to output dimensions to. The number of dim_kwargs should be equal to the number of dimensions on the output data_array. The sort order will be as per the order passed to the function.

{}
Source code in segysak/segy/_segy_freewriter.py
Python
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def segy_freewriter(
    seisnc,
    segyfile,
    data_array="data",
    trace_header_map=None,
    use_text=False,
    dead_trace_key=None,
    vert_dimension="twt",
    chunk_spec=None,
    silent=False,
    **dim_kwargs,
):
    """Convert siesnc format (NetCDF4) to SEG-Y.

    Args:
        seisnc (xarray.Dataset, string): The input SEISNC file either a path or the in memory xarray.Dataset
        segyfile (string): The output SEG-Y file
        data_array (string): The Dataset variable name for the output volume.
        trace_header_map (dict, optional): Defaults to None. A dictionary of seisnc variables
            and byte locations. The variable will be written to the trace headers in the
            assigned byte location. By default CMP=23, cdp_x=181, cdp_y=185, iline=189,
            xline=193.
        use_text (book, optional): Use the seisnc text for the EBCIDC output. This text usally comes from
            the loaded SEG-Y file and may not match the segysak SEG-Y output. Defaults to False and writes
            the default segysak EBCIDC
        dead_trace_key (str): The key for the Dataset variable to use for trace output filter.
        vert_dimension (str): Data dimension to output, defaults to 'twt' or 'depth' whichever
            is present.
        chunk_spec (dict, optional): Xarray open_dataset chunking spec.
        silent (bool, optional): Turn off progress reporting. Defaults to False.
        dim_kwargs (int): The dimension/byte location pairs to output dimensions to. The number of dim_kwargs should be
            equal to the number of dimensions on the output data_array. The sort order will be as per the order passed
            to the function.
    """
    warn(
        "segyfree_writer will be removed in v0.6, please use the accessor ds.seisio.to_segy method instead.",
        DeprecationWarning,
        stacklevel=2,
    )

    kwargs = dict(
        data_array=data_array,
        trace_header_map=trace_header_map,
        silent=silent,
        use_text=use_text,
        dead_trace_key=dead_trace_key,
        vert_dimension=vert_dimension,
    )

    if isinstance(seisnc, xr.Dataset):
        _segy_freewriter(
            seisnc,
            segyfile,
            **kwargs,
            **dim_kwargs,
        )
    else:
        ncfile = seisnc
        with open_seisnc(ncfile, chunks=chunk_spec) as seisnc:
            _segy_freewriter(
                seisnc,
                segyfile,
                **kwargs,
                **dim_kwargs,
            )

output_byte_locs(name)

Return common bytes position variable_dict for segy_writer.

Parameters:

Name Type Description Default
name str

One of [standard_3d, petrel_3d]

required

Returns:

Name Type Description
dict

A dictionary of SEG-Y byte positions and default seisnc variable pairs.

Example

segywriter(ncfile, 'segyfile.sgy', trace_header_map=output_byte_loc('petrel'))

Source code in segysak/segy/_segy_writer.py
Python
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def output_byte_locs(name):
    """Return common bytes position variable_dict for segy_writer.

    Args:
        name (str): One of [standard_3d, petrel_3d]

    Returns:
        dict: A dictionary of SEG-Y byte positions and default seisnc variable
            pairs.

    Example:
        >>> segywriter(ncfile, 'segyfile.sgy', trace_header_map=output_byte_loc('petrel'))
        >>>
    """
    try:
        return OUTPUT_BYTES[name]
    except KeyError:
        raise ValueError(
            f"No byte locatons for {name}, select from {list(OUTPUT_BYTES.keys())}"
        )