|
| 1 | +"""Seismic3DReceiverGathersTemplate MDIO v1 dataset templates.""" |
| 2 | + |
| 3 | +from typing import Any |
| 4 | + |
| 5 | +from mdio.builder.schemas import compressors |
| 6 | +from mdio.builder.schemas.dtype import ScalarType |
| 7 | +from mdio.builder.schemas.v1.variable import CoordinateMetadata |
| 8 | +from mdio.builder.templates.base import AbstractDatasetTemplate |
| 9 | + |
| 10 | + |
| 11 | +class Seismic3DReceiverGathersTemplate(AbstractDatasetTemplate): |
| 12 | + """Seismic 3D receiver gathers template with calculated shot index.""" |
| 13 | + |
| 14 | + def __init__(self) -> None: |
| 15 | + super().__init__(data_domain="time") |
| 16 | + |
| 17 | + self._dim_names = ("receiver", "shot_line", "shot_index", "time") |
| 18 | + self._calculated_dims = ("shot_index",) |
| 19 | + self._physical_coord_names = ( |
| 20 | + "receiver_x", |
| 21 | + "receiver_y", |
| 22 | + "source_coord_x", |
| 23 | + "source_coord_y", |
| 24 | + ) |
| 25 | + self._logical_coord_names = ("shot_point",) |
| 26 | + self._var_chunk_shape = (1, 1, 512, 4096) |
| 27 | + |
| 28 | + @property |
| 29 | + def _name(self) -> str: |
| 30 | + return "ReceiverGathers3D" |
| 31 | + |
| 32 | + def _load_dataset_attributes(self) -> dict[str, Any]: |
| 33 | + return {"surveyType": "3D", "gatherType": "receiver_gathers"} |
| 34 | + |
| 35 | + def _add_coordinates(self) -> None: |
| 36 | + # Add dimension coordinates |
| 37 | + # Note: shot_index is calculated (0-N), so we don't add a coordinate for it |
| 38 | + self._builder.add_coordinate( |
| 39 | + "receiver", |
| 40 | + dimensions=("receiver",), |
| 41 | + data_type=ScalarType.UINT32, |
| 42 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("receiver")), |
| 43 | + ) |
| 44 | + self._builder.add_coordinate( |
| 45 | + "shot_line", |
| 46 | + dimensions=("shot_line",), |
| 47 | + data_type=ScalarType.UINT32, |
| 48 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("shot_line")), |
| 49 | + ) |
| 50 | + self._builder.add_coordinate( |
| 51 | + self.trace_domain, |
| 52 | + dimensions=(self.trace_domain,), |
| 53 | + data_type=ScalarType.INT32, |
| 54 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key(self.trace_domain)), |
| 55 | + ) |
| 56 | + |
| 57 | + # Add non-dimension coordinates |
| 58 | + compressor = compressors.Blosc(cname=compressors.BloscCname.zstd) |
| 59 | + |
| 60 | + # Receiver coordinates (fixed per receiver) |
| 61 | + self._builder.add_coordinate( |
| 62 | + "receiver_x", |
| 63 | + dimensions=("receiver",), |
| 64 | + data_type=ScalarType.FLOAT64, |
| 65 | + compressor=compressor, |
| 66 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("receiver_x")), |
| 67 | + ) |
| 68 | + self._builder.add_coordinate( |
| 69 | + "receiver_y", |
| 70 | + dimensions=("receiver",), |
| 71 | + data_type=ScalarType.FLOAT64, |
| 72 | + compressor=compressor, |
| 73 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("receiver_y")), |
| 74 | + ) |
| 75 | + |
| 76 | + # Shot point coordinate (actual shot point numbers, varies by shot_line and shot_index) |
| 77 | + self._builder.add_coordinate( |
| 78 | + "shot_point", |
| 79 | + dimensions=("shot_line", "shot_index"), |
| 80 | + data_type=ScalarType.UINT32, |
| 81 | + compressor=compressor, |
| 82 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("shot_point")), |
| 83 | + ) |
| 84 | + |
| 85 | + # Source coordinates (vary by shot_line and shot_index) |
| 86 | + self._builder.add_coordinate( |
| 87 | + "source_coord_x", |
| 88 | + dimensions=("shot_line", "shot_index"), |
| 89 | + data_type=ScalarType.FLOAT64, |
| 90 | + compressor=compressor, |
| 91 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("source_coord_x")), |
| 92 | + ) |
| 93 | + self._builder.add_coordinate( |
| 94 | + "source_coord_y", |
| 95 | + dimensions=("shot_line", "shot_index"), |
| 96 | + data_type=ScalarType.FLOAT64, |
| 97 | + compressor=compressor, |
| 98 | + metadata=CoordinateMetadata(units_v1=self.get_unit_by_key("source_coord_y")), |
| 99 | + ) |
0 commit comments