Skip to content
Merged
Show file tree
Hide file tree
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
100 changes: 50 additions & 50 deletions Utilities/Python/FDS_verification_dataplot_inputs.csv

Large diffs are not rendered by default.

36 changes: 13 additions & 23 deletions Utilities/Python/fdsplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ def read_csv_cached(path, **kwargs):
y_min=pp.Min_Ind if flip_axis else pp.Min_Dep,
y_max=pp.Max_Ind if flip_axis else pp.Max_Dep,
legend_location=matlab_legend_to_matplotlib(pp.Key_Position),
legend_expand=pp.Paper_Width_Factor,
plot_type=plot_type,
plot_title=pp.Plot_Title,
)

# --- Save measured (experimental) ---
Expand Down Expand Up @@ -530,15 +532,6 @@ def read_csv_cached(path, **kwargs):
figure_handle=f, # keep same figure
data_label=d2_key_labels[i],
line_style=d2_styles[i],
x_label=pp.Dep_Title if flip_axis else pp.Ind_Title,
y_label=pp.Ind_Title if flip_axis else pp.Dep_Title,
x_min=pp.Min_Dep if flip_axis else pp.Min_Ind,
x_max=pp.Max_Dep if flip_axis else pp.Max_Ind,
y_min=pp.Min_Ind if flip_axis else pp.Min_Dep,
y_max=pp.Max_Ind if flip_axis else pp.Max_Dep,
legend_location=matlab_legend_to_matplotlib(pp.Key_Position),
plot_type=plot_type,
plot_title=pp.Plot_Title,
)

# --- Interpolated, metric-aware model logic ---
Expand Down Expand Up @@ -800,7 +793,7 @@ def plot_to_fig(x_data,y_data,**kwargs):
ax = fig.add_axes([left, bottom, ax_w, ax_h])

# widen paper if legend is outside, keeping axes fixed in physical size
if kwargs.get('legend_location') == 'outside':
if (kwargs.get('legend_location') == 'outside') and (not using_existing_figure):
legend_expand = kwargs.get('legend_expand', 1.25)
old_size = fig.get_size_inches()

Expand Down Expand Up @@ -1339,14 +1332,13 @@ def get_plot_style(style="fds"):

def matlab_legend_to_matplotlib(position):
"""
Convert a MATLAB legend position string to the corresponding matplotlib location string.
Convert a MATLAB legend position string to a matplotlib-compatible location.
"""
if not isinstance(position, str):
return 'best'

Parameters:
position (str): MATLAB-style legend position (e.g., 'northeast', 'southwestoutside')
pos = position.strip().lower()

Returns:
str: Matplotlib-compatible legend location (e.g., 'upper right')
"""
mapping = {
'north': 'upper center',
'south': 'lower center',
Expand All @@ -1356,17 +1348,15 @@ def matlab_legend_to_matplotlib(position):
'southeast': 'lower right',
'southwest': 'lower left',
'northwest': 'upper left',
'northeastoutside': 'center left', # rough equivalent
'northwestoutside': 'center right',
'southeastoutside': 'center left',
'southwestoutside': 'center right',

# outside positions (MATLAB → Matplotlib approximations)
'eastoutside': 'outside',

'best': 'best'
}

if not isinstance(position, str):
return 'best'
return mapping.get(pos, 'best')

return mapping.get(position.strip().lower(), 'best')


def define_plot_parameters(D, irow, lightweight=False):
Expand Down
7 changes: 4 additions & 3 deletions Utilities/Python/scripts/fluid_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,14 @@ def read_prt5(filename, precision, *varargin):
STIME, XP, YP, ZP, QP = read_prt5(ddir + chid[i] + '_1.prt5', 'real*4')

if j[i] == 1:
fdsplotlib.plot_to_fig(x_data=XP[-1, :], y_data=QP[-1, :, 0, 0]/QP[-1, :, 0, 1], figure_handle=fig, marker_style='bo', data_label='FDS part')
fdsplotlib.plot_to_fig(x_data=XP[-1, :], y_data=QP[-1, :, 0, 0]/QP[-1, :, 0, 1], figure_handle=fig, marker_style='bo')
v = np.abs(c_d * a_p * 0.5*rho_g*(XP[-1, :]**2) - QP[-1, :, 0, 0]/QP[-1, :, 0, 1])
elif j[i] == 2:
fdsplotlib.plot_to_fig(x_data=YP[-1, :], y_data=QP[-1, :, 0, 0]/QP[-1, :, 0, 1], figure_handle=fig, marker_style='ro', data_label='FDS part')
fdsplotlib.plot_to_fig(x_data=YP[-1, :], y_data=QP[-1, :, 0, 0]/QP[-1, :, 0, 1], figure_handle=fig, marker_style='ro')
v = np.abs(c_d * a_p * 0.5*rho_g*(YP[-1, :]**2) - QP[-1, :, 0, 0]/QP[-1, :, 0, 1])
elif j[i] == 3:
fdsplotlib.plot_to_fig(x_data=ZP[-1, :], y_data=QP[-1, :, 0, 0]/QP[-1, :, 0, 1], figure_handle=fig, marker_style='go', data_label='FDS part')
fds_key_label = 'FDS part' if i==2 else None
fdsplotlib.plot_to_fig(x_data=ZP[-1, :], y_data=QP[-1, :, 0, 0]/QP[-1, :, 0, 1], figure_handle=fig, marker_style='go', data_label=fds_key_label)
v = np.abs(c_d * a_p * 0.5*rho_g*(ZP[-1, :]**2) - QP[-1, :, 0, 0]/QP[-1, :, 0, 1])

err = np.linalg.norm(v)/len(v)
Expand Down
3 changes: 2 additions & 1 deletion Utilities/Python/scripts/level_set_ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def virtual_wind(phi_s_x: float, phi_s_y: float) -> tuple[float, float]:
plot_title=f'Level set spread rate (LS_ellipse_*ms_{slope:02d}deg)',
x_label='x (m)',
y_label='y (m)',
data_label=f'FDS {U} m/s'
data_label=f'FDS {U} m/s',
legend_location='lower right',
)
else:
fdsplotlib.plot_to_fig(x_data=x_pts,
Expand Down
3 changes: 2 additions & 1 deletion Utilities/Python/scripts/radiating_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
plot_title = 'Radiative Flux from a Hot Square Plate',
data_label='Exact',
y_label='Radiative Heat Flux (kW/m$^2$)',
x_label='Distance from Plate (m)')
x_label='Distance from Plate (m)',
legend_location='lower left')

fdsplotlib.plot_to_fig(x_data=1-flux_20[0], y_data=flux_20[1], marker_style='r-',
figure_handle=fig,
Expand Down
3 changes: 2 additions & 1 deletion Utilities/Python/scripts/tree_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
revision_label=version_string,
plot_title='Initialized bulk density (tree_shapes)',
x_label=r'Input volume (m$^3$)',
y_label='Tree crown mass (kg)'
y_label='Tree crown mass (kg)',
legend_location='lower right',
)

# Plot results
Expand Down
3 changes: 2 additions & 1 deletion Utilities/Python/scripts/turb_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def energy_decay(chid, N):
x_min=0, x_max=0.7, y_min=0, y_max=0.07,
revision_label=version_string,
x_label='Time (s)',
y_label='Kinetic Energy (m$^2$/s$^2$)')
y_label='Kinetic Energy (m$^2$/s$^2$)',
legend_location='upper right')

if chid == 'csmag_32':
M = pd.read_csv(outdir + 'mu0_32_devc.csv', skiprows=2, header=None).values
Expand Down