+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ n
- Added new benchmark functions `make_benchmark_collection_2d_var_plots` and `make_benchmark_collection_3d_var_plots` which can be used with any GEOS-Chem output collection
- Added 1-month benchmark comparison plot options for `Budget`, `UVFlux`, and `StateMet` collections (2D and 3D vars separately) which are off by default
- Added `export MPLBACKEND=agg` to `gcpy/benchmark/modules/benchmark_slurm.sh` to request a non-interactive MatPlotLib backend
- Added `method` keyword argument to `make_regridder_*` routines in `regrid.py`, with default value `conservative`

### Changed
- Updated `gcpy_environment_py313.yml` to use `esmf==8.8.1` and `esmpy==8.8.1` to fix package inconsistency issues
Expand Down
12 changes: 6 additions & 6 deletions gcpy/file_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" + \
Copy link
Contributor Author

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

"currently not supported. Please use the offline regridding\n" + \
"method described in the Regridding section of gcpy.readthedocs.io."
raise RuntimeError(msg)
# ------------------------------------------------------------------

# Load dataset
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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"):
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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"
Expand Down
33 changes: 19 additions & 14 deletions gcpy/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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,
Expand All @@ -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":
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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:
Expand Down Expand Up @@ -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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载