Skip to content

Commit

Permalink
additions and title correction
Browse files Browse the repository at this point in the history
  • Loading branch information
geograham authored and je-cook committed Nov 18, 2024
1 parent 74e1e06 commit f6db784
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 @@ -808,9 +808,9 @@ def plot_psi_coilset(self, grid: Grid = None, **kwargs):
vmax = np.amax(self.total_psi)

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

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L807-L808

Added lines #L807 - L808 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 814 in bluemira/equilibria/plotting.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L810-L814

Added lines #L810 - L814 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L938-L939

Added lines #L938 - L939 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 945 in bluemira/equilibria/plotting.py

View check run for this annotation

Codecov / codecov/patch

bluemira/equilibria/plotting.py#L941-L945

Added lines #L941 - L945 were not covered by tests

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

0 comments on commit f6db784

Please sign in to comment.