def METHOD_NAME(tmpdir, format):
    grid = RasterModelGrid((4, 3))
    grid.add_field("topographic__elevation", np.arange(12, dtype=np.uint8), at="node")
    with tmpdir.as_cwd():
        to_netcdf(grid, "test.nc", format=format)
        actual = xr.open_dataset("test.nc")["at_node:topographic__elevation"]
        assert_array_equal(actual, grid.at_node["topographic__elevation"])
        assert actual.dtype == np.uint8 if format == "NETCDF4" else np.int8