Skip to content

Commit

Permalink
Update to utilize to make callbacks easier. Bump version. Update unit…
Browse files Browse the repository at this point in the history
… tests to automate in vscode. Update volve example to use new .
  • Loading branch information
jonnymaserati committed Jan 6, 2024
1 parent d05ed05 commit 077e11c
Show file tree
Hide file tree
Showing 11 changed files with 667 additions and 628 deletions.
8 changes: 6 additions & 2 deletions examples/volve_wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@

# create a trimesh scene and plot with welleng plotter
print("Making a scene and plotting...")
scene = we.mesh.make_trimesh_scene(data)
we.visual.plot(scene)
plt = we.visual.Plotter()
for well in data.values():
plt.add(well)
plt.show()
# scene = we.mesh.make_trimesh_scene(data)
# we.visual.plot(scene)

##########################################################################
# if you wanted to export a transformed scene so that you can, for example
Expand Down
131 changes: 66 additions & 65 deletions tests/test_clearance_iscwsa.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import unittest
from welleng.survey import Survey, make_survey_header
from welleng.clearance import IscwsaClearance
import numpy as np
Expand All @@ -16,7 +17,7 @@
data = json.load(open(filename))


def generate_surveys(data):
def generate_surveys(self, data=data):
# Generate surveys for imported wells
surveys = {}

Expand Down Expand Up @@ -56,74 +57,74 @@ def generate_surveys(data):
return surveys


def test_minimize_sf(data=data):
surveys = generate_surveys(data)
reference = surveys["Reference well"]
offset = surveys["09 - well"]

result = IscwsaClearance(reference, offset, minimize_sf=False)
result_min = IscwsaClearance(reference, offset, minimize_sf=True)

idx = np.where(result_min.ref.interpolated == False)

# Check that interpolated survey is not corrupted
for attr in [
'azi_grid_rad', 'azi_mag_rad', 'azi_true_rad', 'cov_hla', 'cov_nev',
'pos_nev', 'pos_xyz', 'md', 'radius'
]:
assert np.allclose(
getattr(result.ref, attr), getattr(result_min.ref, attr)[idx]
)

pass

for attr in [
'Rr', 'calc_hole', 'distance_cc', 'eou_boundary',
'eou_separation', 'hoz_bearing', 'idx', 'masd', 'off_cov_hla',
'off_cov_nev', 'off_delta_hlas', 'off_delta_nevs', 'off_pcr',
'ref_cov_hla', 'ref_cov_nev', 'ref_delta_hlas', 'ref_delta_nevs',
'ref_nevs', 'ref_pcr', 'sf', 'wellbore_separation'
]:
# `toolface_bearing` and `trav_cyl_azi_deg` are a bit unstable when
# well paths are parallel.

assert np.allclose(
getattr(result, attr), getattr(result_min, attr)[idx],
rtol=1e-01, atol=1e-02
)

pass


def test_clearance_iscwsa(data=data, rtol=1e-02, atol=1e-03):
surveys = generate_surveys(data)
reference = surveys["Reference well"]

# Perform clearance checks for each survey
for well in surveys:
if well != "09 - well":
continue
if well == "Reference well":
continue
else:
offset = surveys[well]
# skip well 10
if well in ["10 - well"]:
class TestClearanceIscwsa(unittest.TestCase):
def test_minimize_sf(self, data=data):
surveys = generate_surveys(data)
reference = surveys["Reference well"]
offset = surveys["09 - well"]

result = IscwsaClearance(reference, offset, minimize_sf=False)
result_min = IscwsaClearance(reference, offset, minimize_sf=True)

idx = np.where(result_min.ref.interpolated == False)

# Check that interpolated survey is not corrupted
for attr in [
'azi_grid_rad', 'azi_mag_rad', 'azi_true_rad', 'cov_hla', 'cov_nev',
'pos_nev', 'pos_xyz', 'md', 'radius'
]:
assert np.allclose(
getattr(result.ref, attr), getattr(result_min.ref, attr)[idx]
)

pass

for attr in [
'Rr', 'calc_hole', 'distance_cc', 'eou_boundary',
'eou_separation', 'hoz_bearing', 'idx', 'masd', 'off_cov_hla',
'off_cov_nev', 'off_delta_hlas', 'off_delta_nevs', 'off_pcr',
'ref_cov_hla', 'ref_cov_nev', 'ref_delta_hlas', 'ref_delta_nevs',
'ref_nevs', 'ref_pcr', 'sf', 'wellbore_separation'
]:
# `toolface_bearing` and `trav_cyl_azi_deg` are a bit unstable when
# well paths are parallel.

assert np.allclose(
getattr(result, attr), getattr(result_min, attr)[idx],
rtol=1e-01, atol=1e-02
)

pass

def test_clearance_iscwsa(self, data=data, rtol=1e-02, atol=1e-03):
surveys = generate_surveys(data)
reference = surveys["Reference well"]

# Perform clearance checks for each survey
for well in surveys:
if well != "09 - well":
continue
if well == "Reference well":
continue
else:
for b in [False, True]:
result = IscwsaClearance(reference, offset, minimize_sf=b)
offset = surveys[well]
# skip well 10
if well in ["10 - well"]:
continue
else:
for b in [False, True]:
result = IscwsaClearance(reference, offset, minimize_sf=b)
assert np.allclose(
result.sf[np.where(result.ref.interpolated == False)],
np.array(data["wells"][well]["SF"]),
rtol=rtol, atol=atol
)

assert np.allclose(
result.sf[np.where(result.ref.interpolated == False)],
np.array(data["wells"][well]["SF"]),
rtol=rtol, atol=atol
)

pass
pass


# make above test runnanble separately
if __name__ == '__main__':
test_minimize_sf(data=data)
test_clearance_iscwsa(data=data)
unittest.main()
# test_minimize_sf(data=data)
# test_clearance_iscwsa(data=data)
Loading

0 comments on commit 077e11c

Please sign in to comment.