Пример #1
0
    def set_record(self, record, step):
        self.record = record
        self.step = step
        self.xrange = np.linspace(0,
                                  len(self.record.signal) / self.record.fs,
                                  num=len(self.record.signal),
                                  endpoint=False)
        self.xmin = self.xrange[0]
        self.xmax = self.xrange[-1]
        self.markers = {}

        ax = self.minimapFig.axes[0]
        ax.lines = []
        formatter = FuncFormatter(
            lambda x, pos: str(datetime.timedelta(seconds=x)))
        ax.xaxis.set_major_formatter(formatter)
        ax.grid(True, which='both')
        ax.plot(self.xrange,
                self.record.signal,
                color='black',
                rasterized=True)
        ax.set_xlim(self.xmin, self.xmax)
        plotting.adjust_axes_height(ax)
        # Set the playback marker
        self.playback_marker = PlayBackMarker(self.minimapFig, self)
        self.playback_marker.markers[0].set_animated(True)
        # Draw canvas
        self.minimapCanvas.draw()
        self.minimapBackground = self.minimapCanvas.copy_from_bbox(
            self.minimapFig.bbox)
        self.draw_animate()
Пример #2
0
    def set_record(self, record, step):
        self.record = record
        self.step = step
        self.xrange = np.linspace(0, len(self.record.signal) / self.record.fs,
                                  num=len(self.record.signal), endpoint=False)
        self.xmin = self.xrange[0]
        self.xmax = self.xrange[-1]
        self.markers = {}

        ax = self.minimapFig.axes[0]
        ax.lines = []
        formatter = FuncFormatter(lambda x, pos: str(datetime.timedelta(seconds=x)))
        ax.xaxis.set_major_formatter(formatter)
        ax.grid(True, which='both')
        # Set dataseries to plot
        xmin = self.xmin * self.record.fs
        xmax = self.xmax * self.record.fs
        pixel_width = np.ceil(self.minimapFig.get_figwidth() * self.minimapFig.get_dpi())
        x_data, y_data = plotting.reduce_data(self.xrange, self.record.signal, pixel_width, xmin, xmax)
        # self._plot_data.set_xdata(x_data)
        # self._plot_data.set_ydata(y_data)
        ax.plot(x_data, y_data, color='black', rasterized=True)
        ax.set_xlim(self.xmin, self.xmax)
        plotting.adjust_axes_height(ax)
        # Set the playback marker
        self.playback_marker = PlayBackMarker(self.minimapFig, self)
        self.playback_marker.markers[0].set_animated(True)
        # Draw canvas
        self.minimapCanvas.draw()
        self.minimapBackground = self.minimapCanvas.copy_from_bbox(self.minimapFig.bbox)
        self.draw_animate()
Пример #3
0
 def update_cf(self):
     if self.data_loaded:
         self.cf = self.document.record.cf
         self._cf_data.set_xdata(self.time[:len(self.cf)])
         self._cf_data.set_ydata(self.cf)
         plotting.adjust_axes_height(self.cf_ax)
         cf_loaded = (self.cf.size != 0)
         self.CF_loaded.emit(cf_loaded)
         self.set_cf_visible(cf_loaded)
Пример #4
0
 def update_cf(self):
     if self.data_loaded:
         self.cf = self.document.record.cf
         self._cf_data.set_xdata(self.time[:len(self.cf)])
         self._cf_data.set_ydata(self.cf)
         plotting.adjust_axes_height(self.cf_ax)
         cf_loaded = (self.cf.size != 0)
         self.CF_loaded.emit(cf_loaded)
         self.set_cf_visible(cf_loaded)
Пример #5
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0,
                             len(self.signal) / self.fs,
                             num=len(self.signal),
                             endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     self._signal_data = self.signal_ax.plot(self.time,
                                             self.signal,
                                             color='black',
                                             rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time,
                                               self.envelope,
                                               color='red',
                                               rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     self._cf_data = self.cf_ax.plot(self.time[:len(self.cf)],
                                     self.cf,
                                     color='black',
                                     rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax,
                            self.signal,
                            self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
Пример #6
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0, len(self.signal) / self.fs, num=len(self.signal), endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     self._signal_data = self.signal_ax.plot(self.time,
                                               self.signal,
                                               color='black',
                                               rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time,
                                                 self.envelope,
                                                 color='red',
                                                 rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     self._cf_data = self.cf_ax.plot(self.time[:len(self.cf)],
                                           self.cf,
                                           color='black', rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax, self.signal, self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
Пример #7
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0,
                             len(self.signal) / self.fs,
                             num=len(self.signal),
                             endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.minimapSelector.set(
         visible=False)  # Hide minimap selector while loading
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     step_samples = step * self.fs
     self._signal_data = self.signal_ax.plot(self.time[:step_samples],
                                             self.signal[:step_samples],
                                             color='black',
                                             rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time[:step_samples],
                                               self.envelope[:step_samples],
                                               color='red',
                                               rasterized=True)[0]
     # Adjust y axis for signal plot
     signal_yaxis_max_value = max(np.max(self.signal),
                                  np.max(self.envelope))
     signal_yaxis_min_value = np.min(self.signal)
     plotting.adjust_axes_height(self.signal_ax,
                                 max_value=signal_yaxis_max_value,
                                 min_value=signal_yaxis_min_value)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     cf_step_samples = min(step_samples, len(self.cf))
     self._cf_data = self.cf_ax.plot(self.time[:cf_step_samples],
                                     self.cf[:cf_step_samples],
                                     color='black',
                                     rasterized=True)[0]
     # Adjust y axis for CF plot
     if cf_loaded:
         plotting.adjust_axes_height(self.cf_ax,
                                     max_value=np.max(self.cf),
                                     min_value=np.min(self.cf))
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax,
                            self.signal,
                            self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
     # Set event markers
     self.eventMarkers = {}
     for event in self.document.record.events:
         self.create_event(event)
     # Now activate selector again on minimap
     self.minimap.minimapSelector.set(visible=True)
     self.minimap.draw()
Пример #8
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0, len(self.signal) / self.fs, num=len(self.signal), endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.minimapSelector.set(visible=False)  # Hide minimap selector while loading
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     step_samples = step * self.fs
     self._signal_data = self.signal_ax.plot(self.time[:step_samples],
                                               self.signal[:step_samples],
                                               color='black',
                                               rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time[:step_samples],
                                                 self.envelope[:step_samples],
                                                 color='red',
                                                 rasterized=True)[0]
     # Adjust y axis for signal plot
     signal_yaxis_max_value = max(np.max(self.signal), np.max(self.envelope))
     signal_yaxis_min_value = np.min(self.signal)
     plotting.adjust_axes_height(self.signal_ax,
                                 max_value=signal_yaxis_max_value,
                                 min_value=signal_yaxis_min_value)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     cf_step_samples = min(step_samples,len(self.cf))
     self._cf_data = self.cf_ax.plot(self.time[:cf_step_samples],
                                     self.cf[:cf_step_samples],
                                     color='black',
                                     rasterized=True)[0]
     # Adjust y axis for CF plot
     if cf_loaded:
         plotting.adjust_axes_height(self.cf_ax,
                                     max_value=np.max(self.cf),
                                     min_value=np.min(self.cf))
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax, self.signal, self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
     # Set event markers
     self.eventMarkers = {}
     for event in self.document.record.events:
         self.create_event(event)
     # Now activate selector again on minimap
     self.minimap.minimapSelector.set(visible=True)
     self.minimap.draw()