Example #1
0
    def draw_xianduan2(xianduan_list, ax, dd):

        from pylab import Line2D
        line2d_list = []

        for xd in xianduan_list:
            if xd.xtype == XIANDUAN_UP:
                line2d_list.append(Line2D([dd[xd.start_datetime], dd[xd.end_datetime]], \
                    [xd.start_price,xd.end_price], linewidth=20, alpha = 0.4,color = "violet"))
            else:
                line2d_list.append(Line2D([dd[xd.start_datetime], dd[xd.end_datetime]], \
                    [xd.start_price,xd.end_price], linewidth=20, alpha = 0.4,color = "skyblue"))

        for line in line2d_list:
            ax.add_line(line)
        plt.show()
Example #2
0
    def draw_bi2(bi_list, ax, dd):

        from pylab import Line2D
        line2d_list = []

        for bi in bi_list:
            if bi.btype == BI_UP:
                line2d_list.append(Line2D([dd[bi.start_datetime], dd[bi.end_datetime]], \
                    [bi.start_price,bi.end_price], linewidth=10, alpha = 0.7,color = "orangered"))
            else:
                line2d_list.append(Line2D([dd[bi.start_datetime], dd[bi.end_datetime]], \
                    [bi.start_price,bi.end_price], linewidth=10, alpha = 0.7,color = "aquamarine"))

        for line in line2d_list:
            ax.add_line(line)
        plt.show()
Example #3
0
    def drawPlot(self):
        ion()
        fig = figure(1)
        # draw cart
        axes = fig.add_subplot(111, aspect='equal')
        self.box = Rectangle(xy=(self.pos - self.cartwidth / 2.0, -self.cartheight), width=self.cartwidth, height=self.cartheight)
        axes.add_artist(self.box)
        self.box.set_clip_box(axes.bbox)

        # draw pole
        self.pole = Line2D([self.pos, self.pos + sin(self.angle)], [0, cos(self.angle)], linewidth=3, color='black')
        axes.add_artist(self.pole)
        self.pole.set_clip_box(axes.bbox)

        # set axes limits
        axes.set_xlim(-2.5, 2.5)
        axes.set_ylim(-0.5, 2)
Example #4
0
    def drawPlot(self):
        ion()
        self.fig = figure()
        axes = self.fig.add_subplot(111)

        # draw function
        xvalues = arange(self.min, self.max, 0.1)
        yvalues = list(map(self.f, xvalues))
        plot(xvalues, yvalues)

        # draw exploration path
        self.line = Line2D([], [], linewidth=3, color='red')
        axes.add_artist(self.line)
        self.line.set_clip_box(axes.bbox)

        # set axes limits
        axes.set_xlim(min(xvalues) - 0.5, max(xvalues) + 0.5)
        axes.set_ylim(min(yvalues) - 0.5, max(yvalues) + 0.5)
    def drawPlot(self):
        ion()
        self.fig = plt.figure()
        # draw cart
        self.axes = self.fig.add_subplot(111, aspect='equal')
        self.box = Rectangle(xy=(self.cart_location - self.cartwidth / 2.0,
                                 -self.cartheight),
                             width=self.cartwidth,
                             height=self.cartheight)
        self.axes.add_artist(self.box)
        self.box.set_clip_box(self.axes.bbox)

        # draw pole
        self.pole = Line2D(
            [self.cart_location, self.cart_location + np.sin(self.pole_angle)],
            [0, np.cos(self.pole_angle)],
            linewidth=3,
            color='black')
        self.axes.add_artist(self.pole)
        self.pole.set_clip_box(self.axes.bbox)

        # set axes limits
        self.axes.set_xlim(-10, 10)
        self.axes.set_ylim(-0.5, 2)
Example #6
0
ys = []
for a, i in ave_locations.items():
    xs.append(i[0]['x'])
    ys.append(-float(i[0]['y']))
test_xs = []
test_ys = []
for a, i in test_ave_locations.items():
    test_xs.append(i[0]['x'])
    test_ys.append(-float(i[0]['y']))
    
plt.figure(1)
fig, ax = plt.subplots()
plt.scatter(xs, ys, color = 'green')    
plt.scatter(test_xs, test_ys, color = 'red')    
for i in closest_bit_list:
    ax.add_line(Line2D([i[0][0], i[1][0]], [-float(i[0][1]), -float(i[1][1])]))
    if i[3] > 300:
        print(i)
