Skip to content

Commit

Permalink
Add workaround for problems with microseconds
Browse files Browse the repository at this point in the history
Workaround for storage not handling datetimes
with microseconds due to index overflow in netcdf3.
#6952
  • Loading branch information
eivindjahren committed Jan 22, 2024
1 parent bfb7547 commit 0860ea7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/ert/analysis/_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ def _get_obs_and_measure_data(
name: list(set(index.get_level_values(name))) for name in index.names
}
observation = observation.sel(sub_selection)
ds = source_fs.load_responses(group, tuple(iens_active_index))
ds = source_fs.load_responses(group, tuple(iens_active_index)).interp(
report_steps=observation.report_steps
)
try:
filtered_ds = observation.merge(ds, join="left")
except KeyError as e:
Expand Down
3 changes: 2 additions & 1 deletion src/ert/config/_read_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def _read_spec(
hour=hour,
minute=minute,
second=microsecond // 10**6,
microsecond=microsecond % 10**6,
# Due to https://github.com/equinor/ert/issues/6952
# microsecond=self.micro_seconds % 10**6,
)
except Exception as err:
raise ValueError(
Expand Down
13 changes: 0 additions & 13 deletions src/ert/config/summary_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ def __post_init__(self) -> None:
def read_from_file(self, run_path: str, iens: int) -> xr.Dataset:
filename = self.input_file.replace("<IENS>", str(iens))
_, keys, time_map, data = read_summary(f"{run_path}/{filename}", self.keys)

if self.refcase:
assert isinstance(self.refcase, set)
missing = self.refcase.difference(time_map)
if missing:
first, last = min(missing), max(missing)
logger.warning(
f"Realization: {iens}, load warning: {len(missing)} "
f"inconsistencies in time map, first: Time mismatch for response "
f"time: {first}, last: Time mismatch for response time: "
f"{last} from: {run_path}/{filename}.UNSMRY"
)

ds = xr.Dataset(
{"values": (["name", "time"], data)},
coords={"time": time_map, "name": keys},
Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/config/summary_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def to_datetime(self) -> datetime:
hour=self.hour,
minute=self.minutes,
second=self.micro_seconds // 10**6,
microsecond=self.micro_seconds % 10**6,
# Due to https://github.com/equinor/ert/issues/6952
# microsecond=self.micro_seconds % 10**6,
)

@classmethod
Expand Down

0 comments on commit 0860ea7

Please sign in to comment.