Skip to content

Commit 7a5d457

Browse files
Merge branch 'SC-1698' into 'develop'
SC-1698: Fix well attributes and comments conversion and rounding See merge request SOLO-band/python-sdk!87
2 parents ab57aa7 + 7a67f60 commit 7a5d457

File tree

5 files changed

+273
-18
lines changed

5 files changed

+273
-18
lines changed

src/rogii_solo/comment.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def comment_boxes(self) -> ObjectRepository['CommentBox']:
3838
class CommentBox(BaseObject):
3939
def __init__(self, comment: Comment, **kwargs):
4040
self.comment = comment
41-
self.measure_units = comment.well.project.measure_unit
4241

4342
self.commentbox_id = None
4443
self.text = None
@@ -47,12 +46,14 @@ def __init__(self, comment: Comment, **kwargs):
4746
self.__dict__.update(kwargs)
4847

4948
def to_dict(self, get_converted: bool = True) -> Dict[str, Any]:
49+
measure_units = self.comment.well.project.measure_unit
50+
5051
return {
5152
'commentbox_id': self.commentbox_id,
5253
'text': self.text,
53-
'anchor_md': self.convert_z(value=self.anchor_md, measure_units=self.measure_units)
54-
if get_converted
55-
else self.anchor_md,
54+
'anchor_md': self.safe_round(
55+
self.convert_z(value=self.anchor_md, measure_units=measure_units) if get_converted else self.anchor_md
56+
),
5657
}
5758

5859
def to_df(self, get_converted: bool = True) -> DataFrame:

src/rogii_solo/well.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def comments(self) -> ObjectRepository[Comment]:
307307
@property
308308
def attributes(self) -> 'WellAttributes':
309309
if self._attributes is None:
310-
self._attributes = WellAttributes(**self._get_attributes_data())
310+
self._attributes = WellAttributes(well=self, **self._get_attributes_data())
311311

312312
return self._attributes
313313

