Esempio n. 1
0
def plot_inference_results(image, prediction):    
    
    # prepare prediction for overlay
    pred = Image.fromarray(cm.gist_ncar(prediction, bytes=True)).convert('RGBA')
    pred_copy = pred.copy()
    mask = pred_copy.convert("L").point(lambda x: min(x, 150))
    pred_copy.putalpha(mask)
    
    # overlay image with prediction
    merged = image.copy()
    merged.paste(pred_copy, (0, 0), pred_copy)
        
    plt.figure(1)
    
    plt.subplot(2,2,3)
    plt.imshow(image)
    plt.title('Image')
    
    plt.subplot(2,2,4)
    plt.imshow(pred, cmap=cm.gist_ncar)
    plt.title('Prediction')   
    
    plt.subplot(2,1,1)
    plt.imshow(merged)
    plt.title('Image + Prediction')
    
    plt.show()
Esempio n. 2
0
def pretty_plot(data, labels, clusters, lens, plot_name):
    colors = cm.rainbow(np.linspace(0, 1, len(data)))

    fig = plt.figure()
    ax = plt.axes()

    width = 2
    height = 6
    ax.set_xlim(0, len(data[0]) * width)
    ax.set_ylim(0, len(data) * height)

    label_colors = cm.gist_ncar(np.linspace(0, 1, len(set(clusters.values())) + 1))

    for r, row in enumerate(data):
        colors = cm.rainbow(np.linspace(0, 1, lens.get(labels[r], max(row)) - 2))
        colors = np.vstack((np.array([0., 0., 0., 1.]), colors, np.array([0., 0., 0., 1.])))
        for i, pos in enumerate(row):
            if pos is not None:
                ax.add_patch(rect((i * width, r * height), width, height - 2, color=colors[pos - 1]))
                if labels[r] in clusters:
                    ax.add_line(line([i * width, (i + 1) * width], [r * height, r * height], lw=1,
                                     color=label_colors[clusters[labels[r]]]))
                    ax.add_line(line([i * width, (i + 1) * width], [(r + 1) * height - 1, (r + 1) * height - 1], lw=1,
                                     color=label_colors[clusters[labels[r]]]))
    plt.yticks(map(lambda x: x * height + height / 2., range(len(labels))), labels)
    ax.tick_params(axis='y', which='major', labelsize=3)
    plt.tight_layout()
    plt.savefig(plot_name, dpi=300)
Esempio n. 3
0
def plot_inference_results(image, prediction):

    # prepare prediction for overlay
    pred = Image.fromarray(cm.gist_ncar(prediction,
                                        bytes=True)).convert('RGBA')
    pred_copy = pred.copy()
    mask = pred_copy.convert("L").point(lambda x: min(x, 150))
    pred_copy.putalpha(mask)

    # overlay image with prediction
    merged = image.copy()
    merged.paste(pred_copy, (0, 0), pred_copy)

    plt.figure(1)

    plt.subplot(2, 2, 3)
    plt.imshow(image)
    plt.title('Image')

    plt.subplot(2, 2, 4)
    plt.imshow(pred, cmap=cm.gist_ncar)
    plt.title('Prediction')

    plt.subplot(2, 1, 1)
    plt.imshow(merged)
    plt.title('Image + Prediction')

    plt.show()
Esempio n. 4
0
 def displaySidAndQueryName(self):
     data = self.dataManager.loadData(["Aid","Sid","QueryName"],transformFields=False)        
     
     # Specific Aid
     dataAid = data[data.Aid == "012abc55-5801-494f-a77f-a799f1d855de"]
     colors = cm.gist_ncar(np.linspace(0,1,dataAid.QueryName.nunique()))
     pd.crosstab(dataAid.Sid, dataAid.QueryName).plot.barh(stacked=True, color=colors,figsize=(20, 20))
     plt.show()
Esempio n. 5
0
 def draw_ws_obstacles(self):
     colorst = [cm.gist_ncar(i) for i in np.linspace(
         0, 0.9, len(self._workspace.obstacles))]
     for i, o in enumerate(self._workspace.obstacles):
         self._ax.plot(o.origin[0], o.origin[1], 'kx')
         points = o.sampled_points()
         X = np.array(points)[:, 0]
         Y = np.array(points)[:, 1]
         self._ax.plot(X, Y, color=colorst[i], linewidth=2.0)
Esempio n. 6
0
def plot_results(workspace, x_init, x_goal, trajectory, optimizer):

    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    from mpl_toolkits.mplot3d import Axes3D
    plt.figure(figsize=(7, 6.5))
    plt.axis('equal')
    plt.axis(workspace.box.extent_data())
    colorst = [
        cm.gist_ncar(i) for i in np.linspace(0, 0.9, len(workspace.obstacles))
    ]
    for i, o in enumerate(workspace.obstacles):
        plt.plot(o.origin[0], o.origin[1], 'kx')
        points = o.sampled_points()
        X = np.array(points)[:, 0]
        Y = np.array(points)[:, 1]
        plt.plot(X, Y, color=colorst[i], linewidth=2.0)
        print("colorst[" + str(i) + "] : ", colorst[i])
    plt.plot(x_init[0], x_init[1], 'ro')
    plt.plot(x_goal[0], x_goal[1], 'bo')

    nb_points = 100
    X, Y = workspace.box.meshgrid(nb_points)
    Z = optimizer.sdf(np.stack([X, Y]))
    color_style = plt.cm.hot
    color_style = plt.cm.bone
    color_style = plt.cm.magma
    im = plt.imshow(Z,
                    extent=workspace.box.extent_data(),
                    origin='lower',
                    interpolation='bilinear',
                    cmap=color_style)
    plt.colorbar(im, fraction=0.05, pad=0.02)
    cs = plt.contour(X, Y, Z, 16, cmap=color_style)
    # plt.colorbar(cs, fraction=0.05, pad=0.02)
    plot_3d = False
    if plot_3d:
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')
        ax.plot_surface(X,
                        Y,
                        Z,
                        cmap=color_style,
                        linewidth=0,
                        antialiased=False)

    for k in range(optimizer.T + 1):
        q = trajectory.configuration(k)
        plt.plot(q[0], q[1], 'ro')
        # plt.show(block=False)
        # plt.draw()
        # plt.pause(0.0001)
    plt.show()
Esempio n. 7
0
            def print_result(self, final):
                # final is there just to eat up the parameter passed in
                # normalize the output
                # np.savetxt('test.csv', self.output, delimiter=',')
                _max = np.max(self.output)
                _output = self.output / _max if _max != 0 else self.output

                try:
                    _im = Image.fromarray(np.uint8(
                        cm.gist_ncar(_output) * 255))
                except NameError as e:
                    _im = Image.fromarray(np.uint8((_output) * 255))
                _im.save("picconv_test.png")
Esempio n. 8
0
def project_keys(keys,
                 vals,
                 age,
                 num_components=2,
                 num_classes=133,
                 file_path=None):
    from sklearn.manifold import TSNE
    import matplotlib.pyplot as plt
    from sklearn import (manifold, datasets, decomposition, ensemble,
                         discriminant_analysis, random_projection)

    N = len(keys)
    area = (10 * np.random.rand(N))**2  # 0 to 15 point radii
    area = np.ones(N) * 5

    import matplotlib.cm as cm
    colors = cm.gist_ncar(np.linspace(0, 1, num_classes))
    #colors = np.random.rand(N)

    #projection: t-sne
    tsne_model = TSNE(n_components=num_components,
                      verbose=0,
                      random_state=0,
                      angle=.99,
                      init='pca',
                      early_exaggeration=50,
                      n_iter=2000)
    keys_2D = tsne_model.fit_transform(keys)
    plt.scatter(keys_2D[:, 0],
                keys_2D[:, 1],
                s=area,
                c=colors[vals],
                alpha=0.5)
    for i in range(N):
        plt.text(keys_2D[i, 0], keys_2D[i, 1], str(vals[i]), fontsize=8)
    plt.savefig(file_path + '_tsne.png', dpi=250)
    plt.close()

    #projection: t-sne
    keys_2D = decomposition.TruncatedSVD(n_components=2).fit_transform(keys)
    plt.scatter(keys_2D[:, 0],
                keys_2D[:, 1],
                s=area,
                c=colors[vals],
                alpha=0.5)
    for i in range(N):
        plt.text(keys_2D[i, 0], keys_2D[i, 1], str(vals[i]), fontsize=8)
    plt.savefig(file_path + '_pca.png', dpi=250)
    plt.close()
Esempio n. 9
0
            def print_result(self, final=False):
                # normalize the output
                # np.savetxt('test.csv', self.output, delimiter=',')
                _max = np.max(self.output)
                _output = self.output / _max if _max != 0 else self.output

                try:
                    _im = Image.fromarray(np.uint8(
                        cm.gist_ncar(_output) * 255))
                except NameError as e:
                    _im = Image.fromarray(np.uint8((_output) * 255))

                if not final:
                    _im.save("results/test-{}.png".format(self.resultCount))
                else:
                    _im.save("picconv_test.png")
                # https://stackoverflow.com/questions/10965417/how-to-convert-numpy-array-to-pil-image-applying-matplotlib-colormap

                self.resultCount += 1
Esempio n. 10
0
def plot_embedding(X, labels, title=None):
    """
    X: 2D array, [samples x dim]
    labels: list of strings, [samples]
    """
    x_min, x_max = np.min(X, 0), np.max(X, 0)
    X = (X - x_min) / (x_max - x_min)
    # lab_list = sorted(list(set(labels))) # strings
    lab_list = list(set(labels))

    plt.figure()
    ax = plt.subplot(111)

    colors = cm.gist_ncar(np.linspace(0, 1, len(lab_list)))
    for i in range(X.shape[0]):
        plt.scatter(X[i, 0], X[i, 1], color=colors[lab_list.index(labels[i])])

    plt.xticks([]), plt.yticks([])
    plt.show()
    if title is not None:
        plt.title(title)
