Skip to content
Open
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
82 changes: 60 additions & 22 deletions process/core/io/plot/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3206,6 +3206,50 @@ def plot_main_plasma_information(
)


def plot_cs_current_over_time(
axis: plt.Axes,
mfile: MFile,
scan: int,
):
"""Plots the CS coil current profile over time, when available."""
pulse_timings = PulseTimings(
t_plant_pulse_coil_precharge=mfile.get(
"t_plant_pulse_coil_precharge", scan=scan
),
t_plant_pulse_plasma_current_ramp_up=mfile.get(
"t_plant_pulse_plasma_current_ramp_up", scan=scan
),
t_plant_pulse_fusion_ramp=mfile.get("t_plant_pulse_fusion_ramp", scan=scan),
t_plant_pulse_burn=mfile.get("t_plant_pulse_burn", scan=scan),
t_plant_pulse_plasma_current_ramp_down=mfile.get(
"t_plant_pulse_plasma_current_ramp_down", scan=scan
),
t_plant_pulse_dwell=mfile.get("t_plant_pulse_dwell", scan=scan),
)

try:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing a pre-commit failure, could you fix that please?

cs_circuit = [
mfile.get(f"cs_t{i}", scan=scan)
for i in range(pulse_timings.n_pf_active_points_total)
]
axis.plot(
pulse_timings.pf_active_cumulative,
cs_circuit,
label="CS Coil",
linestyle="--",
)
# Add a legend
axis.legend()
# Add a grid for better readability
axis.grid(True, linestyle="--", alpha=0.6)
axis.axhline(0, color="black", linewidth=2)
axis.tick_params(axis="x", labelbottom=False)
axis.set_ylabel("Current [A]", fontsize=12)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a time label be added so both x axes have that ?


except KeyError:
pass


def plot_current_profiles_over_time(axis: plt.Axes, mfile: MFile, scan: int):
"""Plots the current profiles over time for PF circuits, CS coil, and plasma."""
pulse_timings = PulseTimings(
Expand Down Expand Up @@ -3242,21 +3286,6 @@ def plot_current_profiles_over_time(axis: plt.Axes, mfile: MFile, scan: int):
linestyle="--",
)

# Since CS may not always be present try to retrieve values
try:
cs_circuit = [
mfile.get(f"cs_t{i}", scan=scan)
for i in range(pulse_timings.n_pf_active_points_total)
]
axis.plot(
pulse_timings.pf_active_cumulative,
cs_circuit,
label="CS Coil",
linestyle="--",
)
except KeyError:
pass

# Plasma current values
plasmat1 = mfile.get("plasmat1", scan=scan)
plasmat2 = mfile.get("plasmat2", scan=scan)
Expand Down Expand Up @@ -3286,21 +3315,19 @@ def plot_current_profiles_over_time(axis: plt.Axes, mfile: MFile, scan: int):
], # Exclude the last label as it corresponds to the dwell period
rotation=60,
)
# Stagger adjacent labels onto two rows so closely spaced pulse events remain

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the new x axis labels look any different?
Old on left, new on right:

Image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current plot now has a linear scale - OK.

@mkovari mkovari Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have thought the power plot should also be plotted using a linear scale. @chris-ashe

# readable without moving their ticks away from the event times.
for index, label in enumerate(secax.get_xticklabels()):
label.set_y(0.12 if index % 2 else -0.02)
secax.tick_params(axis="x", which="major")

# Add axis labels
axis.set_xlabel("Time [s]", fontsize=12)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be misaligned with the x axis, could that be fixed please

Image

axis.xaxis.set_label_coords(1.05, 0.5)
axis.set_ylabel("Current [A]", fontsize=12)

# Add a title
axis.set_title("Current Profiles Over Time", fontsize=14)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this title be added back please, and some axis titles if possible/appropriate for each plot


# Add a legend
axis.legend()

axis.set_yscale("symlog")

# Add a grid for better readability
axis.grid(True, linestyle="--", alpha=0.6)

Expand Down Expand Up @@ -16951,7 +16978,18 @@ def _add_page(name: str | None = None):
colour_scheme=colour_scheme,
)

plot_current_profiles_over_time(_add_page().add_subplot(111), m_file, scan)
# Use the current-profile axis as the shared x-axis so that the CS current
# is aligned with the PF and plasma current profiles below it.
current_profiles_axis = _add_page("poloidal_current_profiles").add_subplot(212)
plot_current_profiles_over_time(current_profiles_axis, m_file, scan)
plot_cs_current_over_time(
pages["poloidal_current_profiles"].add_subplot(
211, sharex=current_profiles_axis
),
m_file,
scan,
)
pages["poloidal_current_profiles"].subplots_adjust(hspace=0.05)

plot_pf_cs_plasma_mutual_inductance(_add_page().add_subplot(111), m_file, scan)

Expand Down
Loading