Skip to content

Filter non-spatial variables from UGRID datasets #1339

Closed

Description

@philipc2

Discussed in #1324

Originally posted by Chrismarsh July 24, 2025
What is the approach to save a subset ugrid to disk? For example, suppose I do

# massive dataset
ds = ux.open_mfdataset('output.2017.partial/output.2017.nc',
                       'output.2017.partial/output.2017.nc', 
                       parallel=False, lock=False)

# subset part of it
elev = ds.Elevation.subset.bounding_box(lon, lat)

# save subset
elev.to_xarray().to_netcdf('test2.nc', engine="netcdf4")

The test2.nc file does not contain valid ugrid topology:

$ ncdump -h test2.nc
netcdf test2 {
dimensions:
        n_face = 142546 ;
variables:
        double Mesh2_face_x(n_face) ;
                Mesh2_face_x:_FillValue = NaN ;
                Mesh2_face_x:standard_name = "latitude" ;
                Mesh2_face_x:long_name = "Characteristics latitude of 2D mesh triangle (e.g. circumcenter coordinate)." ;
                Mesh2_face_x:units = "degrees_north" ;
        double Mesh2_face_y(n_face) ;
                Mesh2_face_y:_FillValue = NaN ;
                Mesh2_face_y:standard_name = "latitude" ;
                Mesh2_face_y:long_name = "Characteristics latitude of 2D mesh triangle (e.g. circumcenter coordinate)." ;
                Mesh2_face_y:units = "degrees_north" ;
        double face_lon(n_face) ;
                face_lon:_FillValue = NaN ;
                face_lon:standard_name = "latitude" ;
                face_lon:long_name = "Characteristics latitude of 2D mesh triangle (e.g. circumcenter coordinate)." ;
                face_lon:units = "degrees_north" ;
        double face_lat(n_face) ;
                face_lat:_FillValue = NaN ;
                face_lat:standard_name = "latitude" ;
                face_lat:long_name = "Characteristics latitude of 2D mesh triangle (e.g. circumcenter coordinate)." ;
                face_lat:units = "degrees_north" ;
        double Elevation(n_face) ;
                Elevation:_FillValue = NaN ;
                Elevation:_QuantizeBitGroomNumberOfSignificantDigits = 4 ;
                Elevation:mesh = "Mesh2" ;
                Elevation:location = "face" ;
                Elevation:coordinates = "Mesh2_face_x Mesh2_face_y face_lat face_lon" ;
}

```</div>

Activity

  1. philipc2 commented on Aug 12, 2025

    @philipc2
    MemberAuthor

    Related to #345

  2. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Sep 10, 2025
  3. self-assigned this
    on Oct 28, 2025
  4. Sevans711 commented on Aug 10, 2026

    @Sevans711
    Collaborator

    @dylannelson This might also be related to #1444? May be worth considering if the solution there would solve this issue as well.

  5. dylannelson commented on Aug 10, 2026

    @dylannelson
    Member

    @Sevans711 Sure looks like it, same setup, reading from 1 file with a subset after

  6. added
    extra dims
    on Aug 28, 2026
  7. moved this from 🏗 In progress to ✅ Done in UXarray Developmenton Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extra dims

Type

No type

Fields

Priority

Medium

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions