In [ ]:
Example use of the grid wrapper and then interactive plot creation

In [ ]:
# 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

In [2]:
from IPython.html.widgets import interact, interactive, fixed
from matplotlib import pyplot as plt
from IPython.display import clear_output, display, HTML

In [3]:
%run ph2co_grid_computation.py


/Users/adam/repos/astroquery/astroquery/lamda/__init__.py:21: UserWarning: Experimental: LAMDA has not yet been refactored to have its API match the rest of astroquery.
  warnings.warn("Experimental: LAMDA has not yet been refactored to have its API match the rest of astroquery.")
WARNING:astropy:AstropyDeprecationWarning: 'dtypes' has been renamed to the singular 'dtype'.
WARNING: AstropyDeprecationWarning: 'dtypes' has been renamed to the singular 'dtype'. [astropy.table.table]
      Tex               tau        ...      brightness           T_B      
       K                           ... erg / (cm2 Hz s sr)        K       
---------------- ----------------- ... ------------------- ---------------
-0.0817529700928  -0.0342780871976 ...   1.56037207206e-22  0.100352601934
   6.09190527741     41.9634499416 ...   1.73595925381e-14   2.66518509246
 -0.171716538322 -0.00182074261889 ...   2.06896749361e-22 0.0053264336307
/Users/adam/repos/astropy/astropy/units/quantity.py:608: RuntimeWarning: invalid value encountered in true_divide
  return np.true_divide(self, other)

In [4]:
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)

In [5]:
run_plot_temden()



In [5]: