Dear Mathieu,
thanks so much for your reply. I attach you a link with two files. The first one is the raw netcdf data (fesom_netcdf.nc). If you load it you can see the globe and the topography with hexagons instead of triangles. I did a bit of research about the format. It seems that I needed to convert it to netcdf ugrid (fesom_netcdf-ugrid.nc). However, I failed as I get a flat disk. I think I am getting there but I am not sure what else I am missing. This is the code I used to convert it to ugrid.
Convert to unit sphere coordinates
x1 = np.cos(np.deg2rad(y)) * np.cos(np.deg2rad(x))
y1 = np.cos(np.deg2rad(y)) * np.sin(np.deg2rad(x))
z1 = np.sin(np.deg2rad(y))
Create a new UGRID-compliant NetCDF file
ugrid_file = nc.Dataset(‘fesom_ugrid.nc’, ‘w’, format=‘NETCDF4’)
Step 1: Copy dimensions from FESOM file
ugrid_file.createDimension(‘nMesh2_node’, x.size)
ugrid_file.createDimension(‘nMesh2_face’, elem2.shape[0])
ugrid_file.createDimension(‘Three’, 3)
Step 2: Add node coordinates (with CF attributes)
node_x = ugrid_file.createVariable(‘Mesh2_node_x’, ‘f4’, (‘nMesh2_node’,))
node_y = ugrid_file.createVariable(‘Mesh2_node_y’, ‘f4’, (‘nMesh2_node’,))
node_z = ugrid_file.createVariable(‘Mesh2_node_z’, ‘f4’, (‘nMesh2_node’,))
# Add CF metadata
node_x.units = ‘1’ # Unit sphere (dimensionless)
node_y.units = ‘1’
node_z.units = ‘1’
Step 3: Add face-node connectivity (convert to 1-based indexing)
face_node = ugrid_file.createVariable(‘Mesh2_face_nodes’, ‘i4’, (‘nMesh2_face’, ‘Three’),fill_value=-1)
face_node.cf_role = ‘face_node_connectivity’
face_node.start_index = 1
Step 4: Define the mesh topology variable
mesh = ugrid_file.createVariable(‘Mesh2’, ‘i4’)
mesh.cf_role = ‘mesh_topology’
mesh.topology_dimension = 2 # 2D mesh
mesh.node_coordinates = ‘Mesh2_node_x Mesh2_node_y Mesh2_node_z’
mesh.face_node_connectivity = ‘Mesh2_face_nodes’
mesh.face_dimension = ‘nMesh2_face’
Step 5: Copy data variables (e.g., temperature, salinity)
depth_nc = ugrid_file.createVariable(‘depth’, ‘f4’, (‘nMesh2_node’))
depth_nc.standard_name = ‘sea_floor_depth_below_geoid’
depth_nc.coordinates = ‘Mesh2_node_x Mesh2_node_y’
depth_nc.units = “m” ;
depth_nc.location = ‘node’ # Indicate data is on nodes
node_x[:] = x1[:] # Copy data
node_y[:] = y1[:]
node_z[:] = z1[:]
face_node[:,:] = elem2[:,:] + 1 # UGRID uses 1-based indexing
depth_nc[:] = depth[:]
Step 6: Close files
ugrid_file.close()
PS:Download fesom.rar | LimeWire