#for i in closest_list:
    #ax.add_line(Line2D([i[0][0], i[1][0]], [-float(i[0][1]), -float(i[1][1])]))
    #print([i[0][0], -float(i[0][1])], [float(i[1][0]), -float(i[1][1])])
plt.title('Tunnels Closest Points Test by # APs Matched')
plt.ylabel('y coordinate (map pixles)')
plt.xlabel('x coordinate (map pixles)')
plt.plot()

plt.figure(2)
fig, ax = plt.subplots()
plt.scatter(xs, ys, color = 'green')    
plt.scatter(test_xs, test_ys, color = 'red')    
for i in closest_bit_average_list:
Example #7
0
            fontsize=10)
ax.annotate('Tidewater', [2 + width / 2, -10],
            rotation=90,
            horizontalalignment='center',
            verticalalignment='top',
            fontsize=10)

#AXES SETTINGS
ax.axes.get_xaxis().set_visible(False)
ax.get_yaxis().tick_left()
ax.set_ylim([-77, 0])
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(11)
xmin, xmax = ax.get_xaxis().get_view_interval()
ymin, ymax = ax.get_yaxis().get_view_interval()
ax.add_artist(Line2D((xmin, xmin), (ymin, ymax), color='black', linewidth=1.5))
ax.add_artist(Line2D((xmin, xmax), (0, 0), color='black', linewidth=1.))
ax.plot([0.7, xmax], [-74, -74], '--k')
ax.set_ylabel("Mass Balance (Gt yr" + "$\mathregular{^{-1}}$)",
              fontsize=11,
              labelpad=0)

#A,B PLOT ANNOTATIONS
font = mpl.font_manager.FontProperties(family='Arial', weight='bold', size=15)
ax3.annotate('A', [-1.3, -3.8],
             horizontalalignment='center',
             verticalalignment='center',
             fontproperties=font)
