Skip to content

Commit 0cae35f

Browse files
authored
Add a field derived from primary ones in the conditioning (#142)
* compute Ualpha liquid stats * forgot to multiply the fields
1 parent 64f7a46 commit 0cae35f

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

applications/compute_conditional_mean_will.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,24 @@ def radial_mean(
133133
# Read all the fields you want
134134
for filename, field_name in zip(field_file, field_names):
135135
val_dict = {}
136-
field_tmp, _ = read_field(case_folder, time_folder, field_name)
136+
try:
137+
field_tmp, _ = read_field(case_folder, time_folder, field_name)
138+
except FileNotFoundError:
139+
if field_name == "Ualpha.liquid":
140+
alpha_tmp, _ = read_field(
141+
case_folder, time_folder, "alpha.liquid"
142+
)
143+
U_tmp, _ = read_field(case_folder, time_folder, "U.liquid")
144+
field_tmp = alpha_tmp[:, np.newaxis] * U_tmp
145+
else:
146+
raise NotImplementedError(
147+
f"{field_name} is not a valid field name"
148+
)
137149
if len(field_tmp.shape) == 2 and field_tmp.shape[1] == 3:
138150
# You read a velocity I'm assuming you need the axial one
151+
logger.warning(
152+
f"You read a velocity I'm assuming you need the axial one along the direction {vert_ind}"
153+
)
139154
field_tmp = field_tmp[:, vert_ind]
140155

141156
if heights is None:
@@ -228,7 +243,7 @@ def make_plot(fields_cond: dict, heights: list[float], field_names=list[str]):
228243
fields_cond = radial_mean(
229244
case_folder=None,
230245
heights=[5.2, 6.2, 6.3],
231-
field_names=["U.liquid", "alpha.gas"],
246+
field_names=["U.liquid", "alpha.gas", "Ualpha.liquid"],
232247
vert_ind=1,
233248
window_ave=2,
234249
n_bins=32,
@@ -240,5 +255,5 @@ def make_plot(fields_cond: dict, heights: list[float], field_names=list[str]):
240255
make_plot(
241256
fields_cond=fields_cond,
242257
heights=[5.2, 6.2, 6.3],
243-
field_names=["U.liquid", "alpha.gas"],
258+
field_names=["U.liquid", "alpha.gas", "Ualpha.liquid"],
244259
)

0 commit comments

Comments
 (0)