Overview

The LiquidEarth API & Python SDK allows developers to integrate and interact with the server side of LiquidEarth, facilitating complex workflows and data manipulation directly from Python scripts.

<aside> ⚠️ This feature is intended for advanced users. If you require assistance with complex integrations, please contact our technical support team.

</aside>

Installation

To install the LiquidEarth API & Python SDK, use pip:

pip install liquid-earth-api

Configuration

Before using the SDK, you must configure your environment with the necessary API token. The scripts below then get the token via

import os

api_token = os.environ["LIQUID_EARTH_API_TOKEN"]

Ensure your API token is stored in your environment variables for security and ease of access. The token can be generated from the LiquidEarth web portal with a paid license assigned to your user.

Usage

The SDK provides various functions to interact with LiquidEarth. Below are examples demonstrating how to use these functions within your Python applications. We are using gempy models as data examples (see GemPy on GitHub) but any subsurface object would work (see subsurface on GitHub).

Additional requirements for GemPy examples

gempy
pooch

Upload Mesh to Existing Space

This example shows how to upload a mesh to an already existing LiquidEarth space:

import gempy as gp
from gempy.core.data.enumerators import ExampleModel
from liquid_earth_api.api import le_api
import os

def upload_mesh_to_existing_space(space_name):
		api_token = os.environ["LIQUID_EARTH_API_TOKEN"]
		model = gp.generate_example_model(ExampleModel.ANTICLINE, compute_model=True)
    response = le_api.upload_mesh_to_existing_space(
        space_name=space_name,
        data=model.solutions.raw_arrays.meshes_to_subsurface(),
        file_name="new_mesh_file",
        token=api_token)
    print(response)

Create New Space and Upload Mesh

Create a new space in LiquidEarth and upload a mesh simultaneously:

import gempy as gp
from gempy.core.data.enumerators import ExampleModel
from liquid_earth_api.api import le_api
import os

def upload_mesh_to_new_space(space_name):
    api_token = os.environ["LIQUID_EARTH_API_TOKEN"]
    model = gp.generate_example_model(ExampleModel.ANTICLINE, compute_model=True)
    response = le_api.upload_mesh_to_new_space(
        space_name=space_name,
        data=model.solutions.raw_arrays.meshes_to_subsurface(),
        file_name="new_mesh_file",
        token=api_token)
    print(response)