Returnes the frequency-axis lower bin edge values for the spectrogram.
974201
def frequency_bins(header):
  '''
   
  '''

  center_frequency = 1.0e6*header['rf_center_frequency']
  if header["number_of_subbands"] > 1:
    center_frequency += header["subband_spacing_hz"]*(header["number_of_subbands"]/2.0 - 0.5)

  return np.fft.fftshift(\
    np.fft.fftfreq( int(header["number_of_subbands"] * constants.bins_per_half_frame*(1.0 - header['over_sampling'])), \
      1.0/(header["number_of_subbands"]*header["subband_spacing_hz"])) + center_frequency
    )
89118
def get_edges(self):
        

        lr_x, lr_y = self.get_vec_lr()
        tb_x, tb_y = self.get_vec_tb()

        top_left = self.x, self.y
        top_right = self.x + lr_x, self.y + lr_y
        bottom_left = self.x + tb_x, self.y + tb_y
        bottom_right = self.x + lr_x + tb_x, self.y + lr_y + tb_y

        return top_left, top_right, bottom_left, bottom_right
880956
def frequencies_iter(self):
        
        f = self.__matrix.mean(axis=0)
        for i, m in self.mappings.iteritems():
            yield m, f[i]
508213
def _fourier(self):
        

        freq_bin_upper = 2000
        freq_bin_lower = 40
        fs = self._metadata['fs']
        Y_transformed = {}
        for key in self.Y_dict.keys():
            # normalize by fs, bins have units strain/Hz
            fs = self._metadata["fs"]
            Y_transformed[key] = (1./fs)*np.fft.fft(self.Y_dict[key])[freq_bin_lower:freq_bin_upper]
        self.Y_transformed = Y_transformed
        # add in transform metadata
        self._metadata["dF"] = 1./self._metadata["T"]

        # because we are in the fourier domain, we will need the psd
        self.psd = load_psd()[freq_bin_lower:freq_bin_upper]
        dF = self._metadata['dF']
        self.sigma = convert_psd_to_sigma(self.psd, dF)
823184
def band_width(high_data, low_data, period):
    
    catch_errors.check_for_input_len_diff(high_data, low_data)
    diff = np.array(high_data) - np.array(low_data)
    bw = sma(diff, period)
    return bw
36256
def get_spectral_index(src, egy):
    """"""
    delta = 1E-5
    f0 = src.spectrum()(pyLike.dArg(egy * (1 - delta)))
    f1 = src.spectrum()(pyLike.dArg(egy * (1 + delta)))

    if f0 > 0 and f1 > 0:
        gamma = np.log10(f0 / f1) / np.log10((1 - delta) / (1 + delta))
    else:
        gamma = np.nan

    return gamma
893184
def stem_frequencies(self):
        """"""
        stemfreq = self.array.sum(axis=1).astype(np.float)
        stemfreq /= stemfreq.sum()
        return stemfreq
1019329
def get_edge_string(self, i):
        """"""
        order = self.orders[i]
        if order == 0:
            return Graph.get_edge_string(self, i)
        else:
            # pad with zeros to make sure that string sort is identical to number sort
            return "%03i" % order
892082
def get_bounds_x0_eps(tuning_options):
    """"""
    values = tuning_options.tune_params.values()

    if tuning_options.scaling:
        #bounds = [(0, 1) for _ in values]
        #x0 = [0.5 for _ in bounds]
        eps = numpy.amin([1.0/len(v) for v in values])

        #reducing interval from [0, 1] to [0, eps*len(v)]
        bounds = [(0, eps*len(v)) for v in values]
        x0 = [0.5*eps*len(v) for v in values]
    else:
        bounds = get_bounds(tuning_options.tune_params)
        x0 = [(min_v+max_v)/2.0 for (min_v, max_v) in bounds]
        eps = 1e9
        for v_list in values:
            vals = numpy.sort(v_list)
            eps = min(eps, numpy.amin(numpy.gradient(vals)))

    tuning_options["eps"] = eps
    logging.debug('get_bounds_x0_eps called')
    logging.debug('bounds ' + str(bounds))
    logging.debug('x0 ' + str(x0))
    logging.debug('eps ' + str(eps))

    return bounds, x0, eps
