interpretation-models 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {interpretation_models-0.2.0/src/interpretation_models.egg-info → interpretation_models-0.4.0}/PKG-INFO +2 -1
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/pyproject.toml +3 -1
- {interpretation_models-0.2.0 → interpretation_models-0.4.0/src/interpretation_models.egg-info}/PKG-INFO +2 -1
- interpretation_models-0.4.0/src/interpretation_models.egg-info/SOURCES.txt +41 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/interpretation_models.egg-info/requires.txt +1 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/interpretation_models.egg-info/top_level.txt +2 -0
- interpretation_models-0.4.0/src/mappers/collection_ow.py +172 -0
- interpretation_models-0.4.0/src/mappers/metadata_ow.py +18 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/mappers/surfacegrid_ow.py +18 -10
- interpretation_models-0.4.0/src/models/collection.py +20 -0
- interpretation_models-0.4.0/src/models/enums.py +32 -0
- interpretation_models-0.4.0/src/models/interpretation.py +55 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/models/metadata.py +49 -37
- interpretation_models-0.4.0/src/schemas/__init__.py +6 -0
- interpretation_models-0.4.0/src/schemas/definitions/__init__.py +0 -0
- interpretation_models-0.4.0/src/schemas/definitions/v1/Collection.json +101 -0
- interpretation_models-0.4.0/src/schemas/definitions/v1/CollectionActivity.json +29 -0
- interpretation_models-0.4.0/src/schemas/definitions/v1/CollectionItem.json +137 -0
- interpretation_models-0.4.0/src/schemas/definitions/v1/SurfaceGrid.json +245 -0
- interpretation_models-0.4.0/src/schemas/registry.py +95 -0
- interpretation_models-0.4.0/src/tables/__init__.py +18 -0
- interpretation_models-0.4.0/src/tables/generate_schemas.py +98 -0
- interpretation_models-0.4.0/src/tables/model_to_table.py +192 -0
- interpretation_models-0.4.0/src/tables/table_definitions.py +89 -0
- interpretation_models-0.4.0/src/tables/tablespec.py +46 -0
- interpretation_models-0.4.0/tests/test_collection_mapping.py +265 -0
- interpretation_models-0.4.0/tests/test_collection_ow.py +62 -0
- interpretation_models-0.4.0/tests/test_metadata_mappers.py +33 -0
- interpretation_models-0.4.0/tests/test_schema_registry.py +59 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/tests/test_surface.py +2 -2
- interpretation_models-0.4.0/tests/test_surfacegrid_mapping.py +110 -0
- interpretation_models-0.2.0/src/interpretation_models.egg-info/SOURCES.txt +0 -21
- interpretation_models-0.2.0/src/mappers/metadata_ow.py +0 -7
- interpretation_models-0.2.0/src/models/interpretation.py +0 -39
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/LICENSE +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/README.md +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/setup.cfg +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/interpretation_models.egg-info/dependency_links.txt +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/mappers/__init__.py +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/mappers/surface_helpers.py +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/models/__init__.py +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/models/extent.py +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/models/py.typed +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/src/models/surfacegrid_eq_api.py +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/tests/test_extent.py +0 -0
- {interpretation_models-0.2.0 → interpretation_models-0.4.0}/tests/test_surfacegrid_json_validation.py +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: interpretation-models
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Interpretation models maintained by the SID team
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
License-File: LICENSE
|
|
8
8
|
Requires-Dist: dsis-schemas>=0.0.6
|
|
9
9
|
Requires-Dist: pydantic<3,>=2
|
|
10
|
+
Requires-Dist: pytz>=2026.1.post1
|
|
10
11
|
Dynamic: license-file
|
|
11
12
|
|
|
12
13
|
# Interpretation models
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "interpretation-models"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Interpretation models maintained by the SID team"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
dependencies = [
|
|
8
8
|
"dsis-schemas>=0.0.6",
|
|
9
9
|
"pydantic>=2, <3",
|
|
10
|
+
"pytz>=2026.1.post1",
|
|
10
11
|
]
|
|
11
12
|
|
|
12
13
|
[build-system]
|
|
@@ -18,6 +19,7 @@ where = ["src"]
|
|
|
18
19
|
|
|
19
20
|
[tool.setuptools.package-data]
|
|
20
21
|
"models" = ["py.typed"]
|
|
22
|
+
"schemas" = ["definitions/**/*.json"]
|
|
21
23
|
|
|
22
24
|
[dependency-groups]
|
|
23
25
|
dev = [
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: interpretation-models
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Interpretation models maintained by the SID team
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
License-File: LICENSE
|
|
8
8
|
Requires-Dist: dsis-schemas>=0.0.6
|
|
9
9
|
Requires-Dist: pydantic<3,>=2
|
|
10
|
+
Requires-Dist: pytz>=2026.1.post1
|
|
10
11
|
Dynamic: license-file
|
|
11
12
|
|
|
12
13
|
# Interpretation models
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/interpretation_models.egg-info/PKG-INFO
|
|
5
|
+
src/interpretation_models.egg-info/SOURCES.txt
|
|
6
|
+
src/interpretation_models.egg-info/dependency_links.txt
|
|
7
|
+
src/interpretation_models.egg-info/requires.txt
|
|
8
|
+
src/interpretation_models.egg-info/top_level.txt
|
|
9
|
+
src/mappers/__init__.py
|
|
10
|
+
src/mappers/collection_ow.py
|
|
11
|
+
src/mappers/metadata_ow.py
|
|
12
|
+
src/mappers/surface_helpers.py
|
|
13
|
+
src/mappers/surfacegrid_ow.py
|
|
14
|
+
src/models/__init__.py
|
|
15
|
+
src/models/collection.py
|
|
16
|
+
src/models/enums.py
|
|
17
|
+
src/models/extent.py
|
|
18
|
+
src/models/interpretation.py
|
|
19
|
+
src/models/metadata.py
|
|
20
|
+
src/models/py.typed
|
|
21
|
+
src/models/surfacegrid_eq_api.py
|
|
22
|
+
src/schemas/__init__.py
|
|
23
|
+
src/schemas/registry.py
|
|
24
|
+
src/schemas/definitions/__init__.py
|
|
25
|
+
src/schemas/definitions/v1/Collection.json
|
|
26
|
+
src/schemas/definitions/v1/CollectionActivity.json
|
|
27
|
+
src/schemas/definitions/v1/CollectionItem.json
|
|
28
|
+
src/schemas/definitions/v1/SurfaceGrid.json
|
|
29
|
+
src/tables/__init__.py
|
|
30
|
+
src/tables/generate_schemas.py
|
|
31
|
+
src/tables/model_to_table.py
|
|
32
|
+
src/tables/table_definitions.py
|
|
33
|
+
src/tables/tablespec.py
|
|
34
|
+
tests/test_collection_mapping.py
|
|
35
|
+
tests/test_collection_ow.py
|
|
36
|
+
tests/test_extent.py
|
|
37
|
+
tests/test_metadata_mappers.py
|
|
38
|
+
tests/test_schema_registry.py
|
|
39
|
+
tests/test_surface.py
|
|
40
|
+
tests/test_surfacegrid_json_validation.py
|
|
41
|
+
tests/test_surfacegrid_mapping.py
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
from models.metadata import SourceContext
|
|
5
|
+
from models.enums import SourceSystem, OWDataType, InterpretationDataType
|
|
6
|
+
from models.metadata import SourceMetadata, ProcessingMetadata, OWCollectionMetadata, OWCollectionItemMetadata, InterpretationProcessingMetadata
|
|
7
|
+
from models.collection import Collection, CollectionItem
|
|
8
|
+
from mappers.metadata_ow import convert_date_to_utc, id_generate
|
|
9
|
+
from dsis_model_sdk.models.native import InterpretationSet, ISetDataObject
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def map_collection(
|
|
13
|
+
ow_iset: InterpretationSet,
|
|
14
|
+
source_context: SourceContext,
|
|
15
|
+
processing_metadata: InterpretationProcessingMetadata | None = None,
|
|
16
|
+
) -> Collection:
|
|
17
|
+
"""Map an OW InterpretationSet to a Collection.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
ow_iset: DSIS CommonModel interpretation set object to convert
|
|
21
|
+
source_context: SourceContext with database/project info
|
|
22
|
+
processing_metadata: optional processing metadata (UUIDs, timestamps, etc.)
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
Collection instance
|
|
26
|
+
"""
|
|
27
|
+
if ow_iset.update_date is None:
|
|
28
|
+
ow_iset.update_date = ow_iset.create_date
|
|
29
|
+
ow_iset.update_user_id = ow_iset.create_user_id
|
|
30
|
+
|
|
31
|
+
source_metadata = SourceMetadata(
|
|
32
|
+
id=id_generate(source_context, ow_iset.interpretation_set_id),
|
|
33
|
+
system=SourceSystem.OPENWORKS,
|
|
34
|
+
database=source_context.database,
|
|
35
|
+
project=source_context.project,
|
|
36
|
+
name=ow_iset.interpret_set_name,
|
|
37
|
+
remark=ow_iset.remark,
|
|
38
|
+
|
|
39
|
+
create_user=ow_iset.create_user_id,
|
|
40
|
+
update_user=ow_iset.update_user_id,
|
|
41
|
+
create_date=ow_iset.create_date,
|
|
42
|
+
create_date_utc=convert_date_to_utc(
|
|
43
|
+
ow_iset.create_date, source_context.timezone
|
|
44
|
+
) if ow_iset.create_date is not None else None,
|
|
45
|
+
update_date=ow_iset.update_date,
|
|
46
|
+
update_date_utc=convert_date_to_utc(
|
|
47
|
+
ow_iset.update_date, source_context.timezone
|
|
48
|
+
) if ow_iset.update_date is not None else None,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
source_ow_metadata = OWCollectionMetadata(
|
|
52
|
+
field_prospect_name=ow_iset.field_prospect_name,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
return Collection(
|
|
56
|
+
id=id_generate(source_context, ow_iset.interpretation_set_id),
|
|
57
|
+
source=source_metadata,
|
|
58
|
+
source_ow=source_ow_metadata,
|
|
59
|
+
processing=processing_metadata
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def map_dataobject_datatype(ow_datatype: OWDataType) -> InterpretationDataType:
|
|
64
|
+
mapping = {
|
|
65
|
+
OWDataType.MAP2D: InterpretationDataType.SURFACE_GRID,
|
|
66
|
+
OWDataType.RGRID: InterpretationDataType.SURFACE_GRID,
|
|
67
|
+
OWDataType.HORIZON3D: InterpretationDataType.HORIZON,
|
|
68
|
+
OWDataType.POLYGON_SET: InterpretationDataType.POLYGON,
|
|
69
|
+
OWDataType.POINT_SET: InterpretationDataType.POINT_SET,
|
|
70
|
+
}
|
|
71
|
+
return mapping.get(ow_datatype, InterpretationDataType.OTHERS)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _resolve_map2d_grid_id(native_uid: str | None) -> str:
|
|
75
|
+
if native_uid is None:
|
|
76
|
+
return ""
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
native_uid_data = json.loads(native_uid)
|
|
80
|
+
except (TypeError, json.JSONDecodeError):
|
|
81
|
+
return ""
|
|
82
|
+
|
|
83
|
+
data_key = native_uid_data.get("data_key") if isinstance(native_uid_data, dict) else None
|
|
84
|
+
if not isinstance(data_key, str):
|
|
85
|
+
return ""
|
|
86
|
+
|
|
87
|
+
match = re.search(r"(?:^|;)gridId=([^;]+)", data_key)
|
|
88
|
+
return match.group(1).strip() if match and match.group(1).strip() else ""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def resolve_id(ow_data_object: ISetDataObject) -> str:
|
|
92
|
+
"""
|
|
93
|
+
SurfaceGrids in ISetDataObjects can be of type Map2D or RGrid.
|
|
94
|
+
Rgrids are the simpler original grid type, which correponds to a simple grid, with the id set to the data object id.
|
|
95
|
+
Map2D objects are created when the user drags a "Grid & Contour" object into the ISet.
|
|
96
|
+
The Map2D is a container and contains a reference to the Rgrid object plus a polygon with its contour.
|
|
97
|
+
Therefore, the data object id associated with it, is not the id of the grid, but of the container.
|
|
98
|
+
For the Map2D objects, the grid_id of the internal surface is extracted from the native_uid, which is a json-like string.
|
|
99
|
+
We thus have to first get the value of the key "data_key", which is itself a list of property=value pairs
|
|
100
|
+
encoded in a colon-separated string. We then extract the gridId property value from that list using a regexp.
|
|
101
|
+
In the future, other dtataypes may need to be parsed for exceptions in their ids as well.
|
|
102
|
+
"""
|
|
103
|
+
if ow_data_object.data_type == OWDataType.MAP2D.value:
|
|
104
|
+
return _resolve_map2d_grid_id(ow_data_object.native_uid)
|
|
105
|
+
|
|
106
|
+
# for objects other than Map2D, we assume the data object id is the direct id of the intended object
|
|
107
|
+
if not ow_data_object.data_object_id:
|
|
108
|
+
return ""
|
|
109
|
+
return str(ow_data_object.data_object_id)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def map_collection_item(
|
|
113
|
+
ow_data_object: ISetDataObject,
|
|
114
|
+
source_context: SourceContext,
|
|
115
|
+
processing_metadata: ProcessingMetadata | None = None,
|
|
116
|
+
) -> CollectionItem:
|
|
117
|
+
"""Map an OW ISetDataObject to a CollectionItem.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
ow_data_object: DSIS native ISetDataObject to convert
|
|
121
|
+
collection_id: processing_id of the parent Collection
|
|
122
|
+
source_context: SourceContext with database/project info
|
|
123
|
+
processing_metadata: optional processing metadata (UUIDs, timestamps, etc.)
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
CollectionItem instance
|
|
127
|
+
"""
|
|
128
|
+
if ow_data_object.update_date is None:
|
|
129
|
+
ow_data_object.update_date = ow_data_object.create_date
|
|
130
|
+
ow_data_object.update_user_id = ow_data_object.create_user_id
|
|
131
|
+
|
|
132
|
+
ow_id: str = str(ow_data_object.data_object_id) if ow_data_object.data_object_id else ow_data_object.data_key
|
|
133
|
+
source_metadata = SourceMetadata(
|
|
134
|
+
system=SourceSystem.OPENWORKS,
|
|
135
|
+
database=source_context.database,
|
|
136
|
+
project=source_context.project,
|
|
137
|
+
id=ow_id,
|
|
138
|
+
name=ow_data_object.data_object_name,
|
|
139
|
+
remark=ow_data_object.remark,
|
|
140
|
+
create_user=ow_data_object.create_user_id,
|
|
141
|
+
update_user=ow_data_object.update_user_id,
|
|
142
|
+
create_date=ow_data_object.create_date,
|
|
143
|
+
create_date_utc=convert_date_to_utc(
|
|
144
|
+
ow_data_object.create_date, source_context.timezone
|
|
145
|
+
) if ow_data_object.create_date is not None else None,
|
|
146
|
+
update_date=ow_data_object.update_date,
|
|
147
|
+
update_date_utc=convert_date_to_utc(
|
|
148
|
+
ow_data_object.update_date, source_context.timezone
|
|
149
|
+
) if ow_data_object.update_date is not None else None,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
source_ow_metadata = OWCollectionItemMetadata(
|
|
153
|
+
data_type=ow_data_object.data_type,
|
|
154
|
+
data_key=ow_data_object.data_key,
|
|
155
|
+
interpretation_set_id=ow_data_object.interpretation_set_id,
|
|
156
|
+
iset_folder_id=ow_data_object.iset_folder_id,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
ow_datatype: OWDataType = OWDataType(ow_data_object.data_type) if ow_data_object.data_type in OWDataType._value2member_map_ else OWDataType.OTHERS
|
|
160
|
+
resolved_datatype: InterpretationDataType = map_dataobject_datatype(ow_datatype)
|
|
161
|
+
resolved_id = resolve_id(ow_data_object)
|
|
162
|
+
collection_id = ow_data_object.interpretation_set_id
|
|
163
|
+
|
|
164
|
+
return CollectionItem(
|
|
165
|
+
id = id_generate(source_context, f"Collection:{collection_id}:{resolved_datatype.value}:{resolved_id}"),
|
|
166
|
+
collection_id=id_generate(source_context, collection_id),
|
|
167
|
+
object_id=id_generate(source_context, resolved_id),
|
|
168
|
+
datatype=resolved_datatype,
|
|
169
|
+
source=source_metadata,
|
|
170
|
+
source_ow=source_ow_metadata,
|
|
171
|
+
processing=processing_metadata,
|
|
172
|
+
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from models.metadata import SourceContext
|
|
3
|
+
import pytz
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def id_generate(
|
|
7
|
+
context: SourceContext, native_id: str
|
|
8
|
+
) -> str:
|
|
9
|
+
return f"{context.database}:{context.project}:{native_id}"
|
|
10
|
+
|
|
11
|
+
def convert_date_to_utc(
|
|
12
|
+
date: datetime.datetime, timezone: str | None = None
|
|
13
|
+
) -> datetime.datetime | None:
|
|
14
|
+
if timezone is None:
|
|
15
|
+
return date
|
|
16
|
+
local_tz = pytz.timezone(timezone)
|
|
17
|
+
local_dt = local_tz.localize(date) if date.tzinfo is None else date.astimezone(local_tz)
|
|
18
|
+
return local_dt.astimezone(pytz.utc)
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import math
|
|
2
2
|
|
|
3
3
|
from models.metadata import SourceContext
|
|
4
|
-
from models.
|
|
4
|
+
from models.enums import SourceSystem
|
|
5
|
+
from models.metadata import SourceMetadata, OWSurfaceGridMetadata, InterpretationProcessingMetadata
|
|
5
6
|
from models.interpretation import GridGeometry
|
|
6
7
|
from models.interpretation import SurfaceGridRecord
|
|
7
|
-
from mappers.metadata_ow import convert_date_to_utc
|
|
8
|
+
from mappers.metadata_ow import convert_date_to_utc, id_generate
|
|
8
9
|
from dsis_model_sdk.models.common import SurfaceGrid, SurfaceGridProperties
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def map_surfacegrid(
|
|
12
13
|
ow_surface: SurfaceGrid | SurfaceGridProperties,
|
|
13
14
|
source_context: SourceContext,
|
|
14
|
-
processing_metadata:
|
|
15
|
+
processing_metadata: InterpretationProcessingMetadata | None = None,
|
|
15
16
|
) -> SurfaceGridRecord:
|
|
16
17
|
"""Map an OW SurfaceGrid to a SurfaceGridRecord.
|
|
17
18
|
|
|
@@ -26,6 +27,7 @@ def map_surfacegrid(
|
|
|
26
27
|
if ow_surface.update_date is None:
|
|
27
28
|
ow_surface.update_date = ow_surface.create_date
|
|
28
29
|
ow_surface.update_user_id = ow_surface.create_user_id
|
|
30
|
+
|
|
29
31
|
source_metadata = SourceMetadata(
|
|
30
32
|
system=SourceSystem.OPENWORKS,
|
|
31
33
|
database=source_context.database,
|
|
@@ -40,17 +42,17 @@ def map_surfacegrid(
|
|
|
40
42
|
create_date=ow_surface.create_date,
|
|
41
43
|
create_date_utc=convert_date_to_utc(
|
|
42
44
|
ow_surface.create_date, source_context.timezone
|
|
43
|
-
),
|
|
45
|
+
) if ow_surface.create_date is not None else None,
|
|
44
46
|
update_date=ow_surface.update_date,
|
|
45
47
|
update_date_utc=convert_date_to_utc(
|
|
46
48
|
ow_surface.update_date, source_context.timezone
|
|
47
|
-
),
|
|
49
|
+
) if ow_surface.update_date is not None else None,
|
|
50
|
+
)
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
),
|
|
52
|
+
source_ow_metadata = OWSurfaceGridMetadata(
|
|
53
|
+
geo_name=ow_surface.geo_name,
|
|
54
|
+
geo_type=ow_surface.geo_type,
|
|
55
|
+
attribute=ow_surface.attribute,
|
|
54
56
|
)
|
|
55
57
|
|
|
56
58
|
geometry = GridGeometry(
|
|
@@ -66,12 +68,18 @@ def map_surfacegrid(
|
|
|
66
68
|
left_handed=True,
|
|
67
69
|
)
|
|
68
70
|
|
|
71
|
+
# id is nullable, so we try to iterate through other unique attributes in case it is null
|
|
72
|
+
native_id: str = ow_surface.native_uid or ow_surface.alternate_uid or ow_surface.map_data_set_name
|
|
73
|
+
parent_id = ow_surface.parent_surface_grid_id if isinstance(ow_surface, SurfaceGridProperties) else None
|
|
69
74
|
return SurfaceGridRecord(
|
|
75
|
+
id=id_generate(source_context, native_id),
|
|
70
76
|
source=source_metadata,
|
|
77
|
+
source_ow=source_ow_metadata,
|
|
71
78
|
processing=processing_metadata,
|
|
72
79
|
geometry=geometry,
|
|
73
80
|
crs=ow_surface.crs or source_context.crs,
|
|
74
81
|
z_domain=ow_surface.data_domain,
|
|
75
82
|
z_unit=ow_surface.z_unit,
|
|
76
83
|
extent=None, # TODO: calculate from grid geometry
|
|
84
|
+
parent_surface_id=parent_id
|
|
77
85
|
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from models.enums import InterpretationDataType
|
|
3
|
+
from models.metadata import SourceMetadata, ProcessingMetadata, OWCollectionMetadata, OWCollectionItemMetadata
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CollectionItem(BaseModel):
|
|
7
|
+
id:str
|
|
8
|
+
collection_id: str
|
|
9
|
+
object_id: str
|
|
10
|
+
datatype: InterpretationDataType
|
|
11
|
+
source: SourceMetadata | None = None
|
|
12
|
+
source_ow: OWCollectionItemMetadata | None = None
|
|
13
|
+
processing: ProcessingMetadata | None = None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Collection(BaseModel):
|
|
17
|
+
id: str
|
|
18
|
+
source: SourceMetadata | None = None
|
|
19
|
+
source_ow: OWCollectionMetadata | None = None
|
|
20
|
+
processing: ProcessingMetadata | None = None
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SourceSystem(str, Enum):
|
|
5
|
+
OPENWORKS = "OpenWorks R5000"
|
|
6
|
+
PETREL = "Petrel Studio"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class InterpretationDataType(str, Enum):
|
|
10
|
+
SURFACE_GRID = "SurfaceGrid"
|
|
11
|
+
HORIZON = "Horizon"
|
|
12
|
+
POLYGON = "Polygon"
|
|
13
|
+
FAULT = "Fault"
|
|
14
|
+
POINT_SET = "PointSet"
|
|
15
|
+
OTHERS = "Others"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class UpdateType(str, Enum):
|
|
19
|
+
OBJECT_CREATE = "ObjectCreate"
|
|
20
|
+
OBJECT_UPDATE = "ObjectUpdate"
|
|
21
|
+
OBJECT_DELETE = "ObjectDelete"
|
|
22
|
+
COLLECTION_INSERT = "CollectionInsert"
|
|
23
|
+
COLLECTION_REMOVE = "CollectionRemove"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class OWDataType(str, Enum):
|
|
27
|
+
MAP2D = "Map2D"
|
|
28
|
+
RGRID = "Rgrid"
|
|
29
|
+
HORIZON3D = "HorizonAttributeCatalog"
|
|
30
|
+
POLYGON_SET = "MappingPolySet"
|
|
31
|
+
POINT_SET = "PointSet"
|
|
32
|
+
OTHERS = "Others"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from models.extent import Extent
|
|
3
|
+
from models.metadata import SourceMetadata, InterpretationProcessingMetadata, OWMetadata, OWSurfaceGridMetadata, PetrelMetadata
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class InterpretationRecord(BaseModel):
|
|
7
|
+
id: str
|
|
8
|
+
source: SourceMetadata | None = None
|
|
9
|
+
source_ow: OWMetadata | None = None
|
|
10
|
+
source_petrel: PetrelMetadata | None = None
|
|
11
|
+
processing: InterpretationProcessingMetadata | None = None
|
|
12
|
+
extent: Extent | None = None
|
|
13
|
+
crs: str | None = None
|
|
14
|
+
z_domain: str | None = None
|
|
15
|
+
z_unit: str | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class GridGeometry(BaseModel):
|
|
19
|
+
ncol: int | None = None
|
|
20
|
+
nrow: int | None = None
|
|
21
|
+
xori: float | None = None
|
|
22
|
+
yori: float | None = None
|
|
23
|
+
xinc: float | None = None
|
|
24
|
+
yinc: float | None = None
|
|
25
|
+
rotation: float | None = None
|
|
26
|
+
left_handed: bool | None = True # yflip
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class GriddedInterpretationRecord(InterpretationRecord):
|
|
30
|
+
geometry: GridGeometry | None = None
|
|
31
|
+
grid_null_value: float | None = None
|
|
32
|
+
grid_ntotal: int | None = None
|
|
33
|
+
grid_nnan: int | None = None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class VectorInterpretationRecord(InterpretationRecord):
|
|
37
|
+
num_points: int | None = None
|
|
38
|
+
num_properties: int | None = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class SurfaceGridRecord(GriddedInterpretationRecord):
|
|
42
|
+
"""
|
|
43
|
+
A surface defined in a regular 2D grid containing values for each of the points in the grid.
|
|
44
|
+
The grid geometry is defined by the ``geometry`` parameters, which are sufficient to locate each point in space.
|
|
45
|
+
SurfaceGrids are typically (but not necessarily) originated from a horizon, replacing its seismic bin grid by a
|
|
46
|
+
locally defined grid (potentially after regridding)
|
|
47
|
+
The values are stored separately as a flattened 2D array, the format of which is explained in
|
|
48
|
+
http://github.com/equinor/interpretation-models/docs/bulk_data_models.md
|
|
49
|
+
The values can represent a structural surface (depth or time) or a property defined on a surface
|
|
50
|
+
(e.g. attribute, uncertainty, …).
|
|
51
|
+
In the case the values represent a property, there's optionally included a parent structural surface that the
|
|
52
|
+
property is defined on.
|
|
53
|
+
"""
|
|
54
|
+
source_ow: OWSurfaceGridMetadata | None = None
|
|
55
|
+
parent_surface_id: str | None = None
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
from pydantic import BaseModel
|
|
2
2
|
from datetime import datetime
|
|
3
|
-
from
|
|
3
|
+
from models.enums import SourceSystem
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class ProcessingMetadata(BaseModel):
|
|
7
|
+
create_date: datetime | None = None
|
|
8
|
+
update_date: datetime | None = None
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
class InterpretationProcessingMetadata(ProcessingMetadata):
|
|
12
|
+
"""
|
|
13
|
+
Metadata related to the processing of the data, such as timestamps, UUIDs, etc.
|
|
14
|
+
This is included only so these attributes can be included in the table schemas derived from the interpretation models,
|
|
15
|
+
Callers can send the information to include directly in the output object without transformation.
|
|
16
|
+
It is optional - if not storing intermediate processing information, this can be skipped.
|
|
17
|
+
"""
|
|
18
|
+
file_available: bool | None = None
|
|
19
|
+
file_error_message: str | None = None
|
|
20
|
+
file_path: str | None = None
|
|
15
21
|
|
|
16
22
|
|
|
17
|
-
class
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
class SourceContext(BaseModel):
|
|
24
|
+
"""
|
|
25
|
+
Meant as input only so callers can represent project metadata which is not present in typed source objects.
|
|
26
|
+
In the output models, the information derived from this is included as part of SourceMetadata.
|
|
27
|
+
See docs/design_interpretations#source-context for more details.
|
|
28
|
+
"""
|
|
29
|
+
database: str
|
|
30
|
+
project: str
|
|
31
|
+
timezone: str | None = None
|
|
32
|
+
crs: str | None = None
|
|
21
33
|
|
|
22
34
|
|
|
23
35
|
class SourceMetadata(BaseModel):
|
|
@@ -33,32 +45,32 @@ class SourceMetadata(BaseModel):
|
|
|
33
45
|
create_date_utc: datetime | None = None
|
|
34
46
|
update_date: datetime | None = None
|
|
35
47
|
update_date_utc: datetime | None = None
|
|
36
|
-
ow: OWMetadata | None = None
|
|
37
|
-
petrel: PetrelMetadata | None = None
|
|
38
48
|
|
|
39
49
|
|
|
40
|
-
class
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
This is included only so these attributes can be included in the table schemas derived from the interpretation models,
|
|
44
|
-
Callers can send the information to include directly in the output object without transformation.
|
|
45
|
-
It is optional - if not storing intermediate processing information, this can be skipped.
|
|
46
|
-
"""
|
|
47
|
-
id: str
|
|
48
|
-
create_date: datetime | None = None
|
|
49
|
-
update_date: datetime | None = None
|
|
50
|
-
file_availability: str | None = None
|
|
51
|
-
deleted: bool | None = None
|
|
52
|
-
delete_date: datetime | None = None
|
|
50
|
+
class OWMetadata(BaseModel):
|
|
51
|
+
"""Base class for OpenWorks source metadata. Subclassed for each interpretation type."""
|
|
52
|
+
pass
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
class OWSurfaceGridMetadata(OWMetadata):
|
|
56
|
+
"""OpenWorks metadata specific to surface grids."""
|
|
57
|
+
geo_name: str | None = None
|
|
58
|
+
geo_type: str | None = None
|
|
59
|
+
attribute: str | None = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class OWCollectionMetadata(OWMetadata):
|
|
63
|
+
field_prospect_name: str | None = None
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class OWCollectionItemMetadata(OWMetadata):
|
|
67
|
+
data_type: str | None = None
|
|
68
|
+
data_key: str | None = None
|
|
69
|
+
interpretation_set_id: str | None = None
|
|
70
|
+
iset_folder_id: int | None = None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class PetrelMetadata(BaseModel):
|
|
74
|
+
business_project: str | None = None
|
|
75
|
+
data_status: str | None = None
|
|
76
|
+
confidence_factor: str | None = None
|
|
File without changes
|