Beispiel #1
0
 def __redraw(self):
     '''
     draws the contours and the colorbar.
     :return:
     '''
     vmax, vmin, steps, fill_steps = calculate_dBFS_Scales(
         self.__data['z'],
         max_range=self.__display_model.db_range,
         vmax_to_round=False)
     actual_vmax = np.math.ceil(np.nanmax(self.__data['z']))
     line_offset = actual_vmax - vmax
     line_steps = steps + line_offset
     self.__tc = self.__axes.tricontour(
         self.__data['x'],
         self.__data['y'],
         self.__data['z'],
         line_steps if not self.__display_model.normalised else line_steps -
         np.max(line_steps) - 2,
         linewidths=0.5,
         colors='k',
         linestyles='--')
     self.__tc = self.__axes.tricontour(
         self.__data['x'],
         self.__data['y'],
         self.__data['z'],
         levels=[actual_vmax -
                 6] if not self.__display_model.normalised else [-6],
         linewidths=1.5,
         colors='k')
     self.__tcf = self.__axes.tricontourf(self.__data['x'],
                                          self.__data['y'],
                                          self.__data['z'],
                                          fill_steps,
                                          vmin=vmin,
                                          vmax=vmax,
                                          cmap=self.__chart.get_colour_map(
                                              self.__selected_cmap))
     self._cb = colorbar(self.__tcf)
     self._cb.set_ticks(steps)
     configureFreqAxisFormatting(self.__axes)
     self.__tcf.set_clim(vmin=vmin, vmax=vmax)
     if self.__crosshair_axes is not None:
         xlim = self.__axes.get_xlim()
         ylim = self.__axes.get_ylim()
         self.__crosshair_axes.set_xlim(left=xlim[0], right=xlim[1])
         self.__crosshair_axes.set_ylim(bottom=ylim[0], top=ylim[1])
         self.__crosshair_h = self.__crosshair_axes.axhline(color='k',
                                                            linestyle=':')
         self.__crosshair_v = self.__crosshair_axes.axvline(color='k',
                                                            linestyle=':')
         if self.__ani is None:
             logger.info(f"Starting animation in {self.name}")
             self.__ani = animation.FuncAnimation(
                 self.__chart.canvas.figure,
                 self.__redraw_crosshairs,
                 interval=50,
                 init_func=self.__init_crosshairs,
                 blit=True,
                 save_count=50,
                 repeat=False)
Beispiel #2
0
 def display(self):
     '''
     Updates the contents of the polar chart.
     :return: true if it redrew.
     '''
     redrew = False
     if self.shouldRefresh():
         # convert x-y by theta data to theta-r by freq
         xydata = self._measurementModel.getMagnitudeData(type=self._type,
                                                          ref=1)
         self._data = {}
         for idx, freq in enumerate(xydata[0].x):
             theta, r = zip(*[(math.radians(x.hAngle), x.y[idx])
                              for x in xydata])
             self._data[freq] = (theta, r)
         self._axes.set_thetagrids(np.arange(0, 360, 15))
         rmax, rmin, rsteps, _ = calculate_dBFS_Scales(
             np.concatenate([x[1] for x in self._data.values()]),
             maxRange=self.__display_model.dBRange)
         self._axes.set_rgrids(rsteps)
         # show degrees as +/- 180
         self._axes.xaxis.set_major_formatter(
             FuncFormatter(self.formatAngle))
         # show label every 12dB
         self._axes.yaxis.set_major_locator(MultipleLocator(12))
         # v line and marker
         self._vline = self._axes.axvline(0,
                                          linewidth=2,
                                          color='gray',
                                          linestyle=':',
                                          visible=False)
         self._vmarker = self._axes.plot(0,
                                         0,
                                         'bo',
                                         color='gray',
                                         markersize=6)[0]
         # plot some invisible data to initialise
         self._curve = self._axes.plot(
             [math.radians(-180), math.radians(180)], [-200, -200],
             linewidth=2,
             antialiased=True,
             linestyle='solid',
             visible=False)[0]
         self._axes.set_ylim(bottom=rmin, top=rmax)
         self._y_range_update_required = False
         self._refreshData = False
         redrew = True
     else:
         if self._axes is not None and self._y_range_update_required:
             self.updateDecibelRange(self._redrawOnDisplay)
     # make sure we are animating
     if self._ani is None and self._curve is not None:
         logger.info(f"Starting animation in {self.name}")
         self._ani = animation.FuncAnimation(self._chart.canvas.figure,
                                             self.redraw,
                                             interval=50,
                                             init_func=self.initAnimation,
                                             blit=True,
                                             save_count=50)
     return redrew
Beispiel #3
0
 def _redraw(self):
     '''
     draws the contours and the colorbar.
     :return:
     '''
     vmax, vmin, steps, fillSteps = calculate_dBFS_Scales(
         self._data['z'], maxRange=self.__display_model.dBRange)
     self._tc = self._axes.tricontour(self._data['x'],
                                      self._data['y'],
                                      self._data['z'],
                                      steps,
                                      linewidths=0.5,
                                      colors='k',
                                      linestyles='--')
     self._tc = self._axes.tricontour(self._data['x'],
                                      self._data['y'],
                                      self._data['z'],
                                      levels=[vmax - 6],
                                      linewidths=1.5,
                                      colors='k')
     self._tcf = self._axes.tricontourf(self._data['x'],
                                        self._data['y'],
                                        self._data['z'],
                                        fillSteps,
                                        vmin=vmin,
                                        vmax=vmax,
                                        cmap=self._chart.getColourMap(
                                            self._selectedCmap))
     self._cb = colorbar(self._tcf)
     self._cb.set_ticks(steps)
     configureFreqAxisFormatting(self._axes)
     self._tcf.set_clim(vmin=vmin, vmax=vmax)
     if self.__crosshair_axes is not None:
         xlim = self._axes.get_xlim()
         ylim = self._axes.get_ylim()
         self.__crosshair_axes.set_xlim(left=xlim[0], right=xlim[1])
         self.__crosshair_axes.set_ylim(bottom=ylim[0], top=ylim[1])
         self.__crosshair_h = self.__crosshair_axes.axhline(color='k',
                                                            linestyle=':')
         self.__crosshair_v = self.__crosshair_axes.axvline(color='k',
                                                            linestyle=':')
         if self.__ani is None:
             logger.info(f"Starting animation in {self.name}")
             self.__ani = animation.FuncAnimation(
                 self._chart.canvas.figure,
                 self.__redraw_crosshairs,
                 interval=50,
                 init_func=self.__init_crosshairs,
                 blit=True,
                 save_count=50,
                 repeat=False)
Beispiel #4
0
 def display(self):
     '''
     Gets fresh data and redraws.
     :return: true if it redrew.
     '''
     redrew = False
     if self.should_refresh():
         if self.__pressure_curve is None:
             # pressure
             self.__pressure_data = self.__measurement_model.get_magnitude_data(
             )
             self.__pressure_curve = self.__axes.semilogx(
                 self.__pressure_data[0].x,
                 [np.nan] * len(self.__pressure_data[0].x),
                 linewidth=2,
                 antialiased=True,
                 linestyle='solid')[0]
             self.__pressure_marker = self.__axes.plot(0,
                                                       0,
                                                       'bo',
                                                       markersize=8)[0]
             all_data = [x.y for x in self.__pressure_data]
             # directivity
             if self.__di_data:
                 self.__di_curve = self.__secondary_axes.semilogx(
                     self.__di_data[0].x,
                     [np.nan] * len(self.__pressure_data[0].x),
                     linewidth=2,
                     antialiased=True,
                     linestyle='--')[0]
                 self.__di_marker = self.__secondary_axes.plot(
                     0, 0, 'bo', markersize=8)[0]
             if self.__power_data:
                 # power
                 self.__power_curve = self.__axes.semilogx(
                     self.__power_data.x,
                     self.__power_data.y,
                     linewidth=2,
                     antialiased=True,
                     color='k',
                     linestyle='solid')[0]
                 self.__power_marker = self.__axes.plot(0,
                                                        0,
                                                        'ko',
                                                        markersize=8)[0]
                 all_data.append(self.__power_data.y)
             # line
             self.__vline = self.__axes.axvline(x=0,
                                                linewidth=2,
                                                color='gray',
                                                linestyle=':')
             # scales
             ymax, ymin, _, _ = calculate_dBFS_Scales(
                 np.concatenate(all_data),
                 max_range=self.__display_model.db_range)
             self.__axes.set_ylim(bottom=ymin, top=ymax, auto=False)
             configureFreqAxisFormatting(self.__axes)
             self.__y_range_update_required = False
             self.__refresh_data = False
             redrew = True
     else:
         if self.__pressure_curve is not None:
             if self.__y_range_update_required:
                 self.update_decibel_range(self.__redraw_on_display)
     # make sure we are animating
     if self.__ani is None and self.__pressure_data is not None:
         logger.info(f"Starting animation in {self.name}")
         self.__ani = animation.FuncAnimation(self._chart.canvas.figure,
                                              self.redraw,
                                              interval=50,
                                              init_func=self.initAnimation,
                                              blit=True,
                                              save_count=50,
                                              repeat=False)
     return redrew
Beispiel #5
0
 def _update_y_lim(self, data, axes):
     configureFreqAxisFormatting(axes)
     ymax, ymin, _, _ = calculate_dBFS_Scales(
         data, max_range=self.__display_model.db_range)
     axes.set_ylim(bottom=ymin, top=ymax)