Skip to content

Commit

Permalink
add OA function
Browse files Browse the repository at this point in the history
  • Loading branch information
miniufo committed Aug 6, 2023
1 parent a26e3a6 commit 81a605b
Show file tree
Hide file tree
Showing 5 changed files with 443 additions and 292 deletions.
226 changes: 226 additions & 0 deletions notebooks/objective_analysis.ipynb

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""
Created on 2023.06.11
@author: MiniUFO
Copyright 2018. All rights reserved. Use is subject to license terms.
"""
#%% test objective analysis method
import numpy as np
import xarray as xr
from xgrads import oacressman


def test_oacressman():
ds = xr.open_dataset('./ctls/stationPrecip.nc')

lonV = np.linspace(70, 140, 141)
latV = np.linspace(15, 55, 81)

lon = xr.DataArray(lonV, dims='lon', coords={'lon': lonV})
lat = xr.DataArray(latV, dims='lat', coords={'lat': latV})

precip = xr.where(np.isnan(ds.precip), 0, ds.precip).load()

res1, wei1 = oacressman(precip, ds.lons, ds.lats, 'stnID',
lon, lat, rads=[4], method='cressman')
res2, wei2 = oacressman(precip, ds.lons, ds.lats, 'stnID',
lon, lat, rads=[4], method='exp')

assert res1.shape == res2.shape == (31, 81, 141)
assert wei1.shape == wei2.shape == (31, 81, 141)




227 changes: 0 additions & 227 deletions tests/testutils.py

This file was deleted.

5 changes: 3 additions & 2 deletions xgrads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from .core import CtlDescriptor
from .io import open_CtlDataset, open_mfdataset
from .utils import interp_to_latlon, get_coordinates_from_PDEF, \
get_data_projection
__version__ = "0.2.3"
get_data_projection, oacressman

__version__ = "0.2.4"
Loading

0 comments on commit 81a605b

Please sign in to comment.