|  | 
| 66 | 66 | from iris.analysis._area_weighted import AreaWeightedRegridder | 
| 67 | 67 | from iris.analysis._interpolation import (EXTRAPOLATION_MODES, | 
| 68 | 68 |                                           RectilinearInterpolator) | 
| 69 |  | -from iris.analysis._regrid import RectilinearRegridder | 
|  | 69 | +from iris.analysis._regrid import RectilinearRegridder, CurvilinearRegridder | 
| 70 | 70 | import iris.coords | 
| 71 | 71 | from iris.exceptions import LazyAggregatorError | 
| 72 | 72 | import iris._lazy_data | 
| @@ -2560,3 +2560,67 @@ def regridder(self, src_cube, target_grid): | 
| 2560 | 2560 |         from iris.analysis.trajectory import \ | 
| 2561 | 2561 |             UnstructuredNearestNeigbourRegridder | 
| 2562 | 2562 |         return UnstructuredNearestNeigbourRegridder(src_cube, target_grid) | 
|  | 2563 | + | 
|  | 2564 | + | 
|  | 2565 | +class PointInCell(object): | 
|  | 2566 | +    """ | 
|  | 2567 | +    This class describes the point-in-cell regridding scheme for use | 
|  | 2568 | +    typically with :meth:`iris.cube.Cube.regrid()`. | 
|  | 2569 | +
 | 
|  | 2570 | +    The PointInCell regridder can regrid data from a source grid of any | 
|  | 2571 | +    dimensionality and in any coordinate system. | 
|  | 2572 | +    The location of each source point is specified by X and Y coordinates | 
|  | 2573 | +    mapped over the same cube dimensions, aka "grid dimensions" : the grid may | 
|  | 2574 | +    have any dimensionality.  The X and Y coordinates must also have the same, | 
|  | 2575 | +    defined coord_system. | 
|  | 2576 | +    The weights, if specified, must have the same shape as the X and Y | 
|  | 2577 | +    coordinates. | 
|  | 2578 | +    The output grid can be any 'normal' XY grid, specified by *separate* X | 
|  | 2579 | +    and Y coordinates :  That is, X and Y have two different cube dimensions. | 
|  | 2580 | +    The output X and Y coordinates must also have a common, specified | 
|  | 2581 | +    coord_system. | 
|  | 2582 | +
 | 
|  | 2583 | +    """ | 
|  | 2584 | +    def __init__(self, weights=None): | 
|  | 2585 | +        """ | 
|  | 2586 | +        Point-in-cell regridding scheme suitable for regridding over one | 
|  | 2587 | +        or more orthogonal coordinates. | 
|  | 2588 | +
 | 
|  | 2589 | +        Optional Args: | 
|  | 2590 | +
 | 
|  | 2591 | +        * weights: | 
|  | 2592 | +            A :class:`numpy.ndarray` instance that defines the weights | 
|  | 2593 | +            for the grid cells of the source grid. Must have the same shape | 
|  | 2594 | +            as the data of the source grid. | 
|  | 2595 | +            If unspecified, equal weighting is assumed. | 
|  | 2596 | +
 | 
|  | 2597 | +        """ | 
|  | 2598 | +        self.weights = weights | 
|  | 2599 | + | 
|  | 2600 | +    def regridder(self, src_grid, target_grid): | 
|  | 2601 | +        """ | 
|  | 2602 | +        Creates a point-in-cell regridder to perform regridding from the | 
|  | 2603 | +        source grid to the target grid. | 
|  | 2604 | +
 | 
|  | 2605 | +        Typically you should use :meth:`iris.cube.Cube.regrid` for | 
|  | 2606 | +        regridding a cube. There are, however, some situations when | 
|  | 2607 | +        constructing your own regridder is preferable. These are detailed in | 
|  | 2608 | +        the :ref:`user guide <caching_a_regridder>`. | 
|  | 2609 | +
 | 
|  | 2610 | +        Args: | 
|  | 2611 | +
 | 
|  | 2612 | +        * src_grid: | 
|  | 2613 | +            The :class:`~iris.cube.Cube` defining the source grid. | 
|  | 2614 | +        * target_grid: | 
|  | 2615 | +            The :class:`~iris.cube.Cube` defining the target grid. | 
|  | 2616 | +
 | 
|  | 2617 | +        Returns: | 
|  | 2618 | +            A callable with the interface: | 
|  | 2619 | +
 | 
|  | 2620 | +                `callable(cube)` | 
|  | 2621 | +
 | 
|  | 2622 | +            where `cube` is a cube with the same grid as `src_grid` | 
|  | 2623 | +            that is to be regridded to the `target_grid`. | 
|  | 2624 | +
 | 
|  | 2625 | +        """ | 
|  | 2626 | +        return CurvilinearRegridder(src_grid, target_grid, self.weights) | 
0 commit comments