Skip to content

Commit

Permalink
Remove duplicates from summary files
Browse files Browse the repository at this point in the history
  • Loading branch information
Øyvind Eide (EDT DSD SD2) authored and oyvindeide committed Sep 21, 2023
1 parent a00e953 commit 33178ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/clib/lib/enkf/read_summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ ERT_CLIB_SUBMODULE("_read_summary", m) {
const ecl_smspec_type *smspec = ecl_sum_get_smspec(summary);
std::vector<std::pair<std::string, std::vector<double>>>
summary_vectors{};

std::vector<std::string> seen_keys{};
for (int i = 0; i < ecl_smspec_num_nodes(smspec); i++) {
const ecl::smspec_node &smspec_node =
ecl_smspec_iget_node_w_node_index(smspec, i);
const char *key = smspec_node.get_gen_key1();
if (matches(keys, key)) {
if ((matches(keys, key)) &&
!(std::find(seen_keys.begin(), seen_keys.end(), key) !=
seen_keys.end())) {
seen_keys.push_back(key);
int start = ecl_sum_get_first_report_step(summary);
int end = ecl_sum_get_last_report_step(summary);
std::vector<double> data{};
Expand Down
5 changes: 2 additions & 3 deletions src/ert/config/summary_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ def read_from_file(self, run_path: str, iens: int) -> xr.Dataset:
f"from: {run_path}/{filename}.UNSMRY"
)

summary_data = read_summary(summary, self.keys)
summary_data = read_summary(summary, list(set(self.keys)))
summary_data.sort(key=lambda x: x[0])
data = [d for _, d in summary_data]
keys = [k for k, _ in summary_data]

ds = xr.Dataset(
{"values": (["name", "time"], data)},
coords={"time": time_map, "name": keys},
)
return ds.drop_duplicates(["time"])
return ds.drop_duplicates("time")

0 comments on commit 33178ef

Please sign in to comment.