@@ -435,14 +435,34 @@ def update_meta(
435435

436436

437437
class WellAttributes(BaseObject):
438-
def __init__(self, **kwargs):
438+
def __init__(self, well: Well, **kwargs):
439+
self.well = well
440+
439441
self.__dict__.update(kwargs)
440442

441-
def to_dict(self) -> Dict:
442-
return self.__dict__
443+
def to_dict(self, get_converted: bool = True) -> Dict:
444+
measure_units = self.well.project.measure_unit
445+
data = self.__dict__
446+
447+
return {
448+
'Name': data['Name'],
449+
'API': data['API'],
450+
'Operator': data['Operator'],
451+
'KB': self.safe_round(
452+
self.convert_z(value=data['KB'], measure_units=measure_units) if get_converted else data['KB']
453+
),
454+
'Azimuth VS': self.safe_round(
455+
self.convert_angle(data['Azimuth VS']) if get_converted else data['Azimuth VS']
456+
),
457+
'Convergence': self.safe_round(
458+
self.convert_angle(data['Convergence']) if get_converted else data['Convergence']
459+
),
460+
'X-srf': self.safe_round(data['X-srf'] if get_converted else feet_to_meters(data['X-srf'])),
461+
'Y-srf': self.safe_round(data['Y-srf'] if get_converted else feet_to_meters(data['Y-srf'])),
462+
}
443463

444-
def to_df(self) -> DataFrame:
445-
return DataFrame(self.to_dict(), index=[0])
464+
def to_df(self, get_converted: bool = True) -> DataFrame:
465+
return DataFrame(self.to_dict(get_converted), index=[0])
446466

447467

448468
class NestedWell(ComplexObject):

tests/main/test_data_conversion.py

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,3 +1158,228 @@ def test_get_not_converted_ftm_earth_model(ftm_project):
11581158
for idx, layer in enumerate(layers):
11591159
# Must be changed when public method with layer tvd is available
11601160
assert np_is_close(layers_data[idx]['tvt'], layer.tvt)
1161+
1162+
1163+
def test_get_converted_meter_well_attributes(project):
1164+
well = project.wells.find_by_name(WELL_NAME)
1165+
assert well is not None
1166+
1167+
well_data = well.to_dict()
1168+
assert well_data
1169+
1170+
attributes = well.attributes
1171+
assert attributes is not None
1172+
1173+
attributes_data = attributes.to_dict()
1174+
assert attributes_data
1175+
1176+
assert np_is_close(well_data['kb'], attributes_data['KB'])
1177+
assert np_is_close(well_data['azimuth'], attributes_data['Azimuth VS'])
1178+
assert np_is_close(well_data['convergence'], attributes_data['Convergence'])
1179+
assert np_is_close(well_data['xsrf_real'], attributes_data['X-srf'])
1180+
assert np_is_close(well_data['ysrf_real'], attributes_data['Y-srf'])
1181+
1182+
1183+
def test_get_not_converted_meter_well_attributes(project):
1184+
well = project.wells.find_by_name(WELL_NAME)
1185+
assert well is not None
1186+
1187+
well_data = well.to_dict(get_converted=False)
1188+
assert well_data
1189+
1190+
attributes = well.attributes
1191+
assert attributes is not None
1192+
1193+
attributes_data = attributes.to_dict(get_converted=False)
1194+
assert attributes_data
1195+
1196+
assert np_is_close(well_data['kb'], attributes_data['KB'])
1197+
assert np_is_close(well_data['azimuth'], attributes_data['Azimuth VS'])
1198+
assert np_is_close(well_data['convergence'], attributes_data['Convergence'])
1199+
assert np_is_close(well_data['xsrf_real'], attributes_data['X-srf'])
1200+
assert np_is_close(well_data['ysrf_real'], attributes_data['Y-srf'])
1201+
1202+
1203+
def test_get_converted_foot_well_attributes(ft_project):
1204+
well = ft_project.wells.find_by_name(WELL_NAME)
1205+
assert well is not None
1206+
1207+
well_data = well.to_dict()
1208+
assert well_data
1209+
1210+
attributes = well.attributes
1211+
assert attributes is not None
1212+
1213+
attributes_data = attributes.to_dict()
1214+
assert attributes_data
1215+
1216+
assert np_is_close(well_data['kb'], attributes_data['KB'])
1217+
assert np_is_close(well_data['azimuth'], attributes_data['Azimuth VS'])
1218+
assert np_is_close(well_data['convergence'], attributes_data['Convergence'])
1219+
assert np_is_close(well_data['xsrf_real'], attributes_data['X-srf'])
1220+
assert np_is_close(well_data['ysrf_real'], attributes_data['Y-srf'])
1221+
1222+
1223+
def test_get_not_converted_foot_well_attributes(ft_project):
1224+
well = ft_project.wells.find_by_name(WELL_NAME)
1225+
assert well is not None
1226+
1227+
well_data = well.to_dict(get_converted=False)
1228+
assert well_data
1229+
1230+
attributes = well.attributes
1231+
assert attributes is not None
1232+
1233+
attributes_data = attributes.to_dict(get_converted=False)
1234+
assert attributes_data
1235+
1236+
assert np_is_close(well_data['kb'], attributes_data['KB'])
1237+
assert np_is_close(well_data['azimuth'], attributes_data['Azimuth VS'])
1238+
assert np_is_close(well_data['convergence'], attributes_data['Convergence'])
1239+
assert np_is_close(well_data['xsrf_real'], attributes_data['X-srf'])
1240+
assert np_is_close(well_data['ysrf_real'], attributes_data['Y-srf'])
1241+
1242+
1243+
def test_get_converted_ftm_well_attributes(ftm_project):
1244+
well = ftm_project.wells.find_by_name(WELL_NAME)
1245+
assert well is not None
1246+
1247+
well_data = well.to_dict()
1248+
assert well_data
1249+
1250+
attributes = well.attributes
1251+
assert attributes is not None
1252+
1253+
attributes_data = attributes.to_dict()
1254+
assert attributes_data
1255+
1256+
assert np_is_close(well_data['kb'], attributes_data['KB'])
1257+
assert np_is_close(well_data['azimuth'], attributes_data['Azimuth VS'])
1258+
assert np_is_close(well_data['convergence'], attributes_data['Convergence'])
1259+
assert np_is_close(well_data['xsrf_real'], attributes_data['X-srf'])
1260+
assert np_is_close(well_data['ysrf_real'], attributes_data['Y-srf'])
1261+
1262+
1263+
def test_get_not_converted_ftm_well_attributes(ftm_project):
1264+
well = ftm_project.wells.find_by_name(WELL_NAME)
1265+
assert well is not None
1266+
1267+
well_data = well.to_dict(get_converted=False)
1268+
assert well_data
1269+
1270+
attributes = well.attributes
1271+
assert attributes is not None
1272+
1273+
attributes_data = attributes.to_dict(get_converted=False)
1274+
assert attributes_data
1275+
1276+
assert np_is_close(well_data['kb'], attributes_data['KB'])
1277+
assert np_is_close(well_data['azimuth'], attributes_data['Azimuth VS'])
1278+
assert np_is_close(well_data['convergence'], attributes_data['Convergence'])
1279+
assert np_is_close(well_data['xsrf_real'], attributes_data['X-srf'])
1280+
assert np_is_close(well_data['ysrf_real'], attributes_data['Y-srf'])
1281+
1282+
1283+
def test_get_converted_meter_comment_box(project):
1284+
well = project.wells.find_by_name(WELL_NAME)
1285+
assert well is not None
1286+
1287+
comments = well.comments
1288+
assert comments is not None
1289+
1290+
comment_box = comments[0].comment_boxes[0]
1291+
assert comment_box is not None
1292+
1293+
comment_box_data = comment_box.to_dict()
1294+
assert comment_box_data
1295+
1296+
assert np_is_close(
1297+
comment_box_data['anchor_md'],
1298+
Convertible.convert_z(value=comment_box.anchor_md, measure_units=project.measure_unit),
1299+
)
1300+
1301+
1302+
def test_get_not_converted_meter_comment_box(project):
1303+
well = project.wells.find_by_name(WELL_NAME)
1304+
assert well is not None
1305+
1306+
comments = well.comments
1307+
assert comments is not None
1308+
1309+
comment_box = comments[0].comment_boxes[0]
1310+
assert comment_box is not None
1311+
1312+
comment_box_data = comment_box.to_dict(get_converted=False)
1313+
assert comment_box_data
1314+
1315+
assert np_is_close(comment_box_data['anchor_md'], comment_box.anchor_md)
1316+
1317+
1318+
def test_get_converted_ft_comment_box(ft_project):
1319+
well = ft_project.wells.find_by_name(WELL_NAME)
1320+
assert well is not None
1321+
1322+
comments = well.comments
1323+
assert comments is not None
1324+
1325+
comment_box = comments[0].comment_boxes[0]
1326+
assert comment_box is not None
1327+
1328+
comment_box_data = comment_box.to_dict()
1329+
assert comment_box_data
1330+
1331+
assert np_is_close(
1332+
comment_box_data['anchor_md'],
1333+
Convertible.convert_z(value=comment_box.anchor_md, measure_units=ft_project.measure_unit),
1334+
)
1335+
1336+
1337+
def test_get_not_converted_ft_comment_box(ft_project):
1338+
well = ft_project.wells.find_by_name(WELL_NAME)
1339+
assert well is not None
1340+
1341+
comments = well.comments
1342+
assert comments is not None
1343+
1344+
comment_box = comments[0].comment_boxes[0]
1345+
assert comment_box is not None
1346+
1347+
comment_box_data = comment_box.to_dict(get_converted=False)
1348+
assert comment_box_data
1349+
1350+
assert np_is_close(comment_box_data['anchor_md'], comment_box.anchor_md)
1351+
1352+
1353+
def test_get_converted_ftm_comment_box(ftm_project):
1354+
well = ftm_project.wells.find_by_name(WELL_NAME)
1355+
assert well is not None
1356+
1357+
comments = well.comments
1358+
assert comments is not None
1359+
1360+
comment_box = comments[0].comment_boxes[0]
1361+
assert comment_box is not None
1362+
1363+
comment_box_data = comment_box.to_dict()
1364+
assert comment_box_data
1365+
1366+
assert np_is_close(
1367+
comment_box_data['anchor_md'],
1368+
Convertible.convert_z(value=comment_box.anchor_md, measure_units=ftm_project.measure_unit),
1369+
)
1370+
1371+
1372+
def test_get_not_converted_ftm_comment_box(ftm_project):
1373+
well = ftm_project.wells.find_by_name(WELL_NAME)
1374+
assert well is not None
1375+
1376+
comments = well.comments
1377+
assert comments is not None
1378+
1379+
comment_box = comments[0].comment_boxes[0]
1380+
assert comment_box is not None
1381+
1382+
comment_box_data = comment_box.to_dict(get_converted=False)
1383+
assert comment_box_data
1384+
1385+
assert np_is_close(comment_box_data['anchor_md'], comment_box.anchor_md)

tests/main/test_solo_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,15 @@ def test_get_well_attributes(project):
620620
assert attributes_data
621621
assert not attributes_df.empty
622622

623+
assert attributes_data['Name']
624+
assert attributes_data['API']
625+
assert attributes_data['Operator']
626+
assert attributes_data['KB']
627+
assert attributes_data['Azimuth VS']
628+
assert attributes_data['Convergence']
629+
assert attributes_data['X-srf']
630+
assert attributes_data['Y-srf']
631+
623632

624633
def test_get_earth_model(project):
625634
starred_interpretation = project.wells.find_by_name(WELL_NAME).starred_interpretation

tests/papi_data.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,12 +1641,12 @@
16411641
{
16421642
'commentbox_id': '3e277460-4156-496d-850c-48e64ab8b273',
16431643
'text': 'Comment Text 1',
1644-
'anchor_md': {'val': 2375.2755905511813},
1644+
'anchor_md': {'val': 9999.999999998},
16451645
},
16461646
{
16471647
'commentbox_id': '7a31617e-393e-4cda-9fd5-bdeec1a08222',
16481648
'text': 'Comment Text 2',
1649-
'anchor_md': {'val': 2375.2755905511813},
1649+
'anchor_md': {'val': 9999.999999998},
16501650
},
16511651
],
16521652
},
@@ -1660,15 +1660,15 @@
16601660
}
16611661

