diff --git a/src/mdio/builder/templates/seismic_2d_cdp.py b/src/mdio/builder/templates/seismic_2d_cdp.py index 2bc26c2a..3dc6f9d4 100644 --- a/src/mdio/builder/templates/seismic_2d_cdp.py +++ b/src/mdio/builder/templates/seismic_2d_cdp.py @@ -2,6 +2,10 @@ from typing import Any +from mdio.builder.schemas.compressors import Blosc +from mdio.builder.schemas.compressors import BloscCname +from mdio.builder.schemas.dtype import ScalarType +from mdio.builder.schemas.v1.variable import CoordinateMetadata from mdio.builder.templates.base import AbstractDatasetTemplate from mdio.builder.templates.types import CdpGatherDomain from mdio.builder.templates.types import SeismicDataDomain @@ -30,3 +34,40 @@ def _name(self) -> str: def _load_dataset_attributes(self) -> dict[str, Any]: return {"surveyType": "2D", "gatherType": "cdp"} + + def _add_coordinates(self) -> None: + # Add dimension coordinates + self._builder.add_coordinate( + "cdp", + dimensions=("cdp",), + data_type=ScalarType.INT32, + ) + self._builder.add_coordinate( + self._gather_domain, + dimensions=(self._gather_domain,), + data_type=ScalarType.INT32, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key(self._gather_domain)), + ) + self._builder.add_coordinate( + self.trace_domain, + dimensions=(self.trace_domain,), + data_type=ScalarType.INT32, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key(self.trace_domain)), + ) + + # Add non-dimension coordinates + compressor = Blosc(cname=BloscCname.zstd) + self._builder.add_coordinate( + "cdp_x", + dimensions=("cdp",), + data_type=ScalarType.FLOAT64, + compressor=compressor, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("cdp_x")), + ) + self._builder.add_coordinate( + "cdp_y", + dimensions=("cdp",), + data_type=ScalarType.FLOAT64, + compressor=compressor, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("cdp_y")), + ) diff --git a/src/mdio/builder/templates/seismic_3d_cdp.py b/src/mdio/builder/templates/seismic_3d_cdp.py index 247a1f30..5948bab3 100644 --- a/src/mdio/builder/templates/seismic_3d_cdp.py +++ b/src/mdio/builder/templates/seismic_3d_cdp.py @@ -2,6 +2,10 @@ from typing import Any +from mdio.builder.schemas.compressors import Blosc +from mdio.builder.schemas.compressors import BloscCname +from mdio.builder.schemas.dtype import ScalarType +from mdio.builder.schemas.v1.variable import CoordinateMetadata from mdio.builder.templates.base import AbstractDatasetTemplate from mdio.builder.templates.types import CdpGatherDomain from mdio.builder.templates.types import SeismicDataDomain @@ -30,3 +34,45 @@ def _name(self) -> str: def _load_dataset_attributes(self) -> dict[str, Any]: return {"surveyType": "3D", "gatherType": "cdp"} + + def _add_coordinates(self) -> None: + # Add dimension coordinates + self._builder.add_coordinate( + "inline", + dimensions=("inline",), + data_type=ScalarType.INT32, + ) + self._builder.add_coordinate( + "crossline", + dimensions=("crossline",), + data_type=ScalarType.INT32, + ) + self._builder.add_coordinate( + self._gather_domain, + dimensions=(self._gather_domain,), + data_type=ScalarType.INT32, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key(self._gather_domain)), + ) + self._builder.add_coordinate( + self.trace_domain, + dimensions=(self.trace_domain,), + data_type=ScalarType.INT32, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key(self.trace_domain)), + ) + + # Add non-dimension coordinates + compressor = Blosc(cname=BloscCname.zstd) + self._builder.add_coordinate( + "cdp_x", + dimensions=("inline", "crossline"), + data_type=ScalarType.FLOAT64, + compressor=compressor, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("cdp_x")), + ) + self._builder.add_coordinate( + "cdp_y", + dimensions=("inline", "crossline"), + data_type=ScalarType.FLOAT64, + compressor=compressor, + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("cdp_y")), + ) diff --git a/tests/unit/v1/templates/test_seismic_2d_cdp.py b/tests/unit/v1/templates/test_seismic_2d_cdp.py index 765cb87f..5aeccacd 100644 --- a/tests/unit/v1/templates/test_seismic_2d_cdp.py +++ b/tests/unit/v1/templates/test_seismic_2d_cdp.py @@ -83,7 +83,7 @@ def validate_coordinates_headers_trace_mask( cdp_x = validate_variable( dataset, name="cdp_x", - dims=[("cdp", 512), (gather_domain, 36)], + dims=[("cdp", 512)], coords=["cdp_x"], dtype=ScalarType.FLOAT64, ) @@ -92,7 +92,7 @@ def validate_coordinates_headers_trace_mask( cdp_y = validate_variable( dataset, name="cdp_y", - dims=[("cdp", 512), (gather_domain, 36)], + dims=[("cdp", 512)], coords=["cdp_y"], dtype=ScalarType.FLOAT64, ) diff --git a/tests/unit/v1/templates/test_seismic_3d_cdp.py b/tests/unit/v1/templates/test_seismic_3d_cdp.py index 14043e8a..e0caf49f 100644 --- a/tests/unit/v1/templates/test_seismic_3d_cdp.py +++ b/tests/unit/v1/templates/test_seismic_3d_cdp.py @@ -91,7 +91,7 @@ def validate_coordinates_headers_trace_mask( cdp_x = validate_variable( dataset, name="cdp_x", - dims=[("inline", 512), ("crossline", 768), (gather_domain, 36)], + dims=[("inline", 512), ("crossline", 768)], coords=["cdp_x"], dtype=ScalarType.FLOAT64, ) @@ -100,7 +100,7 @@ def validate_coordinates_headers_trace_mask( cdp_y = validate_variable( dataset, name="cdp_y", - dims=[("inline", 512), ("crossline", 768), (gather_domain, 36)], + dims=[("inline", 512), ("crossline", 768)], coords=["cdp_y"], dtype=ScalarType.FLOAT64, )