-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid value encountered in cast #101
Comments
Great, this is very helpful! As far as I can tell, the _FillValue should be present in the attributes according to the UGRID conventions: https://ugrid-conventions.github.io/ugrid-conventions/ But I should take another look at the Moving the replacement up is indeed the better choice and will silence the warning (at the minor cost of creating another copy of the data in memory). |
You are right, but xarray moves some of these attributes to the encoding when os uses them for processing. |
When opening a dataset with triangles and squares, there are
_FilllValue
values in theface_node_connectivity
. This is expected. However, it seems that a warning was introduced"RuntimeWarning: invalid value encountered in cast"
. This also occurs when testing with older xugrid versions, so it might be because of xarray or a related package that I only see this now.Figures all seem fine, so this issue is just to check if the warning should be supressed or removed. I noticed the
face_node_connectivity
(theint32
variablemesh2d_face_nodes
in this example) is converted to nans by xarray, since it contains nans. The function_prepare_connectivity
inxugrid\ugrid\ugridbase.py
then tries to cast this value back to int again.The function searches for the
_FillValue
attribute inda.attrs
, but with xarray this attribute is located inda.encoding
instead. Stillis_fill
results in a correct boolean. However, the fillvalues are not replaced byfill_value
before the array is being converted back toint32
again. I would suggest addingdata[is_fill] = fill_value
right beforecast = data.astype(dtype, copy=True)
:xugrid/xugrid/ugrid/ugridbase.py
Lines 363 to 382 in ae046ce
(and probably removing
cast[is_fill] = fill_value
)Either way, the resulting face_node_connectivity seems to be correct (0-based and -1 as fillvalue)
A MWE below:
The text was updated successfully, but these errors were encountered: