Changelog#

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[0.12.1] 2024-09-09#

Fixed#

  • Release 0.12.0 changed the return type of the face node connectivity of xugrid.Ugrid2d.voronoi_topology from a scipy.sparse.coo_matrix to an ordinary np.array of integers (and similarly for internal voronoi tesselations); this dense array had fill (hard-coded) values of -1, potentially differing from the grid’s fill value. This lead to a number of errors for methods relying on voronoi tesselations (such as contour plots) if the fill value of the grid was not -1. Internally, a FILL_VALUE = -1 is now used everywhere in connectivity arrays, and fill values are no longer passed for internal methods; a value of -1 is always assumed. When converting the grid (back) to a dataset with xugrid.Ugrid1d.to_dataset() or xugrid.Ugrid2d.to_dataset(), the fill value is set back to its original value; the fill value is also set when calling xugrid.UgridDataArrayAccessor.to_netcdf() or xugrid.UgridDatasetAccessor.to_netcdf().

Added#

Changed#

  • xugrid.Ugrid1d and xugrid.Ugrid2d will generally preserve the fill value and start index of grids when roundtripping from and to xarray Dataset. An exception is when the start index or fill value varies per connectivity: xugrid will enforce a single start index and a single fill value per grid. In case of inconsistent values across connectivity arrays, the values associated with the core connectivity are used: for Ugrid2d, this is the face node connectivity.

[0.12.0] 2024-09-03#

Fixed#

  • The xugrid.BarycentricInterpolator now interpolates according to linear weights within the full bounds of the source grid, rather than only within the centroids of the source grid. Previously, it would give no results beyond the centroids for structured to structured regridding, and it would give nearest results (equal to xugrid.CentroidLocatorRegridder) otherwise.

Added#

Changed#

  • Selection operations such as UgridDataArrayAccessor.sel_points() will now also return points that are located on the edges of 2D topologies.

  • xugrid.Ugrid1d.dimensions and xugrid.Ugrid2d.dimensions now raise a FutureWarning; use .dims or .sizes instead.

  • Improved performance of xugrid.open_dataset() and xugrid.merge_partitions() when handling datasets with a large number of variables (>100).

[0.11.2] 2024-08-16#

Fixed#

  • The regridders will no longer flip around data along an axis when regridding from data from structured to unstructured form when the coordinates along the dimensions is decreasing. (Decreasing y-axis is a common occurence in geospatial rasters.)

  • The regridders will no longer error on .regrid() if a structured target grid is non-equidistant, and contains an array delta (d) coordinate rather than a single delta to denote cell sizes along a dimension (i.e. dy along y midpoints, and dx along x.)

Added#

  • xugrid.snap_nodes() to snap neighboring vertices together that are located within a maximum snapping distance from each other. If vertices are located within a maximum distance, some of them are snapped to their neighbors (“targets”), thereby guaranteeing a minimum distance between nodes in the result. The determination of whether a point becomes a target itself or gets snapped to another point is primarily based on the order in which points are processed and their spatial relationships.

[0.11.1] 2024-08-13#

Fixed#

  • The reduction methods for the overlap regridders now behave consistently when all values are NaN or when all weights (overlaps) are zero, and all methods give the same answer irrespective of the order in which the values are encountered.

  • xugrid.merge_partitions() will now raise a ValueError if zero partitions are provided.

  • xugrid.merge_partitions() will no longer error when chunks are inconsistent across variables in a dataset, but now returns a merged dataset while keeping the chunking per variable. (Note that if chunks are inconstent for a variable across partitions that they are still and always unified for the variable.)

Added#

  • Percentiles (5, 10, 25, 50, 75, 90, 95) have been added to the xugrid.OverlapRegridder as standard available reduction methods (available as "p5", "p10", etc.). Custom percentile values (e.g. 2.5, 42) can be setup using xugrid.OverlapRegridder.create_percentile_method().

Changed#

  • Custom reduction functions provide to the overlap regridders no longer require an indices argument.

  • xugrid.Ugrid2d.sel_points(), xugrid.UgridDataArrayAccessor.sel_points() and xugrid.UgridDatasetAccessor.sel_points() now take an out_of_bounds and fill_value argument to determine what to with points that do not fall inside of any grid feature. Previously, the method silently dropped these points. The method now takes a fill_value argument to assign to out-of-bounds points. It gives a warning return uses fill_value=np.nan by default. To enable the old behavior, set out_of_bounds="drop".

[0.11.0] 2024-08-05#

Fixed#

  • xugrid.merge_partitions() now automatically merges chunks (if defined in the partition datasets). This removes the commonly seen PerformanceWarning: Slicing with an out-of-order index is generating ... times more chunks warning in subsequent operations, and also greatly improves the performance of subsequent operations (roughly scaling linearly with the number of partitions). The previous behavior can be maintained by setting merge_ugrid_chunks=False. This keyword will likely be deprecated in the future as merging the UGRID dimension chunks should be superior for (almost all?) subsquent operations.

  • xugrid.snap_to_grid() now returns proper line indexes when multiple linestrings are snapped. Snapping previously could result in correct linestring locations, but wrong line indexes.

Added#

Changed#

[0.10.0] 2024-05-01#

Fixed#

Added#

  • xugrid.earcut_triangulate_polygons() and xugrid.Ugrid2d.earcut_triangulate_polygons() have been added to break down polygon geodataframes into a triangular mesh for further processing.

  • xugrid.OverlapRegridder.weights_as_dataframe() has been added to extract regridding weights (overlaps) from the regridders. This method is also available for BarycentricInterpolator, CentroidLocatorRegridder, and RelativeOverlapRegridder.

[0.9.0] 2024-02-15#

Fixed#

  • xugrid.Ugrid2d.equals() and xugrid.Ugrid1d.equals() test if dataset is equal instead of testing type.

  • Fixed bug in xugrid.concat() and xugrid.merge() where multiple grids were returned if grids did not point to the same object id (i.e. copies).

  • Fixed bug in xugrid.Ugrid1d.merge_partitions(), which caused ValueError: indexes must be provided for attrs.

  • Fixed from_structured methods: the generated faces are now always in counterclockwise direction, also for increasing y-coordinates or decreasing x-coordinates.

Added#

  • xugrid.Ugrid2d.from_structured_multicoord() has been added to generate UGRID topologies from rotated or approximated curvilinear grids.

  • xugrid.Ugrid2d.from_structured_intervals1d() has been added to generate UGRID topologies from “intervals”: the N + 1 vertex coordinates for N faces.

  • xugrid.Ugrid2d.from_structured_intervals2d() has been added to generate UGRID topologies from “intervals”: the (M + 1, N + 1) vertex coordinates for N faces.

  • xugrid.UgridDataArrayAccessor.from_structured() now takes x and y arguments to specify which coordinates to use as the UGRID x and y coordinates.

  • xugrid.UgridDataset.sizes as an alternative to xugrid.UgridDataset.dimensions

  • xugrid.Ugrid2d.max_face_node_dimension which returns the dimension name designating nodes per face.

  • xugrid.AbstractUgrid.max_connectivity_sizes which returns all maximum connectivity dimensions and their corresponding size.

  • xugrid.AbstractUgrid.max_connectivity_dimensions which returns all maximum connectivity dimensions.

Changed#

[0.8.1] 2024-01-19#

Fixed#

  • xugrid.UgridDataArrayAccessor.reindex_like() will now take the tolerance argument into account before sorting. In the past, near ties could be resolved differently between otherwise similar grid topologies due to roundoff.

Added#

Changed#

[0.8.0] 2023-12-11#

Changed#

  • Initialize Meshkernel with a spherical projection if the coordinate reference system (crs) is geographic.

  • Minimum Python version increased to 3.9.

[0.7.1] 2023-11-17#

