Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conda_package/mpas_tools/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ def write_netcdf(
out_filename,
fileName,
]
# Ensure all args are strings (important for Path objects)
args = [str(arg) for arg in args]
if logger is None:
subprocess.run(
args,
Expand Down
15 changes: 12 additions & 3 deletions conda_package/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import xarray as xr

from mpas_tools.io import write_netcdf
from mpas_tools.logging import LoggingContext

from .util import get_test_data_file

Expand All @@ -31,9 +32,17 @@ def test_write_netcdf_basic(tmp_path):
not os.path.exists(TEST_MESH), reason='Test mesh not available'
)
def test_write_netcdf_cdf5_format(tmp_path):
ds = xr.open_dataset(TEST_MESH)
out_file = tmp_path / 'test_cdf5.nc'
write_netcdf(ds, str(out_file), format='NETCDF3_64BIT_DATA')
with LoggingContext('test_write_netcdf_cdf5_format') as logger:
ds = xr.open_dataset(TEST_MESH)
out_file = tmp_path / 'test_cdf5.nc'
# test with and without logging
for logger_arg in [None, logger]:
write_netcdf(
ds,
str(out_file),
format='NETCDF3_64BIT_DATA',
logger=logger_arg,
)
# Use ncdump -k to check format
result = subprocess.run(
['ncdump', '-k', str(out_file)],
Expand Down
Loading