def extract_timeslice(segy_filename, out_filename, slice_index, dtype=None, null=0): """Extract a timeslice from a 3D SEG Y file to a Numpy NPY file. Args: segy_filename: Filename of a SEG Y file. out_filename: Filename of the NPY file. slice_index: The zero-based index (increasing with depth) of the slice to be extracted. dtype: Optional Numpy dtype for the result array. If not provided a dtype compatible with the SEG Y data will be used. null: Optional sample value to use for missing or short traces. Defaults to zero. """ with open(segy_filename, 'rb') as segy_file: segy_reader = create_reader(segy_file) if dtype is None: dtype = make_dtype(segy_reader.data_sample_format) if segy_reader.dimensionality != 3: raise DimensionalityError( "Cannot slice {n} dimensional seismic.".format( segy_reader.dimensionality)) i_size = segy_reader.num_inlines() x_size = segy_reader.num_xlines() t_size = segy_reader.max_num_trace_samples() if not (0 <= slice_index < t_size): raise ValueError( "Time slice index {0} out of range {} to {}".format( slice_index, 0, t_size)) timeslice = np.full((i_size, x_size), null, dtype) for inline_num, xline_num in segy_reader.inline_xline_numbers(): trace_index = segy_reader.trace_index((inline_num, xline_num)) trace = segy_reader.trace_samples(trace_index) try: sample = trace[slice_index] except IndexError: sample = null i_index = segy_reader.inline_numbers().index(inline_num) x_index = segy_reader.xline_numbers().index(xline_num) timeslice[i_index, x_index] = sample np.save(out_filename, timeslice)
def extract_timeslice(segy_filename, out_filename, slice_index, dtype=None, null=0): """Extract a timeslice from a 3D SEG Y file to a Numpy NPY file. Args: segy_filename: Filename of a SEG Y file. out_filename: Filename of the NPY file. slice_index: The zero-based index (increasing with depth) of the slice to be extracted. dtype: Optional Numpy dtype for the result array. If not provided a dtype compatible with the SEG Y data will be used. null: Optional sample value to use for missing or short traces. Defaults to zero. """ with open(segy_filename, 'rb') as segy_file: segy_reader = create_reader(segy_file) if dtype is None: dtype = make_dtype(segy_reader.data_sample_format) if segy_reader.dimensionality != 3: raise DimensionalityError("Cannot slice {n} dimensional seismic.".format(segy_reader.dimensionality)) i_size = segy_reader.num_inlines() x_size = segy_reader.num_xlines() t_size = segy_reader.max_num_trace_samples() if not (0 <= slice_index < t_size): raise ValueError("Time slice index {0} out of range {} to {}".format(slice_index, 0, t_size)) timeslice = np.full((i_size, x_size), null, dtype) for inline_num, xline_num in segy_reader.inline_xline_numbers(): trace_index = segy_reader.trace_index((inline_num, xline_num)) trace = segy_reader.trace_samples(trace_index) try: sample = trace[slice_index] except IndexError: sample = null i_index = segy_reader.inline_numbers().index(inline_num) x_index = segy_reader.xline_numbers().index(xline_num) timeslice[i_index, x_index] = sample np.save(out_filename, timeslice)
def extract_trace(reader, trace_index, sample_numbers): """Extract a single trace as a one-dimensional array. Args: reader: A SegYReader3D object. trace_index: The index of the trace to be extracted. sample_numbers: The sample numbers within each trace at which samples are to be extracted. This argument can be specified in three ways: None (the default) - All samples within the trace will be be extracted. sequence - When a sequence, such as a range or a list is provided only those samples at sample numbers corresponding to the items in the sequence will be extracted. The samples will always be extracted in increasing numeric order and duplicate entries will be ignored. For example sample_numbers=range(100, 200, 2) will extract alternate samples from sample number 100 to sample number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all sample numbers. For example sample_numbers=slice(100, -100) will omit the first one hundred and the last one hundred samples, irrespective of their numbers. Returns: A one-dimensional array. """ if not reader.has_trace_index(trace_index): raise ValueError("Inline number {} not present in {}".format( trace_index, reader)) sample_numbers = ensure_superset(range(0, reader.max_num_trace_samples()), sample_numbers) trace_sample_start = sample_numbers[0] trace_sample_stop = min(sample_numbers[-1] + 1, reader.num_trace_samples(trace_index)) trace_samples = reader.trace_samples(trace_index, start=trace_sample_start, stop=trace_sample_stop) arr = np.fromiter((trace_samples[sample_number - trace_sample_start] for sample_number in sample_numbers), make_dtype(reader.data_sample_format)) return arr
def extract_trace_headers(reader, fields, trace_indexes=None): """Extract trace header fields from the specified trace headers as separate arrays. Args: reader: A SegYReader fields: A an iterable series where each item is either the name of a field as a string or an object such as a NamedField with a 'name' attribute which in turn is the name of a field as a string, such as a NamedField. trace_indexes: An optional iterable series of trace_indexes. If not provided or None, the headers for all trace indexes will be returned. Returns: A namedtuple with attributes which are one-dimensionsal Numpy arrays. """ if trace_indexes is None: trace_indexes = reader.trace_indexes() field_names = [_extract_field_name(field) for field in fields] class SubFormat(metaclass=SubFormatMeta, parent_format=reader.trace_header_format_class, parent_field_names=field_names): pass sub_header_packer = make_header_packer(SubFormat, reader.endian) trace_header_arrays_cls = namedtuple('trace_header_arrays_cls', field_names) trace_headers = [ reader.trace_header(trace_index, sub_header_packer) for trace_index in trace_indexes ] trace_header_arrays = trace_header_arrays_cls(*(np.fromiter( (getattr(trace_header, field_name) for trace_header in trace_headers), dtype=make_dtype(getattr(SubFormat, field_name).value_type.SEG_Y_TYPE), count=len(trace_headers)) for field_name in field_names)) return trace_header_arrays
def extract_trace_headers(reader, fields, trace_indexes=None): """Extract trace header fields from the specified trace headers as separate arrays. Args: reader: A SegYReader fields: A an iterable series where each item is either the name of a field as a string or an object such as a NamedField with a 'name' attribute which in turn is the name of a field as a string, such as a NamedField. trace_indexes: An optional iterable series of trace_indexes. If not provided or None, the headers for all trace indexes will be returned. Returns: A namedtuple with attributes which are one-dimensionsal Numpy arrays. """ if trace_indexes is None: trace_indexes = reader.trace_indexes() field_names = [_extract_field_name(field) for field in fields] class SubFormat(metaclass=SubFormatMeta, parent_format=reader.trace_header_format_class, parent_field_names=field_names): pass sub_header_packer = make_header_packer(SubFormat, reader.endian) trace_header_arrays_cls = namedtuple('trace_header_arrays_cls', field_names) trace_headers = [reader.trace_header(trace_index, sub_header_packer) for trace_index in trace_indexes] trace_header_arrays = trace_header_arrays_cls( *(np.fromiter((getattr(trace_header, field_name) for trace_header in trace_headers), dtype=make_dtype(getattr(SubFormat, field_name).value_type.SEG_Y_TYPE), count=len(trace_headers)) for field_name in field_names) ) return trace_header_arrays
def extract_trace(reader, trace_index, sample_numbers): """Extract a single trace as a one-dimensional array. Args: reader: A SegYReader3D object. trace_index: The index of the trace to be extracted. sample_numbers: The sample numbers within each trace at which samples are to be extracted. This argument can be specified in three ways: None (the default) - All samples within the trace will be be extracted. sequence - When a sequence, such as a range or a list is provided only those samples at sample numbers corresponding to the items in the sequence will be extracted. The samples will always be extracted in increasing numeric order and duplicate entries will be ignored. For example sample_numbers=range(100, 200, 2) will extract alternate samples from sample number 100 to sample number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all sample numbers. For example sample_numbers=slice(100, -100) will omit the first one hundred and the last one hundred samples, irrespective of their numbers. Returns: A one-dimensional array. """ if not reader.has_trace_index(trace_index): raise ValueError("Inline number {} not present in {}".format(trace_index, reader)) sample_numbers = ensure_superset(range(0, reader.max_num_trace_samples()), sample_numbers) trace_sample_start = sample_numbers[0] trace_sample_stop = min(sample_numbers[-1] + 1, reader.num_trace_samples(trace_index)) trace_samples = reader.trace_samples(trace_index, start=trace_sample_start, stop=trace_sample_stop) arr = np.fromiter((trace_samples[sample_number - trace_sample_start] for sample_number in sample_numbers), make_dtype(reader.data_sample_format)) return arr
def extract_trace_header_field_3d(reader_3d, fields, inline_numbers=None, xline_numbers=None, null=None): """Extract a single trace header field from all trace headers as an array. Args: reader_3d: A SegYReader3D fields: A an iterable series where each item is either the name of a field as a string or an object such as a NamedField with a 'name' attribute which in turn is the name of a field as a string, such as a NamedField. inline_numbers: The inline numbers for which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces within the each crossline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at inline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example inline_numbers=range(100, 200, 2) will extract alternate traces from inline number 100 to inline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all inline numbers. For example inline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. xline_numbers: The crossline numbers at which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces at within each inline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at crossline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example xline_numbers=range(100, 200, 2) will extract alternate traces from crossline number 100 to crossline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all crossline numbers. For example xline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. null: An optional null value for missing traces. The null value must be convertible to all field value types. Returns: A namedtuple object with attributes which are two-dimensional Numpy arrays. If a null value was specified the arrays will be ndarrays, otherwise they will be masked arrays. The attributes of the named tuple are in the same order as the fields specified in the `fields` argument. Raises: AttributeError: If the the named fields do not exist in the trace header definition. """ field_names = [_extract_field_name(field) for field in fields] inline_numbers = ensure_superset(reader_3d.inline_numbers(), inline_numbers) xline_numbers = ensure_superset(reader_3d.xline_numbers(), xline_numbers) shape = (len(inline_numbers), len(xline_numbers)) class SubFormat(metaclass=SubFormatMeta, parent_format=reader_3d.trace_header_format_class, parent_field_names=field_names): pass sub_header_packer = make_header_packer(SubFormat, reader_3d.endian) TraceHeaderArrays = namedtuple('TraceHeaderArrays', field_names) arrays = (_make_array(shape, make_dtype(getattr(SubFormat, field_name).value_type.SEG_Y_TYPE), null) for field_name in field_names) trace_header_arrays = TraceHeaderArrays(*arrays) for inline_index, inline_number in enumerate(inline_numbers): for xline_index, xline_number in enumerate(xline_numbers): inline_xline_number = (inline_number, xline_number) if reader_3d.has_trace_index(inline_xline_number): trace_index = reader_3d.trace_index((inline_number, xline_number)) trace_header = reader_3d.trace_header(trace_index, sub_header_packer) for field_name, a in zip(field_names, trace_header_arrays): field_value = getattr(trace_header, field_name) a[inline_index, xline_index] = field_value return trace_header_arrays
def extract_timeslice_3d(reader_3d, sample_number, inline_numbers=None, xline_numbers=None, null=None): """Extract a single timeslice header field from all trace headers as an array. Args: reader_3d: A SegYReader3D sample_number: The zero-based sample index. inline_numbers: The inline numbers for which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces within the each crossline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at inline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example inline_numbers=range(100, 200, 2) will extract alternate traces from inline number 100 to inline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all inline numbers. For example inline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. xline_numbers: The crossline numbers at which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces at within each inline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at crossline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example xline_numbers=range(100, 200, 2) will extract alternate traces from crossline number 100 to crossline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all crossline numbers. For example xline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. null: An optional null value for missing traces. The null value must be convertible to all field value types. Returns: An namedtuple object with attributes which are two-dimensional Numpy arrays. If a null value was specified the arrays will be ndarrays, otherwise they will be masked arrays. The attributes of the named tuple are in the same order as the fields specified in the `fields` argument. Raises: AttributeError: If the the named fields do not exist in the trace header definition. """ inline_numbers = ensure_superset(reader_3d.inline_numbers(), inline_numbers) xline_numbers = ensure_superset(reader_3d.xline_numbers(), xline_numbers) shape = (len(inline_numbers), len(xline_numbers)) dtype = make_dtype(reader_3d.data_sample_format) array = _make_array(shape, dtype, null) sample_number_stop = sample_number + 1 for inline_index, inline_number in enumerate(inline_numbers): for xline_index, xline_number in enumerate(xline_numbers): inline_xline_number = (inline_number, xline_number) if reader_3d.has_trace_index(inline_xline_number): trace_index = reader_3d.trace_index((inline_number, xline_number)) trace_samples = reader_3d.trace_samples(trace_index, start=sample_number, stop=sample_number_stop) array[inline_index, xline_index] = trace_samples[0] return array
def extract_xline_3d(reader_3d, xline_number, inline_numbers=None, sample_numbers=None, null=None): """Extract an inline as a two-dimensional array. Args: reader_3d: A SegYReader3D object. xline_number: The number of the xline to be extracted. inline_numbers: The inline numbers within the crossline at which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces within the crossline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at inline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example inline_numbers=range(100, 200, 2) will extract alternate traces from inline number 100 to inline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all inline numbers. For example inline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. sample_numbers: The sample numbers within each trace at which samples are to be extracted. This argument can be specified in three ways: None (the default) - All samples within the trace will be be extracted. sequence - When a sequence, such as a range or a list is provided only those samples at sample numbers corresponding to the items in the sequence will be extracted. The samples will always be extracted in increasing numeric order and duplicate entries will be ignored. For example sample_numbers=range(100, 200, 2) will extract alternate samples from sample number 100 to sample number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all sample numbers. For example sample_numbers=slice(100, -100) will omit the first one hundred and the last one hundred samples, irrespective of their numbers. null: A null value. When None is specified as the null value a masked array will be returned. Returns: A two-dimensional array. If null is None a masked array will be returned, otherwise a regular array will be returned. The first (slowest changing) index will correspond to the traces (index zero will correspond to the first inline number). The second (fastest changing) index will correspond to the samples (index zero will correspond to the first sample number). """ if xline_number not in reader_3d.xline_numbers(): raise ValueError("Crossline number {} not present in {}".format(xline_number, reader_3d)) inline_numbers = ensure_superset(reader_3d.inline_numbers(), inline_numbers) sample_numbers = ensure_superset(range(0, reader_3d.max_num_trace_samples()), sample_numbers) shape = (len(inline_numbers), len(sample_numbers)) dtype = make_dtype(reader_3d.data_sample_format) array = _make_array(shape, dtype, null) if isinstance(sample_numbers, range): _populate_xline_array_over_sample_range(reader_3d, xline_number, inline_numbers, sample_numbers, array) else: _populate_xline_array_numbered_samples(reader_3d, xline_number, inline_numbers, sample_numbers, array) return array
def extract_timeslice_3d(reader_3d, sample_number, inline_numbers=None, xline_numbers=None, null=None): """Extract a single timeslice header field from all trace headers as an array. Args: reader_3d: A SegYReader3D sample_number: The zero-based sample index. inline_numbers: The inline numbers for which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces within the each crossline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at inline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example inline_numbers=range(100, 200, 2) will extract alternate traces from inline number 100 to inline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all inline numbers. For example inline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. xline_numbers: The crossline numbers at which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces at within each inline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at crossline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example xline_numbers=range(100, 200, 2) will extract alternate traces from crossline number 100 to crossline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all crossline numbers. For example xline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. null: An optional null value for missing traces. The null value must be convertible to all field value types. Returns: An namedtuple object with attributes which are two-dimensional Numpy arrays. If a null value was specified the arrays will be ndarrays, otherwise they will be masked arrays. The attributes of the named tuple are in the same order as the fields specified in the `fields` argument. Raises: AttributeError: If the the named fields do not exist in the trace header definition. """ inline_numbers = ensure_superset(reader_3d.inline_numbers(), inline_numbers) xline_numbers = ensure_superset(reader_3d.xline_numbers(), xline_numbers) shape = (len(inline_numbers), len(xline_numbers)) dtype = make_dtype(reader_3d.data_sample_format) array = _make_array(shape, dtype, null) sample_number_stop = sample_number + 1 for inline_index, inline_number in enumerate(inline_numbers): for xline_index, xline_number in enumerate(xline_numbers): inline_xline_number = (inline_number, xline_number) if reader_3d.has_trace_index(inline_xline_number): trace_index = reader_3d.trace_index( (inline_number, xline_number)) trace_samples = reader_3d.trace_samples( trace_index, sample_number, sample_number_stop) array[inline_index, xline_index] = trace_samples[0] return array
def extract_xline_3d(reader_3d, xline_number, inline_numbers=None, sample_numbers=None, null=None): """Extract an inline as a two-dimensional array. Args: reader_3d: A SegYReader3D object. xline_number: The number of the xline to be extracted. inline_numbers: The inline numbers within the crossline at which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces within the crossline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at inline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example inline_numbers=range(100, 200, 2) will extract alternate traces from inline number 100 to inline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all inline numbers. For example inline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. sample_numbers: The sample numbers within each trace at which samples are to be extracted. This argument can be specified in three ways: None (the default) - All samples within the trace will be be extracted. sequence - When a sequence, such as a range or a list is provided only those samples at sample numbers corresponding to the items in the sequence will be extracted. The samples will always be extracted in increasing numeric order and duplicate entries will be ignored. For example sample_numbers=range(100, 200, 2) will extract alternate samples from sample number 100 to sample number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all sample numbers. For example sample_numbers=slice(100, -100) will omit the first one hundred and the last one hundred samples, irrespective of their numbers. null: A null value. When None is specified as the null value a masked array will be returned. Returns: A two-dimensional array. If null is None a masked array will be returned, otherwise a regular array will be returned. The first (slowest changing) index will correspond to the traces (index zero will correspond to the first inline number). The second (fastest changing) index will correspond to the samples (index zero will correspond to the first sample number). """ if xline_number not in reader_3d.xline_numbers(): raise ValueError("Crossline number {} not present in {}".format( xline_number, reader_3d)) inline_numbers = ensure_superset(reader_3d.inline_numbers(), inline_numbers) sample_numbers = ensure_superset( range(0, reader_3d.max_num_trace_samples()), sample_numbers) shape = (len(inline_numbers), len(sample_numbers)) dtype = make_dtype(reader_3d.data_sample_format) array = _make_array(shape, dtype, null) if isinstance(sample_numbers, range): _populate_xline_array_over_sample_range(reader_3d, xline_number, inline_numbers, sample_numbers, array) else: _populate_xline_array_numbered_samples(reader_3d, xline_number, inline_numbers, sample_numbers, array) return array
def extract_trace_header_field_3d(reader_3d, fields, inline_numbers=None, xline_numbers=None, null=None): """Extract a single trace header field from all trace headers as an array. Args: reader_3d: A SegYReader3D fields: A an iterable series where each item is either the name of a field as a string or an object such as a NamedField with a 'name' attribute which in turn is the name of a field as a string, such as a NamedField. inline_numbers: The inline numbers for which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces within the each crossline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at inline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example inline_numbers=range(100, 200, 2) will extract alternate traces from inline number 100 to inline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all inline numbers. For example inline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. xline_numbers: The crossline numbers at which traces are to be extracted. This argument can be specified in three ways: None (the default) - All traces at within each inline will be be extracted. sequence - When a sequence, such as a range or a list is provided only those traces at crossline numbers corresponding to the items in the sequence will be extracted. The traces will always be extracted in increasing numeric order and duplicate entries will be ignored. For example xline_numbers=range(100, 200, 2) will extract alternate traces from crossline number 100 to crossline number 198 inclusive. slice - When a slice object is provided the slice will be applied to the sequence of all crossline numbers. For example xline_numbers=slice(100, -100) will omit the first one hundred and the last one hundred traces, irrespective of their numbers. null: An optional null value for missing traces. The null value must be convertible to all field value types. Returns: A namedtuple object with attributes which are two-dimensional Numpy arrays. If a null value was specified the arrays will be ndarrays, otherwise they will be masked arrays. The attributes of the named tuple are in the same order as the fields specified in the `fields` argument. Raises: AttributeError: If the the named fields do not exist in the trace header definition. """ field_names = [_extract_field_name(field) for field in fields] inline_numbers = ensure_superset(reader_3d.inline_numbers(), inline_numbers) xline_numbers = ensure_superset(reader_3d.xline_numbers(), xline_numbers) shape = (len(inline_numbers), len(xline_numbers)) class SubFormat(metaclass=SubFormatMeta, parent_format=reader_3d.trace_header_format_class, parent_field_names=field_names): pass sub_header_packer = make_header_packer(SubFormat, reader_3d.endian) TraceHeaderArrays = namedtuple('TraceHeaderArrays', field_names) arrays = (_make_array( shape, make_dtype(getattr(SubFormat, field_name).value_type.SEG_Y_TYPE), null) for field_name in field_names) trace_header_arrays = TraceHeaderArrays(*arrays) for inline_index, inline_number in enumerate(inline_numbers): for xline_index, xline_number in enumerate(xline_numbers): inline_xline_number = (inline_number, xline_number) if reader_3d.has_trace_index(inline_xline_number): trace_index = reader_3d.trace_index( (inline_number, xline_number)) trace_header = reader_3d.trace_header(trace_index, sub_header_packer) for field_name, a in zip(field_names, trace_header_arrays): field_value = getattr(trace_header, field_name) a[inline_index, xline_index] = field_value return trace_header_arrays