DHI/mikeio

isel() always returns a copy of the data

jsmariegaard opened this issue · 0 comments

If you want to change a subset of the values in a DataArray, you may try something like:

 da.isel(time=0).values[:] = 7.0 

or

da[0].values[:] = 7.0 

This will unfortunately not work as isel() (and getitem) returns a copy of the data even when it does not need to. The general rule in NumPy is that simple indexing (single index or slice) will return a view, fancy indexing (e.g. a list of ids or boolean index) will return a copy. MIKE IO should follow the same pattern.

Until this is fixed, you should be able to reformulate your code like this:

da.values[0,:] = 7.0 

Thanks to @msaes88 for reporting!