Open fluidnumerics-joe opened 1 month ago
Hi @fluidnumerics-joe
We haven't done much testing or exploration of FESOM grids, though we would love to support them directly. I'm taking a look at some of the grids listed in https://github.com/ELPHE-WW/unstructured-mesh-parcels-sandbox/issues/2 and will follow up shortly.
Nonetheless, if FESOM2 support is not in the works already, how can I help get this going ?
Here are references for all of our supported grid readers. https://github.com/UXARRAY/uxarray/tree/main/uxarray/io
All we need is to implement a FESOM to UGRID conversion module, supporting at least the following minimal grid representation to follow to the UGRID conventions
Would you mind sharing the FESOM grid you used in the simple example notebook?
Of course. The one example I'm working with to start is here : https://github.com/FESOM/fesom2/tree/main/test/meshes/soufflet
Hi @fluidnumerics-joe , thanks a lot for reaching out! We can work together to investigate getting FESOM grids supported by UXarray.
As #282 and your example suggested, there might be some UGRID conformance issues with FESOM grids, but we can dig into them all together to figure.
Loading just the vertices and face connectivity can be done with
def load_ascii_mesh(mesh_path):
"""
Loads the mesh data from the specified path and returns the node coordinates and element connectivity.
FESOM specific function.
Args:
mesh_path (str): The path to the directory containing the model output.
Returns:
xr.Dataset: Dataset containing the x-coordinates, y-coordinates, and element connectivity array.
"""
import pandas as pd
import numpy as np
import xarray as xr
nodes = pd.read_csv(
mesh_path + "/nod2d.out",
delim_whitespace=True,
skiprows=1,
names=["node_number", "x", "y", "flag"],
)
x2 = nodes.x.values
y2 = nodes.y.values
file_content = pd.read_csv(
mesh_path + "/elem2d.out",
delim_whitespace=True,
skiprows=1,
names=["first_elem", "second_elem", "third_elem"],
)
x2 = np.where(x2 > 180, x2 - 360, x2)
elem = file_content.values - 1
ds = xr.Dataset(
{
"x": (("nod2"), x2),
"y": (("nod2"), y2),
"elements": (("elem", "n3"), elem),
}
)
return ds
This would set the face dimensions (called elements
here) correctly
@fluidnumerics-joe
Thanks for the example! I've opened up a pull request (https://github.com/UXARRAY/uxarray/pull/1013) for this. Will work on it this week.
I noticed a couple issues that mention FESOM (#425 and #282) but the documentation does not indicate that FESOM2 is supported. In a separate project, I am working with a few folks to add unstructured grid support to Ocean Parcels, and we're keen on trying to use UXArray to support file IO and the unstructured mesh descriptions.
I've documented a simple example here that shows we can't read FESOM2 NetCDF files at the moment, so I may have answered my question.
Nonetheless, if FESOM2 support is not in the works already, how can I help get this going ?