Fixed#

  • Support for Meshkernel 3 (#171). Initialize Meshkernel with defaults, setting it to cartesian projection.

[0.7.0] 2023-10-19#

Added#

Changed#

  • UGRID 2D topologies are no longer automatically forced in counterclockwise orientation during initialization.

Fixed#

  • Using an index which only reorders but does not change the size in xugrid.Ugrid1d.topology_subset() or xugrid.Ugrid2d.topology_subset() would erroneously result in the original grid being returned, rather than a new grid with the faces or edges shuffled. This breaks the link the between topology and data when using .isel on a UgridDataset or UgridDataArray. This has been fixed: both data and the topology are now shuffled accordingly.

[0.6.5] 2023-09-30#

Added#

Changed#

  • Selection operations along a line, or at point locations, will now prefix the name of the grid in the x and y coordinates. This avoids name collisions when multiple topologies are present in a dataset.

  • Xugrid now contains a partial copy of the xarray plot utils module, and its tests. The latest xarray release broke xugrid (on import), since (private) parts of xarray were used which no longer existed.

Fixed#

  • xugrid.UgridDatasetAccessor.sel() would return only a single grid topology even when the selection subject contains more than one grid. It now correctly returns subsets of all topologies.

[0.6.4] 2023-08-22#

Fixed#

[0.6.3] 2023-08-12#

Added#

Fixed#

Changed#

[0.6.2] 2023-07-26#

Fixed#

  • Computing indexer to avoid dask array of unknown shape upon plotting. See #117.

  • Bug where chunked dask arrays could not be regridded. See #119.

  • Bug where error was thrown in the RelativeOverlapRegridder upon flipping the y coordinate.

[0.6.1] 2023-07-07#

Fixed#

  • Fillvalue was not properly replaced in cast. See #113.

[0.6.0] 2023-07-05#

Added#

Fixed#

  • Regridding is possible again with regridders initiated from_weights. See #90. This was a broken feature in the 0.5.0 release.

  • Computed weights for structured grids regridders now decrease with distance instead of increase.

  • Fixed edge case for regridding structured grids, where midpoints of the source and target grid are equal.

  • Fixed numba typing error for regridders.

Changed#

  • Regridding structured grids now throws error if computed weights < 0.0 or > 1.0, before these weights were clipped to 0.0 and 1.0 respectively.

[0.5.0] 2023-05-25#

Added#

[0.4.0] 2023-05-05#

Fixed#

Changed#

  • xugrid.Ugrid2d.sel_points() and xugrid.UgridDataArrayAccessor.sel_points() now return a result with an “index” coordinate, containing the (integer) index of the points.

  • xugrid.Ugrid2d will now error during initialization if the node_edge_connectivity is invalid (i.e. contains nodes that are not used in any face).

  • xugrid.UgridDataArrayAccessor.plot.pcolormesh() now defaults to edgecolors="face" to avoid white lines (which can be become relatively dominant in when plotting large grids).

Added#

[0.3.0] 2023-03-14#

Fixed#

Changed#

Added#

[0.2.1] 2023-02-06#

Fixed#

  • xugrid.open_dataarray() will now return xugrid.UgridDataArray instead of only an xarray DataArray without topology.

  • Setting wrapped properties of the xarray object (such as name) now works.

  • Creating new (subset) topologies via e.g. selection will no longer error when datasets contains multiple coordinates systems (such as both longitude and latitude next to projected x and y coordinates).

Changed#

Added#

  • Several regridding methods have been added for face associated data: xugrid.BarycentricInterpolator have been added to interpolate smoothly, xugrid.CentroidLocatorRegridder has been added to simply sample based on face centroid, and xugrid.OverlapRegridder supports may aggregation methods (e.g. area weighted mean).

  • Added xugrid.Ugrid1d.edge_node_coordinates.

  • Added xugrid.Ugrid2d.edge_node_coordinates and xugrid.Ugrid2d.face_node_coordinates.

[0.2.0] 2023-01-19#

Fixed#

Changed#

  • Forwarding to the internal xarray object is now setup at class definition of UgridDataArray and UgridDataset rather than at runtime. This means tab completion and docstrings for the xarray methods should work.

  • The UGRID dimensions in UgridDataArray and UgridDataset are labelled at initialization. This allows us to track necessary changes to the UGRID topology for general xarray operations. Forwarded methods (such as UgridDataArray.isel()) will now create a subset topology if possible, or error if an invalid topology is created by the selection.

  • This also means that selection on one facet of the grid (e.g. the face dimension) will also result in a valid selection of the data on another facet (such as the edge dimension).

  • xugrid.Ugrid1d.sel() and xugrid.Ugrid2d.sel() now take an obj argument and return a DataArray or Dataset.

  • Consequently, xugrid.UgridDataArrayAccessor.isel and xugrid.UgridDatasetAccessor.isel have been removed.

  • xugrid.Ugrid1d.dimensions and xugrid.Ugrid2d.dimensions will now return a dictionary with the keys the dimension names and as the values the sizes of the dimensions.

  • xugrid.Ugrid2d.voronoi_topology will now include exterior vertices to also generate a valid 2D topology when when “island” faces are present (no connections to other faces) or when “slivers” are present (where cells have a only a left or right neighbor).

Added#

  • xugrid.Ugrid1d and xugrid.Ugrid2d can now be initialized with an attrs argument to setup non-default UGRID attributes such as alternative node, edge, or face dimensions.

  • xugrid.Ugrid1d.topology_subset(), xugrid.Ugrid2d.topology_subset(), xugrid.Ugrid1d.isel(), and xugrid.Ugrid2d.isel() now take a return_index argument and will to return UGRID dimension indexes if set to True.

  • xugrid.UgridDataArrayAccessor.clip_box() and xugrid.UgridDatasetAccessor.clip_box() have been added to more easily select data in a bounding box.

  • For convenience, .grid, .grids, .obj properties are now available on all these classes: UgridDataArray, UgridDataset, UgridDataArrayAccessor, and UgridDatasetAccessor.

  • Added xugrid.merge_partitions() to merge topology and data that have been partitioned along UGRID dimensions.

[0.1.10] 2022-12-13#

Fixed#

  • Move matplotlib import into a function body so matplotlib remains an optional dependency.

[0.1.9] 2022-12-13#

Changed#

  • Warn instead of error when the UGRID attributes indicate a set of coordinate that are not present in the dataset.

  • Use pyproject.toml for setuptools instead of setup.cfg.

Added#

Fixed#

[0.1.7] 2022-09-06#

Fixed#

[0.1.5] 2022-08-22#

Fixed#

  • list and dict type annotations have been replaced with List and Dict from the typing module to support older versions of Python (<3.9).

Changed#

Added#

[0.1.4] 2022-08-16#

Fixed#

  • A start_index of 1 in connectivity arrays is handled and will no longer result in indexing errors.

  • levels argument is now respected in line and pcolormesh plotting methods.

Changed#

  • UGRID variables are now extracted via xugrid.UgridRolesAccessor to allow for multiple UGRID topologies in a single dataset.

  • Extraction of the UGRID dimensions now proceeds via the dummy variable attributes, the connetivity arrays, and finally the coordinates.

  • Multiple coordinates can be supported. The UgridRolesAccessor attempts to infer valid node coordinates based on their standard names (one of``projection_x_coordinate, projection_y_coordinate, longitude, latitude``); a warning is raised when these are not found.

  • xugrid.UgridDataset now supports multiple Ugrid topologies. Consequently, its .grid attribute has been replaced by .grids.

  • The xarray object is no longer automatically wrapped when accessing the .obj attribute of a UgridDataArray or UgridDataset.

  • Separate UgridAccessors have been created for UgridDataArray and UgridDataset as many methods are specific to one but not the other.

  • The Ugrid classes have been subtly changed to support multiple topologies in a dataset. The .dataset attribute has been renamed to ._dataset, as access to the dataset should occur via the .to_dataset() method instead, which can check for consistency with the xarray object.

Added#

[0.1.3] 2021-12-23#