Skip to content

Commit cd6d590

Browse files
committed
Refactor Seismic Dataset Templates Documentation and Tests
- Updated docstrings for Seismic3DOffsetTilesTemplate and Seismic3DReceiverGathersTemplate to provide concise descriptions. - Added a new test for chunk size calculation in both templates to ensure proper memory management. - Adjusted existing tests to reflect changes in dataset naming conventions and template attributes. These changes enhance clarity and maintainability of the codebase.
1 parent 7677b25 commit cd6d590

4 files changed

Lines changed: 46 additions & 53 deletions

File tree

src/mdio/builder/templates/seismic_3d_offset_tiles.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,7 @@
1010

1111

1212
class Seismic3DOffsetTilesTemplate(AbstractDatasetTemplate):
13-
"""Seismic Offset Tiles pre-stack 3D Dataset template.
14-
15-
A 5D template for wide-azimuth seismic data organized by offset vector tiles.
16-
Data is binned by CDP location (inline, crossline) with offset vector
17-
decomposition into inline and crossline offset tile components.
18-
19-
Dimensions:
20-
- inline: Inline bin position
21-
- crossline: Crossline bin position
22-
- inline_offset_tile: Inline component of the offset vector tile
23-
- crossline_offset_tile: Crossline component of the offset vector tile
24-
- time/depth: Sample dimension
25-
26-
This organization is optimal for:
27-
- Wide-azimuth data preservation
28-
- 5D interpolation and regularization
29-
- Azimuthal analysis and processing
30-
- Offset vector filtering
31-
32-
The offset vector tiles partition the offset-azimuth space into a regular grid,
33-
preserving both offset magnitude and azimuth information in a format suitable
34-
for modern wide-azimuth processing workflows.
35-
36-
Args:
37-
data_domain: The domain of the dataset ('time' or 'depth').
38-
"""
13+
"""Seismic 3D template for offset vector tile (OVT) binned gathers."""
3914

4015
def __init__(self, data_domain: SeismicDataDomain = "time"):
4116
super().__init__(data_domain=data_domain)

src/mdio/builder/templates/seismic_3d_receiver_gathers.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,7 @@
99

1010

1111
class Seismic3DReceiverGathersTemplate(AbstractDatasetTemplate):
12-
"""Seismic receiver gather pre-stack 3D Dataset template.
13-
14-
A template for surveys with fixed receiver positions (OBN, OBC, land fixed-spread)
15-
where data is organized by receiver position for receiver-side processing.
16-
Shots are organized by shot lines with a calculated shot index.
17-
18-
This template is time-domain only as receiver gathers are typically used
19-
for early-stage processing before depth conversion.
20-
21-
Dimensions:
22-
- receiver: Index of the receiver node/station
23-
- shot_line: Shot line or swath identifier
24-
- shot_index: Sequential index of shots within the line (calculated, 0-N)
25-
- time: Sample dimension
26-
27-
This organization is optimal for:
28-
- Receiver-side wavefield separation (up/down)
29-
- Receiver-consistent deconvolution
30-
- Multi-component processing
31-
- Mirror imaging from OBN
32-
"""
12+
"""Seismic 3D receiver gathers template with calculated shot index."""
3313

3414
def __init__(self) -> None:
3515
super().__init__(data_domain="time")

tests/unit/v1/templates/test_seismic_3d_offset_tiles.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class TestSeismic3DOffsetTilesTemplate:
110110
"""Unit tests for Seismic3DOffsetTilesTemplate."""
111111

112112
def test_configuration(self, data_domain: SeismicDataDomain) -> None:
113-
"""Unit tests for Seismic3DOffsetTilesTemplate configuration."""
113+
"""Test template configuration and attributes."""
114114
t = Seismic3DOffsetTilesTemplate(data_domain=data_domain)
115115

116116
# Template attributes
@@ -128,19 +128,38 @@ def test_configuration(self, data_domain: SeismicDataDomain) -> None:
128128
assert attrs == {"surveyType": "3D", "gatherType": "offset_tiles"}
129129
assert t.default_variable_name == "amplitude"
130130

