Stream: general

Topic: Seam 0 dateline (with periodic = True) regridding with xesmf


view this post on Zulip Mira Berdahl (May 09 2024 at 21:55):

I'm trying to regrid some cmip6 models with xesmf regridder.
The operation works, but upon plotting some (not all) of the regridded models have a seam in the output at the 0 dateline. I found this post (https://github.com/JiaweiZhuang/xESMF/issues/101), but it appears there was a PR resolution a while back . Here is a snippet of code and the seam when plotted:

# define the target grid

starty = 1985; endy = 1986
year_range = range(starty, endy+1)

# ds = dset_dict['CMIP.NCC.NorESM2-LM.historical.Amon.gn']
ds = dt["NorESM2-LM"]["historical"].ds.tas

# Read in the output grid from NorESM
ds_target = ds.sel(time = ds.time.dt.year.isin(year_range)).squeeze()
ds_target


# Define the names of the datasets
dataset_names = ["ACCESS_CM2_hist", "ACCESS_CM2_histNat", "ACCESS_ESM1_5_LM_hist", "ACCESS_ESM1_5_LM_histNat", "BCC_CSM2_MR_hist", "BCC_CSM2_MR_histNat", "CanESM5_hist", "CanESM5_histNat",  "CESM2_hist", "CESM2_histNat" ,"FGOALS_g3_hist", "FGOALS_g3_histNat", "GISS_E2_1_G_hist", "GISS_E2_1_G_histNat" , "HadGEM3_GC31_L_hist", "HadGEM3_GC31_L_histNat", "MIROC6_hist", "MIROC6_histNat" , "MRI_ESM2_0_hist", "MRI_ESM2_0_histNat" , "NorESM2_LM_hist", "NorESM2_LM_histNat"]

# Create an empty dictionary to store the regridded datasets
regridded_datasets = {}

# Loop through each dataset name
for dataset_name in dataset_names:
    print(dataset_name)

    # Define the original dataset
    original_dataset = globals()[dataset_name]

    # Define the regridder object
    regridder = xe.Regridder(
        original_dataset, ds_target, "bilinear", periodic=True, ignore_degenerate=True,
    )  # this takes some time to calculate a weight matrix for the regridding

    # Apply regridding and store the regridded dataset in the dictionary
    regridded_datasets[dataset_name] = regridder(original_dataset.squeeze())  # this is a bit of a lazy operation

image.png

view this post on Zulip Mira Berdahl (May 16 2024 at 22:25):

For anyone interested, it appears this was a bug. More information plus a workaround are here:
https://github.com/pangeo-data/xESMF/issues/363


Last updated: May 16 2025 at 17:14 UTC