Giter VIP home page Giter VIP logo

cgre-aachen / pynoddy Goto Github PK

View Code? Open in Web Editor NEW
68.0 17.0 30.0 32.81 MB

pynoddy is a python package to write, change, and analyse kinematic geological modelling simulations performed with Noddy.

License: GNU General Public License v2.0

Python 93.37% Shell 0.41% Makefile 1.34% Batchfile 0.02% Jupyter Notebook 4.04% Raku 0.83%
noddy python geological-modeling geology kinematic-modeling

pynoddy's Introduction

pynoddy


#f03c15 Important information: Mark Jessell is currently cleaning the Noddy core library in order to adjust our code to a more permissive license - more information, soon!


DOI

What is pynoddy

pynoddy is a python package to write, change, and analyse kinematic geological modelling simulations. It provides methods to define, load, modify, and safe kinematic models for simulation with Noddy. In addition, the package contains an extensive range for postprocessing of results. One main aspect of pynoddy is that it enables the encapsulation of full scientific kinematic modelling experiments for full reproducibility of results.

What is Noddy?

Noddy itself is a kinematic modelling program written by Mark Jessell [1][2] to simulate the effect of subsequent geological events (folding, unconformities, faulting, etc.) on a primary sedimentary pile. A typical example would be:

  1. Create a sedimentary pile with defined thicknesses for multiple formations
  2. Add a folding event (for example simple sinoidal folding, but complex methods are possible!)
  3. Add an unconformity and, above it, a new stratigraphy
  4. Finally, add a sequence of late faults affecting the entire system.

The result could look something like this:

pynoddy blender visualization

Noddy has been used to generate models for teaching and interpretation purposes, but also for scientific studies (e.g. [3]).

Installation

Installation of the pynoddy package

A successful installation of pynoddy requires two steps:

  1. An installation of the python modules in the package pynoddy
  2. The existance of an executable Noddy(.exe) program

Installation of the first part is straight-forward:

For the best (and most complete) installation, we suggest to clone the pynoddy repository on:

https://github.com/flohorovicic/pynoddy

To install pynoddy simply run:

python setup.py install

.. Note:

sufficient privileges are required (i.e. run in sudo with MacOSX/ Linux and set permissions on Windows)

The pynoddy packages themselves can also be installed directly from the Python Package Index (pypi.org) via pip:

pip install pynoddy

A Windows installer is also available on the Pypi page:

https://pypi.python.org/pypi/pynoddy/

Installation of Noddy

Noddy is a command line program, written in C, that performs the kinematic simulation itself. The program compilation is platform dependent, and therefore several ways for installation are possible (see below information for specific platforms).

Using a pre-compiled version of Noddy

The easy way to obtain a executable version of Noddy is simply to download the appropriate version for your operating system. Currently, these executables versions are also stored on github (check the up-to-date online documentation if this should not anymore be the case) in the directory:

https://github.com/flohorovicic/pynoddy/tree/master/noddyapp

Furthermore, the executables for Windows are also available for download on the webpage:

http://www.tectonique.net/pynoddy

Download the appropriate app, rename it to noddy or noddy.exe and place it into a folder that is in your local environment path variable. If you are not sure if a folder is in the PATH or would like to add new one, see below for more information.

Compiling Noddy from source files (recommended installation)

The source code for the executable Noddy is located in the repository directory noddy. In order to perform the installation, a gcc compiler is required. This compiler should be available on Linux and MacOSX operating systems. On Windows, one possibility is to install MinGW. Otherwise, the code requires no specific libraries.

Note for MacOSX users: some header files have to be adapted to avoid conflicts with local libraries. The required adaptations are executed when running the script:

> adjust_for_MacOSX.sh

The compilation is then performed (in a Linux, MacOSX, or Windows MinGW terminal) with the command:

> compile.sh

Compilation usually produces multiple warnings, but should otherwise proceed successfully.

Placing the executable noddy in the Path

For the most general installation, the executable of Noddy should be placed in a folder that can be located from any terminal application in the system. This (usually) means that the folder with the executable has to be in the PATH environment variable. On Linux and MacOSX, a path can simply be added by:

