Skip to content

Commit

Permalink
address a few warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Aug 27, 2024
1 parent cb9262b commit 2351433
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clisops/core/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def detect_type(self) -> str:
)
and all(
[
self.ds.dims[dim] > 2
self.ds.sizes[dim] > 2
for dim in [
self.ds[self.lon_bnds].dims[-1],
self.ds[self.lat_bnds].dims[-1],
Expand Down
8 changes: 4 additions & 4 deletions clisops/utils/dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,14 @@ def reformat_SCRIP_to_CF(ds, keep_attrs=False):
(
ds.grid_dims.values[1],
ds.grid_dims.values[0],
ds.dims["grid_corners"],
ds.sizes["grid_corners"],
)
).astype(np.float32)
lon_b = ds.grid_corner_lon.values.reshape(
(
ds.grid_dims.values[1],
ds.grid_dims.values[0],
ds.dims["grid_corners"],
ds.sizes["grid_corners"],
)
).astype(np.float32)
lat_bnds = np.zeros((ds.grid_dims.values[1], 2), dtype=np.float32)
Expand Down Expand Up @@ -996,7 +996,7 @@ def detect_gridtype(ds, lon, lat, lon_bnds=None, lat_bnds=None):
and all([ds[bnds].ndim == 2 for bnds in [lon_bnds, lat_bnds]])
and all(
[
ds.dims[dim] > 2
ds.sizes[dim] > 2
for dim in [
ds[lon_bnds].dims[-1],
ds[lat_bnds].dims[-1],
Expand All @@ -1008,7 +1008,7 @@ def detect_gridtype(ds, lon, lat, lon_bnds=None, lat_bnds=None):
# rectilinear: bounds [nlat/nlon, 2]
elif (
all([ds[bnds].ndim == 2 for bnds in [lon_bnds, lat_bnds]])
and ds.dims[ds.cf.get_bounds_dim_name(lon)] == 2
and ds.sizes[ds.cf.get_bounds_dim_name(lon)] == 2
):
return "regular_lat_lon"
else:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_core_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_grid_init_ds_tas_cordex(mini_esgf_data):
assert grid.nlon == 225
assert grid.ncells == 45225

ds = ds.drop(["lat", "lon", "lat_vertices", "lon_vertices"])
ds = ds.drop_vars(["lat", "lon", "lat_vertices", "lon_vertices"])
with pytest.raises(
Exception,
match="The grid format is not supported.",
Expand Down Expand Up @@ -566,7 +566,9 @@ def test_detect_duplicated_cells(mini_esgf_data):


def test_subsetted_grid(mini_esgf_data):
ds = xr.open_dataset(mini_esgf_data["CMIP6_TAS_ONE_TIME_STEP"], use_cftime=True)
ds = xr.open_dataset(
mini_esgf_data["CMIP6_TAS_ONE_TIME_STEP"], use_cftime=True
).load()

area = (0.0, 10.0, 175.0, 90.0)

Expand Down

0 comments on commit 2351433

Please sign in to comment.