Ejemplo n.º 1
0
def test_obj_dict_mudLog():

    with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    print(type(obj))
    flatt_witsml = ku.obj_dict(obj.mudLog[0], True)
    assert flatt_witsml['commonData.comments'] == 'MudLog Object'
    assert len(flatt_witsml) == 1244
Ejemplo n.º 2
0
def test_plural_dict_geoIntervall():

    with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    geo_frame = ku.plural_dict(obj.mudLog[0].geologyInterval, True)

    assert geo_frame['mdTop'][0:6] == [
        1860.0, 1870.0, 1880.0, 1890.0, 1890.0, 1900.0
    ]
    assert len(geo_frame) == 28
Ejemplo n.º 3
0
def test_obj_dict_risk():

    with open(os.path.join(sample_path, 'risk.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    flatt_witsml = ku.obj_dict(obj.risk[0], True)

    assert flatt_witsml['mitigation[0]'] == 'Call the boss'
    assert flatt_witsml['mitigation[1]'] == 'Run for cover'
    assert flatt_witsml['uidWellbore'] == 'OC-bf-wb1'
    assert flatt_witsml['nameWellbore'] == 'Wellbore Test Bruce'
    assert len(flatt_witsml) == 45
Ejemplo n.º 4
0
def test_log_to_dict(test_filename):

    with open(os.path.join(sample_path, test_filename), 'r') as test_file:
        logs = witsml.CreateFromDocument(test_file.read())

    logdata_frame = ku.logdata_dict(logs.log[0])

    for mnem in logs.log[0].logData[0].mnemonicList.split(','):
        assert mnem in logdata_frame

    assert len(list(logdata_frame.values())[0]) == len(
        logs.log[0].logData[0].data)

    if logs.log[0].indexType == 'measured depth':
        assert isinstance(logdata_frame[logs.log[0].indexCurve][0], float)
    else:
        assert isinstance(logdata_frame[logs.log[0].indexCurve][0], datetime)
Ejemplo n.º 5
0
def test_plural_dict_lithology():

    with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    lit_frame = ku.plural_dict(obj.mudLog[0].geologyInterval[1].lithology,
                               True)
    lit_frame_no_attr = ku.plural_dict(
        obj.mudLog[0].geologyInterval[1].lithology, False)

    for lit in [lit_frame, lit_frame_no_attr]:
        assert lit['lithPc'] == [70.0, 30.0]
        assert lit['codeLith'] == ['300', '405']
        assert lit['description'] == [
            'Clay Clay-shale [Symbol not found, used by default]',
            'Sand Fine sandstone'
        ]

    assert lit_frame['uid'] == [
        "6e106c6c-07f1-4288-b1d3-f3238606c1a8-Lith0",
        "6e106c6c-07f1-4288-b1d3-f3238606c1a8-Lith1"
    ]
    assert len(lit_frame) == 6
    assert len(lit_frame_no_attr) == 4
Ejemplo n.º 6
0
#%%

import os
from komle.bindings.v1411.read import witsml
from komle.soap_client import StoreClient
from komle.uom_converter import conversion_factor, get_unit
from komle import utils as ku
import pandas as pd  # Not included in komle setup.py

sample_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..',
                           'tests', 'samples')

#%% Open a mud log and unmarshall it

with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as mud_file:
    mud_logs = witsml.CreateFromDocument(mud_file.read())

# %%

print(mud_logs.mudLog[0].name)
# it is convenient with a pretty xml
ku.pretty_save(mud_logs, 'mudlog.xml')

# %% Take the mudLog, mud_logs is a container for several mudLog

mud_log = mud_logs.mudLog[0]
print(f'nameWellbore = {mud_log.nameWellbore}')
print(f'Start {mud_log.startMd.value()} {mud_log.startMd.uom}')
for geo_int in mud_log.geologyInterval:
    # need to call value on leaf nodes with attributes
    print(
Ejemplo n.º 7
0
import pyxb
from komle.bindings.v1411.read import witsml
from komle.soap_client import StoreClient
from komle.uom_converter import conversion_factor, get_unit
from komle import utils as ku
import pandas as pd  # Not included in komle setup.py
from lxml import etree

sample_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..',
                           'tests', 'samples')

#%% Open a mud log and unmarshall it

with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as mud_file:
    mud_logs = witsml.CreateFromDocument(mud_file.read())

# %%

print(mud_logs.mudLog[0].name)
# it is convenient with a pretty xml
ku.pretty_save(mud_logs, 'mudlog.xml')

# %% Take the mudLog, mud_logs is a container for several mudLog

mud_log = mud_logs.mudLog[0]
print(f'nameWellbore = {mud_log.nameWellbore}')
print(f'Start {mud_log.startMd.value()} {mud_log.startMd.uom}')
for geo_int in mud_log.geologyInterval:
    # need to call value on leaf nodes with attributes
    print(
Ejemplo n.º 8
0
def test_unmarshalling(test_filename):
    '''Test unmarshalling energistics well A test files'''
    with open(os.path.join(sample_path, test_filename), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())