16621662
WELL_ATTRIBUTES_DATA_RESPONSE = {
1663-
'Name': {'value': 'nameWell', 'attribute_id': 1},
1663+
'Name': {'value': WELL_NAME, 'attribute_id': 1},
16641664
'API': {'value': 'api', 'attribute_id': 2},
16651665
'Well Type': {'value': 'Deviated', 'attribute_id': 3},
16661666
'Operator': {'value': 'operator', 'attribute_id': 4},
1667-
'KB': {'value': {'val': 1.0}, 'attribute_id': 7},
1668-
'Azimuth VS': {'value': {'val': 2.0}, 'attribute_id': 8},
1669-
'Convergence': {'value': {'val': 3.0}, 'attribute_id': 9},
1670-
'X-srf': {'value': {'val': 13.123359580052492}, 'attribute_id': 12},
1671-
'Y-srf': {'value': {'val': 16.404199475065617}, 'attribute_id': 13},
1667+
'KB': {'value': {'val': WELL_KB}, 'attribute_id': 7},
1668+
'Azimuth VS': {'value': {'val': WELL_AZIMUTH}, 'attribute_id': 8},
1669+
'Convergence': {'value': {'val': WELL_CONVERGENCE}, 'attribute_id': 9},
1670+
'X-srf': {'value': {'val': WELL_XSRF_REAL}, 'attribute_id': 12},
1671+
'Y-srf': {'value': {'val': WELL_YSRF_REAL}, 'attribute_id': 13},
16721672
'Spud date': {'value': '2022-11-17T13:15:31.000+00:00', 'attribute_id': 17},
16731673
'# of Stages': {'value': 43, 'attribute_id': 43},
16741674
'Final TVD': {'value': {'val': 0.49}, 'attribute_id': 49},

0 commit comments

Comments
 (0)