ax.annotate('B', [0.4, -74],
            horizontalalignment='center',
            verticalalignment='center',
def case_study_btd_sim(cal,mod,lat_range,h_range,title_label,figname):
    import matplotlib
    plotting_para()
    import numpy as np
    latmin=lat_range[1]
    latmax=lat_range[0]
    hmin=h_range[0]
    hmax=h_range[1]
    from pylab import Line2D
    import pylab as py
    diff,ctt=btd2(mod)
    c=Cal2(cal)
    lat,lon,Image2,Image3=c.file_sort()
    import matplotlib.pyplot as plt
    ##plt.figure()
    #plt.imshow(Image2,cmap='viridis')
    #plt.show()
    x=range(-500,8200,30)+range(8200,20200,60)+range(20200,30100,180)
    y=np.repeat(lat,5)
    laty=y
    X,Y=np.meshgrid(x,y)
    import numpy.ma as ma
    Z=Image2
    Zm = ma.masked_where(np.isnan(Z),Z)
    #plt.pcolormesh(X,Y,Zm.T)

    #import prettyplotlib as ppl
    #from prettyplotlib import plt
    import numpy as np
    import string
    width,height=plt.figaspect(0.8)
    fig,ax1=plt.subplots(figsize=(width,height),dpi=100)
    colorsList = ['indigo','#FFE600']
    CustomCmap = matplotlib.colors.ListedColormap(colorsList)
    import matplotlib.pyplot as plt
    import matplotlib.patches as mpatches
    import numpy as np
    red_patch = mpatches.Patch(color='#FFE600', label='CALIOP Ice')
    blue_patch = mpatches.Patch(color='indigo', label='CALIOP Liquid')
    red_patch1 = Line2D(range(1), range(1), color='r', marker='o', markersize=6, markerfacecolor="r",
                        linewidth=0, label='MODIS BTD')  # mpatches.Circle((3,3),color='#0067acff',marker='o')

    #blue_patch1 = mpatches.Patch(color='r', label='Undetermined')
    x,y=co_locate(cal,mod)
    ax1.tick_params(axis=u'both', which=u'both', length=3)
    #x,y=co_locate(cal,mod)
    im=ax1.pcolormesh(Y[y,:][::-1],X[y,:][::-1],Zm.T[y,:][::-1],cmap=CustomCmap,alpha=0.6,edgecolor='None')
    ax1.legend(handles=[red_patch,blue_patch,red_patch1], loc='upper right', ncol=1, fontsize=10,handletextpad=0.4, columnspacing=0.4)
    ax1.set_title(title_label,fontsize=12)
    ax1.set_ylim([hmin,hmax])
    ax1.set_xlabel('Latitude ($\degree$)')
    ax1.set_ylabel('CALIOP Cloud Height (m)')
    xticks = np.arange(latmin,latmax+0.5,0.5)[::-1]
    yticks = range(hmin,hmax,500)

    xticklabels=xticks
    yticklabels=range(hmin,hmax,500)

    ax1.set_xticks(xticks)
    ax1.set_xticklabels(xticklabels)

    ax1.set_yticks(yticks)
    ax1.set_yticklabels(yticklabels)
    #fig.show()
    ax1.tick_params(axis=u'both', which=u'both', length=3)
    #ax1.legend()
    #ax1.set_yticklabels(np.arange(0,500,3500))
    ax2=ax1.twinx()
    ax2.plot(laty[y],diff[x[0],x[1]],'ro',markersize=6,linewidth=2)
    ax2.set_ylabel('MODIS BTD (K)',color='red')
    ax2.set_ylim([-0.6,0.6])
    ax2.set_xlim([latmin,latmax])
    ax2.tick_params(axis='y',colors='red', length=3)
    ax2.spines['right'].set_color('red')
    #ax.spines['top'].set_color('red')
    #ax2.xaxis.label.set_color('red')
    #ax2.tick_params(axis='x', colors='red')
    fig.show()
    #fig.savefig(figname)
    return fig
    """Execution"""
Example #9
0
    if yend > 1000:
        step = 100
    if yend > 2000:
        step = 200
    if yend > 10000:
        step = 500
    ax1.set_yticks(range(0, int(yend), step))
    # Draw some tick lines
    ax1.yaxis.grid(True, linestyle='-', which='major', color='grey')
    ax1.yaxis.grid(True, linestyle='-', which='minor', color='lightgrey')
    # Hide these grid behind plot objects
    ax1.set_axisbelow(True)

    # Add a legend
    line1 = Line2D([], [],
                   marker='s',
                   color=palegreen,
                   markersize=10,
                   linewidth=0)
    # line2 = Line2D([], [], marker='o', color=paleblue,
    #                markersize=8, linewidth=2)
    # line3 = Line2D([], [], marker='x', color='r',
    #                linewidth=0, markeredgewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    figlegend([line1], ['Response Time'], 'lower center', prop=prop, ncol=1)

    # Write the PNG file
    if not path.exists(f'./z-results/{argv[1]}/'):
        mkdir(f'./z-results/{argv[1]}/')
    savefig(f'./z-results/{argv[1]}/{argv[1]}-{label}')
Example #10
0
def plots_for_each_casestud2y(cal,mod,rad,lat_range,h_range,title_label_3,figname,loc,dpi,figaspect):
    import numpy as np
    from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
    import matplotlib.font_manager as fm
    from pylab import Line2D
    #here we extract the data from the required cloud fields
    import matplotlib.pyplot as plt
    diff,ctt=btd2(mod)
    from file_god_contains_functions import calipso_sort
    colour, phase1,phase2,diff1,_2105_band,_1600_band,_1200_band,_800,ctt1,lat,lon=btd1(mod,rad)
    Image2,height_array,phase,index,lat1,lon1=calipso_sort(cal,400,3500)
    x,y=co_locate(cal,mod)
    if loc==1:
        y=np.array(y)
        c=np.where((y<970)&(y>710))
    else:
        y = np.array(y)
        c = np.where((y > 690))
        #c = range(670, 770) + range(880, 980)
    #location of transition case study 1
    ##location of transition case study 1
    #
    x1=x[0]
    x2=x[1]#x1, x2 are the respective positions of the modis images
    #it is neccessary to use some of t

    #creating the figure
    #width,height=plt.figaspect(figaspect)
    #fig,ax = plt.subplots(2,2,figsize=(figaspect[0],figaspect[1]),dpi=dpi)
    fig = plt.figure(tight_layout=True,figsize=(figaspect[0],figaspect[1]))
    gs = gridspec.GridSpec(2, 2,width_ratios=[1, 1.2])

   # ax =
    #gs = gridspec.GridSpec(2, 2, width_ratios=[1, 1.08])
    ax1 = fig.add_subplot(gs[0, 0])
    ax2 = fig.add_subplot(gs[0, 1])
    ax3 = fig.add_subplot(gs[1, 0])
    ax4 = fig.add_subplot(gs[1, 1])
    #ax2 = plt.subplot(gs[0,1])
    #ax3=plt.subplot(gs[1,0])
    #ax4=plt.subplot(gs[1, 1])
    #gs.tight_layout()
    #x1=ax[0,0]#fig.add_subplot(221)
    #ax2=ax[0,1]#fig.add_subplot(222)
    #ax3=ax[1,0]#fig.add_subplot(223)
    #ax4=ax[1,1]#fig.add_subplot(224)
    #ax=[ax1,ax2,ax3,ax4]
    plt.subplots_adjust(wspace = 0.33,hspace=0.33)


    #begin our plots with the satellite imagery in ax1


    a=ax1.pcolormesh(lon[:,:1350],lat[:,:1350],colour[0,:,:1350],vmin=0,vmax=0.3,cmap='Greys_r')
    cbar=plt.colorbar(a,ticks=[0,0.1,0.2,0.3,0.4],ax=ax1)
    ax1.plot(lon1[y],lat1[y],label='CALIOP Track',color='r')
    ax1.plot(lon1[y[c]],lat1[y[c]],label='Phase Transition',color='b')

    ax1.set_title('(a)',fontsize=12)
    ax1.set_xlabel('Longitude ($\degree$)')
    ax1.set_ylabel('Latitude ($\degree$)')
    ax1.tick_params(axis=u'both', which=u'both', length=3)

    "here we will attempt to plot the boundary region"
    #lon[:, :1350], lat[:, :1350]
    lat_min=np.nanmax(lat,axis=0)#shape y dimension
    where1=np.where(lat==lat_min)
    loc=[np.where(lat[:,i]==np.nanmax(lat[:,i]))[0][0] for i in range(1355)]
    lon_min=np.array(lon[loc,range(1355)])
    where=np.where((lon_min<45)&(lon_min>35))
    lon_min=lon_min[where]
    lat_min=lat_min[where]
    ax1.plot(lon_min,lat_min,'r--',linewidth=3)
    ax1.plot(lon_min, lat_min+10, 'r--',linewidth=3)
    leg=ax1.legend(loc='upper right',frameon=True)
    cbar.set_label('0.6 $\mu m$  Reflectivity',size=8)
    cbar.ax.tick_params(labelsize=8)
    #leg=ax1.legend(['CALIOP Liquid','CALIOP Ice'],loc='upper right',frameon=True)
    leg.get_frame().set_edgecolor('k')

    #asp = np.diff(ax1.get_xlim())[0] / np.diff(ax1.get_ylim())[0]
    #ax1.set_aspect(asp)


    #the zoomed in imagery in the second axis

    ax2.set_title('(b)',fontsize=12)
    im=ax2.imshow(colour[0,1300:2000,250:950][::-1,:],vmin=0,vmax=0.26,cmap='Greys_r',aspect='auto')
    cbar = fig.colorbar(im, ticks=[0, 0.1, 0.2],ax=ax2)
    cbar.set_label('0.6 $\mu m$  Reflectivity',size=8)
    cbar.ax.tick_params(labelsize=8)
    ax2.set_xticks(np.arange(0,700,100))
    ax2.set_yticks(np.arange(0,700,100))
    ax2.tick_params(axis=u'both', which=u'both', length=3)
    ax2.set_yticklabels([])
    ax2.set_xticklabels([])
    import matplotlib.patches as mpatches
    import numpy as np
    #red_patch = mpatches.Patch(color='#FFE600', label='CALIOP Ice')
    #blue_patch = mpatches.Patch(color='indigo', label='CALIOP Liquid')
    red_patch1 = Line2D(range(1), range(1), color='#FFE600', markerfacecolor='#FFE600',
                        linewidth=3, label='CALIOP Ice')  # mpatches.Circle((3,3),color='#0067acff',marker='o')
    red_patch2 = Line2D(range(1), range(1), color='indigo', markerfacecolor='indigo',
                        linewidth=3, label='CALIOP Liquid')
    #blue_patch1 = mpatches.Patch(color='r', label='Undetermined')
    l = Line2D([325, 325],[135, 240], color='indigo', markerfacecolor='indigo',
                        linewidth=1.5)
    l2 = Line2D([325, 325],[240, 360],color='#FFE600', markerfacecolor='#FFE600',
                        linewidth=1.5)
    ax2.add_line(l)
    ax2.add_line(l2)
    leg=ax2.legend(handles=[red_patch1,red_patch2], loc='upper right', ncol=1, fontsize=9,handletextpad=0.4, columnspacing=0.4,frameon=True)
    leg.get_frame().set_edgecolor('k')
    import matplotlib.cbook as cbook
    from matplotlib_scalebar.scalebar import ScaleBar

    fontprops = fm.FontProperties(family='sans-serif',size=9)
    scalebar = ScaleBar(dx=1.0,length_fraction=0.146,height_fraction=0.005,units='km',box_alpha=0.0,frameon=True,location='lower center',font_properties=fontprops.get_fontconfig_pattern(),color='white')  # 1 pixel = 0.2 meter
    scale=ax2.add_artist(scalebar)
    ax2.annotate("N", xy=(100, 450), xycoords='data',
                xytext=(100, 650), textcoords='data',fontsize=9,color='white',
                arrowprops=dict(facecolor='white',shrink=0.05))
    plt.show()
    #asp = np.diff(ax2.get_xlim())[0] / np.diff(ax2.get_ylim())[0]
    #ax2.set_aspect(asp)

    #arrowprops = dict(arrowstyle="->",
        #              connectionstyle="arc3", facecolor='white'))
    #the third image is the complex profile of cloud phase
    fig1=case_study_btd_sim(ax3,cal,mod,lat_range,h_range,title_label_3,figname)

    #lastly we can sample the data on the location of the transition section
    diff, ctt=btd2(mod)
    #from pylab import *
    c1=np.where(phase[c]==1)
    c2=np.where(phase[c]==2)
    ax4.plot(ctt[x1[c],x2[c]][c1],diff[x1[c],x2[c]][c1],'bo',markersize=5)
    ax4.plot(ctt[x1[c],x2[c]][c2],diff[x1[c],x2[c]][c2],'ro',markersize=5)
    ax4.set_xlim(240,255)
    ax4.set_ylim(-0.7,0.7)
    ax4.tick_params(axis=u'both', which=u'both', length=3)
    xticks=np.arange(240,256,5)
    ax4.set_xticks(xticks)
    ax4.set_xticklabels(xticks)
    yticks=np.linspace(-0.6,0.6,7)
    ax4.set_yticks(yticks)
    ax4.set_yticklabels(yticks)
    leg=ax4.legend(['CALIOP Liquid','CALIOP Ice'],loc='upper right',frameon=True)
    leg.get_frame().set_edgecolor('k')
    ax4.set_xlabel('MODIS 11 $\mu m$ Brightness Temperature (K)')
    #ax4.set_ylabel('BTD (K)')
    ax4.set_title('(d)',fontsize=12)
   #asp = np.diff(ax4.get_xlim())[0] / np.diff(ax4.get_ylim())[0]
    #ax4.set_aspect(asp)

    fig.show()
    return fig
Example #11
0
ax2.annotate('   t$_{eff}$=' + str(teff / 3600.), [zL, 200.])
# Label location of receivers
ax2.annotate('L', [zL / 2., 1.2])
ax2.annotate('PF2', [zL + (z2 - zL) / 2., 1.2])
ax2.annotate('PF1', [z2 + (z1 - z2) / 2., 1.2])
ax2.yaxis.set_label_position("right")
ylabel("Required Magnification")
ylim(1., 300.)
xlim(0., 1.)
yscale('log')

handles, labels = ax2.get_legend_handles_labels()
display = (0, 1, 2, 3, 4, 5)

#Create custom artists
detArtist = Line2D((0, 1), (0, 0), color='k', linestyle='-')
mhiArtist = Line2D((0, 1), (0, 0), color='k', linestyle=':')
magArtist = Line2D((0, 1), (0, 0), color='k', linestyle='--')
m90Artist = Line2D((0, 1), (0, 0), color='g', linestyle='-')
m95Artist = Line2D((0, 1), (0, 0), color='r', linestyle='-')
m10Artist = Line2D((0, 1), (0, 0), color='b', linestyle='-')

#Create legend from custom artist/label lists
fontP = FontProperties()
fontP.set_size('small')

ax2.legend([handle for i, handle in enumerate(handles) if i in display] +
           [detArtist, mhiArtist, magArtist, m90Artist, m95Artist, m10Artist],
           [label for i, label in enumerate(labels) if i in display] + [
               '5$\sigma$ det. limit', 'Int. Flux', 'Req. Mag.',
               'log M$_{HI}$=9.0', 'log M$_{HI}$=9.5', 'log M$_{HI}$=10'