Forum

Create netCDF from a text based triangular mesh with(out) Quickplot

Julius Schlumberger, modified 4 Years ago.

Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 15 Join Date: 12/20/20 Recent Posts
Dear all,
I have a flexible triangular mesh grid (from SHYFEM (https://sites.google.com/site/shyfem/home)) , a text file with an extension .grd that contains all the information on nodes, elements and lines (and water depth). When trying to use Quickplot in both Suite version 2020.02 and 2021.03, it mentions that the netCDF export is still under development. It still produces a .nc file. And this can be read by QGIS when loading as a mesh but not when loaded into Delft3D-FM.
Is there any code available that explains what Quickplot is doing and what might go wrong?
Thanks and all the best,
Julius
thumbnail
Bert Jagers, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 6 Join Date: 12/22/10 Recent Posts
Dear Julius,
QUICKPLOT writes a netCDF file containing the minimum amount of data for a UGRID compliant file. The MATLAB code for writing the netCDF file is located in the
1
export_netcdf
routine in qp_export. I'm happy that QGIS accepts the file, which shows that the data should be correct. It seems that both the D-Flow FM plugin of the Delta Shell environment and RGFGRID require more data in the file; at this moment I do not yet know what it is exactly. Ideally I would prefer those programs to lower the requirements to the level of a minimum UGRID file. I will discuss a way forward with my colleagues.
Best regards,
Bert
Monica Bellucci, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Post: 1 Join Date: 2/25/20 Recent Posts
NetCDF files offer more adaptability and straightforwardness than some conventional raster designs by supporting different factors and definite metadata. In light of the metadata and document structure NetCDF records can be more hard to access than customary raster formats.The NetCDF file isn't set up and can be composed to finance homework solutions. At the point when completed, make certain to call close() on the informational collection.
thumbnail
Bert Jagers, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 6 Join Date: 12/22/10 Recent Posts
Dear Julius,
For a 2D mesh, the UGRID conventions don't require a definition of the mesh edges ... only the face (triangles) need to be defined.
However, since the beginning of the Delft3D FM code the mesh edges (or mesh links) have played an important role. It seems that as a result FM currently when reading a UGRID file always the edge_node_connectivity attribute (and associated array) requires.
I'll adjust the netCDF UGRID export code in QUICKPLOT to (always or optionally) create and write the edge-node connectivity even if the original data set didn't have an explicit numbering of the edges.
Bert
Dmitry Kushnir, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Padawan Posts: 25 Join Date: 11/9/12 Recent Posts
Bert Jagers:

Dear Julius,
For a 2D mesh, the UGRID conventions don't require a definition of the mesh edges ... only the face (triangles) need to be defined.
However, since the beginning of the Delft3D FM code the mesh edges (or mesh links) have played an important role. It seems that as a result FM currently when reading a UGRID file always the edge_node_connectivity attribute (and associated array) requires.
I'll adjust the netCDF UGRID export code in QUICKPLOT to (always or optionally) create and write the edge-node connectivity even if the original data set didn't have an explicit numbering of the edges.
Bert
Hi Bert, 
I'm trying to export FM-grid with some cells excluded due to wetting/drying processes. Is it possible with current version of QUICKPLOT/D-Flow FM? 
Regards, Dmitry
thumbnail
Bert Jagers, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 6 Join Date: 12/22/10 Recent Posts
Dmitry Kushnir
Hi Bert, 
I'm trying to export FM-grid with some cells excluded due to wetting/drying processes. Is it possible with current version of QUICKPLOT/D-Flow FM? 
Regards, Dmitry
This wasn't possible to my knowledge. I've just updated the QUICKPLOT code to enable it. If you're using QUICKPLOT from within MATLAB via Open Earth Tools (or other checkout), then you can update your code checkout and try it immediately. QUICKPLOT will now apply the clipping of the values (e.g. water depth <0.5) to the underlying grid when writing the data to the netCDF file.
Dmitry Kushnir, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Padawan Posts: 25 Join Date: 11/9/12 Recent Posts
Thanks a lot!
Dmitry Kushnir, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Padawan Posts: 25 Join Date: 11/9/12 Recent Posts
Hi Bert, Sorry for getting a little off-topic here, but do you by chance know how to visualize inundation in D-Flow FM? I haven't found any way to do it like in this GIF showing ADCIRC+SWAN simulation: https://multires.eos.ncsu.edu/ccht-ccee-ncsu-edu/wp-content/uploads/sites/10/2016/08/Irene_HS-Wind_APES.gif 
Best, 
Dmitry  
thumbnail
Bert Jagers, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 6 Join Date: 12/22/10 Recent Posts
You can include a satellite background in QUICKPLOT figures via the Plot Manager if your model runs in spherical coordinates (WGS84). However, for models in arbitrary coordinate systems and nicer visuals you can use Q-GIS. This system has great support for the netCDF UGRID format that Delft3D FM has adopted. A recent LinkedIn post by my colleague Govert Verhoeven shows what that environment can create; I've included a snapshot of the animation below. In one of the replies to comments on that post he mentions: 
"Check MDAL and QGIS Mesh Layer on how to visualize hydraulic model results of various modelling software (including D-Flow Flexible Mesh) in Q-GIS. This MDAL functionality was developed by Lutra Consulting. With the right styling you can make great animations!"
Dmitry Kushnir, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Padawan Posts: 25 Join Date: 11/9/12 Recent Posts
Great animation! I will check that tools, thanks! But I mainly had in mind plotting areas where drying/flooding processes occur (screen-grab attached). According to manual, drying and flooding is implemented in D-Flow FM, but I still cannot find the way to represent it graphically.
Kind regards,
Dmitry
thumbnail
Bert Jagers, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 6 Join Date: 12/22/10 Recent Posts
Hi Dmitry, A lot is possible, but I'm not sure I understand exactly what you intend to visualize; I don't see how your figures show drying and flooding -- I think that I'm looking at a figure of the water depth. FM can also write out the water depth to the map-file and you can visualize it and optionally clip (make transparent) the cells for which the water depth is below a certain threshold. If you want to color the dry cells light blue then you have to add that as a first layer to the plot. You can either plot the grid (not hiding what is on the background map within the cells that are sometimes dry) or you can select the quantity "Topology data of 2D mesh - face indices" and select "Colour uniformly" and select light blue. Create the plot. Add to this plot the water depth plot with areas with water depth below for instance 0.01 m clipped (transparent). That should give you a figure that looks similar to your figure if I interpret it correctly. If your model is bigger and actually included the whole sea area on the right, and you intend to visualize only the area that is initially dry, then that's also possible. In that case you'll have to select the 1st time step of the water depth and define a variable, e.g. "initial water depth", via the button on the bottom row of the QUICKPLOT dialog. Subsequently, you select All time steps, and define another variable, e.g. "all water depths". Then you select from the list of opened files, the option "<user defined variables>" and open the "file dependent options" dialog by clicking on the 4th icon in the toolbar. There you can select at the top "all water depths", as operator "A under condition B", then you select the "initial water depth" and as condition you specify "<0.01" (no space between < and 0.01). For this you define the variable "water depth where initially dry". Return to the main dialog and now select this variable from the user defined variables list, and visualize it. This shows you the water depth where there was initially no water, e.g. ideal for coastal flooding.
Dmitry Kushnir, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Padawan Posts: 25 Join Date: 11/9/12 Recent Posts
Ah I see. Thanks very much, Bert, for the detailed explanation. This was extremely helpful. I'll give that a go.
Just one thing: in the Delft3D-FLOW (structured), there was an option to plot temporary inactive water level/velocity points. They could also be added to the plot as a foreground layer, to show dried (flooded) areas.
Best,
Dmitry
thumbnail
Bert Jagers, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 6 Join Date: 12/22/10 Recent Posts
Dmitry: "in the Delft3D-FLOW (structured), there was an option to plot temporary inactive water level/velocity points. They could also be added to the plot as a foreground layer, to show dried (flooded) areas."
Yes, that's correct. The Delft3D-FLOW output has a dedicated reader which adds such features based on the related dry/wet flags for the velocity points. The D-Flow FM results are processed by a generic netCDF file readers and hence largely treated as a netCDF UGRID file of arbitrary origin; furthermore, it doesn't include specific dry/wet flags, so threadholding the water depth is the only option.
The patches plot has a special option "colour uniformly" which might be used for this type of use case, but it seems that I'm currently always clipping the zero values such that this feature can now be used to mask/colour the flooded areas, but not the dry areas. I'll check whether there was any specific need for that clipping; if not, I'll remove it, such that you have full control using the value clipping. That will allow you to use the feature as a dry areas overlay.
Julius Schlumberger, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Youngling Posts: 15 Join Date: 12/20/20 Recent Posts
Dear Bert, dear Monica,
thanks you very much for your replies.
It would be great if you could give a heads up as soon the QUICKPLOT code is updated, but it seems to be a bit trickier than I hoped, so I will probably have to rebuild the grid in RGFGRID.
Thanks!
Julius
Michal Kleczek, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Dmitry Kushnir, modified 4 Years ago.

RE: Create netCDF from a text based triangular mesh with(out) Quickplot

Padawan Posts: 25 Join Date: 11/9/12 Recent Posts
Thanks Michal. I've already tried qgis_umesh plugin developed by Jan Mooiman. This is a nice tool, I like it.