Seam along 0 dateline when regridding with xesmf

Hi, I’m trying to regrid some cmip6 models with xesmf regridder.
The operation works, but then some (not all) of the regridded models have a seam in the output at the 0 dateline. I use periodic = True, which I assume is supposed to deal with this issue.

I found this post (Problem with dateline (longitude=0) for higher resolution global grids · Issue #101 · JiaweiZhuang/xESMF · GitHub), but it appears to be old. 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()) 

Thanks for any help!

Hi @mberdahl – I was surprised that you were left with a seam specifying periodic=True. I didn’t get a seam trying to regrid ACCESS-CM2 using xcdat (which uses xesmf, see docs here and example here).

One note: I think that xesmf is now being maintained here. That might be a good place to open an issue. If you can link to specific datasets (you can often get direct dataset links to CMIP data here) and create a minimally reproducible example, I think that will help others try to reproduce your issue and provide suggestions.

Hi @pochedley , thanks. I posted and got a response on the xESMF git page. Looks like it was a bug and there is a temporary workaround until it is fixed in the code. Perhaps it’ll help someone else.

1 Like

Hi @mberdahl – thank you for the update and for posting a reproducible example (xCDAT also had trouble interpreting how to regrid this data). I think this will be helpful to others.