131+
def test_chunk_size_calculation(self, data_domain: SeismicDataDomain) -> None:
132+
"""Test that chunk shape produces approximately 9 MiB chunks.
133+
134+
The chunk shape (4, 4, 6, 6, 4096) produces:
135+
4 * 4 * 6 * 6 * 4096 = 2,359,296 samples.
136+
With float32 (4 bytes): 2,359,296 * 4 = 9,437,184 bytes = 9 MiB.
137+
"""
138+
t = Seismic3DOffsetTilesTemplate(data_domain=data_domain)
139+
140+
chunk_shape = t.full_chunk_shape
141+
assert chunk_shape == (4, 4, 6, 6, 4096)
142+
143+
samples_per_chunk = 1
144+
for dim_size in chunk_shape:
145+
samples_per_chunk *= dim_size
146+
147+
bytes_per_chunk = samples_per_chunk * 4
148+
assert bytes_per_chunk == 9 * 1024 * 1024 # 9 MiB
149+
131150
def test_build_dataset(self, data_domain: SeismicDataDomain, structured_headers: StructuredType) -> None:
132-
"""Unit tests for Seismic3DOffsetTilesTemplate build."""
151+
"""Test building a complete dataset with the template."""
133152
t = Seismic3DOffsetTilesTemplate(data_domain=data_domain)
134153
t.add_units({"cdp_x": UNITS_METER, "cdp_y": UNITS_METER})
135154
t.add_units({"time": UNITS_SECOND, "depth": UNITS_METER})
136155

137156
dataset = t.build_dataset(
138-
"Wide Azimuth Offset Tiles",
157+
"OVT Gathers",
139158
sizes=(256, 256, 12, 12, 2048),
140159
header_dtype=structured_headers,
141160
)
142161

143-
assert dataset.metadata.name == "Wide Azimuth Offset Tiles"
162+
assert dataset.metadata.name == "OVT Gathers"
144163
assert dataset.metadata.attributes["surveyType"] == "3D"
145164
assert dataset.metadata.attributes["gatherType"] == "offset_tiles"
146165

tests/unit/v1/templates/test_seismic_3d_receiver_gathers.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class TestSeismic3DReceiverGathersTemplate:
117117
"""Unit tests for Seismic3DReceiverGathersTemplate."""
118118

119119
def test_configuration(self) -> None:
120-
"""Unit tests for Seismic3DReceiverGathersTemplate configuration."""
120+
"""Test template configuration and attributes."""
121121
t = Seismic3DReceiverGathersTemplate()
122122

123123
# Template attributes
@@ -137,8 +137,27 @@ def test_configuration(self) -> None:
137137
assert attrs == {"surveyType": "3D", "gatherType": "receiver_gathers"}
138138
assert t.default_variable_name == "amplitude"
139139

140+
def test_chunk_size_calculation(self) -> None:
141+
"""Test that chunk shape produces approximately 8 MiB chunks.
142+
143+
The chunk shape (1, 1, 512, 4096) produces:
144+
1 * 1 * 512 * 4096 = 2,097,152 samples.
145+
With float32 (4 bytes): 2,097,152 * 4 = 8,388,608 bytes = 8 MiB.
146+
"""
147+
t = Seismic3DReceiverGathersTemplate()
148+
149+
chunk_shape = t.full_chunk_shape
150+
assert chunk_shape == (1, 1, 512, 4096)
151+
152+
samples_per_chunk = 1
153+
for dim_size in chunk_shape:
154+
samples_per_chunk *= dim_size
155+
156+
bytes_per_chunk = samples_per_chunk * 4
157+
assert bytes_per_chunk == 8 * 1024 * 1024 # 8 MiB
158+
140159
def test_build_dataset(self, structured_headers: StructuredType) -> None:
141-
"""Unit tests for Seismic3DReceiverGathersTemplate build."""
160+
"""Test building a complete dataset with the template."""
142161
t = Seismic3DReceiverGathersTemplate()
143162
t.add_units({"receiver_x": UNITS_METER, "receiver_y": UNITS_METER})
144163
t.add_units({"source_coord_x": UNITS_METER, "source_coord_y": UNITS_METER})

0 commit comments

Comments
 (0)