Skip to content

Commit

Permalink
additions and title correction
Browse files Browse the repository at this point in the history
  • Loading branch information
geograham committed Oct 3, 2024
1 parent cba214b commit 673d75a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
54 changes: 53 additions & 1 deletion bluemira/equilibria/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from bluemira.equilibria.equilibrium import MHDState
from bluemira.equilibria.optimisation.problem.base import CoilsetOptimisationProblem

from .bluemira.equilibria.flux_surfaces import CoreResults

from bluemira.base.error import BluemiraError
from bluemira.equilibria.diagnostics import CSData, FixedOrFree
from bluemira.equilibria.equilibrium import Equilibrium, FixedPlasmaEquilibrium
Expand Down Expand Up @@ -131,7 +133,7 @@ def __init__(
qpsi_sign=-1,
):
self.diag_ops = diag_ops
self.fixed_or_free = (FixedOrFree.FREE,)
self.fixed_or_free = FixedOrFree.FREE
self.dummy_coils = (None,)
self.from_cocos = (3,)
self.to_cocos = (3,)
Expand Down Expand Up @@ -170,6 +172,56 @@ def plot_profiles(self):
"""Plot profiles"""
return self._profiles.plot()

Check warning on line 173 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L173

Added line #L173 was not covered by tests

def plot_core_analysis(self) -> CoreResults:

Check warning on line 175 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L175

Added line #L175 was not covered by tests
"""
Plot characteristics of the plasma core and return results.
Only for free boundary equilibria.
Returns
-------
:
Dataclass for core results.
Raises
------
BluemiraError:
If the equilibrium is fixed boundary.
"""
if self.fixed_or_free is FixedOrFree.FIXED:
raise BluemiraError(

Check warning on line 192 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L191-L192

Added lines #L191 - L192 were not covered by tests
"This function can only be used for Free Boundary Equilbria."
)
return self._eq.analyse_core()

Check warning on line 195 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L195

Added line #L195 was not covered by tests

def physics_info_table(self, equilibrium_name="Eq_input"):

Check warning on line 197 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L197

Added line #L197 was not covered by tests
"""
Create a Pandas dataframe with the physics information
from the Equilbria of interest.
Not for use with FixedPlasmaEquilibrium.
Returns
-------
dataframe:
Pandas dataframe with summary of physics information.
Raises
------
BluemiraError:
If the equilibrium is fixed boundary.
"""
if self.fixed_or_free is FixedOrFree.FIXED:
raise BluemiraError(

Check warning on line 215 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L214-L215

Added lines #L214 - L215 were not covered by tests
"This function can only be used for Free Boundary Equilbria."
)

summary_dict = [self._eq.analyse_plasma()]
pd.set_option("display.float_format", "{:.2f}".format)
dataframe = pd.DataFrame(summary_dict).T
dataframe.columns = [equilibrium_name]
return dataframe

Check warning on line 223 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L219-L223

Added lines #L219 - L223 were not covered by tests

def plot_equilibria_with_profiles(self, title=None, ax=None, show=True): # noqa: FBT002

Check warning on line 225 in bluemira/equilibria/analysis.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/analysis.py#L225

Added line #L225 was not covered by tests
"""
Plot equilibria alongside profiles.
Expand Down
8 changes: 4 additions & 4 deletions bluemira/equilibria/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,9 @@ def plot_psi_coilset(self, grid: Grid = None, **kwargs):
vmax = np.amax(self.total_psi)

Check warning on line 805 in bluemira/equilibria/plotting.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L804-L805

Added lines #L804 - L805 were not covered by tests

title_type = "Difference "
if PsiPlotType.PSI_REL_DIFF:
if self.diag_ops.psi_diff in PsiPlotType.PSI_REL_DIFF:
title_type = "Relative difference "
if PsiPlotType.PSI_ABS_DIFF:
if self.diag_ops.psi_diff in PsiPlotType.PSI_ABS_DIFF:
title_type = "Absolute difference "

Check warning on line 811 in bluemira/equilibria/plotting.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L807-L811

Added lines #L807 - L811 were not covered by tests

if self.diag_ops.psi_diff in PsiPlotType.DIFF:
Expand Down Expand Up @@ -936,9 +936,9 @@ def plot_psi(self, grid: Grid = None, **kwargs):
vmax = np.amax(self.total_psi)

Check warning on line 936 in bluemira/equilibria/plotting.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L935-L936

Added lines #L935 - L936 were not covered by tests

title_type = "Difference "
if PsiPlotType.PSI_REL_DIFF:
if self.diag_ops.psi_diff in PsiPlotType.PSI_REL_DIFF:
title_type = "Relative difference "
if PsiPlotType.PSI_ABS_DIFF:
if self.diag_ops.psi_diff in PsiPlotType.PSI_ABS_DIFF:
title_type = "Absolute difference "

Check warning on line 942 in bluemira/equilibria/plotting.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L938-L942

Added lines #L938 - L942 were not covered by tests

if self.diag_ops.psi_diff in PsiPlotType.DIFF:
Expand Down

0 comments on commit 673d75a

Please sign in to comment.