Skip to content

Commit

Permalink
FIX: Ensure backwards compatibility with datatree/new versions of xar…
Browse files Browse the repository at this point in the history
…ray (#1681)

* try to use datatree from xarray

* FIX: Fix some small linting errors

* FIX: Fix the import of register datatree accessor

* DEP: Update dependencies to work with newer versions of xarray/xradar

* FIX: Update CI to only run for 3.10+

* FIX: Fix bad version in requirements

---------

Co-authored-by: Max Grover <[email protected]>
Co-authored-by: mgrover1 <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent 24478b2 commit 699f961
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
os: [macos, ubuntu, windows]

steps:
Expand Down
4 changes: 2 additions & 2 deletions continuous_integration/environment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- wradlib
- cartopy
- cvxopt
- xarray<=2024.9.0
- xarray>=2024.10.0
- metpy
- pytest-cov
- pytest-mpl
Expand All @@ -25,7 +25,7 @@ dependencies:
- shapely
- ruff
- mda-xdrlib
- xradar<=0.7.0
- xradar>=0.8.0
- pooch
- versioneer
- black
Expand Down
4 changes: 2 additions & 2 deletions doc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- metpy
- cartopy
- cvxopt
- xarray<=2024.9.0
- xarray>=2024.10.0
- sphinx<7.2
- ipython
- pandoc
Expand All @@ -34,7 +34,7 @@ dependencies:
- pre_commit
- cmweather
- mda-xdrlib
- xradar<=0.7.0
- xradar>=0.8.0
- dask
- pip
- pip:
Expand Down
20 changes: 16 additions & 4 deletions pyart/xradar/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@

import copy

import datatree
import numpy as np
import pandas as pd
from datatree import DataTree, formatting, formatting_html
from datatree.treenode import NodePath

try:
from xarray.core import formatting, formatting_html
from xarray.core.datatree import DataTree
from xarray.core.extensions import register_datatree_accessor
from xarray.core.treenode import NodePath
except ImportError:
from datatree import (
DataTree,
formatting,
formatting_html,
)
from datatree.extensions import register_datatree_accessor
from datatree.treenode import NodePath

from xarray import DataArray, Dataset, concat
from xarray.core import utils
from xradar.accessors import XradarAccessor
Expand Down Expand Up @@ -807,7 +819,7 @@ def _point_altitude_data():
return _point_altitude_data


@datatree.register_datatree_accessor("pyart")
@register_datatree_accessor("pyart")
class XradarDataTreeAccessor(XradarAccessor):
"""Adds a number of pyart specific methods to datatree.DataTree objects."""

Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ cftime
fsspec
s3fs
open_radar_data
xradar<=0.7.0
xradar>=0.8.0
pandas
mda-xdrlib
xarray<=2024.9.0
xarray>=2024.10.0
cartopy
pint

0 comments on commit 699f961

Please sign in to comment.