Esempio n. 11
0
    def draw_ws_obstacles(self):
        """
        Draws the obstacles one worjspace

            Notes:
                - Uses a color map for each obstacles and interates through
                these each of the colors
                - Uses the sampled_points() function to get a contour for
                each of the obstacles
        """
        colorst = [
            cm.gist_ncar(i)
            for i in np.linspace(0, 0.9, len(self._workspace.obstacles))
        ]

        for i, o in enumerate(self._workspace.obstacles):
            self._ax.plot(o.origin[0], o.origin[1], 'kx')
            points = o.sampled_points()
            X = np.array(points)[:, 0]
            Y = np.array(points)[:, 1]
            self._ax.plot(X, Y, color=colorst[i], linewidth=2.0)
Esempio n. 12
0
    def visualize_noimage(self, embed,  y_test, file_path):

        # two ways of visualization: scale to fit [0,1] scale
        # feat = embed - np.min(embed, 0)
        # feat /= np.max(feat, 0)

        # two ways of visualization: leave with original scale
        feat = embed
        ax_min = np.min(embed,0)
        ax_max = np.max(embed,0)
        ax_dist_sq = np.sum((ax_max-ax_min)**2)

        plt.figure()
        ax = plt.subplot(111)
        colormap = plt.get_cmap('tab10')

        plt.axis([ax_min[0], ax_max[0], ax_min[1], ax_max[1]])
        # plt.xticks([]), plt.yticks([])
        plt.title('Learned embedding in the network')

        colors = cm.gist_ncar(np.linspace(0, 1, len(y_test)))
        #plt.plot(embed[:,0], embed[:,1],)
        for i in range(len(embed)):
            plt.scatter(embed[i][0], embed[i][1], color=colors[y_test[i]], s=8)

        plt.savefig(os.path.join(file_path+'.png'), dpi=600, format='png')#, bbox_inches='tight')
        plt.close()

# if __name__ == "__main__":
#
#     mnist = input_data.read_data_sets('MNIST_data', one_hot=False)
#     x_test = mnist.test.images
#     y_test = mnist.test.labels
#     x_test = x_test.reshape([-1, 28, 28])
#
#     embed = np.fromfile('embed.txt', dtype=np.float32)
#     embed = embed.reshape([-1, 2])
#
#     visualize(embed, x_test, y_test)
Esempio n. 13
0
def plot_aero(m,aero,no_colorbar=True,a_max = 1.5):
    """
    Simple function that takes a basemap plotting object ( m) and plots the points of the aeronet sites with their value in color
    For easy aeronet visualisation
    """
    from matplotlib import cm
    from matplotlib.lines import Line2D
    import numpy as np
    x,y = m(aero['Longitude'].astype('double'),aero['Latitude'].astype('double'))
    
    if no_colorbar:
        colors = np.round(aero['AOT_500'].astype('double')/a_max*7.0)/7.0
        c_ar = np.linspace(0,a_max,7)
        leg_ar = ['{:1.2f} - {:1.2f}'.format(c,c_ar[i+1]) for i,c in enumerate(c_ar[0:-1])]
    else:
        colors = aero['AOT_500'].astype('double')

    cls = cm.gist_ncar(c_ar/a_max)
    
    bb = m.scatter(x,y,c=colors,cmap=cm.gist_ncar,marker='s',
                   vmin=0.0,vmax=a_max,edgecolors='None',s=100)
                   
    if no_colorbar:
        fakepoints = []
        for i,cl in enumerate(cls):
            fakepoints.append(Line2D([0],[0],color=cl,linestyle='None',marker='s',markeredgecolor='None'))
        cbar = m.ax.legend(fakepoints,leg_ar,numpoints=1,frameon=True,loc='lower right',bbox_to_anchor=(0.45,1.04),title='AOD 500 nm',ncol=2)
        try:
            m.ax.add_artist(cbar)
        except:
            pass
    else:
        try:
            cbar = m.colorbar(m.ax,bb)
            cbar.set_label('AOD 500 nm')
        except:
            pass
    u = [bb,cbar]
    return u
Esempio n. 14
0
if PLOTTAU:
    TrmThresh = 2.0* np.median(Trms)
    plotMax = 2.0 * np.median(chAvgTsky)
    airmass = np.arange( 1.0, 1.25*np.max(secZ), 0.01)
    figTau = plt.figure(0, figsize = (11,8))
    figTau.suptitle(prefix + ' Optical Depth')
    figTau.text(0.45, 0.05, 'Airmass')
    figTau.text(0.03, 0.45, 'Sky Temperature [K]', rotation=90)
    for spw_index in range(spwNum):
        for pol_index in range(2):
            TskyPL = figTau.add_subplot(2, spwNum, spwNum* pol_index + spw_index + 1 )
            TskyPL.axis([1.0, 1.25*np.max(secZ), 0.0, plotMax])
            TskyPL.plot( airmass, 2.713* np.exp(-Tau0[spw_index]* airmass) + tempAmb[ant_index]* (1.0 - np.exp(-Tau0[spw_index]* airmass)), '-')
            for ant_index in range(antNum):
                plotTsky = chAvgTsky[ant_index, spw_index, pol_index] - TantN[ant_index, spw_index, pol_index]
                TskyPL.scatter( secZ[ant_index], plotTsky, s=15* TrxFlag[ant_index, spw_index, pol_index] + 1, color=cm.gist_ncar( float(ant_index) / antNum ), alpha=0.25, label = antList[ant_index])
            #
            text_sd = 'Pol %s Tau(zenith)=%6.4f' % (PolList[pol_index], Tau0[spw_index])
            TskyPL.text(1.01, 0.95* plotMax, text_sd, fontsize='9')
            if pol_index == 0:
                TskyPL.set_title('SPW ' + `TDMspw_atmCal[spw_index]`)
            #
        #
    #
    TskyPL.legend(loc = 'lower right', prop={'size' :7}, numpoints = 1)
    if PLOTFMT == 'png':
        figTau.savefig('TAU_' + prefix + '.png')
    else :
        figTau.savefig('TAU_' + prefix + '.pdf')
    plt.close('all')
#
    def addDendro(fig,
                  dataGenes,
                  M,
                  coords,
                  linewidth=0.25,
                  adjustText=adjustText):

        genesSubset = list(stimulators) + list(inhibitors)

        ax = fig.add_axes(coords, frame_on=False)
        Z = hierarchy.linkage(np.nan_to_num(M, nan=max(M)),
                              method=linkageMethod,
                              optimal_ordering=True)

        origLineWidth = matplotlib.rcParams['lines.linewidth']
        matplotlib.rcParams['lines.linewidth'] = linewidth
        cmap = cm.gist_ncar(np.linspace(0, 0.5, n_clusters + 1))
        hierarchy.set_link_color_palette(
            [matplotlib.colors.rgb2hex(rgb[:3]) for rgb in cmap])

        D = hierarchy.dendrogram(
            Z,
            ax=ax,
            color_threshold=(Z[-n_clusters, 2] + Z[-n_clusters + 1, 2]) / 2,
            above_threshold_color='k',
            orientation='top')
        hierarchy.set_link_color_palette(None)

        matplotlib.rcParams['lines.linewidth'] = origLineWidth

        reindexed = pd.Index(dataGenes[D['leaves']]).reindex(
            pd.Index(genesSubset).intersection(dataGenes))
        genes = reindexed[0][reindexed[1] > -1].values
        locations = reindexed[1][reindexed[1] > -1]

        if True:
            tickLabelsColors = np.array(['navy'] * len(dataGenes),
                                        dtype=np.dtype('U20'))
            xtickslabels = np.array([''] * len(dataGenes),
                                    dtype=np.dtype('U20'))
            for gene, location in zip(genes, locations):
                xtickslabels[location] = gene
                tickLabelsColors[location] = 'green' if (
                    gene in stimulators) else 'red'

            ax.set_xticklabels(xtickslabels, fontsize=4)
            ax.tick_params(axis='y', labelsize=4, width=0.25, length=1)

            ax.set_yticklabels([])
            ax.set_yticks([])

            for xtick, color in zip(ax.get_xticklabels(), tickLabelsColors):
                xtick.set_color(color)

            texts = []
            origPos = []
            for xpos, xtext, color in zip(ax.get_xticks(), xtickslabels,
                                          tickLabelsColors):
                if xtext != '':
                    texts.append(
                        ax.text(xpos,
                                -2.,
                                xtext,
                                fontsize=6,
                                rotation=90,
                                va='top',
                                ha='center',
                                color=color))
                    origPos.append(xpos)

            ticks_x = []
            ticks_y = []
            vdistance = -0.01 * ax.get_ylim()[1]
            for tick in ax.get_xticks():
                ticks_x.extend([tick, tick, None])
                ticks_y.extend([0, vdistance, None])
            ax.plot(ticks_x, ticks_y, color='k', lw=0.4, clip_on=False)
            ax.set_xticklabels([])

            if adjustText:
                adjust_text(texts,
                            va='top',
                            ha='center',
                            autoalign='x',
                            lim=400,
                            only_move={'text': 'x'})

            v = 0.04 * ax.get_ylim()[1]
            for text, opos in zip(texts, origPos):
                text._y = -v
                ax.plot([text._x, opos], [text._y, 0.],
                        color=text._color,
                        lw=0.5,
                        clip_on=False)

        if True:
            clusters = scipy.cluster.hierarchy.fcluster(
                Z, t=n_clusters, criterion='maxclust')[D['leaves']] - 1
            clusterBoundaries = (
                np.where(clusters - np.roll(clusters, 1) != 0)[0] /
                len(D['leaves'])) * ax.get_xlim()[1]
            clusterBoundaries = np.append(clusterBoundaries, ax.get_xlim()[1])

            clusterCenters = clusterBoundaries[:-1] + (
                (clusterBoundaries - np.roll(clusterBoundaries, 1)) / 2.)[1:]
            vposition = (Z[-n_clusters, 2] + Z[-n_clusters + 1, 2]) / 5

            for cluster, position in zip(np.unique(clusters), clusterCenters):
                ltext = ax.text(position,
                                vposition,
                                '#%s' % cluster,
                                fontsize=7,
                                color='white',
                                va='center',
                                ha='center')
                ltext.set_path_effects([
                    path_effects.Stroke(linewidth=1., foreground='k'),
                    path_effects.Normal()
                ])

        return {
            'order': D['leaves'],
            'M': squareform(M)[:, D['leaves']][D['leaves'], :],
            'genes': genes,
            'allGenes': dataGenes[D['leaves']],
            'locations': locations,
            'tickLabelsColors': tickLabelsColors,
            'xtickslabels': xtickslabels,
            'clusters': clusters,
            'clusterBoundaries': clusterBoundaries / 10.,
            'clusterCenters': clusterCenters / 10.
        }
