Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with showing markers #696

Closed
jcmefra opened this issue Apr 11, 2024 · 2 comments
Closed

Problem with showing markers #696

jcmefra opened this issue Apr 11, 2024 · 2 comments

Comments

@jcmefra
Copy link

jcmefra commented Apr 11, 2024

Problem description

I'm getting an error when I do markers=True in pg.show()

Your environment

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

--------------------------------------------------------------------------------
  Date: Thu Apr 11 15:29:02 2024 -05

                OS : Linux
            CPU(s) : 8
           Machine : x86_64
      Architecture : 64bit
               RAM : 15.6 GiB
       Environment : Jupyter
       File system : ext4

  Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32)
  [GCC 12.3.0]

           pygimli : 1.4.3
            pgcore : 1.4.0
             numpy : 1.23.5
        matplotlib : 3.7.2
             scipy : 1.12.0
              tqdm : 4.66.2
           IPython : 8.14.0
           pyvista : 0.41.1
--------------------------------------------------------------------------------

Steps to reproduce

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

import matplotlib.pyplot as plt
import numpy as np

import pygimli as pg
import pygimli.meshtools as mt
from pygimli.physics import ert

world = mt.createWorld(start=(-100, -40), end=(100, 0))

iPos = (-49,-15) #Inyection Point
iPos2 = (50, -15) #Inyection Point 2
fault = mt.createPolygon([(-100, -40), (-100, -3), (-52, -5), iPos, (-40, -40)], isClosed= True)

layer = mt.createPolygon([iPos, iPos2, (100, -8)], 
                         addNodes=100, interpolate='spline', isClosed=False)

world += layer
world += fault

world.addRegionMarker((40, -10), marker=1)
world.addRegionMarker((-75, -35), marker=2)
world.addRegionMarker((40, -35), marker=3)

pg.show(world, markers=True)
...

Expected behavior

To show the markers.

Actual behavior

Shows an error:

KeyError                                  Traceback (most recent call last)
Cell In[136], [line 1](vscode-notebook-cell:?execution_count=136&line=1)
----> [1](vscode-notebook-cell:?execution_count=136&line=1) pg.show(world, markers=True)

File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:146](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:146), in show(obj, data, **kwargs)
    [143](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:143)             n.pos()[1] = n.pos()[2]
    [144](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:144)         return showMesh(meshSwap, data, **kwargs)
--> [146](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:146)     return showMesh(mesh, data, **kwargs)
    [147](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:147) elif mesh.dim() == 3:
    [149](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:149)     from .pv import showMesh3D

File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:458](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:458), in showMesh(mesh, data, block, colorBar, label, coverage, ax, savefig, showMesh, showBoundary, markers, **kwargs)
    [453](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:453)     pg.viewer.mpl.drawSelectedMeshBoundaries(ax, b,
    [454](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:454)                                              color=(0.0, 0.0, 0.0, 1.0),
    [455](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:455)                                              linewidth=1.4)
    [457](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:457) if kwargs.pop("boundaryMarkers", False):
--> [458](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:458)     pg.viewer.mpl.drawBoundaryMarkers(
    [459](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:459)         ax, mesh,
    [460](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:460)         clipBoundaryMarkers=kwargs.pop('clipBoundaryMarkers', False),
    [461](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:461)         **kwargs.pop('boundaryProps', {}))
    [463](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:463) fitView = kwargs.pop('fitView', fitViewDefault)
    [465](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/showmesh.py:465) if fitView is not False:

File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:542](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:542), in drawBoundaryMarkers(ax, mesh, clipBoundaryMarkers, **kwargs)
    [540](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:540) for i, m in enumerate(ms):
    [541](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:541)     bs = mesh.findBoundaryByMarker(m)
--> [542](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:542)     paths = mesh.findPaths(bs)
    [543](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:543)     col = 'C' + str(i)
    [545](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/viewer/mpl/meshview.py:545)     for p in paths:

File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:426](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:426), in __Mesh_findPaths__(self, bounds)
    [424](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:424)         # starting node
    [425](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:425)         path.append(rID)
--> [426](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:426)         followPath(path, S, rID)
    [428](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:428) ## remaining are closed
    [429](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:429) for i in range(S.shape[0]):

File [~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:396](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:396), in __Mesh_findPaths__.<locals>.followPath(path, S, rID)
    [393](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:393) # print('row', rID, 'col', cID)
    [394](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:394) # print('add', cID)
    [395](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:395) path.append(cID)
--> [396](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:396) S.pop((rID, cID))
    [397](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:397) S.pop((cID, rID))
    [398](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ubuntu_jc/repos/Aguas_Vichy/~/anaconda3/envs/pg/lib/python3.10/site-packages/pygimli/core/mesh.py:398) # print('pop-r', (rID, cID))

KeyError: (0, 207)

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
Copy link
Contributor

halbmy commented Apr 12, 2024

On my computer, it runs smoothly
image

Can you please try creating a new environment with the current version v1.5.0 and try if it works?

@jcmefra
Copy link
Author

jcmefra commented Apr 30, 2024

I updated to the new version and it worked, thank you.

@jcmefra jcmefra closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants