@@ -31,23 +31,18 @@ class ShapeEditor(Viewer):
3131 pf_passive = param .ClassSelector (class_ = IDSToplevel )
3232 wall = param .ClassSelector (class_ = IDSToplevel )
3333 iron_core = param .ClassSelector (class_ = IDSToplevel )
34- nice_mode = param .Selector (
35- objects = [NiceSettings .INVERSE_MODE , NiceSettings .DIRECT_MODE ],
36- default = NiceSettings .INVERSE_MODE ,
37- )
3834
3935 def __init__ (self ):
4036 super ().__init__ ()
4137 self .factory = imas .IDSFactory ()
4238 self .communicator = NiceIntegration (self .factory )
4339 self .plasma_shape = PlasmaShape ()
4440 self .plasma_properties = PlasmaProperties ()
45- self .coil_currents = CoilCurrents (nice_mode = self . param . nice_mode )
41+ self .coil_currents = CoilCurrents ()
4642 self .nice_plotter = NicePlotter (
4743 communicator = self .communicator ,
4844 plasma_shape = self .plasma_shape ,
4945 plasma_properties = self .plasma_properties ,
50- nice_mode = self .param .nice_mode ,
5146 )
5247 self .nice_settings = settings .nice
5348
@@ -67,30 +62,34 @@ def __init__(self):
6762 button_start .disabled = (
6863 (
6964 self .plasma_shape .param .has_shape .rx .not_ ()
70- & (self .param .nice_mode .rx () == NiceSettings .INVERSE_MODE )
65+ & (
66+ self .nice_settings .param .mode .rx ()
67+ == self .nice_settings .INVERSE_MODE
68+ )
7169 )
7270 | self .plasma_properties .param .has_properties .rx .not_ ()
73- | param . rx ( self .required_nice_settings_filled ) .rx .not_ ()
71+ | self .nice_settings . param . are_required_filled .rx .not_ ()
7472 )
7573 button_stop = pn .widgets .Button (name = "Stop" , on_click = self .stop_nice )
7674 nice_mode_radio = pn .widgets .RadioBoxGroup .from_param (
77- self .param .nice_mode , inline = True , margin = (15 , 20 , 0 , 20 )
75+ self .nice_settings . param .mode , inline = True , margin = (15 , 20 , 0 , 20 )
7876 )
7977 buttons = pn .Row (button_start , button_stop , nice_mode_radio )
8078
8179 # Accordion does not allow dynamic titles, so use separate card for each option
8280 options = pn .Column (
8381 self ._create_card (
84- pn . bind ( self .nice_settings .panel , nice_mode = self . param . nice_mode ) ,
82+ self .nice_settings .panel ,
8583 "NICE Configuration" ,
86- is_valid = param .rx (self . required_nice_settings_filled ),
84+ is_valid = self . nice_settings . param .are_required_filled . rx (),
8785 ),
8886 self ._create_card (self .nice_plotter , "Plotting Parameters" ),
8987 self ._create_card (
9088 self .plasma_shape ,
9189 "Plasma Shape" ,
9290 is_valid = self .plasma_shape .param .has_shape ,
93- visible = self .param .nice_mode .rx () == NiceSettings .INVERSE_MODE ,
91+ visible = self .nice_settings .param .mode .rx ()
92+ == self .nice_settings .INVERSE_MODE ,
9493 ),
9594 self ._create_card (
9695 pn .Column (self .plasma_properties , self .nice_plotter .profiles_pane ),
@@ -111,26 +110,6 @@ def __init__(self):
111110 ),
112111 )
113112
114- @param .depends (
115- "nice_mode" ,
116- * (f"nice_settings.{ p } " for p in NiceSettings .BASE_REQUIRED ),
117- "nice_settings.inv_executable" ,
118- "nice_settings.dir_executable" ,
119- )
120- def required_nice_settings_filled (self ):
121- """Checks if all required base settings and the mode-specific
122- executable are filled."""
123- base_ready = all (
124- getattr (self .nice_settings , p ) for p in self .nice_settings .BASE_REQUIRED
125- )
126- if not base_ready :
127- return False
128-
129- if self .nice_mode == NiceSettings .INVERSE_MODE :
130- return bool (self .nice_settings .inv_executable )
131- else :
132- return bool (self .nice_settings .dir_executable )
133-
134113 def _create_card (self , panel_object , title , is_valid = None , visible = True ):
135114 """Create a collapsed card containing a panel object and a title.
136115
@@ -212,7 +191,7 @@ def _create_equilibrium(self):
212191 equilibrium .vacuum_toroidal_field .b0 .resize (1 )
213192
214193 # Only fill plasma shape for NICE inverse mode
215- if self .nice_mode == NiceSettings .INVERSE_MODE :
194+ if self .nice_settings . mode == self . nice_settings .INVERSE_MODE :
216195 equilibrium .time_slice [0 ].boundary .outline .r = self .plasma_shape .outline_r
217196 equilibrium .time_slice [0 ].boundary .outline .z = self .plasma_shape .outline_z
218197
@@ -237,7 +216,7 @@ async def submit(self, event=None):
237216 description IDSs and an input equilibrium IDS."""
238217
239218 self .coil_currents .fill_pf_active (self .pf_active )
240- if self .nice_mode == NiceSettings .DIRECT_MODE :
219+ if self .nice_settings . mode == self . nice_settings .DIRECT_MODE :
241220 xml_params = self .xml_params_dir
242221 else :
243222 xml_params = self .xml_params_inv
@@ -248,7 +227,9 @@ async def submit(self, event=None):
248227 equilibrium = self ._create_equilibrium ()
249228 if not self .communicator .running :
250229 await self .communicator .run (
251- is_direct_mode = (self .nice_mode == NiceSettings .DIRECT_MODE )
230+ is_direct_mode = (
231+ self .nice_settings .mode == self .nice_settings .DIRECT_MODE
232+ )
252233 )
253234 await self .communicator .submit (
254235 ET .tostring (xml_params , encoding = "unicode" ),
@@ -260,7 +241,7 @@ async def submit(self, event=None):
260241 )
261242 self .coil_currents .sync_ui_with_pf_active (self .communicator .pf_active )
262243
263- @param .depends ("nice_mode " , watch = True )
244+ @param .depends ("nice_settings.mode " , watch = True )
264245 async def stop_nice (self , event = None ):
265246 logger .info ("Stopping NICE..." )
266247 await self .communicator .close ()
0 commit comments