MoiseRousseau / PyGeoStudio

Python library allowing reading/writing GeoStudio .gsz file
https://pygeostudio.readthedocs.io
22 stars 2 forks source link

Export to Paraview #10

Closed jonaslindemann closed 4 months ago

jonaslindemann commented 5 months ago

I am trying to open a gsz file using PyGeoStudio:

import PyGeoStudio as pgs
src_file = "./Final-selected/Flowmodel_2023-04-27_V02/Model98.gsz" #specify the geostudio analyses file
geofile = pgs.GeoStudioFile(src_file) #open it with PyGeoStudio
geofile.showAnalysisTree()
analysis = geofile.getAnalysisByID(3)
analysis["Geometry"]["Mesh"].export("mesh.vtk")
analysis["Results"].exportAllResultsVTU("results.vtu")

I get the following error:

Traceback (most recent call last):
  File "/home/bmjl/Development/infravis_dam_project/seapage-data-240207/convert_to_paraview.py", line 11, in <module>
    analysis["Results"].exportAllResultsVTU("results.vtu")
  File "/home/bmjl/.conda/envs/damviz/lib/python3.10/site-packages/PyGeoStudio/Results.py", line 137, in exportAllResultsVTU
    out_mesh = meshio.Mesh(points=points, cells=cells, point_data=point_data)
  File "/home/bmjl/.conda/envs/damviz/lib/python3.10/site-packages/meshio/_mesh.py", line 166, in __init__
    raise ValueError(
ValueError: len(points) = 4298, but len(point_data["Node"]) = 4297

Am I missing something?

MoiseRousseau commented 5 months ago

You did well, but there is something with the exporter. It seems that you have not the same number of nodes in your mesh and in data you export (I supposed it was the always the case). Do you have multiple meshes in your study ? Can you share the GeoStudio file (Model98.gsz) or it is confidential ?

jonaslindemann commented 5 months ago

I don't think I can share the data, but we have asked the vendor if they know why we get this. It seems it is a one off error.

MoiseRousseau commented 5 months ago

The vendor does not support PyGeoStudio, so I don't think they will help you. I can't reproduce the problem on my side. Note I update master because the getSnapshot method (used by export function) does not target the right timestep. But I should not solve you problem as your mesh does not change with time. Keep me informed of what GeoSlope say. Also, what version of GeoStudio are you using ? Does your mesh look good in Paraview (the file mesh.vtk) ? Note you can play with the PyGeoStudio file Results.py in your local Python installation (/home/bmjl/.local/lib/python3.XX/site-packages/PyGeoStudio) and tweak the function getSnapshot(), especially line 75 starting with np.genfromtxt and the skip_header argument (https://numpy.org/doc/stable/reference/generated/numpy.genfromtxt.html) to make it works.

jonaslindemann commented 4 months ago

I have sent you a link via email with the problematic file.

Jonas

MoiseRousseau commented 4 months ago

Jonas, Where did you you sent me the link ? You can reach me at rousseau.moise@gmail.com

MoiseRousseau commented 4 months ago

Solved in https://github.com/MoiseRousseau/PyGeoStudio/releases/tag/v0.4.3