|
1
|
|
|
import os, sys; sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
|
2
|
|
|
|
|
3
|
|
|
import fnmatch |
|
4
|
|
|
|
|
5
|
|
|
import numpy as np |
|
6
|
|
|
import pytest |
|
7
|
|
|
|
|
8
|
|
|
import lasio |
|
9
|
|
|
from lasio import read, las |
|
10
|
|
|
|
|
11
|
|
|
import logging |
|
12
|
|
|
|
|
13
|
|
|
logger = logging.getLogger(__name__) |
|
14
|
|
|
|
|
15
|
|
|
test_dir = os.path.dirname(__file__) |
|
16
|
|
|
|
|
17
|
|
|
egfn = lambda fn: os.path.join(os.path.dirname(__file__), "examples", fn) |
|
18
|
|
|
stegfn = lambda vers, fn: os.path.join( |
|
19
|
|
|
os.path.dirname(__file__), "examples", vers, fn) |
|
20
|
|
|
|
|
21
|
|
|
def test_keys_curve_mnemonics(): |
|
22
|
|
|
l = lasio.read(egfn("sample.las")) |
|
23
|
|
|
# DEPT.M : 1 DEPTH |
|
24
|
|
|
# DT .US/M : 2 SONIC TRANSIT TIME |
|
25
|
|
|
# RHOB.K/M3 : 3 BULK DENSITY |
|
26
|
|
|
# NPHI.V/V : 4 NEUTRON POROSITY |
|
27
|
|
|
# SFLU.OHMM : 5 RXO RESISTIVITY |
|
28
|
|
|
# SFLA.OHMM : 6 SHALLOW RESISTIVITY |
|
29
|
|
|
# ILM .OHMM : 7 MEDIUM RESISTIVITY |
|
30
|
|
|
# ILD .OHMM : 8 DEEP RESISTIVITY |
|
31
|
|
|
assert l.keys() == ['DEPT', 'DT', 'RHOB', 'NPHI', 'SFLU', 'SFLA', 'ILM', 'ILD'] |
|
32
|
|
|
|
|
33
|
|
|
def test_LASFile_getitem(): |
|
34
|
|
|
l = lasio.read(egfn("sample.las")) |
|
35
|
|
|
assert np.all(l['DT'] == [123.45, 123.45, 123.45]) |
|
36
|
|
|
|
|
37
|
|
|
def test_LASFile_getitem_int(): |
|
38
|
|
|
l = lasio.read(egfn("sample.las")) |
|
39
|
|
|
assert np.all(l[1] == [123.45, 123.45, 123.45]) |
|
40
|
|
|
|
|
41
|
|
|
def test_LASFile_getitem_int_negative(): |
|
42
|
|
|
l = lasio.read(egfn("sample.las")) |
|
43
|
|
|
assert np.all(l[-2] == [110.2, 110.2, 110.2]) |
|
44
|
|
|
|
|
45
|
|
|
def test_data_array_slice(): |
|
46
|
|
|
l = lasio.read(egfn("sample.las")) |
|
47
|
|
|
assert np.all(l[1] == l.data[:, 1]) |
|
48
|
|
|
|
|
49
|
|
|
def test_curves_attribute(): |
|
50
|
|
|
l = lasio.read(egfn("sample.las")) |
|
51
|
|
|
assert isinstance(l.curves[1], las.CurveItem) |
|
52
|
|
|
|
|
53
|
|
|
def test_get_curves_method(): |
|
54
|
|
|
l = lasio.read(egfn("sample.las")) |
|
55
|
|
|
assert l.get_curve('DT') == l.curves[1] |
|
56
|
|
|
|
|
57
|
|
|
def test_missing_lasfile_mnemonic(): |
|
58
|
|
|
las = lasio.read(egfn('sample.las')) |
|
59
|
|
|
with pytest.raises(KeyError): |
|
60
|
|
|
las['blahblahblah'] |
|
61
|
|
|
|
|
62
|
|
|
def test_append_curve_and_item(): |
|
63
|
|
|
las = lasio.LASFile() |
|
64
|
|
|
data = [1, 2, 3] |
|
65
|
|
|
las.append_curve('TEST1', data=data) |
|
66
|
|
|
las.append_curve_item(lasio.CurveItem('TEST2', data=data)) |
|
67
|
|
|
assert (las['TEST1'] == las['TEST2']).all() |
|
68
|
|
|
|
|
69
|
|
|
def test_data_attr(): |
|
70
|
|
|
las = lasio.LASFile() |
|
71
|
|
|
las.append_curve('TEST1', data=[1, 2, 3]) |
|
72
|
|
|
las.append_curve_item(lasio.CurveItem('TEST2', data=[4, 5, 6])) |
|
73
|
|
|
las.append_curve('TEST3', data=[7, 8, 9]) |
|
74
|
|
|
logger.debug('las.data = {}'.format(las.data)) |
|
75
|
|
|
# the .all() method assumes these are numpy ndarrays; that should be the case. |
|
76
|
|
|
assert (las.data == np.asarray([[1, 4, 7], [2, 5, 8], [3, 6, 9]])).all() |