Changelog#
1.2.0 (2026-11-23)#
Changes of results (compared to 1.1.0, see the entries below for details)
interp2gridaverages a source grid finer than the destination grid per destination cell, instead of per window of source grid points aligned on the source grid. The results change most where the windows were offset from the destination cells: the 50 m DEM of the seamless weather provider to the seamless 2 km grid (linear) by 61.6 m RMSE (380 m max), as the windows were 1 km off the cells in x andlinearaveraged two of them (a 4 x 2 km box); gridefix ICON-CH1 to the seamless 2 km grid by 2 W m-2 (idw) to 6 W m-2 (nearest_alt) RMSE for the diffuse radiation, INCA by lessNaN are ignored in the averaging: a cell is NaN only if all its source values are NaN (e.g. for the snow limit, NaN below the orography). Destination cells at the edge of the source are no longer NaN (e.g. 314 cells for the DEM above with
try_reg=False, a row for ERA5 to a global 1 degree grid)unstructured source grids are averaged too: native ICON-CH1 to the seamless 2 km grid changes by 0.25 to 0.5 K RMSE for the 2 m temperature, and gets closer to gridefix ICON-CH1 (surface altitude RMSE 108 m → 56 m with
idw, 91 m → 71 m withlinear)nearestandlinearto a coarser destination grid give the mean of the source points of each destination cell, whatevertry_reg, instead of interpolating between the averaged windows; the other methods interpolate from the mean position of the points of each cell. The averaged values are float32 for float32 and 8 or 16 bit integer data, float64 otherwise (try_reg=Truereturned the source dtype, e.g. truncated int16 means), and the dimensions are in the order of the sourceslice_coarsenreturns an unstructured dataset (dimensioncellby default, coordinates in the destination CRS) when it averages the source gridthe slicing buffer of
interp2grid,slice_coarsenandslice_boundingboxcounts grid steps of the coarser of the source and destination grids, and the grid step of unstructured sources is estimated from the area per point (more robust, e.g. for ICON triangles)ens_stats.neighbor_statwithmeanand NaN: the mean of the valid values over the whole space x time window, instead of the mean of the means along each dimension. Without NaN, and forsum,minandmax, the results are unchanged (min/maxidentical,sum/meanwithin float32 rounding). The result is float32 for 8 or 16 bit integer and boolean data (mean/sumwere float64,maxof booleans too)
Changes
added the support of Python 3.14
changed
interp2poiandinterp2gridto no longer copy a dataset with a single data variable before interpolation (newcopyparameter ofds_utils.ds_to_da, defaultTrue). For the operational grids (with cached neighbors), POIs are interpolated up to about 1.5 times faster (e.g. ICON-CH2nearest0.18 s → 0.12 s) with 0.1 to 0.2 GB less memory for ICON, and IFS to the seamless 2 km grid withnearest_alt0.39 s → 0.24 s. A sliced source that is not contiguous in memory is now copied into contiguous rows per grid point, which is slower for large sources: ICON-CH2 in LV95 to the seamless 2 km grid withnearest_altortemp_fixgrad0.23 s → 0.29 s and 0.34 s → 0.39 schanged the averaging of a source grid finer than the destination grid by
interp2grid(andslice_coarsen): the mean of the source points of each destination cell (the cell of their nearest destination node along x and y), with a sparse matrix product, for regular and unstructured sources (unstructured sources were not averaged, with a warning), if the destination grid has regular 1D coordinates in its CRS (otherwise with a warning). For the seamless 2 km grid (with cached neighbors): gridefix ICON-CH1idw0.43 s → 0.27 s,nearest_alt0.31 s → 0.16 s,linear0.54 s → 0.13 s, with up to 0.13 GB more peak memory (copy of the sliced source into contiguous rows per grid point, e.g.nearest_alt0.07 GB → 0.20 GB); the 50 m DEMlinear0.13 s → 0.07 s; native ICON-CH1linear0.03 s instead of 1.05 s without averaging.interp2gridon the output ofslice_coarsen(with the same destination grid and method) gives the same result as on the source gridadded
slice_grid: slices a source grid to a destination grid, keeping its structure and CRS (the grid counterpart ofslice_boundingbox)added the support of unstructured grids to
ens_stats.neighbor_statandupscaled_prob: the neighborhood of each point is itsw_size_xy**2nearest points (the window of a square grid for 3 and 5), with the nearest neighbors searched in meters and cached, ignoring NaN. Native ICON-CH1 (34 fields, 1.15 M points, window 5):mean/sum0.5 s,min/max0.8 s, plus 1.8 s for the first neighbor search (rollingon a regular grid of the same size: 2.4 to 4.3 s)changed
ens_stats.neighbor_stat(andupscaled_prob) on regular grids and along time toscipy.ndimagefilters, applied to all the dimensions of the window at once (dask: one chunk along them). ICON-CH1-EPS gridefix (34 x 11 x 252 x 376)maxwith windows 17 and 3 (data4web-pipelines): 3.8 s → 1.1 s, peak memory 1.07 GB → 0.32 GB; a regular grid of 34 x 1072 x 1072 with window 5:mean4.3 s → 0.6 s,sum2.4 s → 0.5 s,max3.6 s → 1.0 s; native ICON-CH1 with windows 5 and 3:mean/max3.4 s → 1.1 schanged the slicing of unstructured grids opened lazily from a file (e.g.
xarray.open_datasetof a netCDF file, without dask) byinterp2poi,interp2grid,slice_boundingbox,slice_gridandslice_coarsen: the variables on the unstructured dimension are read by chunks of 16 MB, each with one slice (only the chunks with selected points), and loaded, instead of reading the selected points one by one. Native ICON-CH1 netCDF to the seamless 2 km grid:slice_gridand loading 50 s → 1.4 s. Sources in memory, dask arrays and regular grids are unchangedchanged
interp2poiandinterp2gridwithupscaled: the statistic is computed by blocks of POIs, without gathering thekneighbors of all the POIs at once, and withidw: a product with the sparse matrix of the weights, same results. Native ICON-CH1-EPS (10 members x 34 steps) to the 5,622 production POIs of data4web-pipelines withupscaledandk=289: 1.19 s → 0.39 s, peak memory +2.5 GB → +0.3 GB (first call 1.41 s → 0.55 s); gridefix ICON-CH1-EPS (3 variables) to the seamless 2 km grid withidw: 0.78 s → 0.43 s, peak memory +0.92 GB → +0.31 GBchanged
nn_lookup_cached: newdistancesparameter (in the cache key), the distances are None ifFalse, and the indices are int32: the cache of the methods without distances (nearest,upscaled,neighbor_staton unstructured grids) takes 4 times less memory (native ICON-CH1neighbor_statwithw_size_xy=17: 1.3 GB instead of 5.3 GB)added
data_model.get_spatial_coord_names: the names of all the coordinates giving horizontal positions (spatial dimensions, configured y/x pairs, CFaxisX/Y, horizontalstandard_nameorlong_name). Used by the averaging ofinterp2gridandslice_coarsento not average them, also the CF ones next to other positions (e.g. rotated coordinates of an unstructured grid that also has latitude and longitude)added
valuesto the default names of the unstructured grid dimension (GRID_PROCESS__data_model__grid__unstructured_dim): the dimension of non-regular GRIB grids read with cfgrib or earthkit-data, e.g. ICON open data, no longer needs to be renamed
1.1.0 (2026-11-12)#
Changes of results (compared to 1.0.0, see the entries below for details)
interp2poiandinterp2grid(outside of the regular grid interpolation) search nearest neighbors and triangulate in meters instead of latitude/longitude degrees: neighbors, IDW weights andlinear/cubicresults change slightly for grids that were searched in degrees, including native LV95 grids with latitude/longitude coordinatesgrids in rotated pole or latitude/longitude on a sphere without datum (e.g. a CF grid mapping with
earth_radius) now get the datum shift to Swiss coordinates (about 180 m)wrong values or NaN are fixed for grids with integer coordinates and for latitude/longitude grids whose longitude convention (0..360 or -180..180) differs from the one of the POIs or destination grid
create_dst_grid(withtoprightandresolution) andcreate_dst_grid_from_srcreturn different destination grids: exact resolution, and the extent of the source domain reprojected in the destination CRSgrid_interp._get_bufferis renamed toget_buffer(now public)
Changes
added a
py.typedmarker so that type checkers use the inline type hints ofgrid-process(PEP 561)added example notebooks to the documentation illustrating
interp2poiandinterp2gridwith open data, with their dependencies in the optionalexampledependency group. Two of them are global: GFS 2 m temperature to stations worldwide (compared with GHCN-hourly observations) and ERA5 2 m temperature to the IFS 0.1° gridfixed
interp2gridandinterp2poitruncating reprojected coordinates when the grid coordinates are integers (e.g. an LV95 destination grid built withnp.arange), which gave wrong values or NaNfixed
create_dst_gridwithtoprightandresolution: the resolution is now exact andtoprighta closed upper bound, instead of the grid spacing being stretched to end exactly ontoprightfixed
interp2poiandinterp2grid(outside of the regular grid interpolation) searching nearest neighbors and triangulating (linear,cubic) in latitude/longitude degrees, where a degree of longitude is shorter than a degree of latitude (about 0.68 times in Switzerland). Distances are now always in meters: native coordinates projected in meters are used even if latitude/longitude coordinates are present (e.g. LV95 grids), and latitude/longitude grids are converted to Swiss LV95, or to earth-centered earth-fixed coordinates (ECEF) far from Switzerland. Neighbors, IDW weights andlinear/cubicresults change slightly for grids that were searched in latitude/longitude, including native LV95 grids with latitude/longitude coordinatesfixed the reprojection of grids in rotated pole (or latitude/longitude) on a sphere without datum, e.g. from a CF grid mapping with
earth_radius: their latitudes and longitudes are now considered as WGS84 ones, as their latitude/longitude coordinates usually are. The datum shift to Swiss coordinates (about 180 m) was left out.parse_grid_mapping(andget_grid_crs) now return such CF mappings directly on WGS84, withoutpyproj.CRS.from_cf, which took about 0.3 s for a rotated pole; other mappings parsed byfrom_cfare cachedadded the support of global and other non-Swiss latitude/longitude grids by
interp2poiandinterp2grid(exceptlinear,linear_3Dandcubic, which raise an error), with nearest neighbor searches in ECEF coordinates. The maximum distance of the destination to the LV95 central northing for using LV95 is set by the new settinglv95_max_offset(environment variableGRID_PROCESS__lv95_max_offset, default 700 km)changed the methods with altitude, which no longer reproject to Swiss coordinates when the source grid or the destination has another CRS projected in meters (e.g. UTM)
added an explicit error when the destination grid of
interp2gridis unstructured, which is not supportedfixed
interp2poiandinterp2gridwith latitude/longitude source grids whose longitude convention (0..360 or -180..180) differs from the one of the POIs or destination grid: the source was sliced to the wrong longitudes (wrong values in the generic path, e.g. for a global destination grid) and the regular grid interpolation (try_reg=True) returned NaN. Global latitude/longitude grids are also interpolated across their 360 degree seam. When slicing a latitude/longitude source grid, the longitude buffer is widened by 1 / cos(latitude) (as nearest neighbors are now searched in meters) and all longitudes are kept close to the poleschanged the
tempmethod ofinterp2poi: POIs whose nearest grid points all have the same altitude (e.g. close to the poles of a latitude/longitude grid, whose pole rows repeat the same point, or on flat orography) use the fixed lapse rate fallback (as POIs far above or below their neighborhood) instead of raising an errorfixed
create_dst_grid_from_src: the destination grid now spans exactly the bounding box of the source domain reprojected in the destination CRS (from native coordinates projected in meters when available), instead of the reprojected corners of its latitude/longitude bounding box, which could be much larger (e.g. +80 km for ICON-CH2 in LV95) or miss parts of the domain (e.g. 28 km for IFS in LV95)fixed
set_grid_mappingwith CF grid mappings holding numpy arrays or non-float64 numpy values (e.g. astandard_parallelarray read from a netCDF file), which raised aTypeErrorchanged
memoize: the least recently used result is evicted (instead of the oldest one), the cache key can be computed by an optionalkeyfunction (only when caching is active), a cache size of 0 deactivates caching without overhead, and the cache is safe to use from several threads, also when the process forks (the fork waits until no thread is using the cache). Thehkeykeyword argument still worksfixed the in-memory caches of the POI and grid reprojections, whose keys left out the source CRS, and the cache of the regular grid nearest interpolation, which failed with a POI dimension name other than
poi(GRID_PROCESS__data_model__poi__dim)documented the in-memory caches of
interp2poiandinterp2gridand how to set their sizes or deactivate them with the environment variablesGRID_PROCESS__cache_size__<name>(Usage page)changed
interp2poiandinterp2gridoutside of the regular grid interpolation to flatten structured grids with numpy instead ofxarray.stack, andinterp2poito look for the grid points with NaN in all fields (excluded, as before) only among those with NaN in the middle field. Later calls with cached neighbors are faster on large grids (e.g. 0.13 s to 0.05 s for a global 0.25 degree grid to 33 POIs, 1.6 s to 0.5 s from this grid to a global 0.1 degree grid), with identical resultsfixed
interp2poiraising anIndexErrorwhen all POIs are outside an unstructured grid (no grid point left after slicing): they now get NaN, as outside of the regular grid interpolationmade
grid_interp.get_bufferpublic (renamed from_get_buffer): the slicing buffer in grid points of an interpolation method and its arguments, e.g. to slice the input data withslice_boundingboxbeforehand
1.0.0#
First open-source release of grid-process, the continuation of the internal MeteoSwiss library
gridefix-process (last internal version: 6.1.0).
Breaking Change (compared to gridefix-process 6.1.0)
renamed the package from
gridefix-processtogrid-process(import namegrid_process)renamed the environment variable prefix from
GRIDEFIX_PROCESS__toGRID_PROCESS__versioning restarts at
1.0.0