-
Notifications
You must be signed in to change notification settings - Fork 28
Add "method" keyword argument to make_regridder_* routines in gcpy/regrid.py #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,10 +105,10 @@ def file_regrid( | |
# -- 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) | ||
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 | ||
|
@@ -330,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): | ||
|
||
|
@@ -1128,7 +1128,7 @@ def rename_restart_variables( | |
# checkpoint -> classic/diagnostic | ||
# ============================================================== | ||
for var in dset.data_vars.keys(): | ||
if var == "DELP_DRY" or var == "DELPDRY": | ||
if var in ("DELP_DRY", "DELPDRY"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a fix suggested by Pylint |
||
old_to_new[var] = "Met_DELPDRY" | ||
if var == "BXHEIGHT": | ||
old_to_new[var] = "Met_BXHEIGHT" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ def make_regridder_L2L( | |
weightsdir='.', | ||
reuse_weights=False, | ||
in_extent=[-180, 180, -90, 90], | ||
out_extent=[-180, 180, -90, 90] | ||
out_extent=[-180, 180, -90, 90], | ||
method="conservative", | ||
): | ||
""" | ||
Create an xESMF regridder between two lat/lon grids | ||
|
@@ -78,14 +79,14 @@ def make_regridder_L2L( | |
regridder = xe.Regridder( | ||
llgrid_in, | ||
llgrid_out, | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
except BaseException: | ||
regridder = xe.Regridder( | ||
llgrid_in, | ||
llgrid_out, | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
return regridder | ||
|
@@ -96,7 +97,8 @@ def make_regridder_C2L( | |
llres_out, | ||
weightsdir='.', | ||
reuse_weights=True, | ||
sg_params=[1, 170, -90] | ||
sg_params=[1, 170, -90], | ||
method="conservative", | ||
): | ||
""" | ||
Create an xESMF regridder from a cubed-sphere to lat/lon grid | ||
|
@@ -151,14 +153,14 @@ def make_regridder_C2L( | |
regridder = xe.Regridder( | ||
csgrid_list[i], | ||
llgrid, | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
except BaseException: | ||
regridder = xe.Regridder( | ||
csgrid_list[i], | ||
llgrid, | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
regridder_list.append(regridder) | ||
|
@@ -175,7 +177,9 @@ def make_regridder_S2S( | |
tlon_out=170, | ||
tlat_out=-90, | ||
weightsdir='.', | ||
verbose=True): | ||
verbose=True, | ||
method="conservative", | ||
): | ||
""" | ||
Create an xESMF regridder from a cubed-sphere / stretched-grid grid | ||
to another cubed-sphere / stretched-grid grid. | ||
|
@@ -238,7 +242,7 @@ def make_regridder_S2S( | |
try: | ||
regridder = xe.Regridder(igrid_list[i_face], | ||
ogrid_list[o_face], | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
regridder_list[-1][i_face] = regridder | ||
|
@@ -254,7 +258,8 @@ def make_regridder_L2S( | |
csres_out, | ||
weightsdir='.', | ||
reuse_weights=True, | ||
sg_params=[1, 170, -90] | ||
sg_params=[1, 170, -90], | ||
method="conservative" | ||
): | ||
""" | ||
Create an xESMF regridder from a lat/lon to a cubed-sphere grid | ||
|
@@ -309,14 +314,14 @@ def make_regridder_L2S( | |
regridder = xe.Regridder( | ||
llgrid, | ||
csgrid_list[i], | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
except BaseException: | ||
regridder = xe.Regridder( | ||
llgrid, | ||
csgrid_list[i], | ||
method='conservative', | ||
method=method, | ||
filename=weightsfile, | ||
reuse_weights=reuse_weights) | ||
regridder_list.append(regridder) | ||
|
@@ -643,7 +648,7 @@ def regrid_comparison_data( | |
new_data=new_data[cmpminlat_ind:cmpmaxlat_ind + | ||
1, cmpminlon_ind:cmpmaxlon_ind + 1].squeeze() | ||
return new_data | ||
elif cmpgridtype == "ll": | ||
if cmpgridtype == "ll": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing elif -> if after a return statement was suggested by Pylint. |
||
# CS to ll | ||
if nlev == 1: | ||
new_data = np.zeros([global_cmp_grid['lat'].size, | ||
|
@@ -662,7 +667,7 @@ def regrid_comparison_data( | |
new_data=new_data[cmpminlat_ind:cmpmaxlat_ind + | ||
1, cmpminlon_ind:cmpmaxlon_ind + 1].squeeze() | ||
return new_data | ||
elif cmpgridtype == "cs": | ||
if cmpgridtype == "cs": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing elif -> if after a return statement was suggested by Pylint. |
||
# CS to CS | ||
# Reformat dimensions to T, Z, F, Y, X | ||
if 'Xdim' in data.dims: | ||
|
@@ -803,7 +808,7 @@ def rename_existing(ds, rename_dict): | |
|
||
# %%%% Renaming from the common format %%%% | ||
# Reverse rename | ||
ds = rename_existing(ds, | ||
ds = rename_existing(ds, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trimmed trailing whitespace here |
||
{v: k for k, v in dim_formats[format].get('rename', {}).items()}) | ||
|
||
# Ravel dimensions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra indentation was suggested by Pylint