Programming in and around OpendTect; Part 2: Python
Marieke van Hout - de Groot
Executive Vice President Asia-Pacific at dGB Earth Sciences
In this series of 6 social media posts we describe different ways of programming software in and around OpendTect. The various options are listed in the Table below.
Today: Python.
The free External Attribute plugin makes it possible to develop new seismic attributes for OpendTect in Python, a popular open source, high-level, general-purpose, interpreted, dynamic programming language. The External Attribute plugin is part of a package of free plugins provided by Wayne Mogg, download links and installation instructions are provided on the plugin documentation site. As of release 6.0.4 the plugin package also includes a collection of Python external attribute scripts that can be used as is or referred to as examples for development of new attributes.
To create and run Python attribute scripts an installation of Python version 3+ is also required. The recommended solution is to install the free Anaconda Python distribution for you platform. Remember to get a version 3+ package as earlier versions are not supported by the plugin. Out of the box Anaconda comes with a range of handy Python extensions for numerical computation such as Numpy, SciPy and Numba.
As a simple example consider the following Python attribute script that applies a Prewitt (derivative) filter.
Approximately 800 lines of C++ code would be required to implement this same functionality as a C++ OpendTect plugin. Despite this simplicity, a Python attribute has all the benefits of a native OpendTect attribute:
â— It can be displayed in all the same places.
â— It can be used as input to other attributes either native or another Python attribute.
â— It can be used in crossplots.
â— It supports parallel processing.
â— It can be used to generate new seismic volumes via the OpendTect batch processing facility.
Naturally the execution time of a Python attribute will be longer than an equivalent C++ attribute, however this is offset by a more rapid development cycle using a higher level language. Each change to the code of a C++ attribute requires a compile, link and OpendTect shutdown-restart. A change to the Python attribute can be tested by simply redisplaying the attribute.
There is the flexibility to develop something as simple as a single trace filter or as complex as an attribute with multi-trace, multi-attribute input and multi-attribute output. Here is an example of a moderately complex attribute (ex_lpa_smooth.py) that implements a structure preserving filter using 3D, weighted least squares, local polynomial approximation.
Fingers crossed you now want to make your own Python attributes. A good way to start is to download or clone my GitHub repository of Python attributes and see how anything from low pass filtering to computation of gradient structure tensors is possible. In the skeletons folder you will find Python templates for scripts of various input/output complexity to start from. Leave a message on the GitHub issue tracker if you need help or discover a bug. Get coding.
Author: Wayne Mogg
InsightEarth Software Consultant at EdgeSeis LLC
8 å¹´I would like to try this. Thank you.
Geophysicist | Geoscientist | Certified PMP? Project Manager
8 å¹´This is something I was waiting for! Great job, dGB team!
I talk about non-hype AI {Scientist for Machine Learning @ECMWF ?? | Fellow AI4Science @SSI ?? | PhD @DTU ?? | Partner @Youtube ?? | Top 81 @Kaggle code ??}
8 å¹´I am inclined to take a look indeed. Thanks for providing this easy but powerful tool!