Ejemplo n.º 1
0
 def figfun(fig):
     ax = fig.axes[0]
     ax.set_xticklabels('')
     ax.set_yticklabels('')
     fig.subplots_adjust(left=0.05, right=0.95, wspace=0)
     pp.savefig(fig)
     close_figure(fig)
Ejemplo n.º 2
0
 def figfun(fig):
     maxx = max(ax.dataLim.x1 for ax in fig.axes)
     ax = fig.axes[0]
     ax.set_xticklabels('')
     ax.set_yticklabels('')
     ax.set_xlim(0, maxx)
     for ax in fig.axes:
         ax.yaxis.set_ticks_position('left')
         ax.xaxis.set_ticks_position('bottom')
     fig.subplots_adjust(left=0.05, right=0.95, wspace=0)
     pp.savefig(fig)
     close_figure(fig)
Ejemplo n.º 3
0
 def close(self):
     close_figure(self.figure)
Ejemplo n.º 4
0
    def plot_radiation_axis_on_sphere( this, domain=None, kind = None, view = None ):

        import matplotlib as mpl
        from mpl_toolkits.mplot3d import Axes3D
        from matplotlib.pyplot import figure, figaspect, plot, xlabel, ylabel, xlim, ylim, xscale, yscale, legend, subplot, grid, title, draw, show, savefig, axis
        from matplotlib.pyplot import close as close_figure
        from numpy import mod,pi,hstack,array,ones,linalg,arange,zeros_like
        from os.path import join

        # Calc radiation axis: alpha beta gamma and x y z
        kind = 'psi4' if kind is None else kind
        domain = 'time' if domain is None else domain

        #
        gwylmo = this.gwylmo

        #
        if view is None:
            view = (30,-60)

        #
        tag = 'td' if domain in ('t','td','time') else 'fd'

        # Extract useful info
        x,y,z = this.radiation_axis[tag+'_x'],this.radiation_axis[tag+'_y'],this.radiation_axis[tag+'_z']
        alpha,beta,gamma = this.radiation_axis[tag+'_alpha'],this.radiation_axis[tag+'_beta'],this.radiation_axis[tag+'_gamma']
        domain_vals = this.radiation_axis[tag+'_domain']

        #
        fig = figure( figsize=4*figaspect(1) )
        ax = fig.add_subplot(111, projection='3d')
        color = rgb(3)

        #
        plot_3d_mesh_sphere( ax, color='k', alpha=0.05, lw=1 )

        #
        gwylmo.__calc_radiated_quantities__(use_mask=False)
        k = 0
        # remnant = gwylmo.old_remnant if 'old_remnant' in gwylmo.__dict__ else gwylmo.remnant
        remnant = gwylmo.remnant
        jx,jy,jz = remnant['J'][k] / linalg.norm( remnant['J'][k] )
        jfx,jfy,jfz = remnant['J'][-1] / linalg.norm( remnant['J'][-1] )

        #
        if tag == 'td':
            #
            mask = arange( gwylmo.startindex+1, gwylmo.endindex_by_frequency+1 )
        else:
            mask = (abs(gwylmo.f)>gwylmo.wstart_pn/(2*pi)) & (abs(gwylmo.f)<gwylmo.lm[2,2][kind].dt/4)


        #
        lx,ly,lz = (gwylmo.L1+gwylmo.L2)/linalg.norm( gwylmo.L1+gwylmo.L2 )#
        ax.scatter( lx,ly,lz, marker='h', color='lawngreen', label='Initial $L$ (nrutils)',edgecolors='k' )

        #
        ax.scatter( jx,jy,jz,marker='o', c='dodgerblue', label='Initial $J$ (Radiated Est.)' )
        ax.scatter( jfx,jfy,jfz,marker='s', c='dodgerblue', label='Final $J$ (Radiated Est.)',s=80,alpha=0.5 )

        #
        # J = this.gwylmo.remnant['J'].copy()
        J = remnant['J']
        # J /= linalg.norm(J,axis=1)
        for k in range(J.shape[0]):
            J[k] /= linalg.norm(J[k])
        plot( J[:,0],J[:,1],J[:,2], label='$J(t)$ (Radiated Est.)',zorder=-2e4 )

        #
        S = gwylmo.S
        L = gwylmo.L
        bbh_jx,bbh_jy,bbh_jz = (L+S)/linalg.norm( L+S )
        ax.scatter( bbh_jx,bbh_jy,bbh_jz, label='Initial $J$ (BBH)', color='tomato', marker='o' )

        #
        sfx,sfy,sfz = gwylmo.Sf/linalg.norm(gwylmo.Sf)
        ax.scatter( sfx,sfy,sfz, color='tomato', label='Final $J$ (BBH)', marker='v' )

        #
        plot( x[mask],y[mask],z[mask], lw=2, color='grey', label='$\hat{V}(%s)$'%('t' if tag=='td' else 'f') )

        #
        xlabel('$x$')
        ylabel('$y$');

        axlim = 0.64*array([-1,1])
        ax.set_xlim(axlim)
        ax.set_ylim(axlim)
        ax.set_zlim(axlim)

        axis('off')

        #
        ax.view_init(view[0],view[1])

        #
        legend( loc=1, frameon=True )
        title(('Time Domain: ' if tag=='td' else 'Frequency Domain: ' ) + this.gwylmo.simname, loc='right', alpha=0.5, fontsize=16)

        #
        if this.save:
            filepath = join( this.outdir,'%s_%s_sphere_el%i_az%i.pdf'%(gwylmo.simname,tag,view[0],view[1]))
            savefig(filepath,pad_inches=0, bbox_inches='tight')
            close_figure()
Ejemplo n.º 5
0
    def plot_radiation_axis_3panel( this, domain=None, kind = None ):

        #
        from matplotlib.pyplot import figure, figaspect, plot, xlabel, ylabel, xlim, ylim, xscale, yscale, legend, subplot, grid, title, draw, show, savefig
        from matplotlib.pyplot import close as close_figure
        from numpy import mod,pi,hstack,array,ones
        from os.path import join

        # Calc radiation axis: alpha beta gamma and x y z
        kind = 'psi4' if kind is None else kind
        domain = 'time' if domain is None else domain

        #
        gwylmo = this.gwylmo

        #
        tag = 'td' if domain in ('t','td','time') else 'fd'

        # Extract useful info
        x,y,z = this.radiation_axis[tag+'_x'],this.radiation_axis[tag+'_y'],this.radiation_axis[tag+'_z']
        alpha,beta,gamma = this.radiation_axis[tag+'_alpha'],this.radiation_axis[tag+'_beta'],this.radiation_axis[tag+'_gamma']
        domain_vals = this.radiation_axis[tag+'_domain']

        #
        fig = figure( figsize=4*figaspect(1) )
        clr = rgb(3,jet=True); grey = ones(3)*0.8
        lw = 1.5

        #
        domain_min = domain_vals[gwylmo.preinspiral.right_index] if domain in ('t','time') else gwylmo.wstart_pn/(2*pi)
        domain_max = domain_vals[gwylmo.postringdown.left_index] if domain in ('t','time') else gwylmo.lm[2,2][kind].dt/pi

        #
        mask = (domain_vals>=domain_min) & (domain_vals<=domain_max)

        #
        ax = subplot(3,1,1)
        title( gwylmo.simname )
        if domain in ('t','time'):
            plot( domain_vals, gwylmo.lm[2,2][kind].plus, color=grey, linewidth = lw )
            plot( domain_vals, gwylmo.lm[2,2][kind].cross, color=0.8*grey, linewidth = lw )
            plot( domain_vals, gwylmo.lm[2,2][kind].amp, linewidth = lw, label=r'$\psi_{22}$' )
            yscale('log',nonposy='clip')
        else:
            plot( domain_vals, gwylmo.lm[2,2][kind].fd_amp, linewidth = lw, label=r'$\psi_{22}$' )
            xscale('log'); yscale('log')
            ylim( lim(gwylmo.lm[2,2][kind].fd_amp[mask]) )
        grid()
        legend( frameon=False, loc='best' )

        #
        subplot(3,1,2,sharex=ax)
        reshift = lambda V: V - V[mask][0] + mod(V[mask][0],2*pi)
        plot( abs(domain_vals), reshift(alpha), color = clr[0], linewidth = lw, label=r'$\alpha$' )
        plot( abs(domain_vals), reshift(beta),  color = clr[1], linewidth = lw, label=r'$\beta$' )
        plot( abs(domain_vals), reshift(gamma), color = clr[2], linewidth = lw, label=r'$\gamma$' )
        legend( frameon=False, loc='best' )
        ylim( lim( hstack([reshift(alpha)[mask],reshift(beta)[mask],reshift(gamma)[mask]]), dilate=0.1 ) )
        grid()

        #
        subplot(3,1,3,sharex=ax)
        plot( abs(domain_vals), reflect_unwrap(x), color = clr[0], linewidth = lw, label=r'$x$' )
        plot( abs(domain_vals), y,  color = clr[2], linewidth = lw, label=r'$y$' )
        plot( abs(domain_vals), z, color = clr[1], linewidth = lw, label=r'$z$' )
        legend( frameon=False, loc='best' )
        ylim( lim( hstack([x[mask],y[mask],z[mask]]), dilate=0.1 ) )
        grid()
        xlabel( '$t/M$' if 'td'==tag else '$fM$' )

        #
        ax.set_xlim( [ domain_min, domain_max ] )

        #
        if this.save:
            filepath = join( this.outdir,'%s_%s_3panel.pdf'%(gwylmo.simname,tag))
            savefig(filepath,pad_inches=0, bbox_inches='tight')
            close_figure()