<jupyter_start><jupyter_text>Setting parameters for importing and plotting<jupyter_code>plot = False
working_dir = './results/runs/'
perm = "low_perm"

#Creates the simulation time axis
dts = create_simulation_time_axis()

#Load the ground truth case from the test set, corresponds to test set model 67
gt = np.load("./reference/model_67_x.npy")
envelope = gt[0, :, ::-1].T
ds_ref = xr.open_dataset(working_dir+perm+'/reference/reference_noise.nc')
qor_ref = ds_ref['state_variables'][dict(state_variable=2, well=1)]*(-60*60*24)
qwr_ref = ds_ref['state_variables'][dict(state_variable=1, well=1)]*(-60*60*24)
p_ref = ds_ref['state_variables'][dict(state_variable=0, well=0)]/1e5

ref_curves = [qor_ref, qwr_ref, p_ref]<jupyter_output><empty_output><jupyter_text>Loading Unconditional Prior Pressure, Rate and Property Distribution Data|<jupyter_code>unc_curves, unc_poros, unc_perms, unc_zs, unc_misfits = get_unconditionals('./results/runs/', perm)
unc_props = np.concatenate([unc_poros.reshape(1000, 1, 64, 128), unc_perms.reshape(1000, 1, 64, 128)], 1)<jupyter_output><empty_output><jupyter_text>Loading the optimized samples for each inversion case: wells, flow, and flow+wells<jupyter_code>folders = [perm+a for a in ["/wells_adam_bce", "/flow_adam_bce", "/flowwells_adam_bce"]]
all_curves, all_poroperms, all_zs = load_folders("./results/runs/", folders, functionals=["min_map", "min_map", "min_map"])
# inspired by http://nipunbatra.github.io/2014/08/latexify/
params = {
    'text.latex.preamble': ['\\usepackage{gensymb}'],
    'image.origin': 'lower',
    'image.interpolation': 'nearest',
    'image.cmap': 'gray',
    'axes.grid': False,
    'savefig.dpi': 150,  # to adjust notebook inline plot size
    'axes.labelsize': 8, # fontsize for x and y labels (was 10)
    'axes.titlesize': 8,
    'font.size': 8, # was 10
    'legend.fontsize': 6, # was 10
    'xtick.labelsize': 8,
    'ytick.labelsize': 8,
    'text.usetex': True,
    'figure.figsize': [14, 12],
    'font.family': 'serif',
}
matplotlib.rcParams.update(params)
plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=1.5, hspace=0.25)
plot_row_curves(0, unc_props[0:100], unc_curves[0:100], ref_curves, dts, envelope,  desc="(a) Prior Samples")
plot_row_curves(2, all_poroperms[0][0], all_curves[0][0], ref_curves, dts, envelope, desc="(b) Well Data")
plot_row_curves(4, all_poroperms[1][0], all_curves[1][0], ref_curves, dts, envelope, desc="(c) Flow Data")
plot_row_curves(6, all_poroperms[2][0], all_curves[2][0], ref_curves, dts, envelope, desc="(d) Flow+Well")
if plot:
    plt.savefig("./results/figures/all_runs_gt.png", dpi=300, bbox_inches="tight")<jupyter_output><empty_output><jupyter_text>Plotting all the MAP models for the four considered scenarios<jupyter_code>import torch
import random

def inverse_permeability_transform(x, a=0.001, b=1e-12):
    return x/b-a
fig, ax = plt.subplots(20, 5, figsize=(10, 20))
p = np.array([np.where(inverse_permeability_transform(poro_perm[1])>0.5, 1, 0)[::-1] for poro_perm in unc_props[0:100]])

for a, im in zip(ax.flatten(), p):
    a.imshow(im, vmin=0, vmax=1.0)
    
for a in ax.flatten():
    a.set_xticks([])
    a.set_yticks([])
fig.tight_layout()
if plot:
    plt.savefig("./results/figures/unconditional_samples.png", dpi=300, bbox_inches="tight")
misfits_wells = np.load("./results/misfits/low_perm/misfits_wells_adam_gauss_bce.npy")

fig, ax = plt.subplots(20, 5, figsize=(10, 20))
imgs = [np.where(inverse_permeability_transform(poro_perm[1])>0.5, 1, 0)[::-1] for poro_perm in all_poroperms[0][0]]

for a, im in zip(ax.flatten(), imgs):
    a.imshow(im, vmin=0, vmax=1.0)
    
for a in ax.flatten():
    a.set_xticks([])
    a.set_yticks([])
fig.tight_layout()
if plot:
    plt.savefig("./results/figures/wells_samples.png", dpi=300, bbox_inches="tight")
misfits_flow = np.load("./results/misfits/low_perm/misfits_flow_adam_gauss_bce.npy")

fig, ax = plt.subplots(20, 5, figsize=(10, 20))
imgs = np.array([np.where(inverse_permeability_transform(poro_perm[1])>0.5, 1, 0)[::-1] for poro_perm in all_poroperms[1][0]])

for a, im in zip(ax.flatten(), imgs):
    a.imshow(im, vmin=0, vmax=1.0)
    
for a in ax.flatten():
    a.set_xticks([])
    a.set_yticks([])
fig.tight_layout()
if plot:
    plt.savefig("./results/figures/flow_samples.png", dpi=300, bbox_inches="tight")
misfits_flowwells = np.load("./results/misfits/low_perm/misfits_flowwells_adam_gauss_bce.npy")

fig, ax = plt.subplots(20, 5, figsize=(10, 20))
imgs = np.array([np.where(inverse_permeability_transform(poro_perm[1])>0.5, 1, 0)[::-1] for poro_perm in all_poroperms[2][0]])

for a, im in zip(ax.flatten(), imgs):
    a.imshow(im, vmin=0, vmax=1.0)
    
for a in ax.flatten():
    a.set_xticks([])
    a.set_yticks([])
fig.tight_layout()
if plot:
    plt.savefig("./results/figures/flowwells_samples.png", dpi=300, bbox_inches="tight")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17208256693235233, 'fraction_numerical': 0.040261598201512365, 'mean_word_length': 5.685792349726776, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '431608', 'license': 'MIT', 'n_tokens_mistral': 2148, 'n_tokens_neox': 2007, 'n_words': 367, 'path': 'results/Plot Results-Paper.ipynb', 'repo_name': 'LukasMosser/DeepFlow', 'size': '4893'}