Example #1
0
fig_aspect = fig_height_inches/fig_width_inches
margin_x = margin_inches/fig_width_inches
margin_y = margin_inches/fig_height_inches
margin_top = margin_top_inches/fig_height_inches
margin_bottom = margin_bottom_inches/fig_height_inches
subplot_width = subplot_width_inches/fig_width_inches
subplot_height = subplot_height_inches/fig_height_inches

fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
ax = fig.add_axes((margin_x, margin_bottom, subplot_width, subplot_height))
if spec:
    units = r'$\rm{cm^2\ s^{-1}}$'
else:
    units = r'$\rm{g\ cm^{-1}\ s^{-1}}$'
plot_azav (amom, rr, cost, fig=fig, ax=ax, units=units,\
        nlevs=nlevs, minmax=minmax, rvals=rvals)
# Make title + label diff. rot. contrast and no. contours
# Label averaging interval
if rotation:
    time_string = ('t = %.1f to %.1f ' %(t1/time_unit, t2/time_unit))\
            + time_label + '\n' + (r'$\ (\Delta t = %.1f\ $'\
            %((t2 - t1)/time_unit)) + time_label + ')'
else:
    time_string = ('t = %.3f to %.3f ' %(t1/time_unit, t2/time_unit))\
            + time_label + (r'$\ (\Delta t = %.3f\ $'\
            %((t2 - t1)/time_unit)) + time_label + ')'
fsize = 12.
line_height = 1./4./fig_height_inches
fig.text(margin_x, 1 - margin_y, dirname_stripped_title,\
         ha='left', va='top', fontsize=fsize, **csfont)
if spec:
Example #2
0
        margin_bottom_inches

fig_aspect = fig_height_inches / fig_width_inches
margin_x = margin_inches / fig_width_inches
margin_y = margin_inches / fig_height_inches
margin_top = margin_top_inches / fig_height_inches
margin_bottom = margin_bottom_inches / fig_height_inches
subplot_width = subplot_width_inches / fig_width_inches
subplot_height = subplot_height_inches / fig_height_inches

fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
ax = fig.add_axes((margin_x, margin_bottom, subplot_width, subplot_height))

# Plot energy flux
plot_azav (flux_mag, rr, cost, fig=fig, ax=ax,\
    units = r'$\rm{erg}\ \rm{cm}^{-2}\ \rm{s}^{-1}$', plotcontours=False,\
    minmax=minmax)

# Plot streamfunction contours
lilbit = 0.01
maxabs = np.max(np.abs(psi))
plot_azav (psi, rr, cost, fig=fig, ax=ax, plotfield=False,\
     nlevs=nlevs)
#plot_azav (psi, rr, cost, sint, fig=fig, ax=ax, plotfield=False,\
#     levels=(-maxabs/2., -maxabs/4.,\
#    -lilbit*maxabs, 0., lilbit*maxabs, maxabs/4., maxabs/2.))

# Make title
fsize = 12
fig.text(margin_x, 1 - 1/8*margin_top, dirname_stripped,\
         ha='left', va='top', fontsize=fsize, **csfont)
Example #3
0
        if not rbcz is None:
            rav_term_cz = np.sum(term[:, :irbcz] * rw_cz_2d, axis=1)
            rav_term_rz = np.sum(term[:, irbcz:] * rw_rz_2d, axis=1)
            integrated_term_cz = volume_cz * np.sum(shav_term[:irbcz] * rw_cz)
            integrated_term_rz = volume_rz * np.sum(shav_term[irbcz:] * rw_rz)

        # plot azav
        ax_left = margin_x + (iplot % ncol) * (subplot_width + margin_x)
        ax_bottom = 1 - margin_top - margin_subplot_top - subplot_height -\
                (iplot//ncol)*(margin_subplot_top + subplot_height +\
                margin_subplot_bottom)
        ax = fig.add_axes((ax_left, ax_bottom, subplot_width,\
                subplot_height))
        plot_azav (term, rr, cost, fig=fig, ax=ax, units=units,\
               minmax=minmax, plotcontours=plotcontours, rvals=rvals,\
               minmaxrz=minmaxrz, rbcz=rbcz, symlog=symlog,\
        linthresh=linthresh, linscale=linscale, linthreshrz=linthreshrz,\
        linscalerz=linscalerz, plotlatlines=plotlatlines)
        ax.set_title(titles[iplot], verticalalignment='bottom', **csfont)

        # plot shav
        shav_label = labels[iplot] + ': ' +\
                sci_format(integrated_term/lstar, 3)
        if rbcz is None:
            ax_shav.plot(rr / rsun, shav_term, label=shav_label, linewidth=lw)
            ax_rav.plot(tt_lat, rav_term, linewidth=lw)
        else:
            ax_shav.plot(rr[:irbcz]/rsun, shav_term[:irbcz],\
                    label=shav_label, linewidth=lw)
            ax_shav_rz.plot(rr[irbcz:]/rsun, shav_term[irbcz:],\
                    label=shav_label, linewidth=lw)
Example #4
0
        plot_moll(field, cost, fig=fig, ax=ax_moll, varname=varname,\
                minmax=(min_slice, max_slice), clon=clon, symlog=symlog,\
                linscale=linscale_slice, linthresh=linthresh_slice)
        time_string = '%.1f' % time
        time_string = time_string.zfill(tlabel_string_width)
        title = varlabel + '     ' +\
                (r'$r/R_\odot\ =\ %0.3f$' %rval) +\
                '     ' + (r'$t = %s\ P_{\rm{rot}}$' %time_string)
        fig.text(margin_x + 0.5*moll_width, 1. - 0.5*margin_top,\
                title, ha='center', va='center', **csfont, fontsize=14)

        # Make the AZ_Avgs plot:
        field = az.vals[:, :, az.lut[var_index], 0]
        plot_azav (field, rr, cost, fig=fig, ax=ax_azav,\
               units=texunits.get(varname, 'cgs'), minmax=(min_az, max_az),\
               plotcontours=False, plotlatlines=True, cbar_fs=10,\
               rvals=[rval], symlog=symlog, linthresh=linthresh_az,\
               linscale=linscale_az)

        # Make the time-latitude plot underneath everything

        # Arrays for plotting time-latitude diagram (use two, with the one
        # after the current time greyed out)
        #times2, lats2 = np.meshgrid(times, tt_lat, indexing='ij')
        it_current = np.argmin(np.abs(times - time))
        times_1 = times[:it_current + 2]
        # Have some overlap to prevent getting
        # empty arrays at the first and last times
        times_2 = times[it_current:]
        times_2d_1, lats_2d_1 = np.meshgrid(times_1, tt_lat, indexing='ij')
        times_2d_2, lats_2d_2 = np.meshgrid(times_2, tt_lat, indexing='ij')
Example #5
0
        r'$\tau_{\rm{mm,\theta}}$', r'$\tau_{\rm{ms}}$',\
        r'$\tau_{\rm{ms,r}}$', r'$\tau_{\rm{ms,\theta}}$']
units = r'$\rm{g}\ \rm{cm}^{-1}\ \rm{s}^{-2}$'

# Generate figure of the correct dimensions
fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))

for iplot in range(nplots):
    ax_left = margin_x + (iplot%ncol)*(subplot_width + margin_x)
    ax_bottom = 1 - margin_top - subplot_height - margin_subplot_top -\
            (iplot//ncol)*(subplot_height + margin_subplot_top +\
            margin_bottom)
    ax = fig.add_axes((ax_left, ax_bottom, subplot_width, subplot_height))
    plot_azav (torques[iplot], rr, cost, fig=fig, ax=ax, units=units,\
           minmax=minmax, plotcontours=plotcontours, rvals=rvals,\
           minmaxrz=minmaxrz, rbcz=rbcz, symlog=symlog,\
    linthresh=linthresh, linscale=linscale, linthreshrz=linthreshrz,\
    linscalerz=linscalerz, plotlatlines=plotlatlines, plotboundary=plotboundary)

    ax.set_title(titles[iplot], verticalalignment='bottom', **csfont)

# Label averaging interval
if rotation:
    time_string = ('t = %.1f to %.1f ' %(t1/time_unit, t2/time_unit))\
            + time_label + (r'$\ (\Delta t = %.1f\ $'\
            %((t2 - t1)/time_unit)) + time_label + ')'
else:
    time_string = ('t = %.3f to %.3f ' %(t1/time_unit, t2/time_unit))\
            + time_label + (r'$\ (\Delta t = %.3f\ $'\
            %((t2 - t1)/time_unit)) + time_label + ')'
Example #6
0
        margin_bottom_inches

fig_aspect = fig_height_inches/fig_width_inches
margin_x = margin_inches/fig_width_inches
margin_y = margin_inches/fig_height_inches
margin_top = margin_top_inches/fig_height_inches
margin_bottom = margin_bottom_inches/fig_height_inches
subplot_width = subplot_width_inches/fig_width_inches
subplot_height = subplot_height_inches/fig_height_inches

fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
ax = fig.add_axes((margin_x, margin_bottom, subplot_width, subplot_height))

# Plot B_m magnitude
plot_azav (bm, rr, cost, fig=fig, ax=ax, rvals=rvals,\
    units = r'$\rm{G}$', plotcontours=False,\
    minmax=minmax, plotlatlines=plotlatlines)

# Plot streamfunction contours
#maxabs = np.max(np.abs(psi))
maxabs = 3*np.std(psi)
levels = np.linspace(-maxabs, maxabs, 20)
plot_azav (psi, rr, cost, fig=fig, ax=ax, plotfield=False, levels=levels)

# Label averaging interval
if rotation:
    time_string = ('t = %.1f to %.1f ' %(t1/time_unit, t2/time_unit))\
            + time_label + '\n' + (r'$\ (\Delta t = %.1f\ $'\
            %((t2 - t1)/time_unit)) + time_label + ')'
else:
    time_string = ('t = %.3f to %.3f ' %(t1/time_unit, t2/time_unit))\
Example #7
0
margin_x = margin_inches / fig_width_inches
margin_y = margin_inches / fig_height_inches
margin_top = margin_top_inches / fig_height_inches
margin_bottom = margin_bottom_inches / fig_height_inches
subplot_width = subplot_width_inches / fig_width_inches
subplot_height = subplot_height_inches / fig_height_inches

# create axes
units = texunits.get(varname, 'cgs')
texlabel = texlabels.get(varname, 'qval = ' + varname)

fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
ax = fig.add_axes((margin_x, margin_bottom, subplot_width, subplot_height))
plot_azav (field, mer.radius, mer.costheta, fig=fig, ax=ax, units=units,\
        minmax=minmax, minmaxrz=minmaxrz, plotlatlines=plotlatlines,\
        plotcontours=plotcontours, rbcz=rbcz)

# Make title
if rotation:
    time_string = ('t = %.1f ' %(t_loc/time_unit)) + time_label +\
            '\n (1 ' + time_label + (' = %.2f days)'\
            %(time_unit/86400.))
else:
    time_string = ('t = %.3f ' %(t_loc/time_unit)) + time_label +\
            '\n (1 ' + time_label + (' = %.1f days)'\
            %(time_unit/86400.))
#if rotation:
#    time_string = ('t = %.1f ' %(t_loc/time_unit)) + time_label
#else:
#    time_string = ('t = %.3f ' %(t_loc/time_unit)) + time_label
Example #8
0
        field_components = [br, bt, bp]
        titles = [r'$B_r$', r'$B_\theta$', r'$B_\phi$']
        units = r'$\rm{G}$'

        # Generate a figure of the correct dimensions
        fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))

        for iplot in range(3):
            ax_left = margin_x + (iplot % ncol) * (subplot_width + margin_x)
            ax_bottom = 1. - margin_top - margin_subplot_top -\
                    subplot_height - (iplot//ncol)*(subplot_height +\
                    margin_subplot_top + margin_bottom)
            ax = fig.add_axes((ax_left, ax_bottom, subplot_width,\
                    subplot_height))
            plot_azav (field_components[iplot], rr, cost, fig=fig,\
                   ax=ax, units=units, minmax=(mins[iplot], maxes[iplot]),\
                   plotcontours=False)
            ax.set_title(titles[iplot], verticalalignment='bottom',\
                    **csfont)

        # Make the title indicating the simulation time
        fsize = 12
        time = az.time[j]
        if rotation:
            title = ('t = %07.1f ' % (time / time_unit)) + time_label
        else:
            title = ('t = %06.3f ' % (time / time_unit)) + time_label
        fig.text(margin_x + 0.5*subplot_width + (margin_x + subplot_width),\
                1. - 0.3*margin_top, title, ha='center',\
                va='center', **csfont, fontsize=fsize)
        print("saving " + plotdir + savename)
Example #9
0
    base_title = base_titles[key]
    titles = [base_title + r'$_r$', base_title + r'$_\theta$', 'sum',\
            base_title, 'sum - ' + base_title]

    # Generate the actual figure of the correct dimensions
    fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))

    for iplot in range(nplots):
        ax_left = margin_x + (iplot%ncol)*(subplot_width + margin_x)
        ax_bottom = 1 - margin_top - subplot_height - margin_subplot_top -\
                (iplot//ncol)*(subplot_height + margin_subplot_top +\
                margin_bottom)
        ax = fig.add_axes((ax_left, ax_bottom, subplot_width, subplot_height))
        plot_azav (torques[iplot], rr, cost, fig=fig, ax=ax, units=units,\
               minmax=minmax, plotcontours=plotcontours, rvals=rvals,\
               minmaxrz=minmaxrz, rbcz=rbcz)

        ax.set_title(titles[iplot], verticalalignment='bottom', **csfont)

    # Label averaging interval
    if rotation:
        time_string = ('t = %.1f to %.1f ' %(t1/time_unit, t2/time_unit))\
                + time_label + (r'$\ (\Delta t = %.1f\ $'\
                %((t2 - t1)/time_unit)) + time_label + ')'
    else:
        time_string = ('t = %.3f to %.3f ' %(t1/time_unit, t2/time_unit))\
                + time_label + (r'$\ (\Delta t = %.3f\ $'\
                %((t2 - t1)/time_unit)) + time_label + ')'

    # Put some metadata in upper left
fig_width_inches = subplot_width_inches + 2*margin_inches
fig_height_inches = subplot_height_inches + margin_top_inches +\
        margin_bottom_inches

fig_aspect = fig_height_inches/fig_width_inches
margin_x = margin_inches/fig_width_inches
margin_y = margin_inches/fig_height_inches
margin_top = margin_top_inches/fig_height_inches
margin_bottom = margin_bottom_inches/fig_height_inches
subplot_width = subplot_width_inches/fig_width_inches
subplot_height = subplot_height_inches/fig_height_inches

fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
ax = fig.add_axes((margin_x, margin_bottom, subplot_width, subplot_height))

plot_azav (T, rr, cost, fig=fig, ax=ax, posdef=False, minmax=minmax)

# Make title + label diff. rot. contrast and no. contours
fsize = 12
fig.text(margin_x, 1 - 1/16/fig_height_inches, dirname_stripped,\
         ha='left', va='top', fontsize=fsize, **csfont)
fig.text(margin_x, 1 - 5/16/fig_height_inches, r'$-(2/\pi){\rm{tan}}^{-1}(\partial\Omega/\partial z)/(\partial\Omega/\partial\lambda))$',\
         ha='left', va='top', fontsize=fsize, **csfont)
fig.text(margin_x, 1 - 9/16/fig_height_inches,\
         str(iter1).zfill(8) + ' to ' + str(iter2).zfill(8),\
         ha='left', va='top', fontsize=fsize, **csfont)
#fig.text(margin_x, 1 - 0.5*margin_top,\
#         r'$\Delta\Omega_{\rm{tot}} = %.1f\ nHz$' %Delta_Om,\
#         ha='left', va='top', fontsize=fsize, **csfont)
savefile = plotdir + dirname_stripped + '_contour_slope_' +\
        str(iter1).zfill(8) + '_' + str(iter2).zfill(8) + '.png'
Example #11
0
        amom_tot *= shell_volume

        # Generate the actual figure of the correct dimensions
        fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))

        # Make 3 subplot axes
        ax1 = fig.add_axes((margin_x, margin_bottom,\
                subplot_width, subplot_height))
        ax2 = fig.add_axes((2*margin_x + subplot_width, margin_bottom,\
                subplot_width, subplot_height))
        ax3 = fig.add_axes((3*margin_x + 2*subplot_width, margin_bottom,\
                subplot_width, subplot_height))

        # Plot the DR with metadata at the top
        plot_azav (diffrot, rr, cost, fig=fig, ax=ax1, units='nHz',\
                nlevs=nlevs, minmax=minmaxdr, rvals=rvals,\
                plotlatlines=plotlatlines, plotboundary=plotboundary)

        # Put directory name in center
        fsize = 12.
        line_height = 1. / 4. / fig_height_inches
        fig.text(margin_x + 0.5*(1 - 2*margin_x), 1 - margin_y,\
                dirname_stripped, ha='center', va='top', fontsize=fsize,\
                **csfont)

        # Make time label in center
        t_c = (t1 + t2) / 2.
        Dt = t2 - t1
        if rotation:
            time_string = ('t = %.1f ' %(t_c/time_unit))\
                    + time_label + (r'$\ (\Delta t = %.2f\ $'\
Example #12
0
        # Get longitude in degrees
        lon = mer.phi[iphi]*180/np.pi

        savename = 'merslice_' + varname + '_iter' + fname +\
                ('_lon%03.1f' %lon) + '.png'
        print('Plotting merslice: ' + varname + ', iter ' + fname +\
                (', lon %03f' %lon) + ' ...')

        # create axes
        try:
            units = texunits[varname]
        except:
            units = 'cgs'
        fig = plt.figure(figsize=(fig_width_inches, fig_height_inches))
        ax = fig.add_axes((margin_x, margin_y, subplot_width, subplot_height))
        plot_azav (field, rr, cost, fig=fig, ax=ax, units=units,\
                minmax=minmax)

        # Make title + label diff. rot. contrast and no. contours
        fsize = 12
        line_spacing_inches = 1/4
        space = line_spacing_inches/fig_height_inches
        fig.text(margin_x, 1 - space, dirname_stripped, ha='left',\
                va='bottom', fontsize=fsize, **csfont)
        fig.text(margin_x, 1 - 2*space,\
                 'iter = ' + fname, ha='left', va='bottom', fontsize=fsize,\
                 **csfont)
        fig.text(margin_x, 1 - 3*space, texlabel +\
                ('      phi = %03.1f' %lon),\
                 ha='left', va='bottom', fontsize=fsize, **csfont)
        savefile = plotdir + savename
        print ('Saving plot at %s ...' %savefile)