Running Tape 2007 example (LBFGS+pyaflowa)
Closed this issue · 6 comments
I installed seisflows 2.1.1 on my computer (Mac M1 chip). I was trying to reproduce example 2, and I am getting an error related to pyatoa. I don't get this error when running the example in the container developed for the 2022 specfem users' workshop. In that case, there is no problem with Pyatoa. I checked the environment installed on my computer, and pyatoa seems to be correctly installed.
Below is a copy of the error I am getting:
seisflows examples run 2 -r /Users/andreacamilarianoescandon/packages/specfem2d
@@@@@@@@@@
.@@@@. .%&( %@.
@@@@ @@@@ &@@@@@@ ,%@
@@@@ @@@, /@@ @
@@@ @@@@ @@@ @
@@@@ @@@@ @@@ @ @
@@@ @@@@ ,@@@ @ @
@@@@ @@@@ @@@@ @@ @ @
@@@@ @@@@@ @@@@@ @@@ @@ @
@@@@ @@@@@ @@@@@@@@@@@@@@ @@ @
@@@@ @@@@@@ @@@& @@@ @
@@@@@ @@@@@@@@ %@@@@# @@
@@@@# @@@@@@@@@@@@@@@@@ @@
&@@@@@ @@@@( @@&
@@@@@@@ /@@@@
@@@@@@@@@@@@@@@@@
@@@@@@@@@@
================================================================================
SEISFLOWS EXAMPLE 2
///////////////////
This is a [SPECFEM2D] [WORKSTATION] example, which will run an inversion to
assess misfit between a starting homogeneous halfspace model and a target
checkerboard model. This example problem uses the [PYAFLOWA] preprocessing
module and the [LBFGS] optimization algorithm. In this example, windowing in
Pyaflowa is turnd OFF.[4 events, 32 stations, 2 iterations]. The tasks involved
include:
- (optional) Download, configure, compile SPECFEM2D
- [Setup] a SPECFEM2D working directory
- [Setup] starting model from 'Tape2007' example
- [Setup] target model w/ perturbed starting model
- [Setup] a SeisFlows working directory
- [Run] the inversion workflow
================================================================================
================================================================================
EXAMPLE SETUP
SPECFEM2D already configured, skipping 'configure'
executables found in SPECFEM2D/bin directory, skipping 'make'
================================================================================
GENERATING INITIAL MODEL
Setting the SPECFEM2D Par_file for SeisFlows compatiblility
NPROC: 1 -> 1
setup_with_binary_database: 0 -> 1
SAVE_MODEL: default -> binary
save_ASCII_kernels: .true. -> .false.
Running SPECFEM2D with command: ./bin/xmeshfem2D > OUTPUT_FILES/mesher.log.txt
Running SPECFEM2D with command: ./bin/xspecfem2D > OUTPUT_FILES/solver.log.txt
Cleaning up after xspecfem2d, setting up for new run
================================================================================
GENERATING TRUE/TARGET MODEL
Updating SPECFEM2D to set checkerboard model as current model
MODEL: default -> legacy
Running SPECFEM2D with command: ./bin/xmeshfem2D > OUTPUT_FILES/mesher.log.txt
Running SPECFEM2D with command: ./bin/xspecfem2D > OUTPUT_FILES/solver.log.txt
Cleaning up after xspecfem2d, setting up for new run
created parameter file: parameters.yaml
workflow: forward -> inversion
preprocess: default -> pyaflowa
optimize: gradient -> LBFGS
configuring SeisFlows parameter file
================================================================================
CUSTOM IMPORT ERROR
///////////////////
Module could not be imported seisflows.preprocess.pyaflowa
cannot import name 'read_sem' from 'pyatoa.utils.read' (/Users/andreacamilarianoescandon/opt/anaconda3/envs/seisflows/lib/python3.11/site-packages/pyatoa/utils/read.py)
Traceback (most recent call last):
File "/Users/andreacamilarianoescandon/seisflows/seisflows/tools/config.py", line 338, in custom_import
module = import_module(full_dotted_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/andreacamilarianoescandon/opt/anaconda3/envs/seisflows/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1149, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/Users/andreacamilarianoescandon/seisflows/seisflows/preprocess/pyaflowa.py", line 16, in
from pyatoa.utils.read import read_station_codes, read_sem
ImportError: cannot import name 'read_sem' from 'pyatoa.utils.read' (/Users/andreacamilarianoescandon/opt/anaconda3/envs/seisflows/lib/python3.11/site-packages/pyatoa/utils/read.py)
Hi @arianoesc27,
I had the same problem. It is likely that the Pyatoa version you have installed does not have the <read_sem> function. The Pyatoa branch <fixing_timing_issues> on https://github.com/adjtomo/pyatoa has <read_sem> defined (I do not know why this branch has it and others do not).
Best,
Eduardo.
Hi @arianoesc27, @evcano ,
Yes! I apologize for this code-breaking change that was not very well addressed.
A while back I decided to remove the data gathering capabilities from Pyatoa (adjtomo/pyatoa#23), which were quite rigid, in favor of moving all data-handling tasks to PySEP (https://github.com/adjtomo/pysep). In the process I removed the read_sem
function from Pyatoa as there was a redundant version within PySEP that had become more developed.
I then made PySEP a dependency of Pyatoa to get access to that read_sem
function, but did not correct this in SeisFlows. I will push a bugfix PR to SeisFlows soon to remedy this issue, and push stable versions of these packages so we know we have a stable group.
Hi @bch0w
following up on the same example and running it on mac (M1 chip), I had just commented the read_sem import in pyaflowa.py file to move ahead but then the code breaks again while running inversion. Here is the error:
SETTING UP INVERSION WORKFLOW
================================================================================
2023-02-19 13:41:07 (D) | running setup for module 'system.Workstation'
2023-02-19 13:41:10 (D) | copying par/log file to: /Users/adeshpandey/Documents/01Semesters/03Semester/FWI/FWI/Seisflows/logs/sflog_013.txt
2023-02-19 13:41:10 (D) | copying par/log file to: /Users/adeshpandey/Documents/01Semesters/03Semester/FWI/FWI/Seisflows/logs/parameters_013.yaml
2023-02-19 13:41:10 (D) | running setup for module 'solver.Specfem2D'
2023-02-19 13:41:10 (I) | initializing 3 solver directories
2023-02-19 13:41:10 (D) | running setup for module 'preprocess.Pyaflowa'
Traceback (most recent call last):
File "/Users/adeshpandey/opt/anaconda3/envs/seisflows/bin/seisflows", line 8, in
sys.exit(main())
^^^^^^
File "/Users/adeshpandey/Packages/seisflows/seisflows/seisflows.py", line 1395, in main
sf()
File "/Users/adeshpandey/Packages/seisflows/seisflows/seisflows.py", line 447, in call
getattr(self, self._args.command)(**vars(self._args))
File "/Users/adeshpandey/Packages/seisflows/seisflows/seisflows.py", line 704, in submit
system.submit(workdir=self._args.workdir,
File "/Users/adeshpandey/Packages/seisflows/seisflows/system/workstation.py", line 171, in submit
workflow.setup()
File "/Users/adeshpandey/Packages/seisflows/seisflows/workflow/inversion.py", line 171, in setup
super().setup()
File "/Users/adeshpandey/Packages/seisflows/seisflows/workflow/forward.py", line 224, in setup
self._modules[req_mod].setup()
File "/Users/adeshpandey/Packages/seisflows/seisflows/preprocess/pyaflowa.py", line 249, in setup
self._config = Config(
^^^^^^^
File "/Users/adeshpandey/opt/anaconda3/envs/seisflows/lib/python3.11/site-packages/pyatoa/core/config.py", line 155, in init
self._set_external_configs(**kwargs)
File "/Users/adeshpandey/opt/anaconda3/envs/seisflows/lib/python3.11/site-packages/pyatoa/core/config.py", line 318, in _set_external_configs
self.pyadjoint_config, unused_kwargs_pa = set_pyadjoint_config(
^^^^^^^^^^^^^^^^^^^^^
File "/Users/adeshpandey/opt/anaconda3/envs/seisflows/lib/python3.11/site-packages/pyatoa/core/config.py", line 670, in set_pyadjoint_config
paconfig = get_config(adjsrc_type, min_period=min_period,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/adeshpandey/opt/anaconda3/envs/seisflows/lib/python3.11/site-packages/pyadjoint/config.py", line 36, in get_config
assert(adjsrc_type in ADJSRC_TYPES),
AssertionError: adjsrc_type
must be in ['waveform', 'convolution', 'exponentiated_phase', 'cc_traveltime', 'multitaper', 'waveform_dd', 'convolution_dd', 'cc_traveltime_dd', 'multitaper_dd'], not cc
there is a discrepancy in the name of adj_src_typ (the string passed to it) in preprocess/pyflowa.py and pyatoa.py/core/config in the files that get installed ('cc' in one and 'cc_traveltime" in other) while installing seisflows. The same files on github are different ( with adj_src_typ = "cc_traveltime_misfit" passed to it). I can see the file (https://github.com/adjtomo/pyatoa/blob/master/pyatoa/core/config.py) with a format_adj_src_type(choice) function at the end to take care of different names passed to adj_src_type probably but the installed files do not have it and are different than the ones on github.
Thanks @padesh, also another code-breaking change that came from a refactor of Pyadjoint that didn't make it through to SeisFlows, I will fix that in the same PR.
Hi @padesh, @arianoesc27, I think I've fixed this in the latest version of SeisFlows.
Just to be sure we don't have any dependency conflicts, can you wipe your current seisflows
conda environment
conda env remove -n seisflows
and do a fresh install of SeisFlows (latest version is v2.2.0). I hope this solves the issues you have been seeing.
Hi @bch0w, I followed your instructions, and it is working fine now. Thank you!
Andrea