gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:

Home Page:https://www.pygimli.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

3d full inversion does not export results

mariosgeo opened this issue · comments

Problem description

I have 7 3D ERT data sets with topography. I can't find a way to export the results in vtk (or any other format)
I invert them with the following
`

import numpy as np
import matplotlib.pyplot as plt
import pygimli as pg
import pygimli.meshtools as mt
from pygimli.physics import ert
import glob
yt=glob.glob(r'.\2209_09_rotonta_mg\*.dat')
DATA=[]
for i in range(0,len(yt)):
    data=ert.load(yt[i])
    if i==0:
         plc = mt.createParaMeshPLC3D(data, paraDepth=3, paraMaxCellSize=0.1,
                         surfaceMeshQuality=34)
         for s in data.sensors():
         plc.createNode(s-[0.,0.,0.1], marker=-99)
         mesh = mt.createMesh(plc, quality=1.3)

    data["k"] = ert.createGeometricFactors(data,dim=3,mesh=mesh,numerical=True) 
    data["err"] = ert.estimateError(data, relativeError=0.02) 

    DATA.append(data)


tl = ert.TimelapseERT(DATA,mesh=mesh)    
tl.fullInversion()

`

Your environment

Please provide the output of print(pygimli.Report()) here. If that does not
work, please give provide some additional information on your:

Operating system: e.g. Windows,
Python version: e.g. 3.9, 3.10, etc.?
pyGIMLi version: Output of print(pygimli.__version__)
Way of installation: e.g. Conda package,

Steps to reproduce

Expected behavior

Export inversion results

Yes, there is no ready-made export function. How would you like to export? One could create a vtk file and either

  1. include all models into that
vtk = tl.pd
for i, model in enumerate(tl.models):
    vtk[f"model{i}"] = model
vtk.exportVTK("out.vtk")

or
2. export every timestep in a single file so that one could load them all into ParaView as time series

vtk = tl.pd
for i, model in enumerate(tl.models):
    vtk["resistivity"] = model
    vtk.exportVTK(f"out{i}.vtk")

Added a function exportVTK: 9d7e6a1

Thanks Thomas, that solves my issue.