<jupyter_start><jupyter_text>This notebook reproduces Figure 9 in the manuscript: inversion of synthetic data from a nonlinear subglacial lake model for the basal vertical velocity. The synthetic data are produced by running the default simulation in the repository: https://github.com/agstub/sglake-parallel<jupyter_code># add path to code
import sys
sys.path.insert(0, '../code')
import numpy as np

import aux 
aux.nonlin_ex = 1          # specify that we are importing the nonlinear example data/solution

import params
params.cg_tol = 1.5e-3
from synthetic_data import make_data,make_fields
from main import main

noise_level = 0.01                           # noise level (scaled relative to elevation anomaly norm)

inv_w = 1                                    # turn basal velocity inversion 'on'
inv_beta = 0                                 # turn basal drag inversion 'off'
sol_true = make_fields(inv_w,inv_beta)       # get the "true" inverse solution
data = make_data(inv_w,inv_beta,noise_level) # create the data
eps_w = 5e-2                                 # set regularization parameter to ~optimal value

vel_locs = np.zeros(np.shape(data[0]),dtype=int)
sol,fwd,mis = main(data,vel_locs,inv_w,inv_beta,eps_beta=0,eps_w=eps_w);<jupyter_output><empty_output><jupyter_text>Now we calculate the true and estimated volume change $\Delta V = V-V_0$ from the basal vertical velocity:<jupyter_code>from scipy.integrate import trapezoid,cumulative_trapezoid
from params import dx,dt
wb = sol[:,:,50]
wb_true = sol_true[:,:,50]
dV_inv = cumulative_trapezoid(trapezoid(wb,dx=dx,axis=-1),dx=dt,initial=0)
dV_true = cumulative_trapezoid(trapezoid(wb_true,dx=dx,axis=-1),dx=dt,initial=0)<jupyter_output><empty_output><jupyter_text>Finally, we can plot the solution:<jupyter_code>from plotting import snapshots,plot_movie
snapshots(data,fwd,sol,sol_true,inv_w,inv_beta,dV_inv,dV_true)
#plot_movie(data,fwd,sol,sol_true,inv_w,inv_beta)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09211195928753181, 'fraction_numerical': 0.012213740458015267, 'mean_word_length': 4.507002801120448, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '163028', 'license': 'MIT', 'n_tokens_mistral': 680, 'n_tokens_neox': 643, 'n_words': 163, 'path': 'notebooks/4_Fig9.ipynb', 'repo_name': 'agstub/subglacial-inversion', 'size': '1965'}