Esempio n. 16
0
def random_colour(rate):
    return cm.gist_ncar(np.random.random())
Esempio n. 17
0
def plot_aero(m, aero, no_colorbar=True, a_max=1.5):
    """
    Simple function that takes a basemap plotting object ( m) and plots the points of the aeronet sites with their value in color
    For easy aeronet visualisation
    """
    from matplotlib import cm
    from matplotlib.lines import Line2D
    import numpy as np
    x, y = m(aero['Longitude'].astype('double'),
             aero['Latitude'].astype('double'))

    if no_colorbar:
        colors = np.round(aero['AOT_500'].astype('double') / a_max * 7.0) / 7.0
        c_ar = np.linspace(0, a_max, 7)
        leg_ar = [
            '{:1.2f} - {:1.2f}'.format(c, c_ar[i + 1])
            for i, c in enumerate(c_ar[0:-1])
        ]
    else:
        colors = aero['AOT_500'].astype('double')

    cls = cm.gist_ncar(c_ar / a_max)

    bb = m.scatter(x,
                   y,
                   c=colors,
                   cmap=cm.gist_ncar,
                   marker='s',
                   vmin=0.0,
                   vmax=a_max,
                   edgecolors='None',
                   s=100)

    if no_colorbar:
        fakepoints = []
        for i, cl in enumerate(cls):
            fakepoints.append(
                Line2D([0], [0],
                       color=cl,
                       linestyle='None',
                       marker='s',
                       markeredgecolor='None'))
        cbar = m.ax.legend(fakepoints,
                           leg_ar,
                           numpoints=1,
                           frameon=True,
                           loc='lower right',
                           bbox_to_anchor=(0.45, 1.04),
                           title='AOD 500 nm',
                           ncol=2)
        try:
            m.ax.add_artist(cbar)
        except:
            pass
    else:
        try:
            cbar = m.colorbar(m.ax, bb)
            cbar.set_label('AOD 500 nm')
        except:
            pass
    u = [bb, cbar]
    return u
# Import 'numpy' module from installed path
import numpy as np
# Import 'matplotlib' module from installed path
import matplotlib.pyplot as plt
# Import colors from 'matplotlib'
from matplotlib import cm
import csv

# set maximum modularity class
MAX = 10
# create random colors
cs = cm.gist_ncar(np.arange(0, 500, 20))

# # open dataset file
# with open('dataset.csv') as f:
# 	# initialize empty array of shape(MAX, 2)
# 	A_bar = np.zeros(shape=(MAX, 2))
# 	# read file line by line
# 	for row in f:
# 		# split line seperated by comma
# 		labels = row[:-1].split(',')
# 		break
# 	print labels
# 	# create data list
# 	data = []
# 	reader = csv.reader(f)
# 	for line in reader:
# 		# split again
# 		row = line
# 		print row
# 		# create label dictionary
Esempio n. 19
0
def read(fName, color, label, rolling=None):
    d = pd.read_csv(fName)
    dTest = d[d.Mode == "test"]
    dTrain = d[d.Mode == "train"]

    xTrain = dTrain.fAccuracy * 100.
    xTest = dTest.fAccuracy * 100.

    if rolling:
        xTest = xTest.rolling(window=rolling, center=False).mean()
        xTrain = xTrain.rolling(window=rolling, center=False).mean()

    plt.plot(dTrain.Epoch, xTrain, color=color, linestyle="-", label=label)
    plt.plot(dTest.Epoch, xTest, color=color, linestyle="--")
    #plt.show()


fList = ["0.0", "0.2", "0.4", "0.6", "0.8"]

plt.axis([0, 200, 0.1, 100])
for i, f in enumerate(fList):
    read("rec/N1=100_N2=100_Nf=16_DR=%s_v2.dat" % f,
         color=cm.gist_ncar(float(i) / len(fList)),
         label="DropOut=%s" % f,
         rolling=5)
plt.legend()
plt.xlabel("Epoch")
plt.ylabel("Accuracy [%]")
plt.yscale("log")
plt.show()
Esempio n. 20
0
allTimes.append(kokkosOmpTimes)
allNames.append('kokkosOmp')
allTimes.append(kokkosCudaIndependentTimes)
allNames.append('kokkosCudaIndependent')

# these are toggles for whether to make image files and whether to make orbit files for making movies
makeImageFiles = True
#makeImageFiles = False
makeOrbitFilesForMovies = True
#makeOrbitFilesForMovies = False
numberOfOrbitFrames = 100


#markerPool = ['-', '--', ':']
markerPool = ['-', '--']
colors = cm.gist_ncar(numpy.linspace(1, 0, len(allTimes)))
markers = []
for i in range(len(allTimes)):
  markers.append(markerPool[i % len(markerPool)])

fig3d = plt.figure(0)
fig2d = plt.figure(1, figsize=(14, 6))
ax2d = plt.subplot(111)
box2d = ax2d.get_position()
ax2d.set_position([box2d.x0, box2d.y0, box2d.width * 0.60, box2d.height])
bbox_to_anchor2d = (1.87, 0.5)

