From 7ffc59d15d432fd1f039d9f6486e7fb9ed326d06 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Thu, 27 Feb 2020 17:53:51 -0700 Subject: [PATCH] Adding contouring of the CME cloud. This significantly slows down the drawing because a new contour has to be calculated every frame. --- enlilviz/plotting/plots.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/enlilviz/plotting/plots.py b/enlilviz/plotting/plots.py index d24685f..714f746 100644 --- a/enlilviz/plotting/plots.py +++ b/enlilviz/plotting/plots.py @@ -207,6 +207,12 @@ def _init_plot(self): shading='flat') self.plot_data['mesh'] = mesh + # CME Data + data = run.get_slice('cme', 'lat', self.time) + r_lon, lon_r = np.meshgrid(r, lon) + self.plot_data['contour'] = ax.contour(lon_r, r_lon, data, + levels=[0], colors='k') + # Polarity lines arc_min, = ax.plot(lon, inner_pol, c='tab:orange', lw=2) arc_max, = ax.plot(lon, outer_pol, c='tab:orange', lw=2) @@ -246,10 +252,19 @@ def _init_plot(self): def update(self): """Update all variable quantities within the plot.""" run = self.enlil_run + r = run.r lon = np.deg2rad(run.lon) data = run.get_slice(self.var, 'lat', self.time) self.plot_data['mesh'].set_array(data.values.flatten()) + # CME Data + data = run.get_slice('cme', 'lat', self.time) + r_lon, lon_r = np.meshgrid(r, lon) + for level in self.plot_data['contour'].collections: + level.remove() + self.plot_data['contour'] = self.ax.contour(lon_r, r_lon, data, + levels=[0], colors='k') + inner_pol, outer_pol = self._get_polarity_data('lat') self.plot_data['pol_min'].set_data(lon, inner_pol) self.plot_data['pol_max'].set_data(lon, outer_pol) @@ -294,6 +309,12 @@ def _init_plot(self): cmap=cmap, norm=norm, shading='flat') self.plot_data['mesh'] = mesh + # CME Data + data = run.get_slice('cme', 'lon', self.time) + r_lat, lat_r = np.meshgrid(r, lat) + self.plot_data['contour'] = ax.contour(lat_r, r_lat, data, + levels=[0], colors='k') + # Polarity lines arc_min, = ax.plot(lat, inner_pol, c='tab:orange', lw=2) arc_max, = ax.plot(lat, outer_pol, c='tab:orange', lw=2) @@ -331,10 +352,20 @@ def _init_plot(self): def update(self): """Update all variable quantities within the plot.""" run = self.enlil_run + r = run.r lat = np.deg2rad(run.lat) + r_lat, lat_r = np.meshgrid(r, lat) + data = run.get_slice(self.var, 'lon', self.time) self.plot_data['mesh'].set_array(data.values.flatten()) + # CME Data + data = run.get_slice('cme', 'lon', self.time) + for level in self.plot_data['contour'].collections: + level.remove() + self.plot_data['contour'] = self.ax.contour(lat_r, r_lat, data, + levels=[0], colors='k') + inner_pol, outer_pol = self._get_polarity_data('lon') self.plot_data['pol_min'].set_data(lat, inner_pol) self.plot_data['pol_max'].set_data(lat, outer_pol)