> export PATH="path/to/executable/:\$PATH"

Note that this command should be placed into your .bash_profile file to ensure that the path is added whenever you start a new Python script.

On windows, adding a folder to the local environment variable Path is usually done through the System Control Panel (Start - Settings - Control Panel - System). in Advanced mode, open the Environment Variables sub-menu, and find the variable Path. Click to edit the variable, and add the location of your folder to this path.

Noddy executable and GUI for Windows

The original graphical user interface for Noddy and the compiled executable program for Windows can be obtained from:

https://tectonique.net/noddy/

This site also contains the source code, as well as extensive documentation and tutorial material concerning the original implementation of the software, as well as more technical details on the modelling method itself.

Testing the installation

Testing noddy

Simply test the installation by running the generated (or downloaded) executable in a terminal window (on Windows: cmd):

> noddy

or (depending on your compilation or naming convention):

> noddy.exe

Which should produce the general output:

Arguments <historyfile> <outputfile> <calc_mode>:
BLOCK
GEOPHYSICS
SURFACES
BLOCK_GEOPHYS
BLOCK_SURFACES
TOPOLOGY
ANOM_FROM_BLOCK
ALL

Note: if the executable is correctly placed in a folder which is recognised by the (Environment) path variable, then you should be able to run Noddy from any directory. If this is not the case, please check if it is correctly placed in the path (see above).

Testing pynoddy

The pynoddy package contains a set of tests which can be executed in the standard Python testing environment. If you cloned or downloaded the repository, then these tests can directly be performed through the setup script:

> python setup.py test

Of specific relevance is the test that determines if the noddy(.exe) executable is correctly accessible from pynoddy. If this is the case, then the compute_model test should return:

test_compute_model (test.TestHistory) ... ok}

If this test is not ok, then please check carefully the installation of the noddy(.exe) executable.

If all tests are successful, you are ready to go!

How to get started

Tutorial Jupyter notebooks

The best way to get started with pynoddy is to have a look at the IPython notebooks in pynoddy/docs/notebooks. The numbered notebooks are those that are part of the documentation, and a good point to get started.

The notebooks require an installed Jupyter notebook. More information here:

https://jupyter.org

The notebook can be installed via pip or conda.

The Atlas of Strutural Geophysics

The Atlas of Structural Geophysics contains a collection of structural models, together with their expression as geophysical potential fields (gravity and magnetics), with a focus on guiding the interpretation of observed features in potential-field maps.

The atlas is currently available on:

http://tectonique.net/asg

The structural models are created with Noddy and the history files can be downloaded from the atlas. Models from this Atlas can directly be loaded with pynoddy. See example notebooks and documentation for more details.

Documentation

An updated version of the documentation is available within the pynoddy repository (pynoddy/docs).

In addition, an online html version of the documentation is also hosted on readthedocs:

http://pynoddy.readthedocs.org

Technical Notes

Dependencies

pynoddy depends on several standard Python packages that should be shipped with any standard distribution (and are easy to install, otherwise):

  • numpy
  • matplotlib
  • pickle

The uncertainty analysis, quantification, and visualisation methods based on information theory are implemented in the python package pygeoinfo. This package is available on github and part of the python package index. It is automatically installed with the setup script provided with this package.

In addition, to export model results for full 3-D visualisation with VTK, the pyevtk package is used, available on bitbucket:

https://bitbucket.org/pauloh/pyevtk/src/9c19e3a54d1e?at=v0.1.0

The package is automatically downloaded and installed when running python setup.py install.

3-D Visualisation

At this stage, we do not supply methods for 3-D visualisation in python (although this may change in the future). However, we provide methods to export results into a VTK format. Exported files can then be viewed with the highly functional VTK viewers, and several free options are available, for example:

License

pynoddy is free software (see license file included in the repository). Please attribute the work when you use it and cite the publication if you use it in a scientific context - feel free to change and adapt it otherwise!

References

[1] Mark W. Jessell. Noddy, an interactive map creation package. Unpublished MSc Thesis, University of London. 1981.

