Skip to content

Release 3.5.0

Latest

Choose a tag to compare

@ecomodeller ecomodeller released this 08 Nov 12:45
· 1 commit to main since this release
56c252c

What's new in v3.5.0

New features

  • Polygons in sel(area=...) (#1084). A dfsu sel(area=...), read(area=...) and find_index(area=...) accept a shapely polygon or a geopandas geometry, not only a bounding box or a list of coordinates. Model domains, catchments and study areas usually come as shapefiles, and they can now be used directly.
  • Dataset.astype() and DataArray.astype() (#1067). Cast a Dataset or DataArray to another dtype after reading, e.g. mikeio.read("file.dfs2").astype(np.float64).
  • .pcolormesh() on flexible-mesh and spectrum plots (#1107), plus vmin/vmax on vertical profiles and add_colorbar on the grid plots that always drew one. vmin=0 and vmax=0 on flexible-mesh maps are now honoured; they were silently replaced by the data limits.
  • No file handle outlives the call that opened it (#1108). Dfs1 and Dfs3 objects, extract_track, generic.avg_time and generic.quantile kept native handles open; on Windows a process opening more than about 500 files then failed with Error code 2003, and the files stayed locked. All handles are now closed on every path, including errors.
  • Corrupt dfsu timesteps can be skipped (#1086). mikeio.read(..., error_bad_data=False) fills a corrupt timestep as documented; since v2.0.0 every corrupt read raised AttributeError.
  • Time selection by position accepts numpy integers, integer arrays and boolean masks (#1104). da[np.where(cond)[0]], da[mask] and da[np.int64(2)] select those steps. They used to fall back to all time steps without an error, so anything computed from them was wrong.
  • Errors say what to pass (#1097). Wrong argument types that hit a bare assert now raise TypeError/ValueError naming the argument and the accepted values. Numpy integers are accepted for layers= and items=.

Deprecations

All emit a FutureWarning and will be removed in MIKE IO 4.0.

Deprecated Use instead PR
read(..., dtype=np.float64) .astype(np.float64) on the result. Files store float32; the parameter could only upcast. #1067
da[datetime], da[np.datetime64], datetime slices in [] da.sel(time=...). [] is positional on every other dimension. String keys such as da["2018-01-01"] are unaffected. #1104
validate= on Dataset() and Dataset.from_numpy() Nothing; the check always runs. See breaking changes. #961
plot_type= on geometry.plot() and da.plot() The method of that name: .contourf(), .outline(), … #1107
.patch() .pcolormesh() #1107
cmin/cmax on vertical profile plots vmin/vmax #1107
rmin/rmax on spectrum plots ax.set_rmin() / ax.set_rmax() #1107
n_refinements Nothing; it was broken on layered dfsu. #1107

Breaking changes

  • Dataset(..., validate=False) no longer skips validation (#961). DataArrays with different geometries or time axes raise ValueError as they do with the default. The opt-out was used internally on every read path, which hid three bugs in the compatibility check; the check costs microseconds against milliseconds of I/O. If you relied on it, fix the DataArrays before combining them.
  • sel(time=...) with an unsupported key raises TypeError instead of returning every time step (#1104).
  • Wrong argument types raise TypeError/ValueError/ItemsError instead of AssertionError, and a corrupt dfsu timestep raises ValueError instead of AttributeError (#1097, #1086). Code catching the old exception types changes path.
  • Plots of structured grids with a NON-UTM projection label the axes x [m] / y [m] instead of [m] / [m], matching flexible-mesh plots (#991).

Documentation

  • Getting started is rewritten as a tutorial (#1080).
  • The scripts guide has a one-file Streamlit dfs0 viewer (#1090).
  • The spatial mean() is documented as unweighted, with average() for the area-weighted mean (#944).
  • The plotting scope is recorded in ADR 012 (#1107).

Full changelog: v3.4.0...v3.5.0