Example use of the grid wrapper and then interactive plot creation # requires pyradex: grab it from # https://github.com/keflavich/pyradex/ # Both RADEX and pyradex require a fortran compiler! # However, if you're on a mac, you can try using pip install with the precompiled binary I provide: # (this is a source distribution, but it includes the radex.so file) !pip install https://github.com/keflavich/pyradex/releases/download/0.2/pyradex-0.2.macosx-10.9-intel.tar.gz from IPython.html.widgets import interact, interactive, fixed from matplotlib import pyplot as plt from IPython.display import clear_output, display, HTML %run ph2co_grid_computation.py styleargs = {'linewidth': 2, 'alpha': 0.5, 'color':'#5A228B'} def setup(tem=5,dens=5): fig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(2,2, sharex='col', sharey='row', squeeze=True, figsize=(10,7)) plt.subplots_adjust(hspace=0,wspace=0) lines1, = ax1.plot(temperatures, taugrid_71M[dens,:], **styleargs) ax1.set_ylim(-0.2,0.2) p1, = ax1.plot(temperatures[tem],taugrid_71M[dens,tem], 'o',alpha=0.5, markeredgecolor='none') lines2, = ax3.plot(temperatures, texgrid_71M[dens,:], **styleargs) ax3.set_ylim(0,20) p3, =ax3.plot(temperatures[tem],texgrid_71M[dens,tem], 'o',alpha=0.5, markeredgecolor='none') lines3, = ax2.semilogx(densities, taugrid_71M[:,tem], **styleargs) ax2.set_ylim(-0.2,0.2) p2, = ax2.plot(densities[dens],taugrid_71M[dens,tem], 'o',alpha=0.5, markeredgecolor='none') lines4, = ax4.semilogx(densities, texgrid_71M[:,tem], **styleargs) p4, = ax4.plot(densities[dens],texgrid_71M[dens,tem], 'o',alpha=0.5, markeredgecolor='none') ax4.set_ylim(0,20) plt.suptitle("$T=%i$ K, $n=10^{%0.1f}$ cm$^{-3}$" % (temperatures[tem],np.log10(densities[dens])), fontsize=20) ax4.set_xlabel('$n(H_2)$',fontsize=20) ax3.set_xlabel("T",fontsize=20) ax1.set_ylabel(r"$\tau$",fontsize=20) ax3.set_ylabel("$T_{ex}$",fontsize=20) plt.show() return fig,lines1,lines2,lines3,lines4,p1,p2,p3,p4 def run_plot_temden(): fig,lines1,lines2,lines3,lines4,p1,p2,p3,p4 = setup() @interact(tem=(0,temperatures.size-1),dens=(0,densities.size-1)) def plot_temden(tem,dens): lines1.set_data(temperatures, taugrid_71M[dens,:]) lines2.set_data(temperatures, texgrid_71M[dens,:]) lines3.set_data(densities, taugrid_71M[:,tem]) lines4.set_data(densities, texgrid_71M[:,tem]) p1.set_data(temperatures[tem],taugrid_71M[dens,tem]) p2.set_data(densities[dens],taugrid_71M[dens,tem]) p3.set_data(temperatures[tem],texgrid_71M[dens,tem]) p4.set_data(densities[dens],texgrid_71M[dens,tem]) display(fig) run_plot_temden()