Skip to content

Commit f8f3b74

Browse files
andersy005jthielenpre-commit-ci[bot]
authored
Add xwrf/wrf DataArray and Dataset Accessors (#44)
Co-authored-by: jthielen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b1085a8 commit f8f3b74

19 files changed

+228
-223
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ repos:
1616
hooks:
1717
- id: pyupgrade
1818
args:
19-
- '--py37-plus'
19+
- '--py38-plus'
2020

2121
- repo: https://github.com/psf/black
2222
rev: 22.1.0
2323
hooks:
24+
- id: black
2425
- id: black-jupyter
2526

2627
- repo: https://github.com/keewis/blackdoc

ci/environment-upstream-dev.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- pre-commit
1010
- pytest-cov
1111
- pytest-sugar
12-
- wrf-python
1312
- xarray>=0.18,!=0.20.0,!=0.20.1
1413
- pooch
1514
- pip:

ci/environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ dependencies:
99
- pre-commit
1010
- pytest-cov
1111
- pytest-sugar
12-
- wrf-python
1312
- xarray>=0.18,!=0.20.0,!=0.20.1
1413
- pooch
1514
- pip:

setup.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name='xwrf',
29-
description='A lightweight interface for reading in output from the Weather Research and Forecasting (WRF) model into xarray Dataset.',
29+
description='A lightweight interface for working with the Weather Research and Forecasting (WRF) model output in Xarray.',
3030
long_description=long_description,
3131
long_description_content_type='text/markdown',
3232
python_requires='>=3.7',
@@ -36,21 +36,16 @@
3636
url='https://xwrf.readthedocs.io',
3737
project_urls={
3838
'Documentation': 'https://xwrf.readthedocs.io',
39-
'Source': 'https://github.com/NCAR/xwrf',
40-
'Tracker': 'https://github.com/NCAR/xwrf/issues',
39+
'Source': 'https://github.com/ncar-xdev/xwrf',
40+
'Tracker': 'https://github.com/ncar-xdev/xwrf/issues',
41+
'Discussions/Support': 'https://github.com/ncar-xdev/xwrf/discussions',
4142
},
4243
packages=find_packages(exclude=('tests',)),
43-
package_dir={'xwrf': 'xwrf'},
4444
include_package_data=True,
4545
install_requires=install_requires,
4646
license='Apache 2.0',
4747
zip_safe=False,
48-
entry_points={
49-
'xarray.backends': [
50-
'xwrf=xwrf.io_plugin:WRFBackendEntrypoint',
51-
'wrf=xwrf.io_plugin:WRFBackendEntrypoint',
52-
]
53-
},
48+
entry_points={},
5449
keywords='wrf, xarray',
5550
use_scm_version={'version_scheme': 'post-release', 'local_scheme': 'dirty-tag'},
5651
)

tests/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import annotations
2+
3+
import importlib
4+
import typing
5+
6+
import packaging
7+
import pytest
8+
9+
10+
def importorskip(module_name, minversion: str = None) -> typing.Callable:
11+
try:
12+
module = importlib.import_module(module_name)
13+
has = True
14+
15+
if minversion and packaging.version.parse(module.__version__) < packaging.version.parse(
16+
minversion
17+
):
18+
raise ValueError(
19+
f'{module_name} version {module.__version__} is less than {minversion}'
20+
)
21+
except (ImportError, ValueError):
22+
has = False
23+
24+
return pytest.mark.skipif(
25+
not has, reason=f'requires {module_name} with minimum version={minversion}'
26+
)
-4.04 MB
Binary file not shown.
-58.9 KB
Binary file not shown.

tests/test_accessors.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pandas as pd
2+
import pytest
3+
4+
import xwrf
5+
6+
from . import importorskip
7+
8+
9+
@importorskip('cf_xarray')
10+
@pytest.mark.parametrize('name', ['lambert_conformal'])
11+
def test_postprocess(name):
12+
13+
raw_ds = xwrf.tutorial.open_dataset(name)
14+
assert pd.api.types.is_string_dtype(raw_ds.Times.dtype)
15+
assert pd.api.types.is_numeric_dtype(raw_ds.Time.dtype)
16+
assert 'time' not in raw_ds.cf.coordinates
17+
assert raw_ds.cf.standard_names == {}
18+
ds = raw_ds.xwrf.postprocess()
19+
assert pd.api.types.is_datetime64_dtype(ds.Time.dtype)
20+
assert 'time' in ds.cf.coordinates
21+
standard_names = ds.cf.standard_names
22+
23+
assert standard_names['time'] == ['Time']
24+
assert standard_names['humidity_mixing_ratio'] == ['Q2', 'QVAPOR']
25+
assert standard_names['air_temperature'] == ['T2']

tests/test_cf_attrs.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/test_io_plugin.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)