<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Generating a training set of typical geological structures
(Based on 4-Create-model)
Step1:  Single normal fault
We first start with a very simple 3-layer model of a fault
Step2:  Idea
Step3:  Implementation in an experiment object
Step4:  Create experiment object for training set
Step5:  Set values for random variables
Step6:  And now
<ASSISTANT_TASK:>
Python Code:
from matplotlib import rc_params
from IPython.core.display import HTML
css_file = 'pynoddy.css'
HTML(open(css_file, "r").read())
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
repo_path = os.path.realpath('../..')
import pynoddy.history
import numpy as np
%matplotlib inline
rcParams.update({'font.size': 20})
Explanation: Generating a training set of typical geological structures
(Based on 4-Create-model)
End of explanation
reload(pynoddy.history)
reload(pynoddy.events)
nm = pynoddy.history.NoddyHistory()
# add stratigraphy
strati_options = {'num_layers' : 3,
                  'layer_names' : ['layer 1', 'layer 2', 'layer 3'],
                  'layer_thickness' : [1500, 500, 1500]}
nm.add_event('stratigraphy', strati_options )
# The following options define the fault geometry:
fault_options = {'name' : 'Fault_E',
                 'pos' : (4000, 0, 5000),
                 'dip_dir' : 90.,
                 'dip' : 60,
                 'slip' : 1000}
nm.add_event('fault', fault_options)
history = 'normal_fault.his'
output_name = 'normal_fault_out'
nm.write_history(history)
# Compute the model
pynoddy.compute_model(history, output_name) 
# Plot output
import pynoddy.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 = "normal_fault.eps")
Explanation: Single normal fault
We first start with a very simple 3-layer model of a fault
End of explanation
nout.block[np.where(nout.block == 3)] = 1
nout.plot_section('y', layer_labels = strati_options['layer_names'][::-1], 
                  colorbar = True, title = "", cmap = 'gray_r',
                  savefig = False, fig_filename = "normal_fault.eps")
Explanation: Idea: add tilting event?!
Let's make it a bit simpler (for our ML algorithm): we simply set block id's to either 1's or 0's (be careful about this choice... is it a good idea?)
End of explanation
import pynoddy.experiment
reload(pynoddy.experiment)
reload(pynoddy.history)
reload(pynoddy.events)
Explanation: Implementation in an experiment object
End of explanation
ts =  pynoddy.experiment.Experiment(history = 'normal_fault.his')
sec = ts.get_section()
sec.block[np.where(sec.block == 3)] = 1
# ts.plot_section(data = sec.block)
sec.plot_section(cmap = 'gray_r')
Explanation: Create experiment object for training set: (idea: a test set should easily be produced with new draws from the simulation!)
End of explanation
ts.events[1].properties
param_stats = [{'event' : 2, 
              'parameter': 'Slip',
              'stdev': 500.0,
              'type': 'normal'},
              {'event' : 2, 
              'parameter': 'Dip',
              'stdev': 10.0,
              'type': 'normal'},
              {'event' : 2, 
              'parameter': 'X',
              'stdev': 500.0,
              'type': 'normal'},
              {'event' : 2, 
              'parameter': 'Z',
              'stdev': 1500.0,
              'type': 'normal'}]
ts.set_parameter_statistics(param_stats)
ts.random_draw()
ts.plot_section()
ts.random_draw()
sec = ts.get_section()
sec.block[np.where(sec.block == 3)] = 1
# ts.plot_section(data = sec.block)
sec.plot_section(cmap = 'gray_r')
Explanation: Set values for random variables
End of explanation
import copy
ts_rev = copy.deepcopy(ts)
ts_rev.events[2].properties['Slip'] = -1000
ts_rev.events[2].properties['X'] += -1000
# "freeze" to update model base parameters
ts_rev.freeze()
ts_rev.plot_section()
ts_rev.random_draw()
ts_rev.plot_section()
ts_rev.change_cube_size(100)
ts_rev.random_draw()
sec = ts_rev.get_section()
sec.block[np.where(sec.block == 3)] = 1
# ts.plot_section(data = sec.block)
sec.plot_section(cmap = 'gray_r')
sec.block.shape
Explanation: And now: changing to reverse fault
Use same base object, but change slip to negative to invoke reverse fault
End of explanation
<END_TASK>