Extract region from a cube with 2D latitude/longitude coordinates

Open
#4,197 9 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start with iris.cube.Cube.intersection and compare the related implementation in ESMValCore pull request 245. Define how rectangular selection should work for 2D latitude and longitude coordinates, including whether points outside the region are masked, then verify the example no longer raises CoordinateMultiDimError.

Written by the indexing model from the issue text.

Description

Feature: ESMValTool Feature: GeoVista

✨ Feature Request

Motivation

When working with ocean model data, it would be really convenient if iris.cube.Cube.intersection supported 2D latitude and longitude coordinates. Currently

import iris

cube = iris.load_cube("http://esgf1.dkrz.de/thredds/dodsC/cmip5/cmip5/output1/MPI-M/MPI-ESM-LR/historical/mon/ocean/Omon/r1i1p1/v20120625/tos/tos_Omon_MPI-ESM-LR_historical_r1i1p1_185001-200512.nc")

cube.intersection(
    longitude=(10, 20),
    latitude=(10, 20),
    ignore_bounds=True,
)

throws a

CoordinateMultiDimError: Multi-dimensional coordinate not supported: 'longitude'

These coordinates are 2D because they are close enough to a rectangular grid to make this a meaningful data storage format. Therefore it makes sense to be able to select a rectangular cube slice for this type of data. Any points that are outside the region but inside the rectangular slice could e.g. be masked.

I recently implemented something like this in https://github.com/ESMValGroup/ESMValCore/pull/245, but it would be much nicer if this could be supported in iris.

Dominant language
Python
Stars
724
Forks
317
Avg merge
3d 20h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SciTools/iris

All issues in SciTools/iris

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.