[2] Mark W. Jessell, Rick K. Valenta, Structural geophysics: Integrated structural and geophysical modelling, In: Declan G. De Paor, Editor(s), Computer Methods in the Geosciences, Pergamon, 1996, Volume 15, Pages 303-324, ISSN 1874-561X, ISBN 9780080424309, http://dx.doi.org/10.1016/S1874-561X(96)80027-7.

[3] Armit, R. J., Betts, P. G., Schaefer, B. F., & Ailleres, L. (2012). Constraints on long-lived Mesoproterozoic and Palaeozoic deformational events and crustal architecture in the northern Mount Painter Province, Australia. Gondwana Research, 22(1), 207โ€“226. http://doi.org/10.1016/j.gr.2011.11.003

pynoddy's People

Contributors

ahinoamp avatar alex-schaaf avatar danielsk78 avatar flohorovicic avatar leguark avatar lsgeo avatar markjessell avatar samthiele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pynoddy's Issues

Draw faults lines

Hi,

I was wondering if there is a (possibly quick and dirty) way to draw faults lines on sections?
I managed to put a thin black line to separate layers, but drawing faults is much more complicated.
I guess that can only be done by looking into the Noddy C code?

Regards,

Block model empty - not showing cross sections

Problem
The method load_geology() from the NoddyOutput class is not populating the block model correctly. It skips the for line in f.readlines(): from line 200.

