gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:
https://www.pygimli.org
Other
344 stars 131 forks source link

createworld 3D model layering #679

Open kangbow opened 1 month ago

kangbow commented 1 month ago

Problem description

How to divide the 3D model formed in createworld into three layers according to depth, mark them, and fix the resistivity according to the marks in the setRegulation below for inversion

Your environment

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

            OS : Windows
        CPU(s) : 16
       Machine : AMD64
  Architecture : 64bit
   Environment : Python

Python 3.9.18 | packaged by conda-forge | (main, Dec 23 2023, 16:29:04) [MSC v.1929 64 bit (AMD64)]

       pygimli : 1.4.6
        pgcore : 1.4.0
         numpy : 1.26.4
    matplotlib : 3.7.2
         scipy : 1.11.2
        tetgen : 0.6.4
       pyvista : 0.43.2

Steps to reproduce

Tell us how to reproduce this issue. Ideally, you could paste the code that produces the error:

from pygimli.physics import ert
import pygimli as pg
import numpy as np
import matplotlib.pyplot as plt
import pygimli.meshtools as mt
cube_region_1=mt.createWorld(start=[-10, -10,-40], end=[140, 10,0],worldMarker=True,marker=1)
cube_region_2=mt.createCube(size=[128, 0.4, 40], pos=[128/2, 0, -40/2],marker=2)
start_model=cube_region_1+cube_region_2
pg.show(start_model,alpha=0.3,markers=True)
filename = "cp32.shm"
shm = pg.DataContainerERT(filename)
data=ert.load(filename)
data['k']=ert.geometricFactors(data)
data['rhoa']=data['k']*data['u']/data['i']*1000
data.remove(data['rhoa']<0)
data['err'] = ert.estimateError(data,relativeError=0.02)
for s in shm.sensors():
    start_model.createNode(s)
for s in shm.sensorPositions():
    start_model.createNode(s - [0,0,1e-2/2])
inversion_mesh= mt.createMesh(start_model,quality=1.4)
mgr=ert.ERTManager()
mgr.setData(data)
mgr.setMesh(inversion_mesh)
mgr.inv.setRegularization(1, background=True)
mgr.inv.setRegularization(1,fix=200)
mgr.inv.setRegularization(2,startModel=1e4,limits=[100,1e4+20])
mgr.invert(lam=10,zWeight=0.1,verbose=True)
mgr.saveResult()
mgr.showMisfit()

Expected behavior

divide the 3D model formed in createworld into three layers according to depth, mark them, and fix the resistivity according to the marks in the setRegulation below for inversion

Actual behavior

Tell us what happens instead and/or provide the output of your script.

If possible, please add one or more labels to your issue, e.g. if you expect that your issue is rather a question than a problem with the code, please add the label "question".

halbmy commented 1 month ago

So far, the code looks good but you did neither tell us what's going wrong (under Actual behaviour) nor attach the data file to run the code.

kangbow commented 1 month ago

There is no problem with the code, I want to layer it according to depth and set markers based on this world model. In the following code, different values are set according to the tags, and I cannot write such code. I would like to ask for your advice

mgr.inv.setRegularization(1, background=True) mgr.inv.setRegularization(1,fix=200)

到目前为止,代码看起来不错,但您既没有告诉我们出了什么问题(在“实际行为”下),也没有附加数据文件来运行代码。

halbmy commented 1 month ago

You just need the second line. The fix argument implies background. It is a background region that is just not prolongated, but filled with a constant value.

halbmy commented 1 month ago

However, I still don't get the actual problem. Can you please describe what's going wrong?