numpy.sort

Here are the examples of the python api numpy.sort taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

152 Examples 7

Example 151

Project: OSCAAR Source File: dataBank.py
    def plotComparisonWeightings(self, apertureRadiusIndex=0):
        """
        Plot histograms visualizing the relative weightings of the comparison
        stars used to produce the "mean comparison star", from which the
        light curve is calculated.

        Parameters
        ----------
        apertureRadiusIndex : int, optional (default=0)
            Index of the aperture radius list corresponding to the aperture radius
            from which to produce the plot.

        """
        plt.ion()
        weights = self.comparisonStarWeights[apertureRadiusIndex]
        weights = np.sort(weights,axis=1)
        width = 0.5
        indices = weights[0,:]
        coefficients = weights[1,:]
        fig = plt.figure(num=None, figsize=(10, 8), facecolor='w',edgecolor='k')
        fig.canvas.set_window_title('OSCAAR')
        ax = fig.add_subplot(111)
        ax.set_xlim([0,len(indices)+1])
        ax.set_xticks(indices+width/2)
        ax.set_xticklabels(["Star "+str(i) for i in range(len(indices))])
        ax.set_xlabel('Comparison Star')
        ax.set_ylabel('Normalized Weighting')
        ax.set_title('Comparison Star Weights into the Composite Comparison Star for aperture radius %s' \
                     % self.apertureRadii[apertureRadiusIndex])
        ax.axhline(xmin=0,xmax=1,y=1.0/len(indices),linestyle=':',color='k')
        ax.bar(indices,coefficients,width,color='w')
        plt.ioff()
        plt.show()

Example 152

Project: astroML Source File: lumfunc.py
def binned_Cminus(x, y, xmax, ymax, xbins, ybins, normalize=False):
    """Compute the binned distributions using the Cminus method

    Parameters
    ----------
    x : array_like
        array of x values
    y : array_like
        array of y values
    xmax : array_like
        array of maximum x values for each y value
    ymax : array_like
        array of maximum y values for each x value
    xbins : array_like
        array of bin edges for the x function: size=Nbins_x + 1
    ybins : array_like
        array of bin edges for the y function: size=Nbins_y + 1
    normalize : boolean
        if true, then returned distributions are normalized.  Default
        is False.

    Returns
    -------
    dist_x, dist_y : ndarrays
        distributions of size Nbins_x and Nbins_y
    """
    Nx, Ny, cueml_x, cueml_y = Cminus(x, y, xmax, ymax)

    # simple linear interpolation using a binary search
    # interpolate the cuemulative distributions
    x_sort = np.sort(x)
    y_sort = np.sort(y)

    Ix_edges = _sorted_interpolate(x_sort, cueml_x, xbins)
    Iy_edges = _sorted_interpolate(y_sort, cueml_y, ybins)

    if xbins[0] < x_sort[0]:
        Ix_edges[0] = cueml_x[0]
    if xbins[-1] > x_sort[-1]:
        Ix_edges[-1] = cueml_x[-1]

    if ybins[0] < y_sort[0]:
        Iy_edges[0] = cueml_y[0]
    if ybins[-1] > y_sort[-1]:
        Iy_edges[-1] = cueml_y[-1]

    x_dist = np.diff(Ix_edges) / np.diff(xbins)
    y_dist = np.diff(Iy_edges) / np.diff(ybins)

    if normalize:
        x_dist /= len(x)
        y_dist /= len(y)

    return x_dist, y_dist
See More Examples - Go to Next Page
Page 1 Page 2 Page 3 Page 4 Selected