should guess_coord_axis optionally create a variable for unindexed coordinates

Open
#266 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start at the .cf.guess_coord_axis entry point and inspect how unindexed dimensions are currently handled. Add an opt-in behavior for creating coordinate variables from dimension sizes, then verify that the resulting x and y coordinates are assigned the X and Y axes appropriately.

Written by the indexing model from the issue text.

Description

enhancement good first issue
da = xr.DataArray(np.ones(2,3), dims=("x", "y"))

This kind of dataarray exists in CMIP datasets. x,y have absolutely no data (no values, no attrs) associated with them, and so guess_coord_axis does not do anything.

We could have .cf.guess_coord_axis(add_indexes=True) that effectively does

da["x"] = np.arange(da.sizes["x"])
da["y"] = np.arange(da.sizes["y"])

# now do the guessing

This will assign axis='X' and axis='Y' appropriately. I think this would be an OK opt-in feature, though we need a better name than add_indexes.

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.