Skip to content

Commit

Permalink
Merge fixed espresso (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhhh committed Jul 24, 2023
2 parents 7e32b87 + 8e0a157 commit 586bb35
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 18 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/gen_gallery_scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Generate sphinx-gallery scripts from notebooks

on:
workflow_dispatch:
# push:
# branches: main
# paths:
# - 'examples/**'
# schedule:
# - cron: '54 13 * * *'


jobs:
generate_scripts:
name: Generate scripts
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Install Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
sudo apt-get install pandoc
pip install pypandoc
- name: Add/Update badges
uses: trsvchn/colab-badge-action@v4
with:
verbose: true

- name: Run _ipynb_to_gallery.py
run: |
python tools/sphinx_gallery/ipynb_to_gallery.py all
- name: Set git config
continue-on-error: true
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Commit changes to notebooks
continue-on-error: true
run: |
git add examples/*
git commit -m "chore: added badges to colab in examples/"
- name: Commit changes to scripts
continue-on-error: true
run: |
git add tools/sphinx_gallery/scripts/*
git commit -m "chore: update scripts/"
- name: Push back to repo
run: |
git status
git push
43 changes: 43 additions & 0 deletions .github/workflows/test_all_scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check all Python examples work

on:
workflow_dispatch:
# pull_request:
# types:
# - ready_for_review
# paths:
# - 'examples/**'
# push:
# branches: main
# paths:
# - 'examples/**'

jobs:
test:
name: Test running all example scripts
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Install Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Set up Python env
run: |
python -m pip install matplotlib
- name: Install CoFI
run: |
python -m pip install cofi
- name: Run script
run: |
python tools/validation/test_all_notebooks_scripts.py
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
path: ./debug.log
20 changes: 14 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Editor temporary/working/backup files #
#########################################
.vscode/
# Editor / OS related
.vscode
.DS_Store

# Packaging tmp stuff #
#######################
Expand Down Expand Up @@ -47,9 +47,17 @@ src/espresso/_version.py
.pytest_cache
*__pycache__
.ipynb_checkpoints
.cache/*
*__pycache__/
*.pyc
.report.json

# OS generated files #
######################
*.DS_Store*
# # Generated by sphinx-gallery
# tools/sphinx_gallery/generated/

# Custom testing files
tools/validation/_output/
debug.log

# Temporary data files
examples/pygimli_dcip/transform-2020-simpeg
5 changes: 5 additions & 0 deletions contrib/fmm_tomography/fmm_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def get_gauss_model(extent,nx,ny): # build two gaussian anomaly velocity model
gauss1,gauss2 = rv1.pdf(pos),rv2.pdf(pos)
return 2000.*np.ones([nx,ny]) + (vc1-vb)*gauss1/np.max(gauss1) + (vc2-vb)*gauss2/np.max(gauss2)


# build test velocity models
# read vtx format velocity model and source receivers files
def read_vtxmodel(filename, with_line_breaks=True):
Expand Down Expand Up @@ -391,3 +392,7 @@ def read_receivers(filename):
recs[i,1],recs[i,0] = float(columns[0]),float(columns[1])
f.close()
return recs


# 37 EARTH SCIENCES -> 3706 Geophysics -> 370609 Seismology and seismic exploration -> Fast Marching Method -> FmmTomography
# description: The wave front tracker routines solves boundary value ray tracing problems into 2D heterogeneous wavespeed media, defined by continuously varying velocity model calculated by 2D cubic B-splines.
4 changes: 4 additions & 0 deletions contrib/gravity_inversion/gravity_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,3 +619,7 @@ def _inject_density(model, x_nodes, y_nodes, z_nodes, x, y, z, value):
model[ind] = value

return model


# 37 EARTH SCIENCES -> 3706 Geophysics -> 370606 Gravimetrics -> 3D gravity -> GravityInversion
# description: This example implements a simple gravity forward problem. The model represents density within the earth on a 3D Cartesian grid.
3 changes: 2 additions & 1 deletion contrib/magnetotelluric_1D/magnetotelluric_1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,5 @@ def load_data(filename, error_floor = 0.05, subsampling = 3):
return freqs, dobs, derr



# 37 EARTH SCIENCES -> 3706 Geophysics -> 370602 Electrical and electromagnetic methods in geophysics -> Magnetotelluric -> Magnetotelluric1D
# description: Compute the MT response of a 1D resistivty model.
4 changes: 4 additions & 0 deletions contrib/pumping_test/pumping_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,7 @@ def log_prior(self, model):
180.846000, 183.214000, 185.583000, 186.208000])

#yp5 = np.array([])


# 37 EARTH SCIENCES -> 3707 Hydrology -> 370703 Groundwater hydrology -> Pumping Test -> PumpingTest
# description: This example involves the matching of an appropriate forward model to time-drawdown data obtained from a two-well constant rate discharge test.
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,7 @@ def log_prior(self, model):
if depths_in_0_60 and veloc_in_3_7 and params_increasing:
return np.log(1/60).item()
return float("-inf")


# 37 EARTH SCIENCES -> 3706 Geophysics -> 370609 Seismology and seismic exploration -> Receiver function -> ReceiverFunctionInversion
# description: 'Receiver functions' are a class of seismic data used to study discontinuities (layering) in the Earth's crust.
4 changes: 4 additions & 0 deletions contrib/simple_regression/simple_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,7 @@ def curveFittingJac(xpts,nModelParameters, basis='polynomial',domainLength=1.):
else:
raise ValueError("Unsupported basis")
return G


# 49 MATHEMATICAL SCIENCES -> 4905 Statistics -> 490501 Applied statistics -> Curve fitting -> SimpleRegression
# description: This example includes various small 1D regression (curve-fitting) problems. Several different forms of basis function are supported: polynomial, Fourier and discrete.
4 changes: 4 additions & 0 deletions contrib/slug_test/slug_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,7 @@ def log_prior(self, model):
0.0323345, 0.0311248, 0.0299604, 0.0288395, 0.0277606,
0.0267220, 0.0257223, 0.0247600, 0.0238337, 0.0229421,
0.0220838])


# 37 EARTH SCIENCES -> 3707 Hydrology -> 370703 Groundwater hydrology -> Slug test -> SlugTest
# description: This example involves the matching of an appropriate forward model to time-displacement data obtained from a traditional single well slug test.
11 changes: 2 additions & 9 deletions contrib/surface_wave_tomography/surface_wave_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import cartopy.crs as ccrs




class SurfaceWaveTomography(EspressoProblem):
"""Forward simulation class"""

Expand Down Expand Up @@ -159,10 +157,5 @@ def log_prior(self, model):
raise NotImplementedError # optional









# 37 EARTH SCIENCES -> 3706 Geophysics -> 370609 Seismology and seismic exploration -> Ambient noise -> SurfaceWaveTomography
# description: Mapping lateral variations in surface-wave velocity at continental (USA -- example 1) and global (example 2) scale. Here, the problem is linearized, meaning that we assume that surface waves travel along the great-circle path connecting two points on the Earth surface.
8 changes: 6 additions & 2 deletions contrib/xray_tomography/xray_tomography.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from espresso import EspressoProblem
import numpy as np
from espresso import EspressoProblem
from espresso.exceptions import InvalidExampleError
Expand All @@ -7,7 +8,6 @@
import tqdm



class XrayTomography(EspressoProblem):
"""Forward simulation class
"""
Expand Down Expand Up @@ -301,4 +301,8 @@ def pngToModel(pngfile,nx,ny,bg=1.,sc=1.):
model = sc*(bg+np.asarray(png.convert('L').resize((nx,ny)).transpose(Image.Transpose.ROTATE_270))/255.)
except:
model = sc*(bg+np.asarray(png.convert('L').resize((nx,ny)).transpose(Image.ROTATE_270))/255.)
return model
return model


# 37 EARTH SCIENCES -> 3706 Geophysics -> 370609 Seismology And Seismic Exploration -> Xray Tracer -> Xray tomography
# description: We assume that the x-rays travel at the same speed regardless of the medium through which they are passing, and so their paths are straight lines between source and receiver.

0 comments on commit 586bb35

Please sign in to comment.