Esempio n. 1
0
def spatial_grid_clusters(ctrl, unit='km', axes=None, savename=''):
    """Plots the map of the nodes with clusters coloring"""
    obj = ctrl.delay_params

    x,y = [k for k in [obj.gridx, obj.gridy]]
    lims = [sign*0.55*obj.width for sign in [-1,1]]

    # convert to requested unit
    x,y = [lib.samples2dist(k, ctrl.f_samp, unit) for k in [x,y]]
    lims = [lib.samples2dist(k, ctrl.f_samp, unit) for k in lims]

    # Plot the clusters. Different clusters use different markers
    idx_klist = ctrl.idx_klist
    mark = list(__MARKS)
    color = list(__COLORS)
    if len(idx_klist) > len(mark):
        mark += ['x']*len(idx_klist)
        color += ['k']*len(idx_klist)

    
    ax = axes
    for indexes in idx_klist:
        ax = scatter_noerr(x[indexes],y[indexes],axes=ax, marker=mark.pop(0), color=color.pop(0))

    # Fix axes
    ax.set_xlabel('x-axis (' + unit + ')')
    ax.set_ylabel('y-axis (' + unit + ')')
    ax.set_xlim(lims)
    ax.set_ylim(lims)
    return ax
Esempio n. 2
0
def spatial_grid(ctrl, unit='km', show_broadcast=False, axes=None, savename='', **kwargs):
    """Plots the map of the nodes"""
    obj = ctrl.delay_params
    fct = obj.delay_pdf_eval

    x,y = [k for k in [obj.gridx, obj.gridy]]
    lims = [sign*0.55*obj.width for sign in [-1,1]]

    # convert to requested unit
    x,y = [lib.samples2dist(k, ctrl.f_samp, unit) for k in [x,y]]
    lims = [lib.samples2dist(k, ctrl.f_samp, unit) for k in lims]

    ax = scatter_noerr(x,y, axes=axes, **kwargs)

    # Plot green circles to indicate the broadcasting nodes
    radius = (lims[1]-lims[0])* 0.03
    if show_broadcast:
        for idx in ctrl.pivot_node:
            circle = plt.Circle((x[idx], y[idx]), radius, color='b', fill=False)
            ax.add_artist(circle)

    ax.set_xlabel('x-axis (' + unit + ')')
    ax.set_ylabel('y-axis (' + unit + ')')
    ax.set_xlim(lims)
    ax.set_ylim(lims)
    return ax