Python is increasingly useful across the geosciences including petrophysics, and its real value comes from the flexibility it gives you to develop solutions around the problems you actually have.
For many petrophysicists and geoscientists, the challenge is connecting that flexibility with the software used for day-to-day interpretation. You may have developed a calculation, visualisation or analytical method in Python, but the results still need to be reviewed, quality-controlled and shared alongside the rest of your well data.
That is where Python user apps, Jupyter Notebooks and ip2py can work together. Jupyter Notebooks are useful for exploring data and testing ideas. User apps are better suited to repeatable tools that can be passed on to colleagues. ip2py provides a way to connect Python workflows directly with IP, so you can work with the data already held in the IP database without repeatedly exporting and importing files.
This blog covers the main points from my recent webinar, which you can watch in full here.
Examples of data visualisations that can be created with Python User Apps in IP.
User apps have been part of IP for many years and allow you to write in a variety of programming languages. They extend the functionality of IP by allowing you to write code that works with input curves, parameters, zones and output curves.
This is particularly useful when a calculation requires more logic than can be handled easily by a multi-line formula or user formula. You may need conditional statements, loops or a way to iterate over every depth point in a well.
A simple example might involve taking gamma ray and compressional slowness data, applying a calculation at each depth and writing the result back to IP as a new curve.
One advantage of user apps is that the code does not have to remain a private script on one person’s computer. You can define the input curves, output curves and parameters that the app needs and share it amongst colleagues or on a Corporate Folder.
People who already work with IP can use an interface that behaves like an IP module, with no need to open a separate programming environment, find a script and work out which variables to change.
User apps can also include custom plots. This means that a calculation can be accompanied by a visualisation designed specifically for that workflow.
Once you have developed and tested an app, it can be run across wells in a database or passed to colleagues, who can use the workflow without needing to understand every part of the underlying code.
What a User App in IP can do. A simplified example.
Jupyter Notebooks offer a different way of working. I think of them as a kind of laboratory notebook: you can write notes, add code, run individual sections and view the output alongside your thinking.
That makes notebooks particularly useful when you are exploring data or testing a new idea. You can calculate statistics, create plots, compare different approaches and document what you are doing as you go.
You might first develop a calculation in a notebook, test it against different wells and adjust the visualisation until you understand what you want the final workflow to do. Once the idea is sufficiently developed, you can decide whether it should remain a notebook or become a user app.
A notebook is made up of cells, and those cells do not always have to be run in order. Because variables remain in memory, the notebook may appear to be working even though its sequence is no longer reproducible from the beginning.
For that reason, I would recommend treating notebooks as exploratory and experimental environments. Before sharing one, run it from top to bottom and make sure that every cell works in sequence.
ip2py is Geoactive’s Python library for working with an IP project from Python. User apps can be used without ip2py, but the library simplifies some of the interaction between Python and the IP environment.
ip2py covers a wide range of tools, including those that can read and write curves to the IP database, work with borehole image data and work across multiple wells.
Without a dedicated library, you need to think about how to retrieve the data, how to access the IP database and how to write the results back.
ip2py provides functions for working with wells, curves, zones and parameter sets. It can also be used with borehole image data, including pick sets, and it supports writing calculated data back into IP.
You can work directly with the IP database, which removes the need to export data to LAS, load it into Python, carry out a calculation, export the result again and bring it back into IP. That reduces unnecessary movement of data and keeps the results alongside the rest of the project.
You can retrieve well information, check which curves are present, identify missing header information or examine how data coverage varies across a database. You can then use Python to create tables, charts or other visualisations that support quality control and interpretation.
You can use external libraries for data handling, visualisation, image processing or machine learning, while still working with data that is managed in IP.
If you would like to see how any of this could work with your own data or workflows, we are always happy to set up a discussion or meeting and go through it in more detail. If ip2py looks useful to you, get in touch about adding it to your licence, either through support or directly with us.
We can also run bespoke training on Python and user app setup that goes into far more detail than the webinar could, and if you have any questions, just get in touch.
Can I use Python in IP without ip2py?
Yes, you can use Python user apps without an Ip2pylicence, and Ip2pyadds time-saving tools for working with the IP database and lets you launch Jupyter from IP.
What is the difference between a user app and a Jupyter Notebook?
Notebooks suit exploring data and testing ideas, while user apps suit repeatable code that you can run on many wells and share with colleagues.
Can I run my code across multiple wells?
Yes, you can run a user app across all the wells in your database, and you can use the multi-well batch operation or Ip2py to carry out calculations across many wells.
Do I need to build my own database?
No, your results are written back to the IP database, which is already set up to work with well-log data.
Which code editor can I use?
You can use the built-in code editor in IP or point IP at an external editor of your choice.