1313import xarray as xr
1414from segy import SegyFile
1515from segy .standards import get_segy_standard
16+ from tests .integration .testing_data import binary_header_teapot_dome
17+ from tests .integration .testing_data import text_header_teapot_dome
1618from tests .integration .testing_helpers import customize_segy_specs
1719from tests .integration .testing_helpers import get_inline_header_values
1820from tests .integration .testing_helpers import get_values
@@ -266,8 +268,8 @@ def test_3d_import(
266268 segy_to_mdio (
267269 segy_spec = segy_spec ,
268270 mdio_template = TemplateRegistry ().get ("PostStack3DTime" ),
269- input_location = StorageLocation (segy_input . __str__ ( )),
270- output_location = StorageLocation (zarr_tmp . __str__ ( )),
271+ input_location = StorageLocation (str ( segy_input )),
272+ output_location = StorageLocation (str ( zarr_tmp )),
271273 overwrite = True ,
272274 )
273275
@@ -278,11 +280,9 @@ class TestReader:
278280
279281 def test_meta_dataset_read (self , zarr_tmp : Path ) -> None :
280282 """Metadata reading tests."""
281- path = zarr_tmp .__str__ ()
282- # path = "/tmp/pytest-of-vscode/my-mdio/mdio0"
283283 # NOTE: If mask_and_scale is not set,
284284 # Xarray will convert int to float and replace _FillValue with NaN
285- ds = xr .open_dataset (path , engine = "zarr" , mask_and_scale = False )
285+ ds = xr .open_dataset (zarr_tmp , engine = "zarr" , mask_and_scale = False )
286286 expected_attrs = {
287287 "apiVersion" : "1.0.0a1" ,
288288 "createdOn" : "2025-08-06 16:21:54.747880+00:00" ,
@@ -297,13 +297,25 @@ def test_meta_dataset_read(self, zarr_tmp: Path) -> None:
297297 else :
298298 assert actual_attrs_json [key ] == value
299299
300+ attributes = ds .attrs ["attributes" ]
301+ assert attributes is not None
302+
303+ # Validate attributes provided by the template
304+ assert attributes ["surveyDimensionality" ] == "3D"
305+ assert attributes ["ensembleType" ] == "line"
306+ assert attributes ["processingStage" ] == "post-stack"
307+
308+ # Validate text header
309+ assert attributes ["textHeader" ] == text_header_teapot_dome ()
310+
311+ # Validate binary header
312+ assert attributes ["binaryHeader" ] == binary_header_teapot_dome ()
313+
300314 def test_meta_variable_read (self , zarr_tmp : Path ) -> None :
301315 """Metadata reading tests."""
302- path = zarr_tmp .__str__ ()
303316 # NOTE: If mask_and_scale is not set,
304317 # Xarray will convert int to float and replace _FillValue with NaN
305- # path = "/tmp/pytest-of-vscode/my-mdio/mdio0"
306- ds = xr .open_dataset (path , engine = "zarr" , mask_and_scale = False )
318+ ds = xr .open_dataset (zarr_tmp , engine = "zarr" , mask_and_scale = False )
307319 expected_attrs = {
308320 "count" : 97354860 ,
309321 "sum" : - 8594.551666259766 ,
@@ -318,11 +330,9 @@ def test_meta_variable_read(self, zarr_tmp: Path) -> None:
318330 def test_grid (self , zarr_tmp : Path ) -> None :
319331 """Test validating MDIO variables."""
320332 # Load Xarray dataset from the MDIO file
321- path = zarr_tmp .__str__ ()
322- # path = "/tmp/pytest-of-vscode/my-mdio/mdio0"
323333 # NOTE: If mask_and_scale is not set,
324334 # Xarray will convert int to float and replace _FillValue with NaN
325- ds = xr .open_dataset (path , engine = "zarr" , mask_and_scale = False )
335+ ds = xr .open_dataset (zarr_tmp , engine = "zarr" , mask_and_scale = False )
326336
327337 # Note: in order to create the dataset we used the Time template, so the
328338 # sample dimension is called "time"
@@ -366,34 +376,28 @@ def test_grid(self, zarr_tmp: Path) -> None:
366376
367377 def test_inline (self , zarr_tmp : Path ) -> None :
368378 """Read and compare every 75 inlines' mean and std. dev."""
369- path = zarr_tmp .__str__ ()
370- # path = "/tmp/pytest-of-vscode/my-mdio/mdio0"
371379 # NOTE: If mask_and_scale is not set,
372380 # Xarray will convert int to float and replace _FillValue with NaN
373- ds = xr .open_dataset (path , engine = "zarr" , mask_and_scale = False )
381+ ds = xr .open_dataset (zarr_tmp , engine = "zarr" , mask_and_scale = False )
374382 inlines = ds ["amplitude" ][::75 , :, :]
375383 mean , std = inlines .mean (), inlines .std ()
376384 npt .assert_allclose ([mean , std ], [1.0555277e-04 , 6.0027051e-01 ])
377385
378386 def test_crossline (self , zarr_tmp : Path ) -> None :
379387 """Read and compare every 75 crosslines' mean and std. dev."""
380- path = zarr_tmp .__str__ ()
381- # path = "/tmp/pytest-of-vscode/my-mdio/mdio0"
382388 # NOTE: If mask_and_scale is not set,
383389 # Xarray will convert int to float and replace _FillValue with NaN
384- ds = xr .open_dataset (path , engine = "zarr" , mask_and_scale = False )
390+ ds = xr .open_dataset (zarr_tmp , engine = "zarr" , mask_and_scale = False )
385391 xlines = ds ["amplitude" ][:, ::75 , :]
386392 mean , std = xlines .mean (), xlines .std ()
387393
388394 npt .assert_allclose ([mean , std ], [- 5.0329847e-05 , 5.9406823e-01 ])
389395
390396 def test_zslice (self , zarr_tmp : Path ) -> None :
391397 """Read and compare every 225 z-slices' mean and std. dev."""
392- path = zarr_tmp .__str__ ()
393- # path = "/tmp/pytest-of-vscode/my-mdio/mdio0"
394398 # NOTE: If mask_and_scale is not set,
395399 # Xarray will convert int to float and replace _FillValue with NaN
396- ds = xr .open_dataset (path , engine = "zarr" , mask_and_scale = False )
400+ ds = xr .open_dataset (zarr_tmp , engine = "zarr" , mask_and_scale = False )
397401 slices = ds ["amplitude" ][:, :, ::225 ]
398402 mean , std = slices .mean (), slices .std ()
399403 npt .assert_allclose ([mean , std ], [0.005236923 , 0.61279935 ])
0 commit comments