From 91589979ec8bc9978fe28301b922134c0baa02d5 Mon Sep 17 00:00:00 2001 From: flothesof Date: Tue, 3 Dec 2019 16:52:04 +0100 Subject: [PATCH 1/3] Update _def.py --- tofu/geom/_def.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tofu/geom/_def.py b/tofu/geom/_def.py index 2119c8236..0e3912784 100644 --- a/tofu/geom/_def.py +++ b/tofu/geom/_def.py @@ -164,7 +164,6 @@ def Plot_3D_plt_Tor_DefAxes(fs=None, wintit='tofu'): ax.set_xlabel(r"X (m)") ax.set_ylabel(r"Y (m)") ax.set_zlabel(r"Z (m)") - ax.set_aspect(aspect="equal", adjustable='datalim') return ax From dfab135871f74518c15118f1e55fff95efa8edef Mon Sep 17 00:00:00 2001 From: flothesof Date: Wed, 4 Dec 2019 10:07:56 +0100 Subject: [PATCH 2/3] add test and try to make better docstrings --- tofu/geom/_core.py | 17 +++++++++++------ tofu/tests/tests00_root/tests03_plot.py | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tofu/geom/_core.py b/tofu/geom/_core.py index 4e4021a11..97f78abf3 100644 --- a/tofu/geom/_core.py +++ b/tofu/geom/_core.py @@ -4430,10 +4430,16 @@ def _compute_kInOut(self, largs=None, dkwd=None, indStruct=None): indout[0, :] = indStruct[indout[0, :]] return kIn, kOut, vperp, indout, indStruct - def compute_dgeom(self, extra=True, plotdebug=True): + def compute_dgeom(self, extra=True, show_debug_plot=True): + """ + Computes the dgeom attribute (what does dgeom mean? I'm guessing it stands for shortened dict_geometry?). + + :param extra: bool, whether to perform some extra computations (which ones?) + :param show_debug_plot: bool, whether to show a debugging plot for invalid LOSes + """ # Can only be computed if config if provided if self._dconfig["Config"] is None: - msg = "Attribute dgeom cannot be computed without a config !" + msg = "Attribute dgeom cannot be computed without a config!" warnings.warn(msg) return @@ -4444,13 +4450,13 @@ def compute_dgeom(self, extra=True, plotdebug=True): # Perform computation of kIn and kOut kIn, kOut, vperp, indout, indStruct = self._compute_kInOut() - # Clean up (in case of nans) + # Check for LOS that have no visibility inside the plasma domain ind = np.isnan(kIn) kIn[ind] = 0.0 ind = np.isnan(kOut) | np.isinf(kOut) if np.any(ind): kOut[ind] = np.nan - msg = "Some LOS have no visibility inside the plasma domain !\n" + msg = "Some LOS have no visibility inside the plasma domain!\n" msg += "Nb. of LOS concerned: %s out of %s\n" % ( str(ind.sum()), str(kOut.size), @@ -4460,10 +4466,9 @@ def compute_dgeom(self, extra=True, plotdebug=True): msg += "\nIndices of LOS with no visibility:\n" msg += repr(ind.nonzero()[0]) warnings.warn(msg) - if plotdebug: + if show_debug_plot: PIn = self.D[:, ind] + kIn[None, ind] * self.u[:, ind] POut = self.D[:, ind] + kOut[None, ind] * self.u[:, ind] - # To be updated _plot._LOS_calc_InOutPolProj_Debug( self.config, self.D[:, ind], diff --git a/tofu/tests/tests00_root/tests03_plot.py b/tofu/tests/tests00_root/tests03_plot.py index 092fcef6d..f17463cf7 100644 --- a/tofu/tests/tests00_root/tests03_plot.py +++ b/tofu/tests/tests00_root/tests03_plot.py @@ -156,3 +156,22 @@ def test01_plot_shotoverview(self): # All together, with conf kh = tf._plot.plot_shotoverview(self.dobj, config=self.conf) plt.close('all') + + +def test_camera_missing_LOS_debug_plot(): + """This test is meant to test issue #310. It creates a camera with missing LOS + which should trigger a working debug plot to help the user adjust the camera.""" + + config = tf.geom.utils.create_config('NSTX') + + cam2d = tf.geom.utils.create_CamLOS2D( + config=config, + P=[3.4, 0, 0], + N12=10, + F=0.1, + D12=0.1, + angs=[np.pi, np.pi / 6, 0], + Name="Dummy", + Exp="Dummy", + Diag="None", + ) From 51e2e4d67bbbd3e783e1c39aa157684f334c9114 Mon Sep 17 00:00:00 2001 From: flothesof Date: Wed, 4 Dec 2019 10:26:37 +0100 Subject: [PATCH 3/3] Update tests03_plot.py --- tofu/tests/tests00_root/tests03_plot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tofu/tests/tests00_root/tests03_plot.py b/tofu/tests/tests00_root/tests03_plot.py index f17463cf7..1acc991bc 100644 --- a/tofu/tests/tests00_root/tests03_plot.py +++ b/tofu/tests/tests00_root/tests03_plot.py @@ -162,6 +162,8 @@ def test_camera_missing_LOS_debug_plot(): """This test is meant to test issue #310. It creates a camera with missing LOS which should trigger a working debug plot to help the user adjust the camera.""" + # using a "simple" configuration (not many internal structures) + # so that rendering of the debug plot is fast config = tf.geom.utils.create_config('NSTX') cam2d = tf.geom.utils.create_CamLOS2D(