Skip to content

Commit

Permalink
Prevent regridding to/from stretched grids in file_regrid.py
Browse files Browse the repository at this point in the history
gcpy/file_regrid.py
- Because there is an issue in regridding to stretched-grids,
  we now throw a RuntimeError if sg_params_in or sg_params_out
  does not match the default (i.e. non-stretched) values.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Oct 24, 2023
1 parent 5db7347 commit 1cbc921
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gcpy/file_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ def file_regrid(
if sg_params_out is None:
sg_params_out = [1.0, 170.0, -90.0]

# ------------------------------------------------------------------
# There still seem to be a few issues with regridding to cubed-
# sphere stretched grids. For time time being, stop with error
# if sg_params_in or sg_params_out do not equal the defaults.
# -- Bob Yantosca & Lizzie Lundgren (24 Oct 2023)
if not np.array_equal(sg_params_in, [1.0, 170.0, -90.0]) or \
not np.array_equal(sg_params_out, [1.0, 170.0, -90.0]):
msg = "Regridding to or from cubed-sphere stretched grids is\n" + \
"currently not supported. Please use the offline regridding\n" + \
"method described in the Regridding section of gcpy.readthedocs.io."
raise RuntimeError(msg)
# ------------------------------------------------------------------

# Load dataset
dset = xr.open_dataset(
filein,
Expand Down Expand Up @@ -317,7 +330,7 @@ def regrid_cssg_to_cssg(
"""
if verbose:
print("file_regrid.py: Regridding from CS/SG to CS/SG")

# Keep all xarray attributes
with xr.set_options(keep_attrs=True):

Expand Down

0 comments on commit 1cbc921

Please sign in to comment.