Skip to content

uxds.uxgrid data not all loaded during uxds.load() #1838

Open

Description

@Sevans711

After calling uxds.load() for a UxDataset object, the grid has face_lon and face_lat which are dask arrays. Is this intentional? I would have expected there to be no dask arrays internally after calling uxds.load().

I believe this could cause slowdowns later if face_lon and face_lat are used more than once, as they would need to be re-loaded or re-computed each time.

I noticed this during @dylannelson's presentation of this notebook: https://uxarray.github.io/uxarray-community/entries/2026-10-20_uxarray_tutorial_and_collaboratory/notebooks/01-uxarray-workflow.html#reading-the-data, which includes an example of this bug in Section 1 (clicking the "Show Grid Information" arrow and then the "Spherical Coordinates" arrow shows dask face_lon and face_lat).

Here is a minimal reproducer:

import uxarray as ux
import xarray as xr
grid = ux.Grid.from_healpix(zoom=4)
grid._ds['face_lon'] = grid.face_lon.chunk(n_face=-1)
grid._ds['face_lat'] = grid.face_lat.chunk(n_face=-1)
data = xr.DataArray(np.arange(grid.n_face), dims="n_face").chunk(n_face=-1)
arr = ux.UxDataArray(data, uxgrid=grid)
arr.load()
arr.uxgrid.face_lon.chunks  # expected None, got ((3072,),)

Activity

  1. added
    bug
    scalability
    on Oct 22, 2026
  2. erogluorhan commented on Oct 22, 2026

    @erogluorhan
    Member

    I don't have time to look into this immediately, but FWIW: a quick chat with gemini (without any uxarray context) gave me this:

    "
    The One Exception: Lazy Coordinates

    The only time you might still see Dask objects anywhere in the dataset structure is if your Xarray object has coordinate variables that were explicitly left uncomputed or are backed by a different lazy mechanism. However, for the data variables and standard coordinates, everything is fully evaluated and loaded into your local RAM.
    "

    I don't recall if we intentionally left those coords lazy, but I don't believe we did so (we have no load mechanism ourselves I think). I don't think we should keep them lazy either.

    @rajeeja , @cmdupuis3 thoughts?

  3. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Oct 26, 2026
  4. rajeeja commented on Nov 11, 2026

    @rajeeja
    Contributor

    This needs a supported way to load grid data and avoid repeated computation. I’d keep grid loading explicit rather than automatically include it in .load(), since grids can be large and shared between arrays. We should document that behavior and keep load(), compute(), and persist() consistent.

  5. rajeeja commented on Nov 11, 2026

    @rajeeja
    Contributor

    @erogluorhan, I agree that users need a way to load the grid rather than leave it lazy. I’d prefer making that explicit instead of loading it automatically with the data, since a grid can be large and shared by multiple arrays. This would let users choose when to use the extra memory and avoid repeated computation.

  6. jayeshkrishna commented on Nov 11, 2026

    @jayeshkrishna

    I agree with @rajeeja , since the grid is not owned by the array loading the array should not end up loading the grid too. Explicitly documenting the behavior IMO should be the first step here.

  7. cmdupuis3 commented on Nov 11, 2026

    @cmdupuis3
    Collaborator

    Agreed in principle, but I'll add that the end-to-end chunking in #1789 is aiming for chunked grids, and if that's implemented fully, the ideal would probably be to load chunkwise, particularly if the data has the same chunking (hopefully it would).

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

Metadata

Metadata

Labels

bugscalability

Type

No type

Fields

Priority

Medium

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions