def test_sample_indexes(self): with segyio.open(self.filename, "r") as f: indexes = segyio.sample_indexes(f) step = 4000.0 self.assertListEqual(indexes, [t * step for t in range(len(f.samples))]) indexes = segyio.sample_indexes(f, t0=1.5) self.assertListEqual(indexes, [1.5 + t * step for t in range(len(f.samples))]) indexes = segyio.sample_indexes(f, t0=1.5, dt_override=3.21) self.assertListEqual(indexes, [1.5 + t * 3.21 for t in range(len(f.samples))])
def test_sample_indexes(): with segyio.open("test-data/small.sgy") as f: indexes = segyio.sample_indexes(f) step = 4000.0 assert indexes == [t * step for t in range(len(f.samples))] indexes = segyio.sample_indexes(f, t0=1.5) assert indexes == [1.5 + t * step for t in range(len(f.samples))] indexes = segyio.sample_indexes(f, t0=1.5, dt_override=3.21) assert indexes == [1.5 + t * 3.21 for t in range(len(f.samples))]
def _copy_data(segy, variables, dim_names, dim_lens, verbose): """Copy the data to the NetCDF file. Trace data, Time/Depth dimension indices, and trace header values are copied. """ traceIDs = np.reshape(np.arange(segy.tracecount), dim_lens[:-1]) n_trace_dims = len(dim_names[:-1]) for v in variables: if v.name == "Samples": if verbose: click.echo("copying trace data") v[:] = segy.trace.raw[:].reshape(v.shape) elif v.name == dim_names[-1]: if verbose: click.echo("copying time/depth indices") v[:] = np.array(segyio.sample_indexes(segy)).reshape(v.shape) elif v.name in dim_names[:-1]: if verbose: click.echo("copying {}".format(v.name)) v_traceIDs = _get_variable_traceIDs(v, n_trace_dims, dim_names, traceIDs) header_field = _get_header_field(v.name) v[:] = segy.attributes(header_field)[v_traceIDs.flatten() [:]].reshape(v.shape) else: if verbose: click.echo("copying {}".format(v.name)) header_field = _get_header_field(v.name) v[:] = segy.attributes(header_field)[:].reshape(v.shape)