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

pg.interpolate() giving error with regionwise regularization

makeabhishek opened this issue · comments

Python version: e.g. 3.9, 3.10, etc.?

I'm trying to extract data from mgr.paradomain and interpolating it. however it is giving error with regionwise regularization. It is working good if using simple inversion. Geometry is same as mentioned in #712 .

mgrReg = tt.TravelTimeManager(data, verbose=True)
mgrReg.setMesh(mesh)
mgrReg.inv.setRegularization(background=False)
mgrReg.fop.setRegionProperties(regionNr=1, single=True, startModel=1/6000)
mgrReg.fop.setRegionProperties(regionNr=1, startModel=1/5500.)
mgrReg.fop.setRegionProperties(regionNr=2, startModel=1/2000.)

velInvReg = mgrReg.invert(lam=10, useGradient=False, zWeight=12, secNodes=5,blockyModel = True,
                          lambdaFactor=1, cType=2, verbose=True)
x_start_cord = 0 
x_end_cord = 0.06195 
y_start_cord = 0
y_end_cord = 0
number_of_points = 100

# list of probe points for your 1D slice through the center
pntsHorz = np.linspace((x_start_cord, y_start_cord),(x_end_cord, y_end_cord),number_of_points)
pntsVert = np.linspace((y_start_cord, x_start_cord),(y_end_cord, x_end_cord),number_of_points)

velLineHorz = pg.interpolate(mgrReg.paraDomain, mgrReg.velocity, pntsHorz)
velLineVert = pg.interpolate(mgrReg.paraDomain, mgrReg.velocity, pntsVert)

Error

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[36], line 11
      8 pntsHorz = np.linspace((x_start_cord, y_start_cord),(x_end_cord, y_end_cord),number_of_points)
      9 pntsVert = np.linspace((y_start_cord, x_start_cord),(y_end_cord, x_end_cord),number_of_points)
---> 11 velLineHorz = pg.interpolate(mgrReg.paraDomain, mgrReg.velocity, pntsHorz)
     12 velLineVert = pg.interpolate(mgrReg.paraDomain, mgrReg.velocity, pntsVert)
     14 # Result and comparison
     15 # fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5))
     16 # gs = fig.add_gridspec(hspace=5)
   (...)
     53 # errorHorzMAE = mae(spd_profilesAtBurst, velLineHorz) 
     54 # print("MAE Vertivcal and Horizontal: ", errorVertMAE, errorHorzMAE) 

File ~\Documents\pyGimli\pygimli\gimli\pygimli\meshtools\mapping.py:589, in interpolate(*args, **kwargs)
    581             return pg.core.interpolate(args[0], inVec=args[1],
    582                                        x=args[2], y=args[3],
    583                                        z=args[4],
    584                                        fillValue=fallback,
    585                                        verbose=verbose)
    587     if len(args) == 3 and pg.isPosList(args[2]):
    588         # args: (inMesh, inData(dim==1), posList)
--> 589         return pg.core.interpolate(args[0], args[1], destPos=args[2],
    590                                fillValue=fallback,
    591                                verbose=verbose)
    593     return pg.core.interpolate(*args, **kwargs,
    594                                fillValue=fallback,
    595                                verbose=verbose)
    597 # end if pg.core:

RuntimeError: ./core/src/interpolate.cpp:79		void GIMLI::interpolate(const Mesh&, const RMatrix&, const R3Vector&, RMatrix&, bool, double)  data.size not nodeCount and cellCount 1 x 2178 != 1408 != 2686

Not sure if this is the issue, but why do you set subsequently two different values for region 1?

mgrReg.fop.setRegionProperties(regionNr=1, single=True, startModel=1/6000)
mgrReg.fop.setRegionProperties(regionNr=1, startModel=1/5500.)

Oh that's the typo. It's only one value. mgrReg.fop.setRegionProperties(regionNr=1, single=True, startModel=1/6000)

Can you try1/mgr.paraModel as velocity? This is mapping the values back according to the region properties.

Its giving me error 'TypeError: unsupported operand type(s) for /: 'int' and 'method'