ua-snap / cmip6-utils

Pipelines and utilites for working with CMIP6 data
1 stars 1 forks source link

Bad interpolation of northernmost row for some regridded data #51

Closed kyleredilla closed 6 months ago

kyleredilla commented 6 months ago

Looks like something is up with regridding certain datasets. Seems to work OK in the exploratory notebooks, but as implemented in regrid/regrid.py, the northernmost row is filled with a constant value that it definitely unrealistic. E.g. GFDL-ESM4:

image

Presumably this has to do with cropping, since that is the first thing I notice that is in the production script but not in the exploratory notebook.

Code to recreate:

from regrid import open_and_crop_dataset, init_regridder

src_fp = "/import/beegfs/CMIP6/arctic-cmip6/CMIP6/ScenarioMIP/NOAA-GFDL/GFDL-ESM4/ssp585/r1i1p1f1/Amon/tas/gr1/v20180701/tas_Amon_GFDL-ESM4_ssp585_r1i1p1f1_gr1_201501-210012.nc"
dst_fp = "/import/beegfs/CMIP6/arctic-cmip6/CMIP6/ScenarioMIP/NCAR/CESM2-WACCM/ssp585/r1i1p1f1/Amon/tas/gn/v20200702/tas_Amon_CESM2-WACCM_ssp585_r1i1p1f1_gn_225101-229912.nc"

ext_lat_slice = slice(49, 90)
prod_lat_slice = slice(50, 90)
src_init_ds = open_and_crop_dataset(src_fp, lat_slice=ext_lat_slice)
dst_ds = open_and_crop_dataset(dst_fp, lat_slice=prod_lat_slice)

# use one of the source files to be regridded and the destination grid file to create a regridder object
regridder = init_regridder(src_init_ds, dst_ds)

regrid_task = regridder(src_init_ds, keep_attrs=True)
regrid_ds = regrid_task.compute()

regrid_ds.isel(time=0).tas.plot()