Skip to content

Coordinate system agnostic region extraction - #7266

Open
david-bentley wants to merge 11 commits into
SciTools:mainfrom
david-bentley:enhancement/region_extract
Open

Coordinate system agnostic region extraction#7266
david-bentley wants to merge 11 commits into
SciTools:mainfrom
david-bentley:enhancement/region_extract

Conversation

@david-bentley

Copy link
Copy Markdown

Description

Add a function to extract a region, decoupling the specified region bounds from the coordinate system of the cube. For example, given a cube in a rotated pole coordinate system

>>> print(cube)
air_pressure / (Pa)                 (grid_latitude: 151; grid_longitude: 97)
    Dimension coordinates:
        grid_latitude                             x                    -
        grid_longitude                            -                    x
    Scalar coordinates:
        forecast_reference_time     2013-08-15 03:00:00
        level_height                5.0 m
        sigma                       0.9994238, bound=(1.0, 0.99846387)
        time                        2013-08-15 11:00:00
    Attributes:
        Conventions                 'CF-1.7'
        STASH                       m01s00i408
        source                      'Data from Met Office Unified Model'
        um_version                  '8.2'

one can specify a subregion in a regular lat/lon coordinate system to extract that region from the rotated pole cube:

>>> area = (-4.790656510485121, 50.14530257322982, -3.450313532058675, 51.72890111361691)
>>> print(iris.util.extract_region(cube, area, crs=ccrs.PlateCarree()))
air_pressure / (Pa)                 (grid_latitude: 120; grid_longitude: 66)
    Dimension coordinates:
        grid_latitude                             x                    -
        grid_longitude                            -                    x
    Scalar coordinates:
        forecast_reference_time     2013-08-15 03:00:00
        level_height                5.0 m
        sigma                       0.9994238, bound=(1.0, 0.99846387)
        time                        2013-08-15 11:00:00
    Attributes:
        Conventions                 'CF-1.7'
        STASH                       m01s00i408
        source                      'Data from Met Office Unified Model'
        um_version                  '8.2'

The function accepts the same keyword arguments as cube.intersection() (e.g. ignore_bounds, threshold).

Closes #6855

Checklist

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Coordinate system agnostic region extraction

2 participants