conversion between different bounds conventions

Open
#380 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
pandas, python
Domain
data

Research direction

Start by reviewing cf_xarray's existing conversion functions between bounds and vertices, then examine how pandas IntervalIndex could integrate with xarray DataArray objects. Before implementation, clarify whether IntervalIndex conversions only are in scope or whether spatial representations belong in xvec; completion requires an agreed representation scope and corresponding conversion tests.

Written by the indexing model from the issue text.

Description

Bounds can be stored in different ways, and it would be great to have methods to convert between each of them.

Here's the ones I'm familiar with:

  • bounds variables: additional bounds dimension for upper / lower bounds
  • vertex variables: store the breaks in a n + 1 array (needs a new dimension)
  • IntervalIndex: dedicated pandas object for intervals (might need some more integration)

The advantage of IntervalIndex is that it has the same dimensions and size as the cell center coordinate and thus can be attached to DataArray objects.

For spatial, there's a few more, but since they combine 2 coordinates they require stacking the spatial coordinates or need to be broadcast to 2D coordinates. For example:

  • array of bounding boxes: left, bottom, right, top for each grid cell
  • array of bounding coordinates: list of coordinates of arbitrary length for each grid cell (not a good fit for xarray's data model, but the limited awkward objects might work?)
  • array of shapely polygons: one polygon of arbitrary length for each grid cell

cf_xarray already has conversion functions between bounds and vertices, so as far as I can tell conversion to and from IntervalIndex seem to be in scope. For the grid cell representation conversions I'm not sure, maybe put them into xvec?

Dominant language
Python
Stars
181
Forks
49
Avg merge
43m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

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 xarray-contrib/cf-xarray

All issues in xarray-contrib/cf-xarray

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.