You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case, on uxarray version 2026.6.0, it seems to work okay!
If you are still seeing the bug on your end, could you help me reproduce it? If you can provide a small example where it still occurs, I should be able to look into it further and hopefully get things working properly again.
Hi @erogluorhan . I'm just on parental leave at the moment and don't have the capacity to test this until this fall. I will let you know if it's still a problem. Feel free to close this if you wish.
From what I have seen and tested, on every version of uxarray/xarray I've tested on, there seems to be a problem when getting a subset if the grid has time coordinates.
The team suggests that time coordinates are very often not in grid files, so this is not something that is an expected behavior. Changes may be possible to help check for these odd cases.
Fix
This is built on the assumption that the grid you are using has a time coordinate, which I deduced from the error, but if it doesn't then I'm not sure where the 2016 date is coming from in the error. If it does have time, consider dropping it and seeing if running the command after works like this:
This removes only the grid's scalartime (2016-10-01), which is a separate object from the data's time dimension. The grid dataset (uxgrid._ds) holds mesh topology, not the data. The data's time = [2018-04-28, 2023-03-22] lives on Elevation and is untouched, so the subset result still has time and sel(time=...) / sortby("time") keep working exactly as before.
Xarray reproduction:
If you want to reproduce this same error in xarray, you can try
N_FACE=20# --- The DATA: a face-centered variable with a real multi-valued `time` dim coordinate ---data=xr.DataArray(
np.random.rand(2, N_FACE),
dims=["time", "n_face"],
coords={"time": pd.to_datetime(["2018-04-28", "2023-03-22"])},
name="Elevation",
)
grid_ds=xr.Dataset({"subgrid_face_indices": ("n_face", np.arange(5, 12))},)
grid_ds=grid_ds.assign_coords(time=pd.Timestamp("2016-10-01"))
face_indexer=grid_ds["subgrid_face_indices"]
out=data.isel(n_face=face_indexer)
But if you replace the last line with: out = data.isel(n_face=face_indexer.values) (note the .values)
it works again
Follow up work:
I was able to make some extensive notebooks and notes for this issue, in xarray, uxarray, and potential fixes. If anyone is exploring this in the future and wants the folder, let me know.
For now the team has no backend solution for handling grids that may have incidents like this, but if we got more information, like the grid that was used here, or the code leading up to .subset being used, it could help a lot at further diagnosing the problem
Thank you for looking into this in detail @dylannelson! So, basically, if your grid's "time" dimension does not line up with your UxDataset or UxDataArray's "time" dimension, then that will cause a crash. Am I understanding that correctly?
If yes, it does make sense that that would cause a crash, but my initial suspicion is that "uxgrid has time dimension" would never occur in uxarray directly, even if inputting a .nc file with "time" dimension as the grid file, due to how uxarray parses grid files. I haven't confirmed this yet though. If you have more time to look into this, would you be able to try constructing a grid file with a time dimension (e.g., load existing file using xarray, add data var with time dimension, then tell xarray to write result as a netcdf file), then loading it into uxarray as a grid (e.g. ux.open_grid(...)) and then confirm whether the resulting Grid object actually has the "time" dimension or not?
Also, can you provide a complete example of your steps (1) and (2)? How did you read in the grid file (just ux.open_grid()?) and how did you give it time coordinates (what did you do with ds_t after creating it, did you do something like uxgrid._ds = ds_t)? If getting to this crash always requires messing with suggested-to-be-private attributes (i.e. attributes starting with underscore) then I don't think we need to worry about fixing it.
Separately, there is a question of whether something like this is the actual cause of the original bug in this issue report, or a different bug entirely. At this point I still think more information would be required about the original crash, before we can be confident that it has been reproduced. If you are able to show that ux.open_grid(...) can lead to grids with time dimension (which would subsequently lead to the crash you found), I think it would be worthwhile to report that as a separate issue and work on fixing it (e.g. add checks during Grid creation to ensure there are no unexpected dimensions like "time").
Ah! Ok a quick reaction: my grid and data are in the same file. I'll open the file twice: once to get the grid object and once to get the data. This always ends up with time on the grid.
Oh! Thank you for your quick reply, that is extremely helpful. That is enough to convince me that @dylannelson has almost certainly found your bug - nice! Now we should hopefully be able to reproduce, fix, and test. I will let @dylannelson take the lead on that; I think many of my suggested next steps from the message above still apply. (Clarifying, this means I was mistaken earlier. In fact, "uxgrid has time dimension" apparently can occur if grid file had time dimension. But it should not occur, time should not be included in the Grid object even if it is included in the input file.)
Sidenote, onefile open_dataset is now supported for cases like this, see #1479 for more details! This probably wouldn't fix the bug, but it does mean you could do ux.open_dataset(yourfile) instead of ux.open_dataset(yourfile, yourfile), which may be slightly more convenient and should give equivalent results.
That notebook was the suggested order of testing to see if uxarray will allow the time coordinates through:
Opened one of the demo grids in xarray
added time to it (not a thing that we expect people to normally do, but shows that if it does happen, it will persist)
Save it
open with ux.open_grid()
see if time coordinates can be called (they can)
Reproduce the error with this data
"uxgrid has time dimension" would never occur in uxarray directly, even if inputting a .nc file with "time" dimension as the grid file, due to how uxarray parses grid files
I think @erogluorhan had the same suspicion but I am thinking that what we have been observing here may show that this is not the case
time can also exist on a grid as seen by this notebook (and won't go away unless manually removed) in both xarray and uxarray:
Thank you for looking into this and sharing that notebook, it looks to me like you've done a great job demonstrating clearly here that yes, indeed, grid-reading fails to properly strip extra dimensions, like "time".
I think the next step would probably be to work on the fix and some tests, and opening up a PR, if that sounds good! If you get stuck or have questions feel free to either post updates here or send me a direct message separately, I would be happy to help as needed.
@Sevans711 Yeah I think it may help for a few of us to have a call on this one as it develops into its own PR/issue. @erogluorhan and I already had a few thoughts/ideas about where/how it needs to be placed without any certain ways forward. I'll do more digging in the meantime. Depending on where it goes it may have a handful of downstream effects.
Thank you for further looking into this and finding this case, @dylannelson ! A few thoughts/additions:
Having a time dim in grid definition files should be rare, but @Chrismarsh 's this example showed us it is possible
Even in this case, Grid object itself has no direct property for time dimension, but we had an internal Grid._ds of xarray.Dataset type to store variables coming from the grid file, and it receives even non-coordinate variables such as time in this case.
We'll need to look into where we're populating Grid._ds in our I/O, and if we can avoid such contamination.
Activity
rajeeja commentedon Jul 8, 2026
@rajeeja
Sevans711 commentedon Jul 10, 2026
Hi @Chrismarsh, thank you for your bug report. Can you confirm if this is still an issue with the latest version of uxarray?
I tried reproducing using one of the uxarray tutorial datasets which has a time dimension:
In this case, on uxarray version 2026.6.0, it seems to work okay!
If you are still seeing the bug on your end, could you help me reproduce it? If you can provide a small example where it still occurs, I should be able to look into it further and hopefully get things working properly again.
erogluorhan commentedon Jul 17, 2026
Hi @Chrismarsh , please let us know if this is fixed on your end as well.
Chrismarsh commentedon Jul 17, 2026
Hi @erogluorhan . I'm just on parental leave at the moment and don't have the capacity to test this until this fall. I will let you know if it's still a problem. Feel free to close this if you wish.
erogluorhan commentedon Jul 17, 2026
Congrats @Chrismarsh ! No worries at all. We will run one more check on this and then close if things seem fixed.
dylannelson commentedon Jul 31, 2026
After looking at this report for a bit and trying to reproduce it, I had a few takeaways
To Reproduce: (versions | uxarray: <= 2026.7.1.dev6+g4278eb6b7 | <= xarray: 2026.7.0)
/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.ncds_t = ds.assign_coords(time=pd.Timestamp('2016-10-01'))out = elevation.subset.bounding_box((-180, 180), (-90, 90))Error:
Takeway
timecoordinates.Fix
This is built on the assumption that the grid you are using has a time coordinate, which I deduced from the error, but if it doesn't then I'm not sure where the 2016 date is coming from in the error. If it does have time, consider dropping it and seeing if running the command after works like this:
This removes only the grid's scalar
time(2016-10-01), which is a separate object from the data'stimedimension. The grid dataset (uxgrid._ds) holds mesh topology, not the data. The data'stime = [2018-04-28, 2023-03-22]lives onElevationand is untouched, so the subset result still hastimeandsel(time=...)/sortby("time")keep working exactly as before.Xarray reproduction:
If you want to reproduce this same error in xarray, you can try
But if you replace the last line with:
out = data.isel(n_face=face_indexer.values)(note the .values)it works again
Follow up work:
I was able to make some extensive notebooks and notes for this issue, in xarray, uxarray, and potential fixes. If anyone is exploring this in the future and wants the folder, let me know.
For now the team has no backend solution for handling grids that may have incidents like this, but if we got more information, like the grid that was used here, or the code leading up to
.subsetbeing used, it could help a lot at further diagnosing the problemSevans711 commentedon Jul 31, 2026
Thank you for looking into this in detail @dylannelson! So, basically, if your grid's "time" dimension does not line up with your UxDataset or UxDataArray's "time" dimension, then that will cause a crash. Am I understanding that correctly?
If yes, it does make sense that that would cause a crash, but my initial suspicion is that "uxgrid has time dimension" would never occur in uxarray directly, even if inputting a .nc file with "time" dimension as the grid file, due to how uxarray parses grid files. I haven't confirmed this yet though. If you have more time to look into this, would you be able to try constructing a grid file with a time dimension (e.g., load existing file using xarray, add data var with time dimension, then tell xarray to write result as a netcdf file), then loading it into uxarray as a grid (e.g.
ux.open_grid(...)) and then confirm whether the resulting Grid object actually has the "time" dimension or not?Also, can you provide a complete example of your steps (1) and (2)? How did you read in the grid file (just
ux.open_grid()?) and how did you give it time coordinates (what did you do withds_tafter creating it, did you do something likeuxgrid._ds = ds_t)? If getting to this crash always requires messing with suggested-to-be-private attributes (i.e. attributes starting with underscore) then I don't think we need to worry about fixing it.Separately, there is a question of whether something like this is the actual cause of the original bug in this issue report, or a different bug entirely. At this point I still think more information would be required about the original crash, before we can be confident that it has been reproduced. If you are able to show that
ux.open_grid(...)can lead to grids with time dimension (which would subsequently lead to the crash you found), I think it would be worthwhile to report that as a separate issue and work on fixing it (e.g. add checks during Grid creation to ensure there are no unexpected dimensions like "time").1 remaining item
Sevans711 commentedon Jul 31, 2026
Oh! Thank you for your quick reply, that is extremely helpful. That is enough to convince me that @dylannelson has almost certainly found your bug - nice! Now we should hopefully be able to reproduce, fix, and test. I will let @dylannelson take the lead on that; I think many of my suggested next steps from the message above still apply. (Clarifying, this means I was mistaken earlier. In fact, "uxgrid has time dimension" apparently can occur if grid file had time dimension. But it should not occur, time should not be included in the Grid object even if it is included in the input file.)
Flagging as related: #1461
Sidenote, onefile open_dataset is now supported for cases like this, see #1479 for more details! This probably wouldn't fix the bug, but it does mean you could do
ux.open_dataset(yourfile)instead ofux.open_dataset(yourfile, yourfile), which may be slightly more convenient and should give equivalent results.dylannelson commentedon Jul 31, 2026
@Sevans711
timecan also exist on a grid as seen by this notebook (and won't go away unless manually removed) in both xarray and uxarray:06-grid-time-roundtrip-test(1).html
That notebook was the suggested order of testing to see if uxarray will allow the time coordinates through:
ux.open_grid()timecoordinates can be called (they can)I think @erogluorhan had the same suspicion but I am thinking that what we have been observing here may show that this is not the case
Sevans711 commentedon Jul 31, 2026
Thank you for looking into this and sharing that notebook, it looks to me like you've done a great job demonstrating clearly here that yes, indeed, grid-reading fails to properly strip extra dimensions, like "time".
I think the next step would probably be to work on the fix and some tests, and opening up a PR, if that sounds good! If you get stuck or have questions feel free to either post updates here or send me a direct message separately, I would be happy to help as needed.
dylannelson commentedon Jul 31, 2026
@Sevans711 Yeah I think it may help for a few of us to have a call on this one as it develops into its own PR/issue. @erogluorhan and I already had a few thoughts/ideas about where/how it needs to be placed without any certain ways forward. I'll do more digging in the meantime. Depending on where it goes it may have a handful of downstream effects.
erogluorhan commentedon Jul 31, 2026
Thank you for further looking into this and finding this case, @dylannelson ! A few thoughts/additions:
timedim in grid definition files should be rare, but @Chrismarsh 's this example showed us it is possibleGridobject itself has no direct property fortimedimension, but we had an internalGrid._dsofxarray.Datasettype to store variables coming from the grid file, and it receives even non-coordinate variables such as time in this case.We'll need to look into where we're populating
Grid._dsin our I/O, and if we can avoid such contamination.