You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importxugridasxufile_nc=r"p:\11208420-habitat-kernel-dev\development_cases\Richard_EUNIS_ecotopes_20230403\SHYFEM_model_converter\shy.nc"defpreprocess_shyfem_test(ds):
# convert topology_dimension attribute: str to int# topodim = int(ds[mesh_varn].attrs["topology_dimension"])topodim=int(ds["topology"].attrs["dimensionality"])
mesh_attrs= {"cf_role": "mesh_topology",
"node_coordinates": "longitude latitude",
"topology_dimension":topodim,
"face_node_connectivity":"element_index"}
ds["topology"] =ds["topology"].assign_attrs(mesh_attrs)
# add necessary attributes for face_node_connectivityfnc_attrs= {"_FillValue":-1, "start_index":1}
ds["element_index"] =ds["element_index"].assign_attrs(fnc_attrs)
# set x/y coords, is not necessary but nice to avoid them being data_varsds=ds.set_coords(["longitude","latitude"])
# set mesh attr in all data_vars, optional with a single meshdatavar_attrs= {"mesh":"topology"}
forvarninds.data_vars:
ds[varn] =ds[varn].assign_attrs(datavar_attrs)
returndsuds=xu.open_mfdataset(file_nc, preprocess=preprocess_shyfem_test)
uds.u_velocity.isel(time=-1, level=0).ugrid.plot(robust=True)
Maybe this is not necessary if the attrs are added to shyfem output: SHYFEM-model/shyfem#57
The text was updated successfully, but these errors were encountered:
Maybe this is not necessary if the attrs are added to shyfem output: SHYFEM-model/shyfem#57
The text was updated successfully, but these errors were encountered: