Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csyhuang committed Dec 8, 2023
1 parent 35a8de9 commit 46b77ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dependencies:
- netCDF4=1.5.8
- jupyter
- matplotlib
- twine
25 changes: 24 additions & 1 deletion tests/test_output_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 46b77ab

Please sign in to comment.