bp / bp/resqpy

Question: how to create an epc of properties without including the grid

Open
#197 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
67
Forks
18
Avg merge
2h 26m
Merged PRs (30d)
1

Description

I have an application that creates an EPC file containing only ContinuousProperties and the EpcExternalPartReference to the h5 file. The use case is python as an external property calculator. The grid is not explicitly included because the app already contains the grid and it does not need to be round tripped (it is a very simple-minded calculator that does not account for grid geometry and topology!).

I can pick up properties and perform some calculation to create a new one. The problem is when trying to create an epc for the new property.

Happening to know the number of cells and the grid uuid, I expected that the return problem can be mocked up as

```
import numpy as np

import resqpy.model as rq
import resqpy.property as rp

CONTENT_TYPE = 'obj_IjkGridRepresentation'
SUPPORT_UUID = '492f069b-888a-4a17-8cc1-cdc845774f18'
NUMCELLS = 64

new_model = rq.Model('d:/new.epc', new_epc=True)
grid = new_model.create_supporting_representation(support_uuid=SUPPORT_UUID, title='grid',
content_type=CONTENT_TYPE)
new_model.add_part(content_type=CONTENT_TYPE, uuid=SUPPORT_UUID, root=grid)
values = np.arange(start=0, stop=NUMCELLS, dtype=np.float32)
p = rp.Property.from_array(new_model, cached_array=values, source_info='rpm', keyword='PERM_IJ',
property_kind='permeability rock', support_uuid=SUPPORT_UUID)

new_model.store_epc()
```

If the add_part line is included, then I fail with
```
C:\Users\m9imhof\AppData\Local\ExxonMobil\PetrelPythonPlugin\pytrel\python.exe D:/DEV/resqpy/test_local/import_export.py
Traceback (most recent call last):
File "D:\DEV\resqpy\test_local\import_export.py", line 15, in
p = rp.Property.from_array(new_model, cached_array=values, source_info='rpm', keyword='PERM_IJ',
File "D:\DEV\resqpy\resqpy\property.py", line 3542, in from_array
prop.create_xml(support_uuid = support_uuid,
File "D:\DEV\resqpy\resqpy\property.py", line 3736, in create_xml
self.collection.create_xml_for_imported_list_and_add_parts_to_model(
File "D:\DEV\resqpy\resqpy\property.py", line 2685, in create_xml_for_imported_list_and_add_parts_to_model
p_node = self.create_xml(
File "D:\DEV\resqpy\resqpy\property.py", line 3024, in create_xml
self.model.create_reciprocal_relationship(p_node, 'destinationObject', support_root, 'sourceObject')
File "D:\DEV\resqpy\resqpy\model.py", line 2973, in create_reciprocal_relationship
uuid_b = node_b.attrib['uuid']
File "src\lxml\etree.pyx", line 2479, in lxml.etree._Attrib.__getitem__
KeyError: 'uuid'
Process finished with exit code 1
```

Without the add_part line, I fail with
```
C:\Users\m9imhof\AppData\Local\ExxonMobil\PetrelPythonPlugin\pytrel\python.exe D:/DEV/resqpy/test_local/import_export.py
Traceback (most recent call last):
File "D:\DEV\resqpy\test_local\import_export.py", line 15, in
p = rp.Property.from_array(new_model, cached_array=values, source_info='rpm', keyword='PERM_IJ',
File "D:\DEV\resqpy\resqpy\property.py", line 3522, in from_array
prop.collection.set_support(model = prop.model,
File "D:\DEV\resqpy\resqpy\property.py", line 243, in set_support
assert support_part is not None, 'supporting representation part missing in model'
AssertionError: supporting representation part missing in model
Process finished with exit code 1
```

Contributor guide

Open the contributing guide

Research direction

The reproduction enters resqpy/property.py through Property.from_array, then set_support and create_xml, and reaches model.py:create_reciprocal_relationship. Read those paths first and compare the two failure cases; done means the shown property-only model can be stored as an EPC with its external support reference and without embedding the grid.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.