Skip to content

Commit 59e995a

Browse files
authored
Add coordinates to mock data used for import / export (TGSAI#590)
* relax uv version dependency * add geographic coordinates to mock segy * format * apply coord scalar
1 parent bb0e9df commit 59e995a

File tree

3 files changed

+1902
-1879
lines changed

3 files changed

+1902
-1879
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ docs = [
8383

8484

8585
[tool.uv]
86-
required-version = "0.6.11"
86+
required-version = ">=0.6.11"
8787

8888
[tool.ruff]
8989
target-version = "py311"

tests/integration/test_segy_import_export_masked.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,7 @@ def __iter__(self) -> Iterable[MaskedExportConfigTypes]:
145145
# fmt: on
146146

147147

148-
def mock_nd_segy(
149-
path: str,
150-
grid_conf: GridConfig,
151-
segy_factory_conf: SegyFactoryConfig,
152-
) -> None:
148+
def mock_nd_segy(path: str, grid_conf: GridConfig, segy_factory_conf: SegyFactoryConfig) -> None:
153149
"""Create a fake SEG-Y file with a multidimensional grid."""
154150
spec = get_segy_standard(segy_factory_conf.revision)
155151

@@ -161,6 +157,19 @@ def mock_nd_segy(
161157
header_flds.append(HeaderField(name="samples_per_trace", byte=115, format="int16"))
162158
header_flds.append(HeaderField(name="sample_interval", byte=117, format="int16"))
163159

160+
# Add coordinates: {SRC-REC-CDP}-X/Y
161+
header_flds.extend(
162+
[
163+
HeaderField(name="coord_scalar", byte=71, format="int16"),
164+
HeaderField(name="src_x", byte=73, format="int32"),
165+
HeaderField(name="src_y", byte=77, format="int32"),
166+
HeaderField(name="rec_x", byte=81, format="int32"),
167+
HeaderField(name="rec_y", byte=85, format="int32"),
168+
HeaderField(name="cdp_x", byte=115, format="int32"),
169+
HeaderField(name="cdp_y", byte=117, format="int32"),
170+
]
171+
)
172+
164173
spec = spec.customize(trace_header_fields=header_flds)
165174
spec.segy_standard = segy_factory_conf.revision
166175
factory = SegyFactory(spec=spec, samples_per_trace=segy_factory_conf.num_samples)
@@ -177,9 +186,17 @@ def mock_nd_segy(
177186
samples = factory.create_trace_sample_template(trace_numbers.size)
178187
headers = factory.create_trace_header_template(trace_numbers.size)
179188

189+
# Fill dimension coordinates (e.g. inline, crossline, etc.)
180190
for dim_idx, dim in enumerate(grid_conf.dims):
181191
headers[dim.name] = dim_grid[dim_idx].ravel()
182192

193+
# Fill coordinates (e.g. {SRC-REC-CDP}-X/Y
194+
headers["coord_scalar"] = -100
195+
for field in ["cdp_x", "src_x", "rec_x"]:
196+
headers[field] = np.random.randint(low=700000, high=900000, size=trace_numbers.size) * 100
197+
for field in ["cdp_y", "src_y", "rec_y"]:
198+
headers[field] = np.random.randint(low=4000000, high=5000000, size=trace_numbers.size) * 100
199+
183200
samples[:] = trace_numbers[..., None]
184201

185202
with fsspec.open(path, mode="wb") as fp:
@@ -188,10 +205,7 @@ def mock_nd_segy(
188205
fp.write(factory.create_traces(headers, samples))
189206

190207

191-
def generate_selection_mask(
192-
selection_conf: SelectionMaskConfig,
193-
grid_conf: GridConfig,
194-
) -> NDArray:
208+
def generate_selection_mask(selection_conf: SelectionMaskConfig, grid_conf: GridConfig) -> NDArray:
195209
"""Generate a boolean selection mask for a masked export test."""
196210
spatial_shape = [dim.size for dim in grid_conf.dims]
197211
mask_dims = selection_conf.mask_num_dims
@@ -224,9 +238,7 @@ def export_masked_path(tmp_path_factory: pytest.TempPathFactory) -> Path:
224238
class TestNdImportExport:
225239
"""Test import/export of n-D SEG-Ys to MDIO, with and without selection mask."""
226240

227-
def test_import(
228-
self, test_conf: MaskedExportConfig, export_masked_path: Path
229-
) -> None:
241+
def test_import(self, test_conf: MaskedExportConfig, export_masked_path: Path) -> None:
230242
"""Test import of an n-D SEG-Y file to MDIO."""
231243
grid_conf, segy_factory_conf, segy_to_mdio_conf, _ = test_conf
232244

@@ -249,9 +261,7 @@ def test_import(
249261
overwrite=True,
250262
)
251263

252-
def test_export(
253-
self, test_conf: MaskedExportConfig, export_masked_path: Path
254-
) -> None:
264+
def test_export(self, test_conf: MaskedExportConfig, export_masked_path: Path) -> None:
255265
"""Test export of an n-D MDIO file back to SEG-Y."""
256266
grid_conf, segy_factory_conf, segy_to_mdio_conf, _ = test_conf
257267

@@ -277,9 +287,7 @@ def test_export(
277287
actual_sgy = SegyFile(segy_rt_path)
278288
assert_array_equal(actual_sgy.trace[:], expected_sgy.trace[:])
279289

280-
def test_export_masked(
281-
self, test_conf: MaskedExportConfig, export_masked_path: Path
282-
) -> None:
290+
def test_export_masked(self, test_conf: MaskedExportConfig, export_masked_path: Path) -> None:
283291
"""Test export of an n-D MDIO file back to SEG-Y with masked export."""
284292
grid_conf, segy_factory_conf, segy_to_mdio_conf, selection_conf = test_conf
285293

0 commit comments

Comments
 (0)