Skip to content

Commit

Permalink
changed test to hit the new noaa-nodd-kerchunk buckets, rather than n…
Browse files Browse the repository at this point in the history
…exget-dmac
  • Loading branch information
ChrisBarker-NOAA committed Oct 21, 2024
1 parent 32b70f3 commit 8b6282c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/test_grids/test_sgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ def test_grid_topology_location_parse():
@pytest.mark.online
def test_polygon_subset():
'''
This is a basic integration test for the subsetting of a ROMS sgrid dataset using a polygon.
This is a basic integration test for the subsetting of a ROMS sgrid dataset using
a polygon.
'''
if fsspec is None:
raise ImportError("Must have fsspec installed to run --online tests")
fs = fsspec.filesystem(
"reference",
fo="s3://nextgen-dmac-cloud-ingest/nos/wcofs/nos.wcofs.2ds.best.nc.zarr",
fo="s3://noaa-nodd-kerchunk-pds/nos/wcofs/wcofs.fields.best.nc.zarr",
remote_protocol="s3",
remote_options={"anon": True},
target_protocol="s3",
Expand All @@ -71,25 +72,25 @@ def test_polygon_subset():
[-122.38488806417945, 34.98888604471138],
]
)
ds_temp = ds.xsg.subset_vars(['temp_sur'])
ds_temp = ds.xsg.subset_vars(['temp','u', 'v'])
ds_subset = ds_temp.xsg.subset_polygon(polygon)

#Check that the subset dataset has the correct dimensions given the original padding
# Check that the subset dataset has the correct dimensions given the original padding
assert ds_subset.sizes['eta_rho'] == ds_subset.sizes['eta_psi'] + 1
assert ds_subset.sizes['eta_u'] == ds_subset.sizes['eta_psi'] + 1
assert ds_subset.sizes['eta_v'] == ds_subset.sizes['eta_psi']
assert ds_subset.sizes['xi_rho'] == ds_subset.sizes['xi_psi'] + 1
assert ds_subset.sizes['xi_u'] == ds_subset.sizes['xi_psi']
assert ds_subset.sizes['xi_v'] == ds_subset.sizes['xi_psi'] + 1

#Check that the subset rho/psi/u/v positional relationsip makes sense aka psi point is
#'between' it's neighbor rho points
#Note that this needs to be better generalized; it's not trivial to write a test that
#works in all potential cases.
# Check that the subset rho/psi/u/v positional relationship makes sense aka psi point is
# 'between' it's neighbor rho points
# Note that this needs to be better generalized; it's not trivial to write a test that
# works in all potential cases.
assert (ds_subset['lon_rho'][0,0] < ds_subset['lon_psi'][0,0]
and ds_subset['lon_rho'][0,1] > ds_subset['lon_psi'][0,0])

#ds_subset.temp_sur.isel(ocean_time=0).plot(x="lon_rho", y="lat_rho")
# ds_subset.temp_sur.isel(ocean_time=0).plot(x="lon_rho", y="lat_rho")

def test_polygon_subset_2():
ds = xr.open_dataset(sample_sgrid_file, decode_times=False)
Expand Down

0 comments on commit 8b6282c

Please sign in to comment.