Additionally, since the f.readlines() is outside of the with open(self.basename + ".g12", "r") as f: of line 191, a value error arises ValueError: I/O operation on closed file. (issue #40).

Solution
Replace all the f.readlines() to lines. Including the "numpy" method. Lines 200, 218, and 233

Experiment method `get_section_voxels()` throws AttributeError

exp = pynoddy.experiment.Experiment("history.his")
exp.get_section_voxels()

Throws:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-310-fdb1209cdcb8> in <module>
----> 2 exp.get_section_voxels()

/pynoddy/pynoddy/output.py in get_section_voxels(self, direction, position, **kwds)
    455         """
    456 
--> 457         data = kwds.get('data',self.block)
    458 
    459         if direction == 'x':

AttributeError: 'Experiment' object has no attribute 'block'

Expected behavior
Get a np.ndarray containing the section lithology ids.

Current workaround

tmp_out = exp.get_section()
section, _ = tmp_out.get_section_voxels()

NoddyModel class?

Define object (NoddyModel?) that combines input, computation, and output in a convenient way. Possibly: inheriting from both NoddyHistory and NoddyOutput (and NoddyGeophysics)? Should be possible, check!

Importing the experiment module throws SyntaxError

Importing the experiment module throws the SyntaxError below.
Using pip-installed version of pynoddy on Ubuntu WSL 20.04.

import pynoddy.experiment
Traceback (most recent call last):

  File "/home/alex/miniconda3/envs/testenv/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-2-20904f32ce05>", line 10, in <module>
    import pynoddy.experiment

  File "/home/alex/miniconda3/envs/testenv/lib/python3.7/site-packages/pynoddy/experiment/__init__.py", line 19
    from . import util.sampling as Sample
                      ^
SyntaxError: invalid syntax

Create new release 1.2

Create a new release with updated installation information (especially for pip) and tested installation on MacOSX, Windows, and Linux.

Plot orientation

Check orientation of section plots and VTK block output - one of them is wrong...

Unable to plot sections

Hi, I recently found pynoddy and I am struggling to plot sections of the data as done from notebook 1-Simulation.
The following code is given:
N1.plot_section('y', figsize = (5,3))

This gives me the error:
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

I then add an integer
xslice = int(0.1*N1.nx)
N1.plot_section('y', position = xslice, figsize = (5,3))
To get the error
ValueError: 'lower left' is not a valid value for origin; supported values are 'upper', 'lower'
or
if 0.1 is changed to 1 then
IndexError: index 124 is out of bounds for axis 1 with size 94
or
ValueError: I/O operation on closed file.
The same with 3D plots, I always seem to get
AssertionError: Incompatible cell data. 1 cell blocks, but 'triangle' has 59150 blocks.

The I/O error appears to come from the following:
~\Anaconda3\lib\site-packages\pynoddy-1.1-py3.8.egg\pynoddy\output.py in load_geology(self)
198 k = 0
199 self.block = np.ndarray((self.nx, self.ny, self.nz))
--> 200 for line in f.readlines():
201 if line == '\n':
202 # next z-slice

Any help would be greatly appreciated.

Add documentation for randomnoddy

Add documentation for the use of randomnoddy (and the appropriate pynoddy functions, see issue #25). Add notebooks with some case studies and examples.

.his files created with pynoddy cannot be read with noddy GUI or CLI

I've been following the tutorial here: https://pynoddy.readthedocs.io/en/latest/notebooks/5-Geophysical-Potential-Fields.html

I downloaded the history available here: http://tectonique.net/asg/ch3/ch3_5/his/fold_thrust.his

In the tutorial, an updated history is created from a copy of this history:

his = pynoddy.history.NoddyHistory(url = "http://tectonique.net/asg/ch3/ch3_5/his/fold_thrust.his")
his.determine_model_stratigraphy()
his.change_cube_size(50)
history_name = "fold_thrust_edit.his"
his.write_history(history_name)

This is saved to a new file. Attempting to load the new history file in either the GUI or the command line causes noddy to crash with no error message. Attempting to load the original history file, as downloaded from the above link, works.

I looked at the contents of each file, and there are a few minor differences. I am on Windows, and have tested a few of the precompiled executables with no success.

Is this expected behaviour? Should I try compiling noddy myself?

Cheers

Delete the file noddylic.c

Hi Florian,

I've compiled Noddy on my computer.
I got an error that there are two definitions of a main() function.

Once I deleted the file noddylic.c everything compiled just fine.
Perhaps this file should be deleted from the repository.

Best,

Noe

C:\Users\ahinoamp\Downloads\noddymingw\NoddyBasic\Debug/../testNod.c:14: multiple definition of `main'
./noddylic.o:C:\Users\ahinoamp\Downloads\noddymingw\NoddyBasic\Debug/../noddylic.c:5: first defined here

Fix end of event lines

The pointer to end of event lines is wrong in some cases - not sure when exactly. Might have to do with the files read from Virtual Explorer.

Can lead to problems when re-computing the file (actually, to a segmentation fault when calling Noddy):

*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Segmentation fault: 11

The problem is that the event name of the last event is accidentally left out and Noddy seems to get problems when allocating the memory.

Seems to work for most cases, however - need to find out when it doesn't!

missing module and error while running the pynoddy

while we running the pynoddy the following error is coming. what we do, please help

  1. module pynoddy.experiment not found
  2. module pynoddy.experiment.util not found
    3)no files found matching '*.g??' under directory 'examples'
  3. test_compute_model (test.TestHistory) ... ERROR
  4. ERROR: test_compute_model (test.TestHistory)
  5. OSError: [WinError 193] %1 is not a valid Win32 application

testing the pynoddy

C:\Users\NGRI_GVT_001\pynoddy>> python setup.py test
C:\Users\NGRI_GVT_001\anaconda3\lib\site-packages\setuptools\dist.py:461: UserWarning: Normalizing '1.01' to '1.1'
warnings.warn(tmpl.format(**locals()))
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
file pynoddy\experiment.py (for module pynoddy.experiment) not found
file pynoddy\experiment\util.py (for module pynoddy.experiment.util) not found
warning: no files found matching '*.g??' under directory 'examples'
test_compute_model (test.TestHistory) ... ERROR

======================================================================
ERROR: test_compute_model (test.TestHistory)

Traceback (most recent call last):
File "C:\Users\NGRI_GVT_001\pynoddy\test_init_.py", line 15, in test_compute_model
return_val = pynoddy.compute_model(history, output_name)
File "C:\Users\NGRI_GVT_001\pynoddy\pynoddy_init_.py", line 109, in compute_model
subprocess.run([noddy_path, history, output_name, sim_type],
File "C:\Users\NGRI_GVT_001\anaconda3\lib\subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\NGRI_GVT_001\anaconda3\lib\subprocess.py", line 858, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\NGRI_GVT_001\anaconda3\lib\subprocess.py", line 1311, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 is not a valid Win32 application


Ran 1 test in 0.053s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>

this is the error while testing the pynoddy. please help

Saved history cannot be loaded?

If I create a new noddy model as follows:

history = NoddyHistory()
history.add_event('stratigraphy', event_options={'num_layers' : 3,
                                                 'layer_names' : ["top","middle","bottom"],
                                                 'layer_thickness' : [100,200,700]})
history.write_history("model.his")

I can save it / execute it / load it in Noddy GUI without issues.

But.... I can't open it with pynoddy? The following gives me an error:
his = NoddyHistory("model.his")

~/opt/anaconda3/envs/hylite/lib/python3.6/site-packages/pynoddy/events.py in parse_event_lines(self, lines)
127 # self.property_lines[l[0].strip()] = i
128
--> 129 self.name = self.event_lines[-1].split("=")[1].strip()
130
131 def update_properties(self, **kwds):

IndexError: list index out of range

Any thoughts?

Move to "new-style" classes

Update class definitions to "new-style" classes to enable better inheritance (and, maybe in the future, proper descriptor and variable access methods?)

Installing noddy on Mac OS

Hi there,

I am wonderign if you had any expereice with, or can point to any resources on how to install noddy on a mac.

I successfully cloned and installed pynoddy, then in the noddy directory I tried this:

Macintosh-5:~ matteoniccoli$ cd GitHub/pynoddy
Macintosh-5:pynoddy matteoniccoli$ cd noddy
Macintosh-5:noddy matteoniccoli$ ./adjust_for_MacOSX.sh
Macintosh-5:noddy matteoniccoli$ ./compile.sh
-bash: ./compile.sh: Permission denied

but I get a permission problem.

Structural age calculates incorrectly for topology networks

Structural age of edges in the NoddyTopology class calculates incorrectly for unconformities, with stratigraphic units deposited after the unconformity assigned their stratigraphic age rather than the age of the unconformable package.

The problem is best illustrated by creating a model with a initial stratigraphy, fold, unconformity and fault and then plotting a hive diagram. Units deposited after the unconformity are assigned a structural age that is much too high ( younger event than the fault), rather than the age of the unconformity. I am unsure how to best fix this.

installation on Windows

i'v tried to install the pynoddy on Windows,i failed in the first step : python setup.py install,it turned out -- File "c:\users\cww\appdata\local\temp\easy_install-piz0jq\SALib-1.0.2\temp\eas
y_install-xxtpgo\PyScaffold-2.5.6\pyscaffold\utils.py", line 211, in check_setup
tools_version
RuntimeError: Your setuptools version is too old (<12).
Use pip install -U setuptools to upgrade.

then --
F:\finalwork\pynoddy-master>pip install -U setuptools
Requirement already up-to-date: setuptools in c:\users\cww\appdata\local\enthoug
ht\canopy32\user\lib\site-packages
Requirement already up-to-date: packaging>=16.8 in c:\users\cww\appdata\local\en
thought\canopy32\user\lib\site-packages (from setuptools)
Requirement already up-to-date: appdirs>=1.4.0 in c:\users\cww\appdata\local\ent
hought\canopy32\user\lib\site-packages (from setuptools)
Requirement already up-to-date: six>=1.6.0 in c:\users\cww\appdata\local\enthoug
ht\canopy32\user\lib\site-packages (from setuptools)
Requirement already up-to-date: pyparsing in c:\users\cww\appdata\local\enthough
t\canopy32\user\lib\site-packages (from packaging>=16.8->setuptools)
then--
File "c:\users\cww\appdata\local\temp\easy_install-0qpcd7\SALib-1.0.2\temp\eas
y_install-wcef7a\PyScaffold-2.5.6\pyscaffold\utils.py", line 211, in check_setup
tools_version
RuntimeError: Your setuptools version is too old (<12).
Use pip install -U setuptools to upgrade.
it doesn't work,why?what should i do ,which version is the right version?
thank you for your answer,please help me.you can also send the answer to :[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.