From 46b77ab3a1c0ef614bc9bdeb354ce749b17f02b2 Mon Sep 17 00:00:00 2001 From: csyhuang Date: Thu, 7 Dec 2023 22:34:58 -0600 Subject: [PATCH] fix unit tests --- environment.yml | 1 + tests/test_output_results.py | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 7fde64d3..37ed4afb 100644 --- a/environment.yml +++ b/environment.yml @@ -13,3 +13,4 @@ dependencies: - netCDF4=1.5.8 - jupyter - matplotlib +- twine diff --git a/tests/test_output_results.py b/tests/test_output_results.py index 89ad41d0..689ef296 100644 --- a/tests/test_output_results.py +++ b/tests/test_output_results.py @@ -220,4 +220,27 @@ def offgrid_input_data(test_data_dir): """ Return dataset with latitude grids not including equator. """ - return xr.open_dataset(f"{test_data_dir}/offgrid_input_uvt_data.nc") + xlon = np.arange(0, 360, 1.25) + ylat = np.linspace(-90, 90, 192, endpoint=True) + plev = [ + 1000, 975, 950, 925, 900, 875, 850, 825, 800, 775, + 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, + 225, 200, 175, 150, 125, 100, 70, 50, 30, 20, 10, + 7, 5, 3, 2, 1] + + test_data_dir = os.path.dirname(os.path.abspath(__file__)) + "/data" + u_file = xr.open_dataset(f"{test_data_dir}/2005-01-23-0000-u.nc").interp( + {"longitude": xlon, "latitude": ylat, "level": plev}, method="linear", kwargs={"fill_value": "extrapolate"}) + v_file = xr.open_dataset(f"{test_data_dir}/2005-01-23-0000-v.nc").interp( + {"longitude": xlon, "latitude": ylat, "level": plev}, method="linear", kwargs={"fill_value": "extrapolate"}) + t_file = xr.open_dataset(f"{test_data_dir}/2005-01-23-0000-t.nc").interp( + {"longitude": xlon, "latitude": ylat, "level": plev}, method="linear", kwargs={"fill_value": "extrapolate"}) + ds = xr.Dataset({ + "u": (("level", "latitude", "longitude"), u_file.u.data), + "v": (("level", "latitude", "longitude"), v_file.v.data), + "t": (("level", "latitude", "longitude"), t_file.t.data)}, + coords={ + "level": plev, + "latitude": ylat, + "longitude": xlon}) + return ds