Skip to content

Commit

Permalink
In z = 'coverage' heatmaps, surf_spec='total' is changed to surf_spec…
Browse files Browse the repository at this point in the history
…='all' for total coverage.
  • Loading branch information
hprats committed Dec 18, 2024
1 parent 9452cb9 commit d8030c1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/source/plotting_results.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ plt.show()

Mandatory:

- **`surf_spec`** (`str`): Surface species for coverage plots. Use `'total'` for total coverage.
- **`surf_spec`** (`str`): Surface species for coverage plots. Use `'all'` for total coverage.

Optional:

Expand Down Expand Up @@ -340,7 +340,7 @@ plot_heatmap(
x='pressure_CH4',
y='pressure_CO2',
z='coverage',
surf_spec="total",
surf_spec='all',
site_type='tC',
analysis_range=[50, 100],
range_type='time',
Expand Down Expand Up @@ -579,7 +579,7 @@ for n, product in enumerate(['CO', 'H2', 'H2O']):
for n, site_type in enumerate(['tC', 'tM', 'Pt']):
plot_heatmap(
ax=axs[1, n], scan_path=scan_path, x=x_variable, y=y_variable, z="coverage",
surf_spec="total", site_type=site_type,
surf_spec='all', site_type=site_type,
analysis_range=analysis_range, range_type=range_type, weights=weights,
auto_title=auto_title, show_points=show_points, show_colorbar=show_colorbar)

Expand Down
2 changes: 1 addition & 1 deletion examples/DRM_on_PtHfC/coverage_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
x='pressure_CH4',
y='pressure_CO2',
z='coverage',
surf_spec="total",
surf_spec='all',
site_type='tC',
analysis_range=[50, 100],
range_type='time',
Expand Down
2 changes: 1 addition & 1 deletion examples/DRM_on_PtHfC/multiple_heatmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
for n, site_type in enumerate(['tC', 'tM', 'Pt']):
plot_heatmap(
ax=axs[1, n], scan_path=scan_path, x=x_variable, y=y_variable, z="coverage",
surf_spec="total", site_type=site_type,
surf_spec='all', site_type=site_type,
analysis_range=analysis_range, range_type=range_type, weights=weights,
auto_title=auto_title, show_points=show_points, show_colorbar=show_colorbar)

Expand Down
18 changes: 9 additions & 9 deletions zacrostools/plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def plot_heatmap(
side_products : list, optional
Side products for selectivity plots.
surf_spec : str or list
Surface species for coverage plots.
Surface species for coverage plots. If 'all', the total coverage is computed.
levels : list, optional
Contour levels.
min_molec : int, optional
Expand Down Expand Up @@ -373,24 +373,24 @@ def validate_params(z, gas_spec, scan_path, scan_path_ref, min_molec, main_produ
if show_max and z != 'tof':
raise PlotError("'show_max' parameter is only valid when z = 'tof'")

if z == "tof":
if z == 'tof':
if not gas_spec:
raise PlotError("'gas_spec' is required for 'tof' plots")

elif z == "dtof":
elif z == 'dtof':
if not gas_spec or not scan_path_ref:
raise PlotError("'gas_spec' and 'scan_path_ref' are required for 'dtof' plots")
if not os.path.isdir(scan_path_ref):
raise PlotError(f"{scan_path_ref}: 'scan_path_ref' directory does not exist")
if min_molec != 0:
print("Warning: 'min_molec' is ignored if z = 'dtof'")

elif z == "selectivity":
elif z == 'selectivity':
if not main_product or side_products is None:
raise PlotError("'main_product' is required and 'side_products' must be provided (can be an empty list) "
"for 'selectivity' plots")

elif z == "coverage":
elif z == 'coverage':
if not surf_spec:
raise PlotError("'surf_spec' is required for 'coverage' plots")

Expand All @@ -408,7 +408,7 @@ def initialize_kmc_outputs(path, z, scan_path_ref, folder_name, analysis_range,
print(f"Warning: Could not initialize KMCOutput for {folder_name}: {e}")
kmc_output = None

if z == "dtof":
if z == 'dtof':
try:
kmc_output_ref = KMCOutput(path=f"{scan_path_ref}/{folder_name}", analysis_range=analysis_range,
range_type=range_type, weights=weights)
Expand Down Expand Up @@ -448,8 +448,8 @@ def extract_value(magnitude: str, path: str) -> float:
if total_pressure <= 0:
raise PlotError(f"Total pressure is zero or negative in {path}")

gas_specs_names = data.get("gas_specs_names")
gas_molar_fracs = data.get("gas_molar_fracs")
gas_specs_names = data.get('gas_specs_names')
gas_molar_fracs = data.get('gas_molar_fracs')

if gas_specs_names is None or gas_molar_fracs is None:
raise PlotError(f"Gas specifications or molar fractions missing in {input_file_path}")
Expand Down Expand Up @@ -497,7 +497,7 @@ def process_z_value(z, df, folder_name, kmc_output, kmc_output_ref, gas_spec, su
kmc_output.total_production[prod] for prod in [main_product] + side_products)

elif z == "coverage":
if surf_spec == 'total':
if surf_spec == 'all':
df.loc[folder_name, "coverage"] = kmc_output.av_total_coverage_per_site_type[site_type]
else:
coverage = 0.0
Expand Down

0 comments on commit d8030c1

Please sign in to comment.