1291184
def find_Note(data, freq, bits):
    """"""
    data = find_frequencies(data, freq, bits)
    return sorted(find_notes(data), key=operator.itemgetter(1))[-1][0]
640000
def _downsample(self, how, **kwargs):
        
        self._set_binner()
        how = self._is_cython_func(how) or how
        ax = self.ax
        obj = self._selected_obj

        if not len(ax):
            # reset to the new freq
            obj = obj.copy()
            obj.index.freq = self.freq
            return obj

        # do we have a regular frequency
        if ax.freq is not None or ax.inferred_freq is not None:

            if len(self.grouper.binlabels) > len(ax) and how is None:

                # let's do an asfreq
                return self.asfreq()

        # we are downsampling
        # we want to call the actual grouper method here
        result = obj.groupby(
            self.grouper, axis=self.axis).aggregate(how, **kwargs)

        result = self._apply_loffset(result)
        return self._wrap_result(result)
682125
def min_freq(self):
        
        i = np.unravel_index(np.argmin(self.bands), self.bands.shape)

        return self.qpoints[i[1]], self.bands[i]
417220
def get_band(low_hist, high_hist, middle_hist=None):
    
    npoints = low_hist.nbins(0)
    band = Graph(npoints)
    for i in range(npoints):
        center = low_hist.x(i + 1)
        width = low_hist.xwidth(i + 1)
        low, high = low_hist.y(i + 1), high_hist.y(i + 1)
        if middle_hist is not None:
            middle = middle_hist.y(i + 1)
        else:
            middle = (low + high) / 2.
        yerrh = max(high - middle, low - middle, 0)
        yerrl = abs(min(high - middle, low - middle, 0))
        band.SetPoint(i, center, middle)
        band.SetPointError(i, width / 2., width / 2.,
                           yerrl, yerrh)
    return band
1052099
def filter_incomplete_spectra(self, flimit=1000, percAccept=85):
        
        assert percAccept > 0 and percAccept < 100

        def _retain_only_complete_spectra(item, fmax, acceptN):
            """Function called using pd.filter, applied to all spectra in the
            data set. Return true if the number of data points <= **fmax** in
            item is equal, or larger, than **acceptN**.

            Parameters
            ----------
            item : :py:class:`pandas.DataFrame`
                dataframe containing one spectrum
            fmax : float
                maximum frequency up to which data points are counted
            acceptN : int
                the number of data points required to pass this test

            Returns
            -------
            true : bool
                if enough data points are present
            false : bool
                if not enough data points are present
            """
            frequencies = item['frequency'].loc[item['frequency'] < fmax]
            fN = frequencies.size
            if fN >= acceptN:
                return True
            return False

        group_abmn = self.data.groupby(['a', 'b', 'm', 'n'])
        frequencies = np.array(
            list(sorted(self.data.groupby('frequency').groups.keys()))
        )
        assert flimit >= frequencies.min() and flimit <= frequencies.max()
        Nlimit = len(np.where(frequencies <= flimit)[0])
        Naccept = np.ceil(Nlimit * percAccept / 100.0)
        self.data = group_abmn.filter(
            _retain_only_complete_spectra, fmax=flimit, acceptN=Naccept
        ).copy()
1493
def ylim(self, low, high):
        
        self.chart['yAxis'][0]['min'] = low
        self.chart['yAxis'][0]['max'] = high
        return self
1363852
def Eg(self, **kwargs):
        '''
        
        '''
        return min(self.Eg_Gamma(**kwargs),
                   self.Eg_L(**kwargs),
                   self.Eg_X(**kwargs))
777449
def calc_spectrum(signal, rate):
    """"""
    npts = len(signal)
    padto = 1 << (npts - 1).bit_length()
    # print 'length of signal {}, pad to {}'.format(npts, padto)
    npts = padto

    sp = np.fft.rfft(signal, n=padto) / npts
    # print('sp len ', len(sp))
    freq = np.arange((npts / 2) + 1) / (npts / rate)
    # print('freq len ', len(freq))
    return freq, abs(sp)