Skip to content

Commit 8732af0

Browse files
committed
disable desired plasma shape in direct mode
1 parent c21f060 commit 8732af0

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

waveform_editor/gui/shape_editor.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ def __init__(self):
4242
self.communicator = NiceIntegration(self.factory)
4343
self.plasma_shape = PlasmaShape()
4444
self.plasma_properties = PlasmaProperties()
45-
self.coil_currents = CoilCurrents(
46-
guide_msg_visible=self.param.nice_mode.rx() == NiceSettings.INVERSE_MODE
47-
)
45+
self.coil_currents = CoilCurrents(self.param.nice_mode.rx())
4846
self.nice_plotter = NicePlotter(
49-
self.communicator, self.plasma_shape, self.plasma_properties
47+
self.communicator,
48+
self.plasma_shape,
49+
self.plasma_properties,
50+
self.param.nice_mode,
5051
)
5152
self.nice_settings = settings.nice
5253

@@ -84,9 +85,7 @@ def __init__(self):
8485
"NICE Configuration",
8586
is_valid=param.rx(self.required_nice_settings_filled),
8687
),
87-
self._create_card(
88-
pn.Param(self.nice_plotter, show_name=False), "Plotting Parameters"
89-
),
88+
self._create_card(self.nice_plotter, "Plotting Parameters"),
9089
self._create_card(
9190
self.plasma_shape,
9291
"Plasma Shape",

waveform_editor/shape_editor/coil_currents.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
import param
66
from panel.viewable import Viewer
77

8+
from waveform_editor.settings import NiceSettings
9+
810

911
class CoilCurrents(Viewer):
1012
coil_ui = param.List(
1113
doc="List of tuples containing the checkboxes and sliders for the coil currents"
1214
)
1315

14-
def __init__(self, guide_msg_visible=True):
16+
def __init__(self, nice_mode):
1517
super().__init__()
1618
self.sliders_ui = pn.Column(visible=self.param.coil_ui.rx.bool())
1719
guide_message = pn.pane.Markdown(
1820
"_To fix a coil to a specific current, enable the checkbox and provide "
1921
" the desired current value._",
20-
visible=self.param.coil_ui.rx.bool() & guide_msg_visible,
22+
visible=self.param.coil_ui.rx.bool()
23+
& (nice_mode == NiceSettings.INVERSE_MODE),
2124
margin=(0, 10),
2225
)
2326
no_ids_message = pn.pane.Markdown(

waveform_editor/shape_editor/nice_plotter.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import param
99
import scipy
1010
from imas.ids_toplevel import IDSToplevel
11+
from panel.viewable import Viewer
1112

13+
from waveform_editor.settings import NiceSettings
1214
from waveform_editor.shape_editor.nice_integration import NiceIntegration
1315
from waveform_editor.shape_editor.plasma_properties import PlasmaProperties
1416
from waveform_editor.shape_editor.plasma_shape import PlasmaShape
@@ -17,13 +19,14 @@
1719
logger = logging.getLogger(__name__)
1820

1921

20-
class NicePlotter(param.Parameterized):
22+
class NicePlotter(Viewer):
2123
# Input data, use negative precedence to hide from the UI
2224
communicator = param.ClassSelector(class_=NiceIntegration, precedence=-1)
2325
wall = param.ClassSelector(class_=IDSToplevel, precedence=-1)
2426
pf_active = param.ClassSelector(class_=IDSToplevel, precedence=-1)
2527
plasma_shape = param.ClassSelector(class_=PlasmaShape, precedence=-1)
2628
plasma_properties = param.ClassSelector(class_=PlasmaProperties, precedence=-1)
29+
nice_mode = param.Parameter(precedence=-1, allow_refs=True)
2730

2831
# Plot parameters
2932
show_contour = param.Boolean(default=True, label="Show contour lines")
@@ -45,12 +48,15 @@ class NicePlotter(param.Parameterized):
4548
PROFILE_WIDTH = 350
4649
PROFILE_HEIGHT = 350
4750

48-
def __init__(self, communicator, plasma_shape, plasma_properties, **params):
51+
def __init__(
52+
self, communicator, plasma_shape, plasma_properties, nice_mode, **params
53+
):
4954
super().__init__(
5055
**params,
5156
communicator=communicator,
5257
plasma_shape=plasma_shape,
5358
plasma_properties=plasma_properties,
59+
nice_mode=nice_mode,
5460
)
5561
self.DEFAULT_OPTS = hv.opts.Overlay(
5662
xlim=(0, 13),
@@ -124,9 +130,13 @@ def _plot_profiles(self):
124130
hv.opts.Overlay(title="Plasma Profiles"), hv.opts.Curve(framewise=True)
125131
)
126132

127-
@pn.depends("plasma_shape.shape_updated", "show_desired_shape")
133+
@pn.depends("plasma_shape.shape_updated", "show_desired_shape", "nice_mode")
128134
def _plot_plasma_shape(self):
129-
if not self.show_desired_shape or not self.plasma_shape.has_shape:
135+
if (
136+
self.nice_mode == NiceSettings.DIRECT_MODE
137+
or not self.show_desired_shape
138+
or not self.plasma_shape.has_shape
139+
):
130140
return hv.Overlay([hv.Curve([]).opts(self.DESIRED_SHAPE_OPTS)])
131141

132142
r = self.plasma_shape.outline_r
@@ -388,3 +398,17 @@ def _plot_xo_points(self):
388398
hover_tooltips=[("", "X-point")],
389399
)
390400
return o_scatter * x_scatter
401+
402+
def __panel__(self):
403+
return (
404+
pn.Param(
405+
self.param,
406+
show_name=False,
407+
widgets={
408+
"show_desired_shape": {
409+
"visible": self.param.nice_mode.rx()
410+
== NiceSettings.INVERSE_MODE
411+
}
412+
},
413+
),
414+
)

0 commit comments

Comments
 (0)