Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faultroom export lacks mapping of juxtapositions to SMDA names #724

Open
mferrera opened this issue Jul 2, 2024 · 1 comment · May be fixed by #884
Open

Faultroom export lacks mapping of juxtapositions to SMDA names #724

mferrera opened this issue Jul 2, 2024 · 1 comment · May be fixed by #884
Assignees
Labels
Data definitions Issues related to data definitions

Comments

@mferrera
Copy link
Collaborator

mferrera commented Jul 2, 2024

[T]he new faultroom export is lacking mapping of juxtapositions to standardized (SMDA) names.

but I think this should be part of fmu-dataio, probably as part of fmu.dataio.ExportData

The best would be to also include the uuid for the strat unit, but I see that this is currently not included in the global variables stratigraphy. The best solution would be to also include the uuids there and then map everything related to stratigraphy into sumo with both name and uuid. (The reason being obviously that with uuid, you know you get the right one, but the names are not unique as it exist both multiple strat tables in many fields AND various fields have the same strat unit names in the strat tables.

CFG = utils.yaml_load('../../../../../../../../../testdata/global_variables.yml')
stratigraphy_name_mapper = {k: v['name'] for k, v in CFG['stratigraphy'].items()}

def dataio_faultroom():
    edata = dio.ExportData(
        config=CFG, content="fault_properties"
    )
    faultroom_files = Path('../../../../../../../../../testdata/faultroom').glob("*.json")
    for faultroom_file in faultroom_files:
        fdata = dio.readers.read_faultroom_file(faultroom_file)

        # This will change the metadata
        for s in fdata.juxtaposition_fw + fdata.juxtaposition_hw:
            # Trig error if stratigraphy is not in map (thus not in the fmu config)
            assert s in stratigraphy_name_mapper
        fdata.juxtaposition_fw = [stratigraphy_name_mapper.get(s) for s in fdata.juxtaposition_fw]
        fdata.juxtaposition_hw = [stratigraphy_name_mapper.get(s) for s in fdata.juxtaposition_hw]
        output = edata.export(fdata, tagname=faultroom_file.stem)
        print(f"Output is: {output}")

        # Reload and fix json file
        json_file = Path(output)
        faultroom_data = json.loads(json_file.read_text())
        faultroom_data['metadata']['juxtaposition']['fw'] = [stratigraphy_name_mapper.get(x) for x in faultroom_data['metadata']['juxtaposition']['fw']]
        faultroom_data['metadata']['juxtaposition']['hw'] = [stratigraphy_name_mapper.get(x) for x in faultroom_data['metadata']['juxtaposition']['hw']]
        with json_file.open('w') as outfile:
            json.dump(faultroom_data, outfile, indent=4)
@mferrera mferrera added the Data definitions Issues related to data definitions label Jul 2, 2024
@ErichSuter ErichSuter self-assigned this Sep 11, 2024
@mferrera
Copy link
Collaborator Author

In the Faultroom export we have

"juxtaposition": {
"fw": [
"Therys",
"Valysar",
"Volon"
],

These are the juxtaposition names in the faultroom file that are relevant to RMS. However, they are not aligned with the names in SMDA. The idea is to make these RMS names to the ones in SMDA, and this mapping already exists in the global configuration file:

Valysar:
stratigraphic: true
name: Valysar Fm.
Therys:
stratigraphic: true
name: Therys Fm.
Volon:
stratigraphic: true
name: Volon Fm.

The idea is when exported the faultroom metadata, the SMDA name should be exported in the metadata, not the RMS name.

This requires having access to the global configuration file, so it should be done in the object data provider without modifying the original faultroom export file or its parsed object in Python.

return FaultRoomSurfaceSpecification(
horizons=self.obj.horizons,
faults=self.obj.faults,
juxtaposition_hw=self.obj.juxtaposition_hw,
juxtaposition_fw=self.obj.juxtaposition_fw,
properties=self.obj.properties,
name=self.obj.name,
)

Then an initial implementation could be placing a helper function either in the data provider class so that it has access to dataio.config

class FaultRoomSurfaceProvider(ObjectDataProvider):
obj: FaultRoomSurface

We can take some inspiration from the existing implementation in the ObjectDataProvider base class:

if (
isinstance(self.dataio.config, GlobalConfiguration)
and (strat := self.dataio.config.stratigraphy)
and name in strat
):
if (alias := strat[name].alias) is None:
strat[name].alias = [name]
elif name not in alias:
alias.append(name)
return strat[name]

In this case we'd only need the name and can ignore some part:

if (
    isinstance(self.dataio.config, GlobalConfiguration)
    and (strat := self.dataio.config.stratigraphy)
    and name in strat
):
    return strat[name].name

ErichSuter added a commit to ErichSuter/fmu-dataio that referenced this issue Dec 5, 2024
ErichSuter added a commit to ErichSuter/fmu-dataio that referenced this issue Dec 5, 2024
ErichSuter added a commit to ErichSuter/fmu-dataio that referenced this issue Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data definitions Issues related to data definitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants