Beispiel #1
0
 def __init__(self,
              bins,
              sample_rate,
              fft_window='hann',
              fft_overlap=0.5,
              crop_factor=0,
              log_scale=True,
              remove_dc=False,
              detrend=None,
              lnb_lo=0,
              max_threads=0,
              max_queue_size=0):
     self._bins = bins
     self._sample_rate = sample_rate
     self._fft_window = fft_window
     self._fft_overlap = fft_overlap
     self._fft_overlap_bins = math.floor(self._bins * self._fft_overlap)
     self._crop_factor = crop_factor
     self._log_scale = log_scale
     self._remove_dc = remove_dc
     self._detrend = detrend
     self._lnb_lo = lnb_lo
     self._executor = threadpool.ThreadPoolExecutor(
         max_workers=max_threads,
         max_queue_size=max_queue_size,
         thread_name_prefix='PSD_thread')
     self._base_freq_array = numpy.fft.fftfreq(self._bins,
                                               1 / self._sample_rate)
Beispiel #2
0
    def __init__(self, output=sys.stdout):
        self._close_output = False

        # If output is integer, assume it is file descriptor and open it
        if isinstance(output, int):
            self._close_output = True
            if sys.platform == 'win32':
                output = msvcrt.open_osfhandle(output, 0)
            output = open(output, 'wb')

        # Get underlying buffered file object
        try:
            self.output = output.buffer
        except AttributeError:
            self.output = output

        # Use only one writer thread to preserve sequence of written frequencies
        self._executor = threadpool.ThreadPoolExecutor(
            max_workers=1,
            max_queue_size=100,
            thread_name_prefix='Writer_thread')