Test slice models

There was a problem with exporting "2D-like" slice models. Check what's going on:


In [128]:
import sys, os
import matplotlib.pyplot as plt
# adjust some settings for matplotlib
from matplotlib import rcParams
# print rcParams
rcParams['font.size'] = 15
# determine path of repository to set paths corretly below
os.chdir(r'/Users/Florian/git/pynoddy/docs/notebooks/')# some basic module imports
repo_path = os.path.realpath('../..')

import pynoddy

In [129]:
reload(pynoddy.history)
reload(pynoddy.events)
reload(pynoddy.output)

# Change to sandbox directory to store results
os.chdir(os.path.join(repo_path, 'sandbox'))

# Path to exmaple directory in this repository
example_directory = os.path.join(repo_path,'examples')
# Compute noddy model for history file
history = 'simple_two_faults.his'
history_ori = os.path.join(example_directory, history)
output_name = 'noddy_out'

H1 = pynoddy.history.NoddyHistory(history_ori)
# Before we do anything else, let's actually define the cube size here to
# adjust the resolution for all subsequent examples
H1.change_cube_size(100)
# compute model - note: not strictly required, here just to ensure changed cube size
H1.write_history(history)
pynoddy.compute_model(history, output_name)

his_full_3d = pynoddy.history.NoddyHistory(history)
block_full_3d = pynoddy.output.NoddyOutput(output_name)

# now create the slice history with the same cube size
H1 = pynoddy.history.NoddyHistory(os.path.join(example_directory, 
                                                         "simple_two_faults_slice.his"))
H1.change_cube_size(100)
# compute model - note: not strictly required, here just to ensure changed cube size
H1.write_history(history)
pynoddy.compute_model(history, output_name)
his_2d_slice = pynoddy.history.NoddyHistory(history)
block_2d_slice = pynoddy.output.NoddyOutput(output_name)


 STRATIGRAPHY
 FAULT
 FAULT
 STRATIGRAPHY
 FAULT
 FAULT
 STRATIGRAPHY
 FAULT
 FAULT
 STRATIGRAPHY
 FAULT
 FAULT

In [130]:
block_full_3d.nx, block_full_3d.ny, block_full_3d.nz


Out[130]:
(124, 94, 50)

In [131]:
block_2d_slice.nx, block_2d_slice.ny, block_2d_slice.nz


Out[131]:
(100, 2, 50)

In [132]:
block_full_3d.plot_section('x', position=20)



In [135]:
block_2d_slice.plot_section('y', position=0)



In [136]:
block_2d_slice.block = np.array(block_2d_slice.block)

In [137]:
block_2d_slice.export_to_vtk(vtk_filename = "slice_model")

In [28]:
block_full_3d.export_to_vtk()

Test problem with axes orientation

There seems to be a problem with the axis orientation, probably also related to the problem of the slice plots above. Check what's going on with a couple of simple models:


In [5]:
reload(pynoddy.history)

# Change to sandbox directory to store results
os.chdir(os.path.join(repo_path, 'sandbox'))

# Path to exmaple directory in this repository
example_directory = os.path.join(repo_path,'examples')

In [123]:
noddy_his = os.path.join(example_directory, "slightly_complicated.his")
noddy_out = 'slightly_complicated_out'
# recompute model
pynoddy.compute_model(noddy_his, noddy_out)

In [124]:
f = open(noddy_out + ".g12").readlines()

In [125]:
len(f[0].strip().split("\t"))


Out[125]:
47

In [126]:
# Now open output file
reload(pynoddy.output)
no = pynoddy.output.NoddyOutput(noddy_out)
print no.block.shape
imshow(no.block[10,:,:], interpolation = 'nearest')
no.export_to_vtk(vtk_filename = noddy_out)


(62, 47, 25)

In [127]:
no.plot_section('x')
no.plot_section('y')
no.plot_section('z')



In [114]:
im = imshow(no.block[40,:,:], interpolation='nearest')



In [91]:
nh = pynoddy.history.NoddyHistory(noddy_his)


 STRATIGRAPHY
 FAULT

In [94]:
nh.events[1].__dict__


Out[94]:
{'event_lines': ['Event #1\t= STRATIGRAPHY\r\n',
  '\tNum Layers\t= 7\r\n',
  '\tUnit Name\t= Base\r\n',
  '\tHeight\t= -31000\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 4.00e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.60e-003\r\n',
  '\tMagSusY\t= 1.60e-003\r\n',
  '\tMagSusZ\t= 1.60e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.60e-003\r\n',
  '\tColor Name\t= Color 92\r\n',
  '\tRed\t= 0\r\n',
  '\tGreen\t= 153\r\n',
  '\tBlue\t= 48\r\n',
  '\tUnit Name\t= Lower\r\n',
  '\tHeight\t= 1000\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 3.00e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.50e-003\r\n',
  '\tMagSusY\t= 1.50e-003\r\n',
  '\tMagSusZ\t= 1.50e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.50e-003\r\n',
  '\tColor Name\t= Color 141\r\n',
  '\tRed\t= 102\r\n',
  '\tGreen\t= 46\r\n',
  '\tBlue\t= 0\r\n',
  '\tUnit Name\t= L Middle\r\n',
  '\tHeight\t= 2000\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 2.80e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.40e-003\r\n',
  '\tMagSusY\t= 1.40e-003\r\n',
  '\tMagSusZ\t= 1.40e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.40e-003\r\n',
  '\tColor Name\t= Color 130\r\n',
  '\tRed\t= 0\r\n',
  '\tGreen\t= 102\r\n',
  '\tBlue\t= 4\r\n',
  '\tUnit Name\t= Middle\r\n',
  '\tHeight\t= 3000\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 2.60e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.30e-003\r\n',
  '\tMagSusY\t= 1.30e-003\r\n',
  '\tMagSusZ\t= 1.30e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.30e-003\r\n',
  '\tColor Name\t= Color 42\r\n',
  '\tRed\t= 59\r\n',
  '\tGreen\t= 0\r\n',
  '\tBlue\t= 204\r\n',
  '\tUnit Name\t= U Middle\r\n',
  '\tHeight\t= 3500\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 2.40e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.20e-003\r\n',
  '\tMagSusY\t= 1.20e-003\r\n',
  '\tMagSusZ\t= 1.20e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.20e-003\r\n',
  '\tColor Name\t= Color 70\r\n',
  '\tRed\t= 204\r\n',
  '\tGreen\t= 59\r\n',
  '\tBlue\t= 0\r\n',
  '\tUnit Name\t= Upper\r\n',
  '\tHeight\t= 4500\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 2.20e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.10e-003\r\n',
  '\tMagSusY\t= 1.10e-003\r\n',
  '\tMagSusZ\t= 1.10e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.10e-003\r\n',
  '\tColor Name\t= Color 75\r\n',
  '\tRed\t= 111\r\n',
  '\tGreen\t= 0\r\n',
  '\tBlue\t= 153\r\n',
  '\tUnit Name\t= Top\r\n',
  '\tHeight\t= 5500\r\n',
  '\tApply Alterations\t= ON\r\n',
  '\tDensity\t= 2.00e+000\r\n',
  '\tAnisotropic Field\t= 0\r\n',
  '\tMagSusX\t= 1.00e-003\r\n',
  '\tMagSusY\t= 1.00e-003\r\n',
  '\tMagSusZ\t= 1.00e-003\r\n',
  '\tMagSus Dip\t= 9.00e+001\r\n',
  '\tMagSus DipDir\t= 9.00e+001\r\n',
  '\tMagSus Pitch\t= 0.00e+000\r\n',
  '\tRemanent Magnetization\t= 0\r\n',
  '\tInclination\t=  30.00\r\n',
  '\tAngle with the Magn. North\t=  30.00\r\n',
  '\tStrength\t= 1.00e-003\r\n',
  '\tColor Name\t= Color 66\r\n',
  '\tRed\t= 204\r\n',
  '\tGreen\t= 175\r\n',
  '\tBlue\t= 0\r\n',
  '\tName\t= Strat\r\n'],
 'event_type': 'STRATIGRAPHY',
 'num_layers': 7}

In [16]:
?? np.loadtxt

Void ratio as degree of compactness


In [1]:
def e(n): return n/(1-n)

In [2]:
e(0.5)


Out[2]:
1.0

In [8]:
ns = np.linspace(0.01,0.8)

In [18]:
plt.plot(ns, e(ns))
plt.title('Void ratio as degree of compactness')
plt.xlabel('Eulerian porosity')
plt.ylabel('Void ratio')
plt.axvline(0.5, color = 'k', linestyle = ':')
plt.axhline(1.0, color = 'k', linestyle = ':')


Out[18]:
<matplotlib.lines.Line2D at 0x104e47750>

In [ ]: