Skip to content

Well

Well is the most fundamental data object in the whitson+ database model. This section shows an example of creating, editing and deleting well objects using whitson+ API.

Create a well

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import requests

ACCESS_TOKEN = os.environ["WHITSON_API_TOKEN"]
CLIENT_NAME = os.environ["CLIENT_NAME"]


def upload_well(payload: dict):
    """
    upload well information to create a well in the database
    """
    base_url = f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells"
    response = requests.post(
        base_url,
        headers={
            "content-type": "application/json",
            "Authorization": f"Bearer {ACCESS_TOKEN}",
        },
        json=payload,
    )
    if response.status_code >= 200 and response.status_code < 300:
        print(f"success on {well_name}")
    else:
        print(response.text)

if __name__ == "__main__":
    payload = {
            "name": "SPE-DATA-REPOSITORY-DATASET-1-WELL-1-OSPREY",
            "uwi_api": "SPE-DATA-REPOSITORY-DATASET-1-WELL-1-OSPREY",
            "project_id": 1,
            "t_res": 225,   # reservoir temperature
            "p_res_i": 5400,    # initial reservoir pressure
            "gor": 3300,    # initial gor
            "h": 78,    # reservoir height
            "h_f": 78,  # fracture height
            "phi": 0.063,   # porosity
            "l_w": 5883,    # lateral length
            "n_f": 252,     # number of fractures
            "Sw_i": 26,     # initial water saturation
            "fluid_pumped": 275579,
            "prop_pumped": 13514540,
            "stages": 28,
            "clusters" 252,
        }
    upload_well(payload)

Create a well without the default wellbore configuration

A default wellbore configuration (WellData) is created whenever a well is created by the API using the above method. There are situations where you may not necessarily want to have the default wellbore configuration, you can disable the creation of default wellbore configuration by adding a query parameter to the API call.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
def upload_well(payload: dict, add_default_wellbore: bool = True):
    """
    upload well information to create a well in the database
    """
    base_url = f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells"
    response = requests.post(
        base_url,
        headers={
            "content-type": "application/json",
            "Authorization": f"Bearer {ACCESS_TOKEN}",
        },
        json=payload,
        params={"add_default_wellbore": add_default_wellbore},
    )
    if response.status_code >= 200 and response.status_code < 300:
        print(f"success on {well_name}")
    else:
        print(response.text)

Edit a well

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from typing import Optional
import os
import requests

ACCESS_TOKEN = os.environ["WHITSON_API_TOKEN"]
CLIENT_NAME = os.environ["CLIENT_NAME"]


def get_well(
    project_id: Optional[int] = None,
    name: Optional[str] = None,
    uwi_api: Optional[str] = None,
):
    """
    Get a list of wells.
    """
    base_url = f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells"
    response = requests.get(
        base_url,
        headers={
            "content-type": "application/json",
            "Authorization": f"Bearer {ACCESS_TOKEN}",
        },
        params={"project_id": project_id, "name": name, "uwi_api": uwi_api},
    )
    res = response.json()
    if not res:
        raise Exception("no existing wells")
    return res


def edit_well(well_id: int, payload: dict):
    """
    Edit well information for a well.
    """
    base_url = f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells/{well_id}"
    response = requests.put(
        base_url,
        headers={
            "content-type": "application/json",
            "Authorization": f"Bearer {ACCESS_TOKEN}",
        },
        json=payload,
    )
    if response.status_code >= 200 and response.status_code < 300:
        print(f"success on well_id {well_id}")
    else:
        print(response.text)


if __name__ == "__main__":
    payload = {
        "t_res": 250,  # reservoir temperature
        "p_res_i": 6400,  # initial reservoir pressure
    }
    well_json = get_well(
        project_id=1, name="SPE-DATA-REPOSITORY-DATASET-1-WELL-1-OSPREY"
    )[0]
    edit_well(well_json["id"], payload)

Delete a well

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from typing import Optional
import os
import requests

ACCESS_TOKEN = os.environ["WHITSON_API_TOKEN"]
CLIENT_NAME = os.environ["CLIENT_NAME"]


def get_well(
    project_id: Optional[int] = None,
    name: Optional[str] = None,
    uwi_api: Optional[str] = None,
):
    """
    Get a list of wells.
    """
    base_url = f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells"
    response = requests.get(
        base_url,
        headers={
            "content-type": "application/json",
            "Authorization": f"Bearer {ACCESS_TOKEN}",
        },
        params={"project_id": project_id, "name": name, "uwi_api": uwi_api},
    )
    res = response.json()
    if not res:
        raise Exception("no existing wells")
    return res


def delete_well(well_id: int):
    """
    Delete well and its associated data.
    """
    base_url = f"http://{CLIENT_NAME}.whitson.com/api-external/v1/wells/{well_id}"
    response = requests.delete(
        base_url,
        headers={
            "content-type": "application/json",
            "Authorization": f"Bearer {ACCESS_TOKEN}",
        },
    )
    if response.status_code >= 200 and response.status_code < 300:
        print(f"well {well_id} is deleted.")
    else:
        print(response.text)


if __name__ == "__main__":
    well_json = get_well(
        project_id=1, name="SPE-DATA-REPOSITORY-DATASET-1-WELL-1-OSPREY"
    )[0]
    delete_well(well_json["id"])