Conversation
|
Hey @akeeste I added the updates for the updated variable names in the Delft3D 2025 version. I was thinking about updating the code to also accept xarry in addition to netCDF. |
|
Hey @akeeste pending all the checks pass, this is ready for review. |
|
Thanks @browniea I'll look for some time to review next week |
| gci: float | ||
| Grid Convergence Index (GCI). | ||
| """ | ||
| # Calculate the approximate relative error |
There was a problem hiding this comment.
Add basic type checks (all inputs are numerical, fine_grid and coarse_grid are the same shape, etc)
There was a problem hiding this comment.
Added, using np.issubdtype to check for numerical values. I noticed the other functions use np.issubdtype with specific types. This difference might make sense since the GCI function has different functionality. Making note of it here so it can be revisited if needed.
| if not isinstance(data, netCDF4.Dataset): | ||
| raise TypeError("data must be a NetCDF4 object") | ||
| if not isinstance(data, (netCDF4.Dataset, xr.Dataset)): | ||
| raise TypeError("data must be a NetCDF4 object or xarray Dataset") |
There was a problem hiding this comment.
Add a test for xarray input
| ) | ||
| waterlevel = np.ma.getdata(data.variables["mesh2d_s1"][time_index, :], False) | ||
| coords = str(data.variables["waterdepth"].coordinates).split() | ||
| coords = str(data.variables["mesh2d_waterdepth"].coordinates).split() |
There was a problem hiding this comment.
A couple questions on this change:
- When did this variable name become relevant
- Is the old
waterdepthvariable name still relevant?
There was a problem hiding this comment.
waterdepth still works per the following elif statment #L275
I initially updated the variable name in this PR #248 but I missed this water depth bug.
|
@akeeste The xarry input is a little more complicate than I initially thought. It might be worth adding an example. I'll plan to have a few functions converted for you to look at our next meeting. The rest of the changes are done. |
Updates to
io/d3d.pycodecalculate_grid_convergence_indexfunction to calculate the grid convergence index between two grid's results basted on the equation GCI