ec-jrc / pyPoseidon

Framework for Hydrodynamic simulations
https://pyposeidon.readthedocs.io/
European Union Public License 1.2
20 stars 7 forks source link

Output data needs to indicate whether a node is a boundary one or not #167

Open pmav99 opened 9 months ago

pmav99 commented 9 months ago

This is needed for GDACS

brey commented 6 months ago

I have second thoughts about adding it to the post-processing. The code is

import pyposeidon.mesh as pm
    #add boundary nodes
    mesh = pm.set(type='tri2d', mesh_file=os.path.join(b.rpath + 'hgrid.gr3'))

    out_total = xr.merge([out,mesh.Dataset[['type','node','id']]])

but it would take long for a big global mesh and the data will be in every output file. I suggest we save mesh.Dataset[['type','node','id']] to a single file once and this can be used to identify boundaries for all runs.

pmav99 commented 6 months ago

Sure, it can be part of the model definition.

pmav99 commented 6 months ago

That being said, do we need to call xr.merge()? Wouldn't that be faster?

out_total = out.assign(
    btype=mesh.Dataset.type,
    bnode=mesh.Dataset.node,
    bid=mesh.Dataset.id
)
brey commented 6 months ago

I agree if we needed to merge them. We will not do that. We are just going to save to a netcdf file that relates to the model and is unique.

import pyposeidon.mesh as pm
    #add boundary nodes
    mesh = pm.set(type='tri2d', mesh_file=os.path.join(b.rpath + 'hgrid.gr3'))

   mesh.Dataset[['type','node','id']]].to_netcdf("boundary_connectivity.nc")

This will be done once and the file can be used to identify boundary nodes for all outputs, if need be. It doesn't need to be part of pyposeidon.

brey commented 6 months ago

I think we can close this issue.

pmav99 commented 6 months ago

Should we export this file by default? Should we also be able to read it? And/or to add a reference it in the *model.json ? Or maybe just document, that extracting this information can be done with the snippet above?