grids ===== .. py:module:: grids Functions --------- .. autoapisummary:: grids.interpolate_unstructured grids.is_structured grids.needs_cyclic_point Module Contents --------------- .. py:function:: interpolate_unstructured(x, y, z, resolution=1000, method='linear') Interpolate unstructured data to a structured grid. This function takes unstructured (scattered) data points and interpolates them to a structured grid, handling NaN values in `z` and providing options for different interpolation methods. It creates a regular grid based on the given resolution and interpolates the z-values from the unstructured points onto this grid. :param x: 1D array of x-coordinates. :type x: array_like :param y: 1D array of y-coordinates. :type y: array_like :param z: 1D array of z-values at each (x, y) point. :type z: array_like :param resolution: The number of points along each axis for the structured grid. Default is 1000. :type resolution: int, optional :param method: The interpolation method to use. Default is 'linear'. The methods supported are: - 'linear': Linear interpolation between points. - 'nearest': Nearest-neighbor interpolation. - 'cubic': Cubic interpolation, which may produce smoother results. :type method: {'linear', 'nearest', 'cubic'}, optional :returns: * **grid_x** (*ndarray*) -- 2D array representing the x-coordinates of the structured grid. * **grid_y** (*ndarray*) -- 2D array representing the y-coordinates of the structured grid. * **grid_z** (*ndarray*) -- 2D array of interpolated z-values at the grid points. NaNs may be present in regions where interpolation was not possible (e.g., due to large gaps in the data). .. py:function:: is_structured(x, y, tol=1e-05) Determines whether the x and y points form a structured grid. This function checks if the x and y coordinate arrays represent a structured grid, i.e., a grid with consistent spacing between points. The function supports 1D arrays (representing coordinates of a grid) and 2D arrays (representing the actual grid coordinates) of x and y. :param x: A 1D or 2D array of x-coordinates. For example, this can be longitude or the x-coordinate in a Cartesian grid. :type x: array_like :param y: A 1D or 2D array of y-coordinates. For example, this can be latitude or the y-coordinate in a Cartesian grid. :type y: array_like :param tol: Tolerance for floating-point comparison to account for numerical precision errors when checking spacing consistency. The default is 1e-5. :type tol: float, optional :returns: True if the data represents a structured grid, i.e., the spacing between consecutive points in both x and y is consistent. False otherwise. :rtype: bool .. py:function:: needs_cyclic_point(lons)