pyrocko / kite

InSAR unwrapped surface displacement processing for earthquake modelling.
https://pyrocko.org/kite/
GNU General Public License v3.0
78 stars 34 forks source link

ImportError: cannot import name 'CompoundModelProcessor' from 'kite.sources' #103

Closed lengri closed 1 year ago

lengri commented 1 year ago

I set up a conda environment for using kite in Ubuntu 22.04 using the following commands: conda create -n pyrockoEnv conda activate pyrockoEnv conda install -c pyrocko pyrocko pip install git+https://github.com/Turbo87/utm pip install git+https://github.com/pyrocko/kite

Doing conda list shows pyrocko, utm and kite in my env package list. Specifically, kite shows as kite 1.5.6.dev2+ga9d3a3f pypi_0 pypi.

I setup a PyCharm project using an interpreter based on the conda environment and can do things like help("pyrocko") & help("utm") without problem, but typing help("kite") results in

problem in kite - ImportError: cannot import name 'CompoundModelProcessor' from 'kite.sources' (/home/lennart/miniconda3/envs/pyrockoEnv/lib/python3.10/site-packages/kite/sources/init.py)

The same error happens when trying to follow the Modelling Static Displacement Script. When typing from kite import SandboxScene:

Traceback (most recent call last): File "/home/lennart/PycharmProjects/pythonProject/testingPyrocko.py", line 1, in from kite import SandboxScene File "/home/lennart/miniconda3/envs/pyrockoEnv/lib/python3.10/site-packages/kite/init.py", line 6, in from .sandbox_scene import SandboxScene, TestSandboxScene # noqa File "/home/lennart/miniconda3/envs/pyrockoEnv/lib/python3.10/site-packages/kite/sandbox_scene.py", line 11, in from kite.sources import CompoundModelProcessor, DislocProcessor, PyrockoProcessor ImportError: cannot import name 'CompoundModelProcessor' from 'kite.sources' (/home/lennart/miniconda3/envs/pyrockoEnv/lib/python3.10/site-packages/kite/sources/init.py) Process finished with exit code 1`

Any ideas how to fix this?

c-rutland commented 1 year ago

I had the same issue - I don't think it is pulling the processors from the right place. I am not an expert here, but so far this fix is working for me:

In the file: /lib/python3.10/site-packages/kite/sandbox_scene.py

Instead of line 11: from kite.sources import CompoundModelProcessor, DislocProcessor, PyrockoProcessor

Use the following: from kite.sources.compound_sources import CompoundModelProcessor from kite.sources.okada import DislocProcessor from kite.sources.pyrocko_gf import PyrockoProcessor

lengri commented 1 year ago

I tried changing the imports, but it still doesn't work, unfortunately. The error-message is also still the same. But thanks for the suggestion!

emolch commented 1 year ago

Should be fixed now on master. Please check...

lengri commented 1 year ago

The OkadaSource part works now, although I had to install libstdcxx-ng before being able to plot anything. However, the rectangular source model PyrockoRectangluarSource doesn't work.

Running this modified script based on the Modelling Static Displacement script results in the following error:

Could not execute pyrocko.gf.LocalEngine.process! LocalEngine Exception: directory "/home/lennart/PycharmProjects/kiteProject2/gfstore_halfspace" does not seem to contain a GF store ("config" file not found)

I thought it might be caused by something related to PyCharm, but I also cannot run talpa from the command line. Typing talpa from inside my conda env results in:

File "/home/lennart/miniconda3/envs/KiteEnv/bin/talpa", line 5, in from kite.talpa.main import main File "/home/lennart/miniconda3/envs/KiteEnv/lib/python3.10/site-packages/kite/talpa/init.py", line 1, in from .talpa import Talpa # noqa File "/home/lennart/miniconda3/envs/KiteEnv/lib/python3.10/site-packages/kite/talpa/talpa.py", line 8, in from .sandbox_model import SandboxModel File "/home/lennart/miniconda3/envs/KiteEnv/lib/python3.10/site-packages/kite/talpa/sandbox_model.py", line 8, in from . import sources File "/home/lennart/miniconda3/envs/KiteEnv/lib/python3.10/site-packages/kite/talpa/sources/init.py", line 3, in from .pyrocko import ( File "/home/lennart/miniconda3/envs/KiteEnv/lib/python3.10/site-packages/kite/talpa/sources/pyrocko.py", line 6, in from kite.sources import ( ImportError: cannot import name 'PyrockoDoubleCouple' from 'kite.sources' (/home/lennart/miniconda3/envs/KiteEnv/lib/python3.10/site-packages/kite/sources/init.py)

Or do I need to activate talpa in another way?

emolch commented 1 year ago

Hi @lengri, sorry for the trouble. We are currently in the process of getting kite running with current versions of its dependencies. There are still some pieces which have not been updated. I added some quick fixes to get talpa running again but there might still be some remaining issues. Please try again with current master.

lengri commented 1 year ago

No worries! I set up the new version of kite and can now open tapla, but adding a RectangularSourceyields

ERROR:SandboxScene.PyrockoProcessor:Could not execute pyrocko.gf.LocalEngine.process! LocalEngine Exception: directory "/home/lennart" does not seem to contain a GF store ("config" file not found) ERROR:SandboxScene.PyrockoProcessor:Could not execute pyrocko.gf.LocalEngine.process! LocalEngine Exception: directory "/home/lennart" does not seem to contain a GF store ("config" file not found)

OkadaSource works fine.

hvasbath commented 1 year ago

Thats to be expected as the other sources require pre-computed Greens Functions- the "store" it is referring to.

miili commented 1 year ago

@lengri, compute or download a static GF store. See https://greens-mill.pyrocko.org/ to use the Pyrocko sources. More info here https://pyrocko.org/docs/current/topics/pyrocko-gf.html