|
3 | 3 | This set of tests has to run after the segy_roundtrip_teapot tests have run because |
4 | 4 | the teapot dataset is used as the input for the create_empty_like test. |
5 | 5 |
|
6 | | -NOTE: The only reliable way to ensure the test order (including the case when the |
| 6 | +NOTE: The only reliable way to ensure the test order (including the case when the |
7 | 7 | test are run in parallel) is to use the alphabetical order of the test names. |
8 | 8 | """ |
9 | 9 |
|
|
29 | 29 | from xarray import Dataset as xr_Dataset |
30 | 30 |
|
31 | 31 |
|
32 | | -from tests.integration.testing_helpers import UNITS_NONE, UNITS_SECOND, UNITS_METER, UNITS_FOOT, UNITS_METER_PER_SECOND, UNITS_FEET_PER_SECOND |
| 32 | +from tests.integration.testing_helpers import UNITS_FEET_PER_SECOND |
| 33 | +from tests.integration.testing_helpers import UNITS_FOOT |
| 34 | +from tests.integration.testing_helpers import UNITS_METER |
| 35 | +from tests.integration.testing_helpers import UNITS_METER_PER_SECOND |
| 36 | +from tests.integration.testing_helpers import UNITS_NONE |
| 37 | +from tests.integration.testing_helpers import UNITS_SECOND |
33 | 38 | from tests.integration.testing_helpers import get_teapot_segy_spec |
34 | | -from tests.integration.testing_helpers import validate_xr_variable |
35 | 39 | from tests.integration.testing_helpers import get_values |
36 | | - |
| 40 | +from tests.integration.testing_helpers import validate_xr_variable |
37 | 41 |
|
38 | 42 | from mdio import __version__ |
39 | 43 | from mdio.api.create import create_empty |
|
46 | 50 | from mdio.converters.mdio import mdio_to_segy |
47 | 51 | from mdio.core import Dimension |
48 | 52 |
|
| 53 | + |
49 | 54 | class PostStack3DVelocityTemplate(Seismic3DPostStackTemplate): |
50 | 55 | """Custom template that uses 'velocity' as the default variable name instead of 'amplitude'.""" |
51 | 56 |
|
@@ -81,6 +86,7 @@ def _name(self) -> str: |
81 | 86 | domain_suffix = self._data_domain.capitalize() |
82 | 87 | return f"PostStack3DVelocity{domain_suffix}" |
83 | 88 |
|
| 89 | + |
84 | 90 | class TestCreateEmptyMdio: |
85 | 91 | """Tests for create_empty_mdio function.""" |
86 | 92 |
|
@@ -146,7 +152,9 @@ def validate_teapod_dataset_metadata(cls, ds: xr_Dataset, is_velocity: bool) -> |
146 | 152 | assert attributes["gatherType"] == "stacked" |
147 | 153 |
|
148 | 154 | @classmethod |
149 | | - def validate_teapod_dataset_variables(cls, ds: xr_Dataset, header_dtype: np.dtype | None, is_velocity: bool) -> None: |
| 155 | + def validate_teapod_dataset_variables( |
| 156 | + cls, ds: xr_Dataset, header_dtype: np.dtype | None, is_velocity: bool |
| 157 | + ) -> None: |
150 | 158 | """Validate an empty MDIO dataset structure and content.""" |
151 | 159 | # Check that the dataset has the expected shape |
152 | 160 | assert ds.sizes == {"inline": 345, "crossline": 188, "time": 1501} |
@@ -209,16 +217,13 @@ def mdio_no_headers(self, empty_mdio_dir: Path) -> Path: |
209 | 217 | self._create_empty_mdio(create_headers=False, output_path=empty_mdio) |
210 | 218 | return empty_mdio |
211 | 219 |
|
212 | | - |
213 | 220 | def test_dataset_metadata(self, mdio_with_headers: Path) -> None: |
214 | 221 | """Test dataset metadata for empty MDIO file.""" |
215 | 222 | ds = open_mdio(mdio_with_headers) |
216 | 223 | self.validate_teapod_dataset_metadata(ds, is_velocity=True) |
217 | 224 |
|
218 | | - |
219 | 225 | def test_variables(self, mdio_with_headers: Path, mdio_no_headers: Path) -> None: |
220 | 226 | """Test grid validation for empty MDIO file.""" |
221 | | - |
222 | 227 | ds = open_mdio(mdio_with_headers) |
223 | 228 | header_dtype = get_teapot_segy_spec().trace.header.dtype |
224 | 229 | self.validate_teapod_dataset_variables(ds, header_dtype=header_dtype, is_velocity=True) |
@@ -381,18 +386,15 @@ def test_populate_empty_dataset(self, mdio_with_headers: Path) -> None: |
381 | 386 | output_path=mdio_with_headers.parent / "populated_empty.sgy", |
382 | 387 | ) |
383 | 388 |
|
384 | | - |
385 | | - def test_create_empty_like(self, teapot_mdio_tmp: Path) -> None: |
| 389 | + def test_create_empty_like(self, teapot_mdio_tmp: Path, empty_mdio_dir: Path) -> None: |
386 | 390 | """Create an empty MDIO file like the input MDIO file. |
387 | | - |
| 391 | +
|
388 | 392 | This test has to run after the segy_roundtrip_teapot tests have run because |
389 | 393 | its uses 'teapot_mdio_tmp' created by the segy_roundtrip_teapot tests as the input. |
390 | 394 | """ |
391 | | - |
392 | 395 | ds = create_empty_like( |
393 | 396 | input_path=teapot_mdio_tmp, |
394 | | - # TODO: write to a file |
395 | | - output_path=None, # We don't want to write to disk for now |
| 397 | + output_path=empty_mdio_dir / "create_empty_like.mdio", |
396 | 398 | keep_coordinates=True, |
397 | 399 | overwrite=True, |
398 | 400 | ) |
|
0 commit comments