Skip to content

Commit 81a605b

Browse files
committed
add OA function
1 parent a26e3a6 commit 81a605b

File tree

5 files changed

+443
-292
lines changed

5 files changed

+443
-292
lines changed

notebooks/objective_analysis.ipynb

Lines changed: 226 additions & 0 deletions
Large diffs are not rendered by default.

tests/test_utils.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on 2023.06.11
4+
5+
@author: MiniUFO
6+
Copyright 2018. All rights reserved. Use is subject to license terms.
7+
"""
8+
#%% test objective analysis method
9+
import numpy as np
10+
import xarray as xr
11+
from xgrads import oacressman
12+
13+
14+
def test_oacressman():
15+
ds = xr.open_dataset('./ctls/stationPrecip.nc')
16+
17+
lonV = np.linspace(70, 140, 141)
18+
latV = np.linspace(15, 55, 81)
19+
20+
lon = xr.DataArray(lonV, dims='lon', coords={'lon': lonV})
21+
lat = xr.DataArray(latV, dims='lat', coords={'lat': latV})
22+
23+
precip = xr.where(np.isnan(ds.precip), 0, ds.precip).load()
24+
25+
res1, wei1 = oacressman(precip, ds.lons, ds.lats, 'stnID',
26+
lon, lat, rads=[4], method='cressman')
27+
res2, wei2 = oacressman(precip, ds.lons, ds.lats, 'stnID',
28+
lon, lat, rads=[4], method='exp')
29+
30+
assert res1.shape == res2.shape == (31, 81, 141)
31+
assert wei1.shape == wei2.shape == (31, 81, 141)
32+
33+
34+
35+

tests/testutils.py

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

xgrads/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
from .core import CtlDescriptor
33
from .io import open_CtlDataset, open_mfdataset
44
from .utils import interp_to_latlon, get_coordinates_from_PDEF, \
5-
get_data_projection
6-
__version__ = "0.2.3"
5+
get_data_projection, oacressman
6+
7+
__version__ = "0.2.4"

0 commit comments

Comments
 (0)