In [1]:
import numpy as np

%matplotlib inline
import matplotlib.pyplot as plt
import astropy.units as u

import pysac.mhs_atmosphere as atm


WARNING:traits.has_traits:DEPRECATED: traits.has_traits.wrapped_class, 'the 'implements' class advisor has been deprecated. Use the 'provides' class decorator.

In [7]:
#Read in the VAL3C model
empirical_data = atm.hs_atmosphere.read_VAL3c_MTW(MTW_file=False)[:-26]

# Create a Z array at the interpolated resolution and interpolate.
ZZ = u.Quantity(np.linspace(empirical_data['Z'][0], empirical_data['Z'][-1], 128), unit=empirical_data['Z'].unit)
table = atm.hs_atmosphere.interpolate_atmosphere(empirical_data, ZZ)

# Create a figure and make space for the axes.
fig, ax = plt.subplots(gridspec_kw={'right':0.775, 'left':0.13}, figsize=(15,8))

# Shortcut all the Mm conversion.
Z = empirical_data['Z'].to(u.Mm)

lrho, = ax.plot(Z, empirical_data['rho'].quantity.si, 'x', color='blue')
lrho_i, = ax.plot(ZZ.to(u.Mm), table['rho'].quantity.si, color='blue')

ax2 = ax.twinx()
lp, = ax2.plot(Z, empirical_data['p'].to(u.Pa), 'x', color='green')
lp_i, = ax2.plot(ZZ.to(u.Mm), table['p'].to(u.Pa), color='green')


ax3 = ax.twinx()
ax3.spines["right"].set_position(("axes", 1.18))
lt, = ax3.plot(Z, empirical_data['T'], 'x', color='red')
lt_i, = ax3.plot(ZZ.to(u.Mm), table['T'], color='red')


# Set primary axes properties and labels
ax.semilogy()
ax.set_ylabel(r"Density [{}]".format(lrho._yorig.unit._repr_latex_()))
ax.set_xlabel(r"Height [{}]".format(lrho._xorig.unit._repr_latex_()))
ax.set_xlim(Z[0].value-0.1, Z[-1].value+0.1)


# Pressure Axis
ax2.semilogy()
ax2.set_ylabel(r"Pressure [{}]".format(lp._yorig.unit._repr_latex_()))


# Temp axis
ax3.set_ylabel(r"Temperature [{}]".format(lt._yorig.unit._repr_latex_()))

# Set the colours for the ticks and the labels.
ax.tick_params(axis='y', colors=lrho.get_color())
ax2.tick_params(axis='y', colors=lp.get_color())
ax3.tick_params(axis='y', colors=lt.get_color())

ax.yaxis.label.set_color(lrho.get_color())
ax2.yaxis.label.set_color(lp.get_color())
ax3.yaxis.label.set_color(lt.get_color())

fig


Out[7]:

In [9]:
table


Out[9]:
<Table length=128>
ZpTrhomu
kmdyn / cm2Kg / cm3
float64float64float64float64float64
-75.0212505.2856166604.888862413.91130749015e-071.23884247641
-61.7716535433191134.0858366535.971390443.64314548677e-071.23991852077
-48.5433070866171912.1416796467.773024883.39336885969e-071.24092846946
-35.3149606299154623.3071276400.286262363.16071709454e-071.24139725517
-22.0866141732139073.1735026333.503677782.94401609869e-071.24179325032
-8.85826771654125086.883396267.417923542.74217227613e-071.24193097891
4.37007874016112507.164416202.021728682.55416700857e-071.24203404157
17.5984251969101192.5607276137.307898132.37905151491e-071.24206681019
30.826771653591015.84241496073.269311882.21594206315e-071.24209957968
...............
1485.944881891.544845444566427.902147022.84626158446e-121.22118002624
1499.173228351.430299304666456.814857072.62007548044e-121.22014894192
1512.40157481.324246453336485.857616512.41186388514e-121.21911872818
1525.629921261.226057136056515.031010312.22019840416e-121.21750150977
1538.858267721.135148292886544.335626062.04376415443e-121.21574296774
1552.086614171.050980096246573.772054011.88135074375e-121.21398696572
1565.314960630.9730527452776603.340887031.73184396709e-121.21223350005
1578.543307090.9009034980596633.04272071.59421816284e-121.21048256706
1591.771653540.8341039237136662.878153241.46752917643e-121.2087341631
1605.00.7722573583656692.847785581.35090788316e-121.2069882845

In [14]:
fig = plt.figure()
plt.plot(table['T'],'x')
fig


Out[14]:

In [ ]: