Create a Noddy history file

We describe here how to generate a simple history file for computation with Noddy using the functionality of pynoddy. If possible, it is advisable to generate the history files with the Windows GUI for Noddy as this method provides, to date, a simpler and more complete interface to the entire functionality.

For completeness, pynoddy contains the functionality to generate simple models, for example to automate the model construction process, or to enable the model construction for users who are not running Windows. Some simple examlpes are shown in the following.


In [1]:
from matplotlib import rc_params

In [2]:
from IPython.core.display import HTML
css_file = 'pynoddy.css'
HTML(open(css_file, "r").read())


Out[2]:

In [3]:
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/flow/git/pynoddy/docs/notebooks/')
repo_path = os.path.realpath('../..')
import pynoddy.history

In [4]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [5]:
rcParams.update({'font.size': 20})

Defining a stratigraphy

We start with the definition of a (base) stratigraphy for the model.


In [6]:
# Combined: model generation and output vis to test:
history = "simple_model.his"
output_name = "simple_out"
reload(pynoddy.history)
reload(pynoddy.events)

# create pynoddy object
nm = pynoddy.history.NoddyHistory()
# add stratigraphy
strati_options = {'num_layers' : 8,
                  'layer_names' : ['layer 1', 'layer 2', 'layer 3', 
                                   'layer 4', 'layer 5', 'layer 6', 
                                   'layer 7', 'layer 8'],
                  'layer_thickness' : [1500, 500, 500, 500, 500, 500, 500, 500]}
nm.add_event('stratigraphy', strati_options )

nm.write_history(history)


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-6-35368657035b> in <module>()
     15 nm.add_event('stratigraphy', strati_options )
     16 
---> 17 nm.write_history(history)

/Users/flow/git/pynoddy/pynoddy/history.pyc in write_history(self, filename)
    785         for i,line in enumerate(history_lines):
    786             # add empty line before "BlockOptions", if not there:
--> 787             if ('BlockOptions' in line) and (self.history_lines[i-1] != "\n"):
    788                 f.write("\n")
    789             f.write(line)

IndexError: list index out of range

In [7]:
# Compute the model
reload(pynoddy)
pynoddy.compute_model(history, output_name)

In [8]:
# Plot output
reload(pynoddy.output)
nout = pynoddy.output.NoddyOutput(output_name)
nout.plot_section('y', layer_labels = strati_options['layer_names'][::-1], 
                  colorbar = True, title="",
                  savefig = False, fig_filename = "ex01_strati.eps")


Add a fault event

As a next step, let's now add the faults to the model.


In [9]:
reload(pynoddy.history)
reload(pynoddy.events)
nm = pynoddy.history.NoddyHistory()
# add stratigraphy
strati_options = {'num_layers' : 8,
                  'layer_names' : ['layer 1', 'layer 2', 'layer 3', 'layer 4', 'layer 5', 'layer 6', 'layer 7', 'layer 8'],
                  'layer_thickness' : [1500, 500, 500, 500, 500, 500, 500, 500]}
nm.add_event('stratigraphy', strati_options )




# The following options define the fault geometry:
fault_options = {'name' : 'Fault_E',
                 'pos' : (6000, 0, 5000),
                 'dip_dir' : 270,
                 'dip' : 60,
                 'slip' : 1000}

nm.add_event('fault', fault_options)

In [10]:
nm.events


Out[10]:
{1: <pynoddy.events.Stratigraphy at 0x1109f1950>,
 2: <pynoddy.events.Fault at 0x110a08090>}

In [11]:
nm.write_history(history)

In [12]:
# Compute the model
pynoddy.compute_model(history, output_name)

In [13]:
# Plot output
reload(pynoddy.output)
nout = pynoddy.output.NoddyOutput(output_name)
nout.plot_section('y', layer_labels = strati_options['layer_names'][::-1], 
                  colorbar = True, title = "",
                  savefig = False, fig_filename = "ex01_fault_E.eps")



In [14]:
# The following options define the fault geometry:
fault_options = {'name' : 'Fault_1',
                 'pos' : (5500, 3500, 0),
                 'dip_dir' : 270,
                 'dip' : 60,
                 'slip' : 1000}

nm.add_event('fault', fault_options)

In [15]:
nm.write_history(history)

In [16]:
# Compute the model
pynoddy.compute_model(history, output_name)

In [17]:
# Plot output
reload(pynoddy.output)
nout = pynoddy.output.NoddyOutput(output_name)
nout.plot_section('y', layer_labels = strati_options['layer_names'][::-1], colorbar = True)



In [18]:
nm1 = pynoddy.history.NoddyHistory(history)


 STRATIGRAPHY
 FAULT
 FAULT

In [19]:
nm1.get_extent()


Out[19]:
(10000.0, 7000.0, 5000.0)

In [22]:
reload(pynoddy.history)
reload(pynoddy.events)
nm = pynoddy.history.NoddyHistory()
# add stratigraphy
strati_options = {'num_layers' : 8,
                  'layer_names' : ['layer 1', 'layer 2', 'layer 3',
                                   'layer 4', 'layer 5', 'layer 6', 
                                   'layer 7', 'layer 8'],
                  'layer_thickness' : [1500, 500, 500, 500, 500, 
                                       500, 500, 500]}
nm.add_event('stratigraphy', strati_options )

# The following options define the fault geometry:
fault_options = {'name' : 'Fault_W',
                 'pos' : (4000, 3500, 5000),
                 'dip_dir' : 90,
                 'dip' : 60,
                 'slip' : 1000}

nm.add_event('fault', fault_options)
# The following options define the fault geometry:
fault_options = {'name' : 'Fault_E',
                 'pos' : (6000, 3500, 5000),
                 'dip_dir' : 270,
                 'dip' : 60,
                 'slip' : 1000}

nm.add_event('fault', fault_options)
nm.write_history(history)

In [23]:
# Change cube size
nm1 = pynoddy.NoddyHistory(history)
nm1.change_cube_size(50)
nm1.write_history(history)


 STRATIGRAPHY
 FAULT
 FAULT

In [24]:
# Compute the model
pynoddy.compute_model(history, output_name)

In [25]:
# Plot output
reload(pynoddy.output)
nout = pynoddy.output.NoddyOutput(output_name)
nout.plot_section('y', layer_labels = strati_options['layer_names'][::-1], 
                  colorbar = True, title="",
                  savefig = True, fig_filename = "ex01_faults_combined.eps",
                  cmap = 'YlOrRd') # note: YlOrRd colourmap should be suitable for colorblindness!



In [26]:
nout.export_to_vtk()

In [27]:
# Compare to "simple two faults" model in examples folder
nm_faults = pynoddy.history.NoddyHistory(r'../../examples/simple_two_faults.his')


 STRATIGRAPHY
 FAULT
 FAULT

In [28]:
nm_faults.events


Out[28]:
{1: <pynoddy.events.Stratigraphy at 0x1120a9b10>,
 2: <pynoddy.events.Fault at 0x1120a9e90>,
 3: <pynoddy.events.Fault at 0x1120a9250>}

In [29]:
nm_faults.events[3].properties


Out[29]:
{'Amplitude': 2000.0,
 'Blue': 0.0,
 'Color Name': 'Custom Colour 5',
 'Cyl Index': 0.0,
 'Dip': 60.0,
 'Dip Direction': 270.0,
 'Geometry': 'Translation',
 'Green': 0.0,
 'Movement': 'Hanging Wall',
 'Pitch': 90.0,
 'Profile Pitch': 90.0,
 'Radius': 1000.0,
 'Red': 254.0,
 'Rotation': 30.0,
 'Slip': 1000.0,
 'X': 5500.0,
 'XAxis': 2000.0,
 'Y': 7000.0,
 'YAxis': 2000.0,
 'Z': 5000.0,
 'ZAxis': 2000.0}

In [30]:
nm_faults.write_history("test_ori")

In [31]:
pynoddy.compute_model("test_ori", "ori_fault")

In [32]:
n_out_faults = pynoddy.output.NoddyOutput("ori_fault")

In [33]:
n_out_faults.plot_section('y')



In [34]:
nout.plot_section('y', layer_labels = strati_options['layer_names'][::-1], colorbar = True)



In [35]:
os.getcwd()


Out[35]:
'/Users/flow/git/pynoddy/docs/notebooks'

In [ ]: