44
55import numpy as np
66import pytest
7- from xarray import DataArray as xr_DataArray
8- from zarr import zeros as zarr_zeros
97from zarr .codecs import BloscCodec
108
119from mdio import to_mdio
@@ -295,7 +293,7 @@ def test_to_xarray_dataset(tmp_path: Path) -> None:
295293 xr_ds = to_xarray_dataset (dataset )
296294
297295 file_path = output_path (tmp_path , f"{ xr_ds .attrs ['name' ]} " , debugging = False )
298- xr_ds . to_zarr ( store = file_path , mode = "w" , compute = False )
296+ to_mdio ( dataset = xr_ds , output_path = file_path , mode = "w" , compute = False )
299297
300298
301299def test_seismic_poststack_3d_acceptance_to_xarray_dataset (tmp_path : Path ) -> None :
@@ -306,62 +304,3 @@ def test_seismic_poststack_3d_acceptance_to_xarray_dataset(tmp_path: Path) -> No
306304
307305 file_path = output_path (tmp_path , f"{ xr_ds .attrs ['name' ]} " , debugging = False )
308306 to_mdio (xr_ds , output_path = file_path , mode = "w-" , compute = False )
309-
310-
311- def test_to_zarr_from_zarr_zeros_1 (tmp_path : Path ) -> None :
312- """Test writing XArray dataset with data as Zarr zero array to Zarr.
313-
314- Set encoding in as DataArray attributes
315- """
316- # Create a data type and the fill value
317- dtype = np .dtype ([("inline" , "int32" ), ("cdp_x" , "float64" )])
318-
319- my_attr_encoding = {"fill_value" : np .void ((0 , 0 ), dtype = dtype )}
320-
321- # Create a zarr array using the data type,
322- # Specify encoding as the array attribute
323- data = zarr_zeros ((36 , 36 ), dtype = dtype )
324- aa = xr_DataArray (name = "myattr" , data = data )
325- aa .encoding = my_attr_encoding
326-
327- file_path = output_path (tmp_path , "to_zarr/zarr_zarr_zerros_1" , debugging = False )
328- aa .to_zarr (file_path , mode = "w" , compute = False )
329-
330-
331- def test_to_zarr_from_zarr_zeros_2 (tmp_path : Path ) -> None :
332- """Test writing XArray dataset with data as Zarr zero array to Zarr.
333-
334- Set encoding in the to_zar method
335- """
336- # Create a data type and the fill value
337- dtype = np .dtype ([("inline" , "int32" ), ("cdp_x" , "float64" )])
338-
339- my_attr_encoding = {"fill_value" : np .void ((0 , 0 ), dtype = dtype )}
340-
341- # Create a zarr array using the data type,
342- # Do not specify encoding as the array attribute
343- data = zarr_zeros ((36 , 36 ), dtype = dtype )
344- aa = xr_DataArray (name = "myattr" , data = data )
345-
346- file_path = output_path (tmp_path , "to_zarr/zarr_zarr_zerros_2" , debugging = False )
347- # Specify encoding per array
348- encoding = {"myattr" : my_attr_encoding }
349- aa .to_zarr (file_path , mode = "w" , encoding = encoding , compute = False )
350-
351-
352- def test_to_zarr_from_np (tmp_path : Path ) -> None :
353- """Test writing XArray dataset with data as NumPy array to Zarr."""
354- # Create a data type and the fill value
355- dtype = np .dtype ([("inline" , "int32" ), ("cdp_x" , "float64" )])
356-
357- my_attr_encoding = {"fill_value" : np .void ((0 , 0 ), dtype = dtype )}
358-
359- # Create a zarr array using the data type
360- # Do not specify encoding as the array attribute
361- data = np .zeros ((36 , 36 ), dtype = dtype )
362- aa = xr_DataArray (name = "myattr" , data = data )
363-
364- file_path = output_path (tmp_path , "to_zarr/zarr_np" , debugging = False )
365- # Specify encoding per array
366- encoding = {"myattr" : my_attr_encoding }
367- aa .to_zarr (file_path , mode = "w" , encoding = encoding , compute = False )
0 commit comments