Repository navigation
What's new in v3.5.0
New features
- Polygons in
sel(area=...)(#1084). A dfsusel(area=...),read(area=...)andfind_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()andDataArray.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), plusvmin/vmaxon vertical profiles andadd_colorbaron the grid plots that always drew one.vmin=0andvmax=0on flexible-mesh maps are now honoured; they were silently replaced by the data limits.- No file handle outlives the call that opened it (#1108).
Dfs1andDfs3objects,extract_track,generic.avg_timeandgeneric.quantilekept native handles open; on Windows a process opening more than about 500 files then failed withError 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 raisedAttributeError. - Time selection by position accepts numpy integers, integer arrays and boolean masks (#1104).
da[np.where(cond)[0]],da[mask]andda[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
assertnow raiseTypeError/ValueErrornaming the argument and the accepted values. Numpy integers are accepted forlayers=anditems=.
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 raiseValueErroras 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 raisesTypeErrorinstead of returning every time step (#1104).- Wrong argument types raise
TypeError/ValueError/ItemsErrorinstead ofAssertionError, and a corrupt dfsu timestep raisesValueErrorinstead ofAttributeError(#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, withaverage()for the area-weighted mean (#944). - The plotting scope is recorded in ADR 012 (#1107).
Full changelog: v3.4.0...v3.5.0