In [2]:
from IPython.core.display import HTML
css_file = 'pynoddy.css'
HTML(open(css_file, "r").read())
Out[2]:
In [3]:
# Basic settings
import sys, os
import subprocess
# Now import pynoddy
import pynoddy
# determine path of repository to set paths corretly below
repo_path = os.path.realpath('../..')
In [4]:
# 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_file = 'simple_two_faults.his'
history = os.path.join(example_directory, history_file)
output_name = 'noddy_out'
# call Noddy
# NOTE: Make sure that the noddy executable is accessible in the system!!
sys
print subprocess.Popen(['noddy.exe', history, output_name, 'BLOCK'],
shell=False, stderr=subprocess.PIPE,
stdout=subprocess.PIPE).stdout.read()
#
For convenience, the model computation is wrapped into a Python function in pynoddy:
In [5]:
pynoddy.compute_model(history, output_name)
Note: The Noddy call from Python is, to date, calling Noddy through the subprocess function. In a future implementation, this call could be subsituted with a full wrapper for the C-functions written in Python. Therefore, using the member function compute_model is not only easier, but also the more "future-proof" way to compute the Noddy model.
Noddy simulations produce a variety of different output files, depending on the type of simulation. The basic output is the geological model. Additional output files can contain geophysical responses, etc.
Loading the output files is simplified with a class class container that reads all relevant information and provides simple methods for plotting, model analysis, and export. To load the output information into a Python object:
In [6]:
N1 = pynoddy.NoddyOutput(output_name)
The object contains the calculated geology blocks and some additional information on grid spacing, model extent, etc. For example:
In [7]:
print("The model has an extent of %.0f m in x-direction, with %d cells of width %.0f m" %
(N1.extent_x, N1.nx, N1.delx))
In [10]:
N1.plot_section('y')
In [9]:
N1.export_to_vtk()
In [33]:
In [ ]: