Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/ccs_scripts/aggregate/_migration_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def generate_migration_time_property(
) -> xtgeo.GridProperty:
"""
Calculates a 3D grid property reflecting the migration time. Migration time is
defined as the first time step at which the property value exceeds the provided
`lower_threshold`.
defined as the first time step at which the property value exceeds its initial
condition
"""
# Calculate time since simulation start
times = [datetime.datetime.strptime(_prop.date, "%Y%m%d") for _prop in co2_props]
Expand All @@ -24,10 +24,11 @@ def generate_migration_time_property(
t_prop = co2_props[0].copy(newname=MIGRATION_TIME_PNAME + "_" + prop_name)
t_prop.values[~t_prop.values.mask] = np.inf
for co2, dt in zip(
co2_props,
time_since_start,
co2_props[1:],
time_since_start[1:],
):
above_threshold = co2.values > co2_threshold
diff_prop = co2.values - co2_props[0].values
above_threshold = diff_prop > co2_threshold
t_prop.values[above_threshold] = np.minimum(t_prop.values[above_threshold], dt)
# Mask inf values
if not isinstance(t_prop.values.mask, np.ndarray):
Expand Down