Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support printing Datasets on xarray>2024.1.0 #153

Merged
merged 5 commits into from
Jul 1, 2024
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
3 changes: 1 addition & 2 deletions src/grib2io/xarray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import dataclass, field, astuple
import itertools
import logging
from pathlib import Path
import typing

import numpy as np
Expand Down Expand Up @@ -100,7 +99,7 @@ class GribBackendArray(BackendArray):
def __init__(self, array, lock):
self.array = array
self.shape = array.shape
self.dtype = array.dtype
self.dtype = np.dtype(array.dtype)
self.lock = lock


Expand Down
22 changes: 22 additions & 0 deletions tests/test_print_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import xarray as xr


def test_da_repr(tmp_path, request):
"""Test writing a single DataArray to a single grib2 message."""
target_dir = tmp_path / "test_to_grib2"
target_dir.mkdir()

datadir = request.config.rootdir / "tests" / "data" / "gfs_20221107"

filters = {
"productDefinitionTemplateNumber": 0,
"typeOfFirstFixedSurface": 1,
"shortName": "TMP",
}
ds1 = xr.open_dataset(
datadir / "gfs.t00z.pgrb2.1p00.f012_subset",
engine="grib2io",
filters=filters,
)

_ = repr(ds1)
Loading