pyremo.preproc.remap
- remap(ds, domain_info, vc, surflib, initial=False, static=False)[source]
Remap CF-compliant GCM/analysis data to a REMO target domain.
This performs the REMO preprocessing chain analogous to the legacy FORTRAN “intorg” tool: 1) horizontal interpolation of 3‑D and 2‑D fields to the rotated target grid, 2) first pressure correction using a PBL estimate, 3) vertical interpolation from input hybrid coefficients (
akgm,bkgm)to the requested vertical coordinate
vc(ak,bk),second pressure correction with hydrostatic consistency,
wind rotation and divergence correction,
surface field remapping (SST, sea ice) and optional initial fields.
- Parameters:
ds (
xarray.Dataset) – CF-compliant dataset holding at leastta(air temperature),ua/va(winds),hus(specific humidity),ps(surface pressure),tos(SST),orog(orography),sftlf(land fraction). Optionallyclwfor cloud liquid water content. Must also contain hybrid coordinate coefficientsakgmandbkgm(full levels) needed for vertical interpolation.domain_info (
dict) – Description of the target rotated domain with keys such asll_lon,ll_lat,dlon,dlat,nlon,nlat,pollon,pollat. Optional metadata likeCORDEX_domainordomain_idis preserved.vc (
pandas.DataFrame) – Vertical coordinate definition with columnsakandbk(half levels) andakh/bkh(mid levels); typically produced via pyremo tables.surflib (
xarray.Dataset) – Surface library on the target grid providing at leastBLA(land/sea mask) andFIB(surface geopotential/orography divided by gravity). Wheninitialorstaticis True, additional static fields (e.g.WSMX) are merged if available.initial (
bool, default:False) – If True, add dynamic/static fields required for model initial conditions (soil moisture/temperature, glacier mask, etc.). Impliesstatic=True.static (
bool, default:False) – If True, merge static fields fromsurflib(e.g. land/sea mask, orography) into the returned dataset.
- Returns:
xarray.Dataset– Forcing dataset on the target domain with rotated coordinates (rlon,rlat) and vertical dimensionlev. Includes at leastT,U,V,PS, humidity diagnostics (QD,QW,QDBLwhen available),TSW,TSI, optionalSEAICE, and vertical coordinate coefficients (hyai,hybi,hyam,hybm). Global attributes and domain identifiers are propagated.- Raises:
KeyError – If required variables (e.g.
ta,ua,va,hus,ps,tos,orog,sftlf) or hybrid coefficients (akgm,bkgm) are missing fromds.ValueError – If
domain_infois inconsistent or the vertical coordinatevclacks the expectedak/bkcolumns.
Notes
After interpolation, a nearest-neighbour selection aligns the result to the exact target grid points from
surflibto ensure coordinate identity. Time and calendar metadata are preserved when present.