Issue with `_find_separatrix()` for CDB loaded data
Issue with _find_separatrix()
in versions:
There are no such issues in an older code, ref 85877fd2,
which is installed in modules as pleque/unstable
.
Code to reproduce
from pleque.io.compass import cdb as pleque_io_cdb
# Any of these produce an error
eq = pleque_io_cdb(21673, 1150.0, revision=-1)
# eq = pleque_io_cdb(21554, 1210.0, revision=-1)
# eq = pleque_io_cdb(20908, 1150.0, revision=-1)
# eq = pleque_io_cdb(15964, 1160.0, revision=-1)
eq.plot_overview()
Trace
/compass/home/hecko/repos/pleque/pleque/io/tools.py:35: UserWarning: rename 'Rt' to 'R' does not create an index anymore. Try using swap_dims instead or use set_index after rename to create an indexed coordinate.
ds = ds.rename({'Rt': 'R', 'Zt': 'Z'})
/compass/home/hecko/repos/pleque/pleque/io/tools.py:35: UserWarning: rename 'Zt' to 'Z' does not create an index anymore. Try using swap_dims instead or use set_index after rename to create an indexed coordinate.
ds = ds.rename({'Rt': 'R', 'Zt': 'Z'})
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[12], line 7
2 # eq = pleque_io_cdb(21673, 1150.0, revision=-1)
3 # eq = pleque_io_cdb(21554, 1210.0, revision=-1)
4 # eq = pleque_io_cdb(20908, 1150.0, revision=-1)
5 eq = pleque_io_cdb(15964, 1160.0, revision=-1)
----> 7 eq.plot_overview()
File ~/repos/pleque/pleque/core/equilibrium.py:986, in Equilibrium.plot_overview(self, ax, **kwargs)
981 def plot_overview(self, ax=None, **kwargs):
982 """
983 Simple routine for plot of plasma overview
984 :return:
985 """
--> 986 return self._plot_overview(ax, **kwargs)
File ~/repos/pleque/pleque/core/equilibrium.py:995, in Equilibrium._plot_overview(self, ax, **kwargs)
993 from pleque.utils.plotting import plot_equilibrium
994 # plt.figure()
--> 995 return plot_equilibrium(self, ax=ax, **kwargs)
File ~/repos/pleque/pleque/utils/plotting.py:93, in plot_equilibrium(eq, ax, colorbar, **kwargs)
90 ax.fill_between(eq._first_wall[:, 0], eq._first_wall[:, 1], color='lightgrey')
91 ax.plot(eq._first_wall[:, 0], eq._first_wall[:, 1], color='k', lw=2,
92 label='First wall')
---> 93 sep = eq.separatrix
94 in_fw = eq.in_first_wall(sep)
95 ax.plot(sep.R[in_fw], sep.Z[in_fw], color='C3', lw=2, alpha=0.5)
File ~/repos/pleque/pleque/core/equilibrium.py:1322, in Equilibrium.separatrix(self)
1320 if not self._limiter_plasma:
1321 if not hasattr(self, '_separatrix'):
-> 1322 self._find_separatrix()
1323 return self._as_fluxsurface(self._separatrix)
1324 else:
File ~/repos/pleque/pleque/core/equilibrium.py:1346, in Equilibrium._find_separatrix(self)
1343 for j in separatrix:
1344 # todo: this is not separatrix... for example in limiter plasma and without first wall
1345 intersection = np.array(self.first_wall._string.intersection(j._string))
-> 1346 if len(intersection) > 0:
1347 self._separatrix = j.as_array(("R", "Z"))
1348 found = True
TypeError: len() of unsized object
Edited by Jan Hečko