Python module setup

 JewelLabs  This functionality falls under the JewelLabs disclaimer. It is still under development and is provided on an 'as-is' basis, without any warranty, support or upgrades.

Python scripting allows for the usage of the Python language to control JewelSuite software through, but not limited to, JewelEarth's API. It gives you access to the wide range of libraries available for Python such as machine learning and numerical libraries.

In order to use Python you have to manually install it on your machine. To do this, follow the below setup instructions.

Installing Python

  1. Make sure that JewelSuite is closed before you proceed with the next steps.
  2. From https://bakerhughes.flexnetoperations.com download all the contents of the PythonModule folder to your local computer. In case you do not have access to the download portal, please contact SoftwareSupport@bakerhughes.com.
  3. Double click the JewelEarth Python <version> executable. This will install Python in the following location : C:\Users\{UserProfile}\PythonModule which is the default location that will be used by JewelSuite. It is possible to change to a different default location, see Changing the default Python Module location.
  4. The PythonModule folder can be found in your user profile directory after all the files have been extracted.

Opening Python

  1. Open JewelSuite and open the Horizons.jewel solution from \PythonModule\Solutions.
  2. Go to JewelLabs > Python > Open Python Module.
  3. The Python module opens as a floating pane. You can dock and pin the pane.
  4. The Python module pane, unpinned and pinned. The Variables tab is populated once you assign a variable.    click to enlarge

  5. If Python is initialized successfully, you are ready to (run examples and) use Python. The examples are located in {JewelSuiteDir}\Python\Examples.

Using Python - running commands

The Python module has different sections, see image below.

The different sections in the Python module.    click to enlarge

A chat-like user interface is provided between you and the Python interpreter. This means that you send Python text messages, in this case these are code, then the reply from Python will be given on another chat cell indented to the left.

The different chats in the Python module.    click to enlarge

  1. Type a command in the chat input window. Entering multiple command lines is also supported. To go to the next line, press Shift + Enter.
  2. To run your code, press Enter or click the play icon at the bottom right of the chat input window.
  3. The command line(s) move to the chat output window. Commands that you have entered are listed in a white box with a blue border (chat message), messages that come from Python are listed in a blue box (chat output). To edit a command, select the command in the output window and click the pencil icon. To run the command again, click the play icon.

    Click the pencil icon to adjust your command. Next, click the play icon to run the command again.    click to enlarge

  4. When new code is sent to Python, the variables list is updated accordingly. If you have many variables, an easy way to keep them organized is by opening a new Python Workbook with the green plus icon in the toolbar. Variables are only available in one workbook.
  5. Once a variable is imported, you can use the lower part of the module to add more commands to your variables. To open a list of all available functions and properties to call for a variable, type the name of the variable in the chat input window, followed by a period. To close the list, press Esc.
  6. You can select a command from the list with predefined functions and properties.    click to enlarge

  7. Use the up and down arrows or your mouse to select an operation from the list. Press enter to get the operation in the input chat window.
  8. Press enter or click the play icon at the bottom right of the chat input window to run the command.

Using Python - Running examples

The examples are located in {JewelSuiteDir}\Python\Examples.

  1. To run an example, click the folder icon in the bottom right corner of the chat input window.
  2. Browse to the folder location, and select an example. Click Open.
  3. The command or commands in the example are run immediately.
  4. The information from the example (e.g. the used commands) and the results are listed in the output chat window.

Running Jupyter Notebook

  1. Go to .
  2. Double click on the Python folder.
  3. Go to Python\Examples\notebooks and double click launch_jupyter_notebook.bat to start jupyter in a local hosted html window.
  4. A few standard notebooks are listed here:
  5. Jupyter with standard notebooks listed.    click to enlarge

  6. Click on a notebook (*.jpynb) to open it in a new window.
  7. Open a notebook to run or modify it.    click to enlarge

  8. To run the example, select the cell and click Run in the toolbar or use the key combination Shift + Enter. You can also select multiple cells to run.
  9. Click Run to run a notebook .    click to enlarge

  10. When jupyter notebook is running the selected cell, it will be indicated with a [*] in front of it.
  11. While code is being run, it is indicated with an asterix.    click to enlarge

    An entry that says open_solution must be run, else the cells below it will error.
  12. To edit a cell, double click in it to enter the edit mode. Make your change(s) and click Run again to update the code.
  13. You can edit and rerun code.    click to enlarge

Running Python in a console

  1. Open a command window in the JewelSuite Batch Server directory.
  2. Command window in Batch Server directory.    click to enlarge

  3. Execute the set_python_environment.bat.
  4. Execute set_python_environment.bat.    click to enlarge

  5. Run Python <path to script>. The examples are located in {JewelSuiteDir}\Python\Examples.
  6. Run Python.    click to enlarge

    Important  The script must have an open_solution call in it to work.

Troubleshooting initialization

To locate Python, JewelSuite attempts to use settings that are typically found under C:\Users\{UserProfile}\AppData\Local\Baker Hughes\UserSettings.JewelSuiteGeoMechanics.{version}.json

When the Python Module is first started, it will create an entry called “PythonHome”, under AdditionalSettings:

"AdditionalSettings": {

….

"PythonHome": "C:\\Users\\{username}\\PythonModule\\Python37"

}

If Python.exe is not found in this directory, JewelSuite will assume this is not the Python home directory and will not initialize the Python engine.

Changing the default Python Module location

Important  Make sure that JewelSuite is closed before you change the default location.

You can change the default Python interpreter used by JewelSuite by editing the \UserSettings.JewelSuiteGeoMechanics.{version}.json file, typically found under C:\Users\{UserProfile}\AppData\Local\Baker Hughes.

The entry PythonHome under AdditionalSettings is created the first time the PythonModule is started in JewelLabs and otherwise, it will be missing. When editing the PythonHome entry, make sure the path points to the location of the Python.exe and Python{version}.dll locations.

Manually installing libraries

Some of the required libraries ()are not pre-packed with the application and have to be installed manually. To do so:

  1. Close JewelSuite.
  2. Open a command window in %USERPROFILE%\PythonModule\Scripts.
  3. Enter the following command:
  4. pip install lasio

  5. The result should look like the image below:
  6. Run Python    click to enlarge

  7. The library can now be used like any other library within JewelEarth.