Skip to content

Commit

Permalink
Add test data from fmu dataio
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sol committed Jan 17, 2024
1 parent cf974dc commit 993e3b5
Show file tree
Hide file tree
Showing 3 changed files with 1,254 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/subscript/fmuobs/fmuobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from ert import ErtScript
from ert.shared.plugins.plugin_manager import hook_implementation # type: ignore

from fmu.config.utilities import yaml_load
from fmu.dataio import ExportData
from subscript import __version__, getLogger
from subscript.fmuobs.parsers import (
compute_date_from_days,
Expand Down Expand Up @@ -366,13 +368,40 @@ def fmuobs(
dump_results(dframe, csv, yml, resinsight, ertobs, PosixPath(inputfile).parent)


def export_w_meta(observations, config_path, case_path):
"""Export dictionary with corresponding metadata as json
Args:
observations (dict): the dictionary
config_path (str): path to fmu config file
case_path (str): path to an fmu case
Returns:
str: path to exported json file
"""
config = yaml_load(config_path)

exp = ExportData(
config=config,
name="observations",
tagname="all",
content="property",
casepath=case_path,
fmu_context="case",
)
export_path = exp.export(observations)
# LOGGER.debug("Exported to %s:", export_path)
return export_path


def dump_results(
dframe: pd.DataFrame,
csvfile: Optional[str] = None,
yamlfile: Optional[str] = None,
resinsightfile: Optional[str] = None,
ertfile: Optional[str] = None,
parent_dir: PosixPath = PosixPath("."),
parent_dir: Optional[PosixPath] = PosixPath("."),
fmu_config_file: Optional[str] = None,
) -> None:
"""Dump dataframe with ERT observations to CSV and/or YML
format to disk. Writes to stdout if filenames are "-". Skips
Expand Down Expand Up @@ -432,6 +461,10 @@ def dump_results(
else:
print(ertobs_str)

if fmu_config_file is not None:
obs_dict_2_sumo = df2obsdict(dframe)
export_w_meta(obs_dict_2_sumo, fmu_config_file)


class FmuObs(ErtScript):
"""This class defines the ERT workflow hook.
Expand Down
44 changes: 44 additions & 0 deletions tests/testdata_fmuobs/drogon/ertrun1/share/metadata/fmu_case.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
schema: https://main-fmu-schemas-dev.radix.equinor.com/schemas/0.8.0/fmu_results.json
source: fmu
version: 0.8.0
class: case
tracklog:
- datetime: "2021-05-05T09:20:40.475110"
event: created
user:
user_id: peesv
fmu:
case:
name: somecasename
uuid: a40b05e8-e47f-47b1-8fee-f52a5116bd37
user:
id: peesv
description:
- My case / ERT run description
restart_from: x40b09e8-d47f-49b1-8fxx-g52a5119bd37_iter-3
model:
description:
- Tutorials & stuff
- Testing new things
name: ff
revision: 21.0.0.dev
masterdata:
smda:
coordinate_system:
identifier: ST_WGS84_UTM37N_P32637
uuid: ad214d85-dac7-19da-e053-c918a4889309
country:
- identifier: Norway
uuid: ad214d85-8a1d-19da-e053-c918a4889309
discovery:
- short_identifier: DROGON
uuid: ad214d85-8a1d-19da-e053-c918a4889309
field:
- identifier: DROGON
uuid: 00000000-0000-0000-0000-000000000000
stratigraphic_column:
identifier: DROGON_2020
uuid: some-unique-id-to-be-provided-by-smda
access:
asset:
name: Drogon # adding level to make room for unique ID in the future
Loading

0 comments on commit 993e3b5

Please sign in to comment.