feat: add ragged.io submodule with conversions for CF conventions
These are the CF conventions.
This PR still needs tests, obviously, but I want to know what the final form of the API should be, with regard to reading/writing from h5py and zarr.
c.f. https://github.com/pydata/xarray/discussions/7988#discussioncomment-8536524
Copying the example from https://github.com/pydata/xarray/discussions/7988#discussioncomment-8536524, so that it's more easily associated with this PR:
>>> import ragged.io
>>> a = ragged.array([
... [1.01, 1.02],
... [2.01, 2.02, 2.03, 2.04],
... [3.01, 3.02, 3.03],
... [4.01, 4.02, 4.03, 4.04, 4.05, 4.06]
... ])
>>> ragged.io.to_cf_contiguous(a)
(ragged.array([1.01, 1.02, 2.01, 2.02, 2.03, ..., 4.02, 4.03, 4.04, 4.05, 4.06]),
ragged.array([2, 4, 3, 6]))
>>> ragged.io.from_cf_contiguous(*ragged.io.to_cf_contiguous(a))
ragged.array([
[1.01, 1.02],
[2.01, 2.02, 2.03, 2.04],
[3.01, 3.02, 3.03],
[4.01, 4.02, 4.03, 4.04, 4.05, 4.06]
])
>>> ragged.io.to_cf_indexed(a)
(ragged.array([1.01, 1.02, 2.01, 2.02, 2.03, ..., 4.02, 4.03, 4.04, 4.05, 4.06]),
ragged.array([0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]))
>>> ragged.io.from_cf_indexed(*ragged.io.to_cf_indexed(a))
ragged.array([
[1.01, 1.02],
[2.01, 2.02, 2.03, 2.04],
[3.01, 3.02, 3.03],
[4.01, 4.02, 4.03, 4.04, 4.05, 4.06]
])
This is the current state of the interface, after the first two commits of this PR. Maybe it will change before the PR is merged.
I think we should drop it. I was hoping to get the Zarr and Pangeo communities interested in ragged by adopting some of the conventions for raggedness that they use, but I haven't received any feedback beyond the in-person meeting where we talked about it. If the feature doesn't have users, we can't be sure that what's implemented here is what they want. (I don't have any sample files that conform to this convention.)
So I'm going to close the PR. It still exists, and should turn up in searches if anyone ever wants to revive this idea.