# make an image of just the number of dot products
# TODO: you might want to make an image of the number of cells, so you'd adjust this.
fig3d = plt.figure(0)
ax = fig3d.gca(projection='3d')
Esempio n. 21
0
def dendro(
        df_corr,
        #selGenes,

        #celltype,
    genesSubset,
        fig_file=None,
        inhLoc=0,
        metric='euclidean',
        linkageMethod='ward',
        pca=None,
        n_clusters=5):

    fig, axs = plt.subplots(1, 1, figsize=(15, 8))

    #for i, species in enumerate(['H**o sapiens', 'Mus musculus']):

    #print('Reading corelations of %s data' % species, flush=True)
    #df_corr = pd.read_hdf(corrFile, key=species)
    #df_corr = df_corr[df_corr.columns.intersection(np.unique(selGenes))]
    print(df_corr.shape, flush=True)

    ax = axs  #[0]

    origLineWidth = matplotlib.rcParams['lines.linewidth']
    matplotlib.rcParams['lines.linewidth'] = 0.75

    if pca == None:
        Z = hierarchy.linkage(df_corr.values.T,
                              metric=metric,
                              method=linkageMethod,
                              optimal_ordering=True)
    else:
        Z = hierarchy.linkage(PCA(n_components=pca).fit_transform(
            df_corr.values.T),
                              metric=metric,
                              method=linkageMethod,
                              optimal_ordering=True)

    cmap = cm.gist_ncar(np.linspace(0, 0.5, n_clusters +
                                    1))  #gist_ncar #nipy_spectral #hsv
    hierarchy.set_link_color_palette(
        [matplotlib.colors.rgb2hex(rgb[:3]) for rgb in cmap])
    D = hierarchy.dendrogram(
        Z,
        ax=ax,
        color_threshold=(Z[-n_clusters, 2] + Z[-n_clusters + 1, 2]) / 2,
        above_threshold_color='lightgrey',
        orientation='top')

    reindexed = pd.Index(df_corr.columns[D['leaves']]).reindex(
        pd.Index(genesSubset).intersection(df_corr.columns))

    hierarchy.set_link_color_palette(None)

    matplotlib.rcParams['lines.linewidth'] = origLineWidth

    genes = reindexed[0][reindexed[1] > -1].values
    locations = reindexed[1][reindexed[1] > -1]

    tickLabelsColors = np.array(['black'] * len(df_corr.columns),
                                dtype=np.dtype('U20'))
    xtickslabels = np.array([''] * len(df_corr.columns), dtype=np.dtype('U20'))
    for gene, location in zip(genes, locations):
        xtickslabels[location] = gene
        tickLabelsColors[location] = 'green' if (
            gene in genesSubset[:inhLoc]) else 'red'

    ax.set_xticklabels(xtickslabels, fontsize=3.5)

    for xtick, color in zip(ax.get_xticklabels(), tickLabelsColors):
        xtick.set_color(color)

    texts = []
    origPos = []
    for xpos, xtext, color in zip(ax.get_xticks(), xtickslabels,
                                  tickLabelsColors):
        if xtext != '':
            texts.append(
                ax.text(xpos,
                        -2.,
                        xtext,
                        fontsize=6,
                        rotation=90,
                        va='top',
                        ha='center',
                        color=color))
            origPos.append(xpos)

    adjust_text(texts,
                va='top',
                ha='center',
                autoalign='x',
                lim=200,
                only_move={'text': 'x'})

    v = 0.04 * ax.get_ylim()[1]

    for text, opos in zip(texts, origPos):
        text._y = -v
        ax.plot([text._x, opos], [text._y, 0.],
                color=text._color,
                lw=0.5,
                clip_on=False)

    ax.spines['left'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.spines['bottom'].set_visible(False)
    ax.set_xticklabels([])
    ax.set_yticklabels([])
    ax.set_xticks([])
    ax.set_yticks([])
    #ax.set_ylabel(species)

    #fig.suptitle('Celltype: %s' % celltype, fontsize=12)
    #if fig != None:
    #    fig.savefig(fig_file, dpi=600)
    fig.savefig("tmp")

    reindexed = pd.Index(df_corr.columns[D['leaves']]).reindex(df_corr.columns)
    reindexed = pd.DataFrame(reindexed[1],
                             index=reindexed[0],
                             columns=["Dendrogram"])

    return reindexed
Esempio n. 22
0
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.cm as cm

def read(fName,color,label,rolling=None):
    d = pd.read_csv(fName)
    dTest  = d[d.Mode=="test" ]
    dTrain = d[d.Mode=="train"]

    xTrain = dTrain.fAccuracy * 100.
    xTest  = dTest .fAccuracy * 100.

    if rolling:
        xTest  = xTest .rolling(window=rolling,center=False).mean()
        xTrain = xTrain.rolling(window=rolling,center=False).mean()
    
    plt.plot(dTrain.Epoch, xTrain , color=color, linestyle="-" , label=label)
    plt.plot(dTest.Epoch , xTest  , color=color, linestyle="--")
    #plt.show()
    
fList = ["0.0","0.2","0.4","0.6","0.8"]

plt.axis([0,200,0.1,100])
for i,f in enumerate(fList):
    read("rec/N1=100_N2=100_Nf=16_DR=%s_v2.dat"%f, color=cm.gist_ncar(float(i)/len(fList)), label="DropOut=%s"%f, rolling=5)
plt.legend()
plt.xlabel("Epoch")
plt.ylabel("Accuracy [%]")
plt.yscale("log")
plt.show()
Esempio n. 23
0
                 continue
         
         print '{}'.format(filename)
         
         web_page = Webpage('quick', p, filename, days[d]['heros'])
         web_page.find_played()
         web_page.go_search()
 
 print 'End parsing\n'
 
 #---------------------------------------------------------------------------------------------------------
 # Niveau de chacun en partie classée
 days_list = [d for d in days]
 days_list.sort()
 
 colors = cm.gist_ncar(np.linspace(0, 0.95, len(players_gen)))
 p_colors = {}
 for i, p in enumerate(players_gen):
     p_colors[p.name] = colors[i]
 
 players_d = {}
 for d in days_list:
     for p_h in days[d]['heros'][0].players:
         if p_h.player not in players_d:
             players_d[p_h.player] = {'days': [], 'lvl': [], 'played': []}
         elif p_h.played == players_d[p_h.player]['played'][-1]:
             continue
         elif p_h.played < players_d[p_h.player]['played'][-1]:
             print 'Warning: {} - {}: less games played than the date before!'.format(
                     p_h.player,
                     d_txt
Esempio n. 24
0
         TskyPL = figTau.add_subplot(2, spwNum,
                                     spwNum * pol_index + spw_index + 1)
         TskyPL.axis([1.0, 1.25 * np.max(secZ), 0.0, plotMax])
         TskyPL.plot(
             airmass, 2.713 * np.exp(-Tau0[spw_index] * airmass) +
             tempAmb[ant_index] *
             (1.0 - np.exp(-Tau0[spw_index] * airmass)), '-')
         for ant_index in range(antNum):
             plotTsky = chAvgTsky[ant_index, spw_index,
                                  pol_index] - TantN[ant_index, spw_index,
                                                     pol_index]
             TskyPL.scatter(
                 secZ[ant_index],
                 plotTsky,
                 s=15 * TrxFlag[ant_index, spw_index, pol_index] + 1,
                 color=cm.gist_ncar(float(ant_index) / antNum),
                 alpha=0.25,
                 label=antList[ant_index])
         #
         text_sd = 'Pol %s Tau(zenith)=%6.4f' % (PolList[pol_index],
                                                 Tau0[spw_index])
         TskyPL.text(1.01, 0.95 * plotMax, text_sd, fontsize='9')
         if pol_index == 0:
             TskyPL.set_title('SPW ' + ` TDMspw_atmCal[spw_index] `)
         #
     #
 #
 TskyPL.legend(loc='lower right', prop={'size': 7}, numpoints=1)
 if PLOTFMT == 'png':
     figTau.savefig('TAU_' + prefix + '.png')
 else:
def plot_all_parameters_vs_all_other_average(window_average=0.5e-3,
                                             sampling_time=2.5e-6,
                                             plot=True,
                                             normalized_structure=True,
                                             normalized_velocity=True,
                                             subtraction_order=4,
                                             calculate_average=False,
                                             gpi_plane_calculation=True,
                                             elm_burst_window=False,
                                             pdf=True,
                                             symbol_size=1,
                                             plot_error=False):

    if calculate_average:
        pearson_keys = [
            'Velocity ccf',  #0,1
            'Velocity str avg',  #2,3
            'Size avg',  #4,5
            'Position avg',  #6,7
            'Area avg',  #8
            'Elongation avg',  #9
            'Angle avg',
            'Separatrix dist avg'
        ]  #10
    else:
        pearson_keys = [
            'Velocity ccf',  #0,1
            'Velocity str max',  #2,3
            'Size max',  #4,5
            'Position max',  #6,7
            'Area max',  #8
            'Elongation max',  #9
            'Angle max',
            'Separatrix dist max'
        ]  #10

    plot_inds = np.asarray([0, 1, 4, 5, 11])
    gs = GridSpec(len(plot_inds), len(plot_inds))
    results = calculate_avg_velocity_results(
        window_average=500e-6,
        sampling_time=2.5e-6,
        pdf=False,
        plot=False,
        return_results=not plot_error,
        return_error=plot_error,
        plot_error=False,
        normalized_velocity=True,
        normalized_structure=True,
        subtraction_order=subtraction_order,
        opacity=0.2,
        correlation_threshold=0.6,
        plot_max_only=False,
        plot_for_publication=False,
        gpi_plane_calculation=gpi_plane_calculation,
        plot_scatter=False,
    )
    if not plot_error:
        velocity_results = results
    else:
        velocity_results, error_results = results

    velocity_results['Tau'] /= 1e3
    if elm_burst_window:
        ind = np.where(
            np.logical_and(velocity_results['Tau'] >= 0,
                           velocity_results['Tau'] < window_average))
    else:
        ind = np.where(
            np.logical_and(velocity_results['Tau'] >= -window_average,
                           velocity_results['Tau'] < window_average))
    for ind_first in range(12):
        for ind_second in range(12):
            if ind_first <= 7:
                a = velocity_results[pearson_keys[ind_first //
                                                  2]][ind,
                                                      np.mod(ind_first, 2)]
                a = a[0, :]
                a_err = error_results[pearson_keys[ind_first //
                                                   2]][ind,
                                                       np.mod(ind_first, 2)]
                a_err = a_err[0, :]
            else:
                a = velocity_results[pearson_keys[ind_first - 4]][ind]
                a_err = error_results[pearson_keys[ind_first - 4]][ind]
            if ind_second <= 7:
                b = velocity_results[pearson_keys[ind_second //
                                                  2]][ind,
                                                      np.mod(ind_second, 2)]
                b = b[0, :]
                b_err = error_results[pearson_keys[ind_second //
                                                   2]][ind,
                                                       np.mod(ind_second, 2)]
                b_err = b_err[0, :]
            else:
                b = velocity_results[pearson_keys[ind_second - 4]][ind]
                b_err = error_results[pearson_keys[ind_second - 4]][ind]
            if (ind_first in plot_inds and ind_second in plot_inds):
                ind1 = int(np.where(plot_inds == ind_first)[0])
                ind2 = int(np.where(plot_inds == ind_second)[0])
                colors = iter(cm.gist_ncar(np.linspace(0, 1, len(a))))
                if ind_first != ind_second:
                    plt.subplot(gs[ind2, ind1])
                    plt.plot(a, b, lw='0.2')
                    for ind_a in range(len(a)):
                        color = copy.deepcopy(next(colors))
                        plt.scatter(a[ind_a],
                                    b[ind_a],
                                    color=color,
                                    s=symbol_size)
                        if plot_error:
                            plt.errorbar(a[ind_a],
                                         b[ind_a],
                                         xerr=a_err[ind_a],
                                         yerr=b_err[ind_a],
                                         color=color,
                                         lw=0.2)
                    #plt.scatter(a,b,color='tab:blue')
                    if ind_first <= 7:
                        label_first = pearson_keys[ind_first // 2]
                        label_second = ['radial',
                                        'poloidal'][np.mod(ind_first, 2)]
                        xlabel = label_first + ' ' + label_second
                    else:
                        xlabel = pearson_keys[ind_first - 4]
                    if ind_second <= 7:
                        label_first = pearson_keys[ind_second // 2]
                        label_second = ['radial',
                                        'poloidal'][np.mod(ind_second, 2)]
                        ylabel = label_first + ' ' + label_second
                    else:
                        ylabel = pearson_keys[ind_second - 4]

                    plt.xlabel(xlabel)
                    plt.ylabel(ylabel)
                    plt.xlim([
                        min(a) - abs(max(a) - min(a)) * 0.1,
                        max(a) + abs(min(a) - max(a)) * 0.1
                    ])
                    plt.ylim([
                        min(b) - abs(max(b) - min(b)) * 0.1,
                        max(b) + abs(min(b) - max(b)) * 0.1
                    ])
                else:
                    plt.subplot(gs[ind2, ind1])
                    plt.plot(velocity_results['Tau'][ind] * 1e3, b, lw=0.2)
                    for ind_a in range(len(a)):
                        plt.scatter(
                            velocity_results['Tau'][ind][ind_a] * 1e3,
                            b[ind_a],
                            color=next(colors),
                            s=symbol_size,
                        )
                    plt.xlim([-window_average * 1e3, window_average * 1e3])
                    plt.ylim([
                        min(b) - abs(max(b) - min(b)) * 0.1,
                        max(b) + abs(min(b) - max(b)) * 0.1
                    ])
                    plt.xlabel('Tau [ms]')
                    if ind_second <= 7:
                        label_first = pearson_keys[ind_second // 2]
                        label_second = ['radial',
                                        'poloidal'][np.mod(ind_second, 2)]
                        ylabel = label_first + ' ' + label_second
                    else:
                        ylabel = pearson_keys[ind_second - 4]
                    plt.ylabel(ylabel)
Esempio n. 26
0
#a=ts.groupby([ts.index.minute, 'statuscode'])
a=ts.groupby([ts.time_min, 'statuscode'])

print('GROUP1:', a.groups)

#b = a.agg(sum)
#b = a.agg(count)
#b = a.agg(size)
b = a.agg(len)
print('len aggr:', b)

gr2 = b.groupby('statuscode')
print('statuscode-groups:', gr2.groups)

import matplotlib.cm as cm
col_cyc = iter( cm.gist_ncar(np.linspace(0, 1, len(gr2)) ) ) #gist_rainbow


legends = []

for name, group in gr2:
    print("groupname:",name) 
    the_col = next(col_cyc)
    if counts[name] < 100:
      continue
    if int(name) < 340:
      continue

    legname = '%s-(#%s)' % (name, counts[name])
    legends.append(legname)
    if 0: print(group)
Esempio n. 27
0
names = sorted(set([name for name, start, end in events]))
t0 = events[0][1]

tot_times = [
    sum([end - start for name, start, end in events if name == n])
    for n in names
]

info = list(zip(names, tot_times))
info.sort(key=lambda x: x[1], reverse=True)

ml = max(len(n) for n in names) + 2
for name, time in info:
    print(name.rjust(ml), time * 1e-9)

print("May ignore setup/transfer times")

import pylab as plt
import matplotlib.lines as mlines
from matplotlib import cm

t0 = events[0][1]
colors = {name: cm.gist_ncar(n / len(names)) for n, name in enumerate(names)}
for n, (name, start, end) in enumerate(events):
    plt.plot([start, end], [n, n], color=colors[name])

plt.legend(
    [mlines.Line2D([], [], color=colors[name], label=name) for name in names],
    names)
plt.show()
Esempio n. 28
0
def main():
    """
    This program is meant to be able to take a set of lattice vectors
    for the most commonlattices, sc, fcc, hcp, bcc, and retur a picture
    with the desired surface, eg (100), (110), (111), as well as vectors
    indicating the 2D unit cell. This is still under development and is
    not generalized yet.
    """

    (a1,a2,a3,surface_normal,ns) = read_input()

    surface_normal = reduced_norm(surface_normal)

    #Here we find the atoms in the plane that passes through the
    #origin that is normal to the vector surface_normal
    atoms_in_plane = []
   
    #loop over possible lattice vector combinations.
    for i in range(-10,10):
        for j in range(-10,10):
            for m in range(-10,10):
                #find the multiples of the lattice vectors
                b1 = scalar_prod(i,a1)
                b2 = scalar_prod(j,a2)
                b3 = scalar_prod(m,a3)
                #add up the lattice vectors to determine the loctaion
                #of the atom
                atom = [b1[0]+b2[0]+b3[0],b1[1]+b2[1]+b3[1],b1[2]+b2[2]+b3[2]]
                #if the vector from the orgin to the point is in the
                #plane then it's dot product with the normal vector
                #will be zero and we want to add it to th list of
                #atoms in th plane.
                if (dot_prod(atom,surface_normal)==0):
                    atoms_in_plane.append(atom)

    #After that we find out how many atoms were in that plane, which
    #is useful for the plotting later and then start building the
    #other planes, the plane variable tracks how many planes there are
    #and the distance between the current plane and the origin, the
    #different planes should always be equadistant. The shift array
    #keeps the location of an atom in each plane, which is then
    #treated as the new origin when finding the rest of the atoms in
    #that plane.
    atoms_per_plane = [len(atoms_in_plane)]
    planes = [0]
    shift = [[0,0,0]]
    
    #ns is the number of planes we want, this if there was only one
    #were done.
    if(ns > 1):
        #keep finding new planes and new atoms until we've found each
        #desired plane.
        
        while(len(planes) < ns):
            #logical, returns true once a new plane is found.
            next_plane = False

            #temporary variable useful for the loops
            t = 0
            #nn is used to limit the number of lattice vector
            #combinations used so that we don't have to generate an
            #arbitrarily large list. Instead if we need more lattice
            #points we'll increment nn.
            nn = 2

            #here we actually find the next plane in the sequenc. This
            #is done by going through the possible lattice vector
            #combinations and find the magnitude of their projection
            #onto the normal vector. If that value isn't in the list
            #of planes then we add it to the planes array, add the
            #lattice site to the shift array, then change next_plane
            #to True.
            while(next_plane == False):
                possible_sites = list(product(range(nn),repeat=3))
                
                while((next_plane == False) and (t < len(possible_sites))):
                    v = possible_sites[t]
                    #p2 is the lattice point in concideration
                    p2 = [v[0]*a1[0]+v[1]*a2[0]+v[2]*a3[0],v[0]*a1[1]+v[1]*a2[1]+v[2]*a3[1],v[0]*a1[2]+v[1]*a2[2]+v[2]*a3[2]]
                    #dtp is the magnitude of the projection of the
                    #vector from the origin to p2 along the normal
                    #vector.
                    dtp = distance_between_planes([0,0,0],p2,surface_normal)
                    #If dpt isn't zero or in planes then we found a new plane.
                    if((dtp != 0) and (dtp not in planes)):
                        next_plane = True
                        planes.append(dtp)
                        shift.append(p2)
                        t += 1
                    else:
                        t += 1
                        
                if(next_plane == False):
                    #If we've been to all the points and haven't found
                    #a new plane then we need to increase the
                    #multiples of the lattice vectors we consider.
                    nn +=1
        
        #For every plane we've found we now need to find the atoms in
        #that plane.
        for p in range(len(planes)):
            #We don't want to do the plane through the origin, we
            #alread found all the atoms in it.
            if (planes[p] != 0):
                atoms_in_nextplane = []
                #loop over possible lattice vector combinations.
                for i in range(-10,10):
                    for j in range(-10,10):
                        for k in range(-10,10):
                            #p2 is the point that the normal vector
                            #will pass through, ie the new origin for
                            #this plane
                            p2 = shift[p]
                            #find the multiples of the lattice vectors
                            b1 = scalar_prod(i,a1)
                            b2 = scalar_prod(j,a2)
                            b3 = scalar_prod(k,a3)
                            #add up the lattice vectors to determine
                            #the loctaion of the atom
                            atom = [b1[0]+b2[0]+b3[0],b1[1]+b2[1]+b3[1],b1[2]+b2[2]+b3[2]]
                            #now shift the atom by p2 to put it in the
                            #appropriate coordinates for the plane
                            #passing through p2
                            shifted_atom = [atom[0]-p2[0],atom[1]-p2[1],atom[2]-p2[2]]
                            #if the vector from the orgin to the point
                            #is in the plane then it's dot product
                            #with the normal vector will be zero and
                            #we want to add it to th list of atoms in
                            #th plane.
                            if (dot_prod(shifted_atom,surface_normal)==0):
                                atoms_in_nextplane.append(atom)

                #Add the atoms in the plane to the complete list of
                #atoms.
                for i in atoms_in_nextplane:
                    atoms_in_plane.append(i)
                atoms_per_plane.append(len(atoms_in_nextplane))

    #Now we need to change our x,y coordinates so that we can go from
    #a 3D space to a 2D surface plot for atomic positions.
    if (surface_normal != [1,0,0]):
        new_y = cross_prod([1,0,0],surface_normal)
    else:
        new_y = cross_prod([0,0,1],surface_normal)
           
    new_x = cross_prod(new_y,surface_normal)

    #make the new x and y axis into unit vectors to get the
    #dimmensions right.
    new_z = find_unit_vector(surface_normal)
    new_y = find_unit_vector(new_y)
    new_x = find_unit_vector(new_x)

    atoms = []
    
    # we need to project our atomic positions onto the new 2D plane.
    for i in atoms_in_plane:
        # if (i!=[0,0,0]):
        #     proj_x = scalar_prod(dot_prod(i,new_x)/mt.sqrt(dot_prod(i,i)),i)
        #     proj_y = scalar_prod(dot_prod(i,new_y)/mt.sqrt(dot_prod(i,i)),i)
        #     atoms.append([proj_x,proj_y])
        # else:
        #     atoms.append(i)
        atoms.append([dot_prod(new_x,i),dot_prod(new_y,i)])

    #variables for the plot. which color changes so that each plane
    #will have a different color of atom so that we can tell which
    #atom are in the same plane.
    at_atom = 0
    which_color = 0
    
    #Now we plot each plane order
    for i in atoms_per_plane:
        for j in range(i):
            x = which_color/float(ns)
            y_mag = mt.sqrt(dot_prod(new_y,new_y))
            x_mag = mt.sqrt(dot_prod(new_x,new_x))
            plt.axis('equal')
            plt.ylim((-2.5*y_mag,2.5*y_mag))
            plt.xlim((-2.5*x_mag,2.5*x_mag))
            plt.plot(atoms[at_atom][0],atoms[at_atom][1], marker = 'o', color = cm.gist_ncar(x),ms = 40,ls = '')
            at_atom += 1
        which_color += 1

    plt.show()
    return()    
Esempio n. 29
0
def makePlot ():  
    global asciiStartTime 
    global maxT 
    global minT 
    global lineSize
    maxPV=-999.0
    minPV=9999.0
    svid=""
    allToPlot ={}
    maxT= -100000.0 # float hours
    minT=  100000.0 # float hours
    numberplotted=0
    for svid in SVidList:
	    times = []
	    azis = []
	    eles = []
	    parms = []
            slipcount=0
	    for aRow in SVpositionList:
	        if svid == aRow[0]:
                            if plottype == "Skyplot":
			        times.append (aRow[1] )       
                                azv =   float(aRow[2])
			        azis.append( azv*(np.pi/180))  
                                anele = float(aRow[3])
			        eles.append(90.00-anele)    
                            else:
                                t=float(aRow[1])
                                if t>maxT: maxT = t
                                if t<minT: minT = t
			        times.append ( aRow[1] )       
                                azv =   float(aRow[2])
			        azis.append(azv)
                                anele = float(aRow[3])
			        eles.append(anele)
                            if doParmPlot :
                                pv = aRow[4]
                                if pv[-1:]=="S" : 
				   pv = pv[:-1]    
                                pv = float(pv)
                                if pv>maxPV: maxPV= pv
                                if pv<minPV: minPV= pv
			        parms.append (pv) 
	    if doParmPlot : 
                plotDataArrays= (times, azis, eles, parms)   
            else:
	        plotDataArrays= (times, azis, eles)
	    allToPlot[svid] = plotDataArrays
    print "  "+parmtype+" data values span "+`minPV`+" to "+`maxPV`
    print "  Done reading data to plot.  The figure is being created."
    starttime_t1= datetime.now()
    bgcolor="#FFFFff" 
    if plottype == "Skyplot":
        fig= figure (figsize=(widthDistance, widthDistance), dpi=pixeldensity, facecolor=bgcolor, edgecolor='k')
        ax = fig.add_axes([0.1, 0.1,  0.8, 0.8], projection='polar', axisbg=bgcolor) 
    else:
        fig= figure (figsize=(1.6*widthDistance, 1.2*widthDistance/1.62), dpi=pixeldensity, facecolor=bgcolor, edgecolor='k')
        ax = fig.add_axes([0.1, 0.13, 0.8, 0.8],  axisbg=bgcolor) 
    if showLegend :
	box = ax.get_position()
	ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    numberColors=30 
    size=0.3
    svPRNIndex=0 
    plotlist=[]
    svlist=[]
    trackcount=1
    bandindex=0
    mplot=None
    pvtop=-9999
    pvbot = 9999
    numberplotted = 0
    for svid in sorted(allToPlot.keys()) : 
        bandindex += 1
        if svid[0:1]=="R" and doglonass!=True : continue 
        if svid[0:1]=="G" and dogps!=True     : continue 
        if svid[0:1]=="E" and dogalileo!=True : continue 
        if svid[0:1]=="S" and dosbas!=True    : continue 
        if svid[0:1]=="J" and doqzss!=True   : continue
        if svid[0:1]=="C" and dobeidou!=True : continue 
    	if len(doShowSVslist)>0:
	    if svid not in doShowSVslist:
		continue;
        if trackcount > trackCountLimit : continue
    	trackcount+=1
        svPRNIndex= int(svid [1:])
        if svid[0:1]=="R" : svPRNIndex += 32 
	plotDataArrays=allToPlot[svid]
        times=plotDataArrays[0]
        azis= plotDataArrays[1]
        eles= plotDataArrays[2] 
        if parmtype  ==  "Multipath combination" :
		minPV=-1.5
		maxPV= 1.5
        elif parmtype ==  "Signal to Noise" :
		minPV= 20.0
		maxPV= 60.0
        elif parmtype =="Ionspheric Delay (m)": 
		minPV=-30.0
		maxPV= 40.0
        elif  parmtype =="Ionspheric Delay Derivative (m/min)":
		minPV= -0.5
		maxPV=  0.5
        if colorMax != 1.234567 :
                maxPV= colorMax
        if colorMin != 1.234567 :
                minPV= colorMin
        # else use minPV maxPV values already found from the data

        if plottype == "Skyplot" or plottype == "Azimuth-elevation plot":
	    if True==doParmPlot:
                parms= plotDataArrays[3] 
                colmap=mptl.cm.hsv 
		prange= maxPV - minPV 
		pvtop = -999993.0
		pvbot= 999993.0
		for pi in range (0, len(parms)):
		    pnew=parms[pi]
		    if pnew>maxPV : pnew=maxPV;
		    if pnew<minPV : pnew=minPV;
		    pnew = (pnew - minPV) / prange 
		    parms[pi]=pnew
		    if parms[pi] > pvtop : pvtop = parms[pi] 
		    if parms[pi] < pvbot : pvbot = parms[pi] 
		#if debug: print "        pvbot, pvtop= "+`pvbot`+" to "+`pvtop`+"     min max PV="+`minPV`+" to "+`maxPV` +"\n"
		norm=mptl.colors.Normalize(vmin=0.0, vmax=1.0)
		mplot = plt.scatter (azis, eles, c=parms,   norm=norm,  s=lineSize, cmap=mptl.cm.hsv, lw=0)
		numberplotted += 1
            else:
              if colorname == "" : 
                  mplot = plt.scatter(azis, eles, s=size, color=cm.gist_ncar(1.0*svPRNIndex/numberColors) )
                  numberplotted += 1
              else :
                  mplot = plt.scatter(azis, eles, s=size, color=colorname)
                  numberplotted += 1
        elif plottype == "Time-elevation plot":  
	    if True==doParmPlot:
                parms= plotDataArrays[3] 
                colmap=mptl.cm.hsv 
		#print "  parameter allowed range ="+`maxPV`+" to "+`minPV`
		prange= maxPV - minPV 
		pvtop = -999993.0
		pvbot= 999993.0
		for pi in range (0, len(parms)):
		    pnew=parms[pi]
		    if pnew>maxPV : pnew=maxPV;
		    if pnew<minPV : pnew=minPV;
		    pnew = (pnew - minPV) / prange 
		    parms[pi]=pnew
		    if parms[pi] > pvtop : pvtop = parms[pi] 
		    if parms[pi] < pvbot : pvbot = parms[pi] 
		norm=mptl.colors.Normalize(vmin=0.0, vmax=1.0)
		mplot = plt.scatter (times, eles, c=parms,   norm=norm,  s=lineSize, cmap=mptl.cm.hsv, lw=0)
		numberplotted += 1
            else:
              if colorname == "" : 
                mplot = plt.scatter (times, eles, s=lineSize, color=cm.gist_ncar(1.0*svPRNIndex/numberColors) )
                numberplotted += 1
              else :
                mplot = plt.scatter(times, eles, s=lineSize, color=colorname)
                numberplotted += 1
        elif plottype == "Time-parameter plot":  # ppp
	    if True==doParmPlot:
                parms= plotDataArrays[3] 
                yvals=[]
		for pi in range (0, len(parms)):
		    yvals.append(parms[pi] )
                colmap=mptl.cm.hsv 
		prange= maxPV - minPV 
                # to set color legend and color of points correctly, need this: 
		pvtop = -999993.0
		pvbot= 999993.0
		for pi in range (0, len(parms)):
		    pnew=parms[pi]
		    if pnew>maxPV : pnew=maxPV;
		    if pnew<minPV : pnew=minPV;
		    pnew = (pnew - minPV) / prange  # shoves parm values into 0 to 1 range
		    parms[pi]=pnew
		    if parms[pi] > pvtop : pvtop = parms[pi] 
		    if parms[pi] < pvbot : pvbot = parms[pi] 
		norm=mptl.colors.Normalize(vmin=0.0, vmax=1.0)
                # plt.plot line style: in plt.plot function: k- means a connected black line; 
                # see matplotlib.org/api/pyplot_api.html
                # ko black circle point markers.  g green, b blue , etc.
		mplot = plt.plot (times, yvals, 'ko',  markersize=1.5 )
		numberplotted += 1
            else :
		print "\n   Your teqcplot command needs a parameter input filename, to make a time-parameter plot.\n"
		sys.exit(1)
        elif   "GNSS Band Plot"==plottype : 
            for yi in range (0, len(eles)):
                eles[yi]= bandindex * 1.0 
	    if True==doParmPlot:
                parms= plotDataArrays[3] 
                colmap=mptl.cm.hsv 
		prange= maxPV - minPV 
		pvtop = -999993.0
		pvbot= 999993.0
		for pi in range (0, len(parms)):
		    pnew=parms[pi]
		    if pnew>maxPV : pnew=maxPV;
		    if pnew<minPV : pnew=minPV;
		    pnew = (pnew - minPV) / prange 
		    parms[pi]=pnew
		    if parms[pi] > pvtop : pvtop = parms[pi] 
		    if parms[pi] < pvbot : pvbot = parms[pi] 
		norm=mptl.colors.Normalize(vmin=0.0, vmax=1.0)
		mplot = plt.scatter (times, eles, c=parms,   norm=norm,  s=lineSize, marker='s', cmap=mptl.cm.hsv, lw=0)
		numberplotted += 1
            else:
                mplot = plt.scatter(times, eles, s=lineSize, color=cm.gist_ncar(1.0*svPRNIndex/numberColors) )
                numberplotted += 1
        else:
            print "  NOTE: plot type=_"+plottype+"_ is not recognized.  Exit. \n"
            sys.exit()
        if showLabel :
            if plottype == "Skyplot" or plottype == "Azimuth-elevation plot": 
                lenaz=len(azis)
                ax.annotate (svid, (azis[ (lenaz/3)], eles[(lenaz/3)]) )
            elif plottype == "Time-elevation plot" or "GNSS Band Plot"==plottype:
                lenaz=len(times)
                ax.annotate (svid, ( times[(lenaz/3)], eles[(lenaz/3)] )                         )
            elif plottype == "Time-parameter plot" :  # ppp lll
                svnumb =  5 * (int(svid[1:])) # for an offset from start point
                ax.annotate (svid, (times[ svnumb ], parms[ svnumb ]) )
                #print "      put svid label at time=" + `times[0]` + "    y="+ `eles[0]`
        plotlist.append(mplot)
        svlist.append(svid)
    if True==doParmPlot and mplot!= None and plottype != "Time-parameter plot": 
        pvtop=1.0000
        pvbot=0.0
        dran=(pvtop-pvbot) /4
	m1= pvbot 
	m2= m1 + dran  
	m3= m1 + 2* dran 
	m4= m1 + 3*dran
	m5= pvtop
        lran=(maxPV-minPV) /4
	l1= minPV                       
	l2= l1 + lran  
	l3= l1 + 2* lran 
	l4= l1 + 3*lran
	l5= maxPV                      
        colorbar = plt.colorbar(mplot, shrink=0.85, pad=0.075) 
	colorbar.set_ticks     ([m1,m2,m3,m4,m5]) 
        colorbar.set_ticklabels([l1,l2,l3,l4,l5]) 
    #print "  Colors limited to values "+`minPV`+" to "+`maxPV`
    ax.grid(True)
    if plottype == "Skyplot" : 
	    ax.set_theta_zero_location('N')
	    ax.set_theta_direction(-1)
	    ax.set_rmax(90.0)
	    ax.set_yticks(range              (0, 90, 10))    # (min int, max int, increment) 
	    ax.set_yticklabels(map(str, range(90, 0, -10)))
    if plottype == "Azimuth-elevation plot":
	    ax.set_xticks(range(-360, 405, 45))              
	    ax.set_xticklabels(map(str, range(-360, 405, 45)))   
	    ax.set_yticks(range              (0, 100, 10))                 
	    ax.set_yticklabels(map(str, range(0, 100, 10)))   
    if plottype == "Time-elevation plot" :
	    ax.set_xticks(range(0, 25, 3))              
	    ax.set_yticks(range              (0, 100, 10))                 
	    ax.set_yticklabels(map(str, range(0, 100, 10)))   
    if plottype=="Time-parameter plot" :        # ppp
	    ax.set_xticks(range(0, 25, 3))              
            spacing = int ( (maxPV-minPV) / 5.0)
            if 1>spacing : spacing = 1
	    ax.set_yticks(range              (int(minPV), int(maxPV+1.0), spacing))
	    ax.set_yticklabels(map(str, range(int(minPV), int(maxPV+1.0), spacing)))   
    if plottype == "GNSS Band Plot" :
	    ax.set_xticks(range(0, 25, 3))              
            plt.setp(ax.get_yticklabels(), visible=False)
    if showLegend :
        plots=tuple(plotlist)
        svs= tuple(svlist)
    	plt.legend(plots,svs,scatterpoints=1,ncol=1,fontsize=10,markerscale=5.0, loc=2, bbox_to_anchor=(1.05, 1))
    title1= plottype+" for station "+azifile[-12:-8]
    if "" != parmtype :
        title1= title1 + ".   "+parmtype+" from "+parmfile
    elif "" == parmtype and plottype == "GNSS Band Plot" :
        title1= "   Visibility for station "+azifile[-12:-8]
    if plottype == "Skyplot" : 
        plt.suptitle(title1, y=0.90, fontsize=11)
    else:
        plt.suptitle(title1,         fontsize=11)
    doyear=azifile[-8:-5]
    if len(doyear) < 3 : doyear=""
    if plottype == "Azimuth-elevation plot":
        title2= " \n Azimuth, degrees \n Data starts "+asciiStartTime+".  Day of year "+doyear
    elif plottype == "Time-elevation plot" or plottype=="Time-parameter plot" or "GNSS Band Plot"==plottype :
        title2=  " \n Time, hours of day \n Data starts "+asciiStartTime+".  Day of year "+doyear
    else:
        title2= "Data starts "+asciiStartTime+".  Day of year "+doyear 
    if plottype == "Skyplot" :
        if True==doParmPlot:
            plt.title(title2, y= -0.15, fontsize=11)  
        else:
            plt.title(title2, y= -0.11, fontsize=11)  
    else:
        plt.title(title2, y= -0.15, fontsize=11)  
    if plottype == "Azimuth-elevation plot" or plottype == "Time-elevation plot":
        plt.ylim(-2.0, 92.0)
        plt.ylabel('Elevation, degrees', fontsize=10)
    if plottype == "Azimuth-elevation plot":
        plt.xlim(-370.0, 370.0)
    if plottype == "Time-elevation plot" or plottype=="Time-parameter plot" :
        # sett
        if minHour > -998.0 :
            minT = minHour
        if maxHour > -998.0 :
            maxT = maxHour
        plt.xlim(minT-1, maxT+1) 
    if plottype=="Time-parameter plot" : #ppp
        plt.ylim( (minPV), (maxPV))
    if  "GNSS Band Plot"==plottype :
        plt.ylim(-1.0, trackCountLimit+1.0)
        plt.xlim(minT-1, maxT+1) 
        plt.ylabel('SVs', fontsize=10)
    elapsedtime= (datetime.now() - starttime_t1)
    print "  Plotted "+`numberplotted`+" tracks in "+`(elapsedtime.total_seconds())`+" seconds."
    plt.show()
Esempio n. 30
0
def make_color_map(labels):
    unique_labels = sorted(np.unique(labels))
    n_labels = len(unique_labels)
    return dict((label, cm.gist_ncar(idx / n_labels))
                for idx, label in enumerate(unique_labels))
Esempio n. 31
0
def makePlot():
    global noprint
    global asciiStartTime
    global maxT
    global minT
    global lineSize
    maxPV = -999.0
    minPV = 9999.0
    svid = ""
    allToPlot = {}
    maxT = -100000.0  # float hours
    minT = 100000.0  # float hours
    numberplotted = 0
    for svid in SVidList:
        times = []
        azis = []
        eles = []
        parms = []
        slipcount = 0
        for aRow in SVpositionList:
            if svid == aRow[0]:
                if plottype == "Skyplot":
                    times.append(aRow[1])
                    azv = float(aRow[2])
                    azis.append(azv * (np.pi / 180))
                    anele = float(aRow[3])
                    eles.append(90.00 - anele)
                else:
                    t = float(aRow[1])
                    if t > maxT: maxT = t
                    if t < minT: minT = t
                    times.append(aRow[1])
                    azv = float(aRow[2])
                    azis.append(azv)
                    anele = float(aRow[3])
                    eles.append(anele)
                if doParmPlot:
                    pv = aRow[4]
                    if pv[-1:] == "S":
                        pv = pv[:-1]
                    pv = float(pv)
                    if pv > maxPV: maxPV = pv
                    if pv < minPV: minPV = pv
                    parms.append(pv)
        if doParmPlot:
            plotDataArrays = (times, azis, eles, parms)
        else:
            plotDataArrays = (times, azis, eles)
        allToPlot[svid] = plotDataArrays

    if noprint != 1:
        print("  " + parmtype + " data values span " + minPV + " to " + maxPV)
    if noprint != 1:
        print("  Done reading data to plot.  The figure is being created.")

    starttime_t1 = datetime.now()
    bgcolor = "#FFFFff"
    if plottype == "Skyplot":
        fig = figure(figsize=(widthDistance, widthDistance),
                     dpi=pixeldensity,
                     facecolor=bgcolor,
                     edgecolor='k')
        ax = fig.add_axes([0.1, 0.1, 0.8, 0.8],
                          projection='polar',
                          facecolor=bgcolor)
    else:
        fig = figure(figsize=(1.6 * widthDistance, 1.2 * widthDistance / 1.62),
                     dpi=pixeldensity,
                     facecolor=bgcolor,
                     edgecolor='k')
        ax = fig.add_axes([0.1, 0.13, 0.8, 0.8], facecolor=bgcolor)
    if showLegend:
        box = ax.get_position()
        ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    numberColors = 30
    size = 0.3
    svPRNIndex = 0
    plotlist = []
    svlist = []
    trackcount = 1
    bandindex = 0
    mplot = None
    pvtop = -9999
    pvbot = 9999
    numberplotted = 0
    for svid in sorted(allToPlot.keys()):
        bandindex += 1
        # do not plot unwanted SVs:
        if svid[0:1] == "R" and doglonass != True: continue
        if svid[0:1] == "G" and dogps != True: continue
        if svid[0:1] == "E" and dogalileo != True: continue
        if svid[0:1] == "S" and dosbas != True: continue
        if svid[0:1] == "J" and doqzss != True: continue
        if svid[0:1] == "C" and dobeidou != True: continue
        if len(doShowSVslist) > 0:
            if svid not in doShowSVslist:
                continue
        if trackcount > trackCountLimit: continue
        trackcount += 1
        svPRNIndex = int(svid[1:])
        if svid[0:1] == "R": svPRNIndex += 32
        plotDataArrays = allToPlot[svid]
        times = plotDataArrays[0]
        azis = plotDataArrays[1]
        eles = plotDataArrays[2]
        if parmtype == "Multipath combination":
            minPV = -1.5
            maxPV = 1.5
        elif parmtype == "Signal to Noise":
            minPV = 20.0
            maxPV = 60.0
        elif parmtype == "Ionspheric Delay (m)":
            minPV = -30.0
            maxPV = 40.0
        elif parmtype == "Ionspheric Delay Derivative (m/min)":
            minPV = -0.5
            maxPV = 0.5
        if colorMax != 1.234567:
            maxPV = colorMax
        if colorMin != 1.234567:
            minPV = colorMin
        # else use minPV maxPV values already found from the data

        if plottype == "Skyplot" or plottype == "Azimuth-elevation plot":
            if True == doParmPlot:
                parms = plotDataArrays[3]
                colmap = mptl.cm.hsv
                prange = maxPV - minPV
                pvtop = -999993.0
                pvbot = 999993.0
                for pi in range(0, len(parms)):
                    pnew = parms[pi]
                    if pnew > maxPV: pnew = maxPV
                    if pnew < minPV: pnew = minPV
                    pnew = (pnew - minPV) / prange
                    parms[pi] = pnew
                    if parms[pi] > pvtop: pvtop = parms[pi]
                    if parms[pi] < pvbot: pvbot = parms[pi]
                #if debug: print "        pvbot, pvtop= "+`pvbot`+" to "+`pvtop`+"     min max PV="+`minPV`+" to "+`maxPV` +"\n"
                norm = mptl.colors.Normalize(vmin=0.0, vmax=1.0)
                mplot = plt.scatter(azis,
                                    eles,
                                    c=parms,
                                    norm=norm,
                                    s=lineSize,
                                    cmap=mptl.cm.hsv,
                                    lw=0)
                numberplotted += 1
            else:
                if colorname == "":
                    mplot = plt.scatter(azis,
                                        eles,
                                        s=size,
                                        color=cm.gist_ncar(1.0 * svPRNIndex /
                                                           numberColors))
                    numberplotted += 1
                else:
                    mplot = plt.scatter(azis, eles, s=size, color=colorname)
                    numberplotted += 1
        elif plottype == "Time-elevation plot":
            if True == doParmPlot:
                parms = plotDataArrays[3]
                colmap = mptl.cm.hsv
                #print "  parameter allowed range ="+`maxPV`+" to "+`minPV`
                prange = maxPV - minPV
                pvtop = -999993.0
                pvbot = 999993.0
                for pi in range(0, len(parms)):
                    pnew = parms[pi]
                    if pnew > maxPV: pnew = maxPV
                    if pnew < minPV: pnew = minPV
                    pnew = (pnew - minPV) / prange
                    parms[pi] = pnew
                    if parms[pi] > pvtop: pvtop = parms[pi]
                    if parms[pi] < pvbot: pvbot = parms[pi]
                norm = mptl.colors.Normalize(vmin=0.0, vmax=1.0)
                mplot = plt.scatter(times,
                                    eles,
                                    c=parms,
                                    norm=norm,
                                    s=lineSize,
                                    cmap=mptl.cm.hsv,
                                    lw=0)
                numberplotted += 1
            else:
                if colorname == "":
                    mplot = plt.scatter(times,
                                        eles,
                                        s=lineSize,
                                        color=cm.gist_ncar(1.0 * svPRNIndex /
                                                           numberColors))
                    numberplotted += 1
                else:
                    mplot = plt.scatter(times,
                                        eles,
                                        s=lineSize,
                                        color=colorname)
                    numberplotted += 1
        elif plottype == "Time-parameter plot":  # ppp
            if True == doParmPlot:
                parms = plotDataArrays[3]
                yvals = []
                for pi in range(0, len(parms)):
                    yvals.append(parms[pi])
                colmap = mptl.cm.hsv
                prange = maxPV - minPV
                # to set color legend and color of points correctly, need this:
                pvtop = -999993.0
                pvbot = 999993.0
                for pi in range(0, len(parms)):
                    pnew = parms[pi]
                    if pnew > maxPV: pnew = maxPV
                    if pnew < minPV: pnew = minPV
                    pnew = (pnew - minPV
                            ) / prange  # shoves parm values into 0 to 1 range
                    parms[pi] = pnew
                    if parms[pi] > pvtop: pvtop = parms[pi]
                    if parms[pi] < pvbot: pvbot = parms[pi]
                norm = mptl.colors.Normalize(vmin=0.0, vmax=1.0)
                # plt.plot line style: in plt.plot function: k- means a connected black line;
                # see matplotlib.org/api/pyplot_api.html
                # ko black circle point markers.  g green, b blue , etc.
                mplot = plt.plot(times, yvals, 'ko', markersize=1.5)
                numberplotted += 1
            else:
                print(
                    "\n   Your teqcplot command needs a parameter input filename, to make a time-parameter plot.\n"
                )
                sys.exit(1)
        elif "GNSS_Band_Plot" == plottype:
            for yi in range(0, len(eles)):
                eles[yi] = bandindex * 1.0
            if True == doParmPlot:
                parms = plotDataArrays[3]
                colmap = mptl.cm.hsv
                prange = maxPV - minPV
                pvtop = -999993.0
                pvbot = 999993.0
                for pi in range(0, len(parms)):
                    pnew = parms[pi]
                    if pnew > maxPV: pnew = maxPV
                    if pnew < minPV: pnew = minPV
                    pnew = (pnew - minPV) / prange
                    parms[pi] = pnew
                    if parms[pi] > pvtop: pvtop = parms[pi]
                    if parms[pi] < pvbot: pvbot = parms[pi]
                norm = mptl.colors.Normalize(vmin=0.0, vmax=1.0)
                mplot = plt.scatter(times,
                                    eles,
                                    c=parms,
                                    norm=norm,
                                    s=lineSize,
                                    marker='s',
                                    cmap=mptl.cm.hsv,
                                    lw=0)
                numberplotted += 1
            else:
                mplot = plt.scatter(times,
                                    eles,
                                    s=lineSize,
                                    color=cm.gist_ncar(1.0 * svPRNIndex /
                                                       numberColors))
                numberplotted += 1
        else:
            print("  NOTE: plot type=_" + plottype +
                  "_ is not recognized.  Exit. \n")
            sys.exit()
        if showLabel:
            if plottype == "Skyplot" or plottype == "Azimuth-elevation plot":
                lenaz = len(azis)
                ax.annotate(svid, (azis[int(lenaz / 3)], eles[int(lenaz / 3)]))
            elif plottype == "Time-elevation plot" or "GNSS_Band_Plot" == plottype:
                lenaz = len(times)
                ax.annotate(svid,
                            (times[int(lenaz / 3)], eles[int(lenaz / 3)]))
            elif plottype == "Time-parameter plot":  # ppp lll
                svnumb = 5 * (int(svid[1:]))  # for an offset from start point
                ax.annotate(svid, (times[svnumb], parms[svnumb]))
                #print "      put svid label at time=" + `times[0]` + "    y="+ `eles[0]`
        plotlist.append(mplot)
        svlist.append(svid)
    if True == doParmPlot and mplot != None and plottype != "Time-parameter plot":
        pvtop = 1.0000
        pvbot = 0.0
        dran = (pvtop - pvbot) / 4
        m1 = pvbot
        m2 = m1 + dran
        m3 = m1 + 2 * dran
        m4 = m1 + 3 * dran
        m5 = pvtop
        lran = (maxPV - minPV) / 4
        l1 = minPV
        l2 = l1 + lran
        l3 = l1 + 2 * lran
        l4 = l1 + 3 * lran
        l5 = maxPV
        colorbar = plt.colorbar(mplot, shrink=0.85, pad=0.075)
        colorbar.set_ticks([m1, m2, m3, m4, m5])
        colorbar.set_ticklabels([l1, l2, l3, l4, l5])
    #print "  Colors limited to values "+`minPV`+" to "+`maxPV`
    ax.grid(True)
    if plottype == "Skyplot":
        ax.set_theta_zero_location('N')
        ax.set_theta_direction(-1)
        ax.set_rmax(90.0)
        ax.set_yticks(range(0, 90, 10))  # (min int, max int, increment)
        ax.set_yticklabels(map(str, range(90, 0, -10)))
    if plottype == "Azimuth-elevation plot":
        ax.set_xticks(range(-360, 405, 45))
        ax.set_xticklabels(map(str, range(-360, 405, 45)))
        ax.set_yticks(range(0, 100, 10))
        ax.set_yticklabels(map(str, range(0, 100, 10)))
    if plottype == "Time-elevation plot":
        ax.set_xticks(range(0, 25, 3))
        ax.set_yticks(range(0, 100, 10))
        ax.set_yticklabels(map(str, range(0, 100, 10)))
    if plottype == "Time-parameter plot":  # ppp
        ax.set_xticks(range(0, 25, 3))
        spacing = int((maxPV - minPV) / 5.0)
        if 1 > spacing: spacing = 1
        ax.set_yticks(range(int(minPV), int(maxPV + 1.0), spacing))
        ax.set_yticklabels(
            map(str, range(int(minPV), int(maxPV + 1.0), spacing)))
    if plottype == "GNSS_Band_Plot":
        ax.set_xticks(range(0, 25, 3))
        plt.setp(ax.get_yticklabels(), visible=False)
    if showLegend:
        plots = tuple(plotlist)
        svs = tuple(svlist)
        plt.legend(plots,
                   svs,
                   scatterpoints=1,
                   ncol=1,
                   fontsize=10,
                   markerscale=5.0,
                   loc=2,
                   bbox_to_anchor=(1.05, 1))
    title1 = plottype + " for station " + azifile[-12:-8]
    if "" != parmtype:
        title1 = title1 + ".   " + parmtype + " from " + parmfile
    elif "" == parmtype and plottype == "GNSS_Band_Plot":
        title1 = "   Visibility for station " + azifile[-12:-8]
    if plottype == "Skyplot":
        plt.suptitle(title1, y=0.90, fontsize=11)
    else:
        plt.suptitle(title1, fontsize=11)
    doyear = azifile[-8:-5]
    if len(doyear) < 3: doyear = ""
    if plottype == "Azimuth-elevation plot":
        title2 = " \n Azimuth, degrees \n Data starts " + asciiStartTime + ".  Day of year " + doyear
    elif plottype == "Time-elevation plot" or plottype == "Time-parameter plot" or "GNSS_Band_Plot" == plottype:
        title2 = " \n Time, hours of day \n Data starts " + asciiStartTime + ".  Day of year " + doyear
    else:
        title2 = "Data starts " + asciiStartTime + ".  Day of year " + doyear
    if plottype == "Skyplot":
        if True == doParmPlot:
            plt.title(title2, y=-0.15, fontsize=11)
        else:
            plt.title(title2, y=-0.11, fontsize=11)
    else:
        plt.title(title2, y=-0.15, fontsize=11)
    if plottype == "Azimuth-elevation plot" or plottype == "Time-elevation plot":
        plt.ylim(-2.0, 92.0)
        plt.ylabel('Elevation, degrees', fontsize=10)
    if plottype == "Azimuth-elevation plot":
        plt.xlim(-370.0, 370.0)
    if plottype == "Time-elevation plot" or plottype == "Time-parameter plot":
        # sett
        if minHour > -998.0:
            minT = minHour
        if maxHour > -998.0:
            maxT = maxHour
        plt.xlim(minT - 1, maxT + 1)
    if plottype == "Time-parameter plot":  #ppp
        plt.ylim((minPV), (maxPV))
    if "GNSS_Band_Plot" == plottype:
        plt.ylim(-1.0, trackCountLimit + 1.0)
        plt.xlim(minT - 1, maxT + 1)
        plt.ylabel('SVs', fontsize=10)
    elapsedtime = (datetime.now() - starttime_t1)
    if noprint != 1:
        print("  Plotted " + numberplotted + " tracks in " +
              (elapsedtime.total_seconds()) + " seconds.")
    filestarttime = strftime('%Y%m%d_%H:%M:%S', gmtime())
    filename = svid + "_" + plottype[:10] + "_" + filestarttime + ".png"

    # ============       To show the new plot in a pop-up window in the screen:
    plt.show()  # Note: process pauses here until user clicks on something.
Esempio n. 32
0
# ax2.set_yscale('log')
fig1, ax1 = plt.subplots(1, 1, figsize=(10, 6))
fig2, ax2 = plt.subplots(1, 1, figsize=(11, 5))
ax1.set_yscale('log')
# ax2.set_yscale('log')
ax1.grid(True)
ax2.grid(True)

dirpath = "../outputpy"
files, n_files = get_files(dirpath)

noise_std = np.array([])
dataset_label = np.array([])
noise_std_unc = np.array([])

colors = iter(cm.gist_ncar(np.linspace(0, 1, 6)))

for j, file_iter in enumerate(files):
    print(j, file_iter)

    noisehist = False
    if (("_pedsub_BPM" in file_iter)
            and ("neg20" in file_iter)):  #("20" in file_iter)
        with open(dirpath + '/' + file_iter, 'rb') as f:
            input_data = np.load(f)

            # if (("noise" not in file_iter) and ("BPM" not in file_iter) and ("Mask" not in file_iter) and (file_iter[0]=='0')): #("20" in file_iter)
            # if (("noise" in file_iter) and ("Mask" not in file_iter)):
            noisehist = True
            print("noise")