Exemple #1
0
def regrid_to_max_resolution(cubes, **kwargs):
    """
    Returns all the cubes re-gridded to the highest horizontal resolution.

    Horizontal resolution is defined by the number of grid points/cells covering the horizontal plane.
    See :func:`iris.analysis.interpolation.regrid` regarding mode of interpolation.

    Args:

    * cubes:
        An iterable of :class:`iris.cube.Cube` instances.

    Returns:
        A list of new :class:`iris.cube.Cube` instances.

    .. deprecated:: 1.10

        The module :mod:`iris.analysis.interpolate` is deprecated.
        Please replace usage of :func:`regrid_to_max_resolution` with
        :meth:`iris.cube.Cube.regrid`.

    """
    # TODO: This could be significantly improved for readability and functionality.
    resolution = lambda cube_: (cube_.shape[cube_.coord_dims(cube_.coord(axis="x"))[0]]) * (cube_.shape[cube_.coord_dims(cube_.coord(axis="y"))[0]])
    grid_cube = max(cubes, key=resolution)
    return [cube.regridded(grid_cube, **kwargs) for cube in cubes]
Exemple #2
0
def regrid_to_max_resolution(cubes, **kwargs):
    """
    Returns all the cubes re-gridded to the highest horizontal resolution.

    Horizontal resolution is defined by the number of grid points/cells covering the horizontal plane.
    See :func:`iris.analysis.interpolation.regrid` regarding mode of interpolation.

    Args:

    * cubes:
        An iterable of :class:`iris.cube.Cube` instances.

    Returns:
        A list of new :class:`iris.cube.Cube` instances.

    .. deprecated:: 1.10

        The module :mod:`iris.analysis.interpolate` is deprecated.
        Please replace usage of :func:`regrid_to_max_resolution` with
        :meth:`iris.cube.Cube.regrid`.

    """
    # TODO: This could be significantly improved for readability and functionality.
    resolution = lambda cube_: (cube_.shape[cube_.coord_dims(cube_.coord(axis="x"))[0]]) * (cube_.shape[cube_.coord_dims(cube_.coord(axis="y"))[0]])
    grid_cube = max(cubes, key=resolution)
    return [cube.regridded(grid_cube, **kwargs) for cube in cubes]
Exemple #3
0
def _curl_regrid(cube, prototype):
    """
    Simple wrapper to :ref`iris.cube.Cube.regridded` to deal with None in a way that makes sense in the context of curl.

    """
    # We are definitely dealing with cubes or None - otherwise we have a programmer error...
    assert isinstance(cube, iris.cube.Cube) or cube is None
    assert isinstance(prototype, iris.cube.Cube)

    if cube is None:
        return None
    # #301 use of resample would be better here.
    return cube.regridded(prototype)
Exemple #4
0
def _curl_regrid(cube, prototype):
    """
    Simple wrapper to :ref`iris.cube.Cube.regridded` to deal with None in a way that makes sense in the context of curl.

    """
    # We are definitely dealing with cubes or None - otherwise we have a programmer error...
    assert isinstance(cube, iris.cube.Cube) or cube is None
    assert isinstance(prototype, iris.cube.Cube)

    if cube is None:
        return None
    # #301 use of resample would be better here.
    return cube.regridded(prototype)