Пример #1
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
Пример #2
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
Пример #3
0
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(
        f'{geo_int.mdBottom.value()} - {geo_int.mdTop.value()}  {geo_int.mdTop.uom}'
    )
    for lit in geo_int.lithology:
        print(f'Lit: {lit.lithPc.value()} {lit.lithPc.uom}')

# %% Construct a dictonary out of the plural geologyIntervall
# This can be feed into a data frame

geo_dict = ku.plural_dict(mud_log.geologyInterval)
pd.DataFrame(geo_dict)

#%%
# Or just use lithology for intervall 1, excluding attributes
lit_dict = ku.plural_dict(mud_log.geologyInterval[1].lithology,
                          include_attr=False)
pd.DataFrame(lit_dict)

#%% Lookup a witsml unit annotation

uom = get_unit('ft')
print(uom.Name)
print([quantity for quantity in uom.QuantityType])
print(uom.toxml())
Пример #4
0
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 Trajectory and unmarshall it
 
with open(os.path.join(sample_path, 'Trajectory.xml'), 'r') as mud_file:
    traj = witsml.CreateFromDocument(mud_file.read())

# %%

print(traj.DTimTrajStart)

# %% Convert stations to dataframe

station_dict = ku.plural_dict(traj.TrajectoryStation)
pd.DataFrame(station_dict)

# %% Trajectory documentation

print(traj.__doc__)
print(traj.TrajectoryStation[0].__doc__)

#%% Work with log files

with open(os.path.join(sample_path, 'Log.xml'), 'r') as log_file:
    # logs is a regular python object according to the witsml schema
    logs = witsml.CreateFromDocument(log_file.read())

#%%