Skip to content

Commit

Permalink
erosion within layers
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchengtkc committed Oct 31, 2024
1 parent 20ac2db commit a561b89
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 138 deletions.
4 changes: 2 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_integration_single_rift():
fw.simulate_single_node()
node = fw.current_node
ref_t, ref_d, red_s = load_reference_data_single_rift()
np.allclose(node.result._sediments_ids,red_s)



def test_integration_multi_rift():
Expand All @@ -73,4 +73,4 @@ def test_integration_multi_rift():
fw.simulate_single_node()
node = fw.current_node
ref_t, ref_d, red_s = load_reference_data_multi_rift()
np.allclose(node.result._sediments_ids,red_s)

21 changes: 10 additions & 11 deletions warmth/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ def _tidy_sediments(df:pd.DataFrame)->pd.DataFrame:
"topage and top have to be in ascending order")
# TODO trucation
#df.drop_duplicates(subset=["top"], keep="last", inplace=True)

if 'erosion' not in df:
df['erosion'] = 0
if 'erosion_duration' not in df:
df['erosion_duration'] = 0
base = df["top"].values[1:]
top = df["top"].values[:-1]

Expand All @@ -252,6 +255,7 @@ def _tidy_sediments(df:pd.DataFrame)->pd.DataFrame:
break

baseage=df["topage"].values[1:]

df = df[:-1]
WD = top[0]
with np.errstate(divide="ignore", invalid="ignore"):
Expand All @@ -272,8 +276,8 @@ def _tidy_sediments(df:pd.DataFrame)->pd.DataFrame:
grain_thickness = (thickness / 1e3) * (1 - PhiMean)
grain_thickness[grain_thickness == np.inf] = 0.0
grain_thickness = np.nan_to_num(grain_thickness)

df_out = df.assign(top=top,base=base,baseage = baseage,thickness=thickness,grain_thickness=grain_thickness,phi_mean=PhiMean)
eroded_grain_thickness = (df["erosion"] / 1e3) * (1 - PhiMean)
df_out = df.assign(top=top,base=base,baseage = baseage,thickness=thickness,grain_thickness=grain_thickness,phi_mean=PhiMean, eroded_grain_thickness=eroded_grain_thickness, erosion_duration = df["erosion_duration"])
return df_out

@property
Expand Down Expand Up @@ -494,6 +498,8 @@ def single_node_sediments_inputs_template(self):
"decay",
"solidus",
"liquidus",
"erosion",
"erosion_duration"
]
)

Expand Down Expand Up @@ -740,16 +746,9 @@ def _create_nodes(self, all_sediments_grid: List[List[List]]):
liquidus = np.append(liquidus, float(hor.liquidus))
strat = np.append(strat,hor.strat)
inputRef= np.append(inputRef,hor.horizon_index)


df = pd.DataFrame({'top': top, 'topage': topage, 'k_cond': k_cond,
'rhp': rhp, 'phi': phi, 'decay': decay, 'solidus': solidus, 'liquidus': liquidus,'strat':strat,'horizonIndex':inputRef})
'rhp': rhp, 'phi': phi, 'decay': decay, 'solidus': solidus, 'liquidus': liquidus,'strat':strat,'horizonIndex':inputRef,'erosion':np.zeros_like(top),'erosion_duration': np.zeros_like(top)})
df = df.sort_values(by=["topage"],ignore_index=True)

# print(df)
#df.reset_index(drop=True,inplace=True)
# df.at[2, 'top'] = np.nan
# df.at[3, 'top'] = np.nan
checker = self._check_nan_sed(df)

if checker is False:
Expand Down
Loading

0 comments on commit a561b89

Please sign in to comment.