<jupyter_start><jupyter_text>Visualization of inversion<jupyter_code>import matplotlib as mpb

# show all the matplotlib backends 
#mpb.rcsetup.all_backends 

# force matplotlib to use the 'Qt5Agg' backend 
#mpb.use(arg='Qt5Agg', force=True)
import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
import scipy.stats as sp

from fatiando.vis import mpl
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import sys
sys.path.insert(0, '../../code')

import mag_polyprism_functions as mfun
import plot_functions as pf
mypath = 'results/single-test/'
with open(mypath+'inversion.pickle') as w:
        inversion = pickle.load(w)
xp = inversion['xp']
yp = inversion['yp']
zp = inversion['zp']
dobs = inversion['observed_data']
N = xp.size
plt.figure(figsize=(6,5))
ax=mpl.subplot(1,1,1)
#plt.title('Residual', fontsize=20)
plt.tricontourf(yp, xp, inversion['residual'], 20, cmap='RdBu_r').ax.tick_params(labelsize=12)
plt.xlabel('$y$(km)', fontsize=18)
plt.ylabel('$x$(km)', fontsize=18)
#plt.xlim(np.min(xp), np.max(xp))
#plt.ylim(np.min(yp), np.max(yp))
clb = plt.colorbar(pad=0.01, aspect=20, shrink=1)
mpl.m2km()
clb.ax.set_title('nT')
clb.ax.tick_params(labelsize=13)
inset = inset_axes(ax, width="40%", height="30%", loc=1, borderpad=0.7)
mean = np.mean(inversion['residual'])
std = np.std(inversion['residual'])
nbins=30
n, bins, patches = plt.hist(inversion['residual'],bins=nbins, normed=True, facecolor='blue')
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
inset.text(0.68, 0.95, "$\mu$ = {:.2f}\n$\sigma$ = {:.2f}".format(mean, std),
                transform=inset.transAxes, fontsize=7,
            va='top', ha='left', bbox=props)
gauss = sp.norm.pdf(bins, mean, std)
plt.plot(bins, gauss, 'k--', linewidth=1., label='Gaussian')

plt.show()
#img(filename=mypath+'diorama_tfa_residual.png', width=1600, height=400)
x = inversion['xp']/1000.
y = inversion['yp']/1000.
z = inversion['zp']/1000.
verts = pf.plot_prisms(inversion['prisms'], 0.001)
verts_initial = pf.plot_prisms(inversion['initial_estimate'], 0.001)
fig = plt.figure(figsize=(10,8))
ax = fig.add_subplot(111, projection='3d')

# plot sides
ax.add_collection3d(Poly3DCollection(verts, alpha=0.3, 
 facecolor='r', linewidths=1.0, edgecolors='r'))

ax.set_xlim(684, 694)
ax.set_ylim(6916, 6926)
ax.set_zlim(7, -1, 100)
ax.tick_params(labelsize= 13, pad=8)
ax.set_xlabel('Y (km)', fontsize= 17)
ax.set_ylabel('X (km)', fontsize= 17)
ax.set_zlabel('Z (km)', fontsize= 17)
ax.set_xticks(np.arange(684, 694,2))
ax.set_yticks(np.arange(6916, 6926,2))
ax.yaxis.labelpad=13
ax.zaxis.labelpad=13
ax.xaxis.labelpad=13
ax.view_init(-10, 120)
ax.autoscale_view()

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1816865725660514, 'fraction_numerical': 0.053203040173724216, 'mean_word_length': 6.179220779220779, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '576197', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1143, 'n_words': 205, 'path': 'code/anitapolis/single_vizualiation.ipynb', 'repo_name': 'pinga-lab/magnetic-radial-inversion', 'size': '2763'}