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
2 changes: 2 additions & 0 deletions process/core/io/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module containing plotting routines"""

from process.core.io.plot.sankey import plot_sankey_plotly
from process.core.io.plot.scans import plot_scan
from process.core.io.plot.solutions import (
Expand Down
2 changes: 1 addition & 1 deletion process/core/io/plot/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""PROCESS cli"""
"""PROCESS plotting cli"""

from pathlib import Path

Expand Down
2 changes: 2 additions & 0 deletions process/core/io/plot/costs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module containing cost plotting routines"""

from process.core.io.plot.costs.costs_bar import cost_comp_1990, cost_comp_2014
from process.core.io.plot.costs.costs_pie import cost_model_1990, cost_model_2014

Expand Down
2 changes: 2 additions & 0 deletions process/core/io/plot/costs/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""PROCESS costs plotting CLI"""

import sys

import click
Expand Down
1 change: 1 addition & 0 deletions process/core/io/plot/images/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module containing images for plotting routines"""
9 changes: 6 additions & 3 deletions process/core/io/plot/sankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


def plot_sankey_plotly(m_file: Path):
"""Plot the Sankey diagram"""
if not PLOT_SANKEY:
print(
"\nPlotly is not installed, unable to create sankey diagram!\n"
Expand All @@ -34,6 +35,7 @@ def plot_sankey_plotly(m_file: Path):


def power_balance_sankey(m_file: Path):
"""Set up the power balance Sankey diagram"""
m_file: MFile = MFile(m_file)
p_hcd_injected_total_mw = m_file.get("p_hcd_injected_total_mw", scan=-1)
p_plasma_ohmic_mw = m_file.get("p_plasma_ohmic_mw", scan=-1)
Expand Down Expand Up @@ -362,6 +364,7 @@ def power_balance_sankey(m_file: Path):


def plotly(sankey_dict, m_file: Path):
"""Set up the Sankey diagram"""
fig = go.Figure(data=[sankey_dict])

fig.update_layout({
Expand Down Expand Up @@ -404,6 +407,7 @@ def add(
rotation: float = 0,
**kwargs,
):
"""Add a Sankey diagram"""
__doc__ = super().__doc__ # noqa: F841
# Here we first check if the "add" method has received arguments that
# the Sankey class can't handle.
Expand Down Expand Up @@ -564,9 +568,8 @@ def minimise_dxdy(x_opt):
return result.x


def plot_sankey(
mfilename=Path("MFILE.DAT"), format_: str = "pdf"
): # Plot simplified power flow Sankey Diagram
def plot_sankey(mfilename=Path("MFILE.DAT"), format_: str = "pdf"):
"""Plot simplified power flow Sankey Diagram"""
# Pulling values from the MFILE
mfilename = Path(mfilename)
m_file = MFile(mfilename)
Expand Down
8 changes: 7 additions & 1 deletion process/core/io/plot/scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ def plot_scan(
twod_contour: bool = False,
stack_plots: bool = False,
):
"""Main plot scans script."""
"""Main plot scans script.

Raises
------
ValueError
If stack_plots does not have at least two output variables
"""
outputdir = outputdir or Path.cwd()
input_files = mfiles if isinstance(mfiles, Iterable) else [mfiles]

Expand Down
11 changes: 11 additions & 0 deletions process/core/io/plot/stress_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

@dataclass
class StressPlotConfig:
"""Dataclass containing TF stress plot
configuration parameters
"""

axis_font_size: float
axis_tick_size: int = 16
legend_size: int = 12
Expand All @@ -24,6 +28,7 @@ class StressPlotConfig:
outdir: Path | None = None

def __post_init__(self):
"""Set the output directory"""
if self.outdir is None:
self.outdir = Path.cwd()
if not Path(self.outdir).is_dir():
Expand All @@ -38,6 +43,7 @@ def plot_stress(
input_file,
plot_conf: StressPlotConfig | dict | None = None,
):
"""Create the relevant stress plots"""
if plot_conf is None:
plot_conf = StressPlotConfig(axis_font_size)
elif isinstance(plot_conf, dict):
Expand Down Expand Up @@ -300,6 +306,7 @@ def terminal_output(
toroidal_strain,
vertical_strain,
):
"""Output TF stress details to terminal"""
ii_ins = 0
ii_mids = int(0.5 * float(n_radial_array_layer))
ii_outs = n_radial_array_layer - 1
Expand Down Expand Up @@ -385,6 +392,7 @@ def stress_summary(
save_format,
plot_conf,
):
"""Plot structural stress"""
lw = plot_conf.line_width
ms = plot_conf.mark_size
ats = plot_conf.axis_tick_size
Expand Down Expand Up @@ -458,6 +466,7 @@ def smeared_stress_summary(
save_format,
plot_conf,
):
"""Plot smeared stress"""
lw = plot_conf.line_width
ms = plot_conf.mark_size
ats = plot_conf.axis_tick_size
Expand Down Expand Up @@ -547,6 +556,7 @@ def strain_summary(
save_format,
plot_conf,
):
"""Plot TF strain"""
lw = plot_conf.line_width
ms = plot_conf.mark_size
ats = plot_conf.axis_tick_size
Expand Down Expand Up @@ -598,6 +608,7 @@ def strain_summary(


def displacement(n_layers, radius, radial_displacement, save_format, plot_conf):
"""Plot the radial displacement"""
plt.plot(radius[0], radial_displacement[0], color="dodgerblue")
for ii in range(1, n_layers):
plt.plot(radius[ii], radial_displacement[ii], color="dodgerblue")
Expand Down
Loading
Loading