Closed Mateasek closed 2 years ago
Will these indices allow one to plot the SOLPS data using the functions like pcolormesh
? If yes, than I agree that we should have them.
Hi @vsnever ,
It should be possible if we also keep the mapping from quadrangles to the b2grid as done for the triangles. Then you could use for example matplotlib.collections.PolyCollection
to combine the grid with the grid values to produce plots.
We do something similar for plotting voxel grids in core: https://github.com/cherab/core/blob/e83bb8cf1ba19d0a645b774c460347ef302e2926/cherab/tools/inversions/voxels.pyx#L683-L688.
Hi @Mateasek, @jacklovell,
It seemed to me that we already have everything to make the plots with PolyCollection
. The RZ-coordinates of cell vertices are defined in SOLPSSimulation.mesh.r(z)
(4, Ny, Nx) arrays and all the data is defined on the original (Ny, Nx) grid.
I made a draft PR #47 to show what I had in mind. If there is already a way how to plot the grid and values, then I'm sorry but I missed it. The advantage of what I proposed is probably that we will have the quadrangle grid saved the same way as the triangle one. Having the quadrangle indicies and vertexes is somehow more understandable and standard for me.
Now I see, the idea is to keep the unique vertices as this allows for more simple plotting. I like it because previously I had to add a separate polygon for each cell to the collection to plot the data.
Yes, sorry, I didn't explain it properly. I will change the PR.
Another possibility to do is to keep only the values of unique_vertices
and construct the triangle, quadrangle values in the properties.
I was contacted recently by a colleague of mine about the possibility to plot/get B2 mesh with Cherab. I think that saving quadrangle indicies into SOLPSMesh could be useful for various reasons like plots or checks of simulation results. It is after all the original B2 mesh and it is quite pitty it is not kept when the indices are in fact calculated. Adding it is quite straightforward and similar to how triangle indices are generated. What do you think @vsnever, @jacklovell?