-
Notifications
You must be signed in to change notification settings - Fork 24
🎨 Enhance readability of CS current plots and improve label forma… #4556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
| 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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( | ||
|
|
@@ -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) | ||
|
|
@@ -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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current plot now has a linear scale - OK.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
|
|
@@ -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) | ||
|
|
||
|
|
||


There was a problem hiding this comment.
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?