Regression test suite: Test of all plotting functions

Plotting functions are called in the order as they appear in the code. Each field calls first the function with default input and then with user-specified input. You can find the documentation here.

$\odot$ Plotting functions tests


In [1]:
#from imp import *
#s=load_source('sygma','/home/nugrid/nugrid/SYGMA/SYGMA_online/SYGMA_dev/sygma.py')
#import mpld3
#mpld3.enable_notebook()
import sygma as s
reload(s)
import matplotlib.pyplot as plt
%matplotlib inline


/home/christian/test/ipython/IPython/kernel/__init__.py:10: UserWarning: The `IPython.kernel` package has been deprecated. You should import from ipython_kernel or jupyter_client instead.
  warn("The `IPython.kernel` package has been deprecated. "

In [2]:
s1=s.sygma(iniZ=0.02,dt=1e7,tend=2e7)


SYGMA run in progress..
   SYGMA run completed - Run time: 0.72s

plot_yield_input

To plot the yield data


In [3]:
s1.plot_yield_input()  #[1,3,5,12][Fe/H]
s1.plot_yield_input(fig=2,xaxis='mini',yaxis='[Fe/H]',iniZ=0.0001,masses=[1,3,12,25],marker='s',color='r',shape='-')
s1.plot_yield_input(fig=3,xaxis='[C/H]',yaxis='[Fe/H]',iniZ=0.0001,masses=[1,3,12,25],marker='x',color='b',shape='--')


The following commands plot the ISM metallicity in spectroscopic notation.

s1.plot_mass


In [4]:
s1.plot_mass()
s1.plot_mass(specie='N',shape='--',marker='x')



In [5]:
#s1.plot_mass_multi()
#s1.plot_mass_multi(fig=1,specie=['C','N'],ylims=[],source='all',norm=False,label=[],shape=['-','--'],marker=['o','D'],color=['r','b'],markevery=20)
#plt.legend()

In [ ]:

s1.plot_massfrac


In [6]:
s1.plot_massfrac()
s1.plot_massfrac(yaxis='He-4',shape='--',marker='x')


s1.plot_spectro


In [7]:
s1.plot_spectro()
s1.plot_spectro(yaxis='[O/Fe]',marker='x',shape='--')


s1.plot_totmasses


In [8]:
s1.plot_totmasses()
s1.plot_totmasses(source='agb',shape='--',marker='x')
s1.plot_totmasses(mass='stars',shape=':',marker='^')


Test of SNIa and SNII rate plots


In [9]:
import sygma as s
reload(s)
s1=s.sygma(iolevel=0,mgal=1e11,dt=1e7,tend=1.3e10,imf_type='salpeter',imf_bdys=[1,30],special_timesteps=-1,hardsetZ=0.0001,table='yield_tables/isotope_yield_table_h1.txt',sn1a_on=True, sn1a_table='yield_tables/sn1a_h1.txt', iniabu_table='yield_tables/iniabu/iniab1.0E-04GN93_alpha_h1.ppn',pop3_table='yield_tables/popIII_h1.txt')


SYGMA run in progress..
   SYGMA run completed - Run time: 21.53s

In [10]:
#s1.plot_sn_distr(rate=True,label1='SN1a, rate',label2='SNII, rate',marker1='o',marker2='s')
s1.plot_sn_distr(fig=4,rate=False,label1='SN1a, number',label2='SNII number',marker1='d',marker2='p')
##plt.xlim(1e6,1e10)
#plt.ylabel('Number/Rate')
s1.plot_sn_distr()
s1.plot_sn_distr(fig=5,rate=True,rate_only='',xaxis='time',label1='SN1a',label2='SN2',shape1=':',shape2='--',marker1='o',marker2='s',color1='k',color2='b',markevery=20)


One point at the beginning for only 1 starburst


In [11]:
#s1=s.sygma(iolevel=0,mgal=1e11,dt=1e6,tend=1.3e10,imf_type='salpeter',imf_bdys=[1,30],special_timesteps=-1,iniZ=-1,hardsetZ=0.0001,table='yield_tables/isotope_yield_table_h1.txt',sn1a_on=True, sn1a_table='yield_tables/sn1a_h1.txt', iniabu_table='yield_tables/iniabu/iniab1.0E-04GN93_alpha_h1.ppn',pop3_table='yield_tables/popIII_h1.txt')

In [12]:
#s1.plot_sn_distr(rate=True,label1='SN1a, rate',label2='SNII, rate',marker1='o',marker2='s')
#s1.plot_sn_distr(rate=False,label1='SN1a, number',label2='SNII number',marker1='d',marker2='p')
#plt.xlim(1e6,1e10)
#plt.ylabel('Number/Rate')

In [13]:
#s1=s.sygma(iniZ=0.0001,dt=1e9,tend=2e9)
#s2=s.sygma(iniZ=0.02)#,dt=1e7,tend=2e9)
reload(s)
s1=s.sygma(iolevel=0,iniZ=0.02,dt=1e8,tend=1e9) #standart not workign
#s2=s.sygma(iniZ=0.02,dt=1e8,tend=1e10)


SYGMA run in progress..
   SYGMA run completed - Run time: 0.71s

plot_mass_range_contributions


In [14]:
s1.plot_mass_range_contributions()
s1.plot_mass_range_contributions(fig=7,specie='O',rebin=0.5,label='',shape='-',marker='o',color='b',markevery=20,extralabel=False,log=False)

#s1.plot_mass_range_contributions(fig=7,specie='O',prodfac=True,rebin=0.5,label='',shape='-',marker='o',color='r',markevery=20,extralabel=False,log=False)


Tests with two starbursts


In [15]:
import sygma as s
reload(s)
ssp1=s.sygma(iolevel=0,dt=1e8,mgal=1e11,starbursts=[0.1,0.1],tend=1e9,special_timesteps=-1,imf_type='kroupa',imf_bdys=[0.1,100],sn1a_on=False,hardsetZ=0.0001,table='yield_tables/isotope_yield_table_h1.txt', sn1a_table='yield_tables/sn1a_h1.txt', iniabu_table='yield_tables/iniabu/iniab1.0E-04GN93_alpha_h1.ppn')


SYGMA run in progress..
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-4c0a0e5cc15d> in <module>()
      1 import sygma as s
      2 reload(s)
----> 3 ssp1=s.sygma(iolevel=0,dt=1e8,mgal=1e11,starbursts=[0.1,0.1],tend=1e9,special_timesteps=-1,imf_type='kroupa',imf_bdys=[0.1,100],sn1a_on=False,hardsetZ=0.0001,table='yield_tables/isotope_yield_table_h1.txt', sn1a_table='yield_tables/sn1a_h1.txt', iniabu_table='yield_tables/iniabu/iniab1.0E-04GN93_alpha_h1.ppn')

/home/christian/NuGrid/SYGMA_PROJECT/GCE/OMEGA_SYGMA_New/sygma.pyc in __init__(self, sfr, imf_type, alphaimf, imf_bdys, sn1a_rate, iniZ, dt, special_timesteps, tend, mgal, transitionmass, iolevel, ini_alpha, table, hardsetZ, sn1a_on, sn1a_table, iniabu_table, extra_source_on, extra_source_table, pop3_table, imf_bdys_pop3, imf_yields_range_pop3, starbursts, beta_pow, nb_1a_per_m, Z_trans, f_arfo, imf_yields_range)
    228 
    229         # Get the SFR of every timestep
--> 230         self.sfrin_i = self.__sfr()
    231 
    232         # Run the simulation

/home/christian/NuGrid/SYGMA_PROJECT/GCE/OMEGA_SYGMA_New/sygma.pyc in __sfr(self)
    295                     # Use the input value
    296                     sfr_i.append(self.starbursts[i-1])
--> 297                     history.sfr.append(sfr_i[i-1])
    298 
    299             # If an input file is read for the SFR ...

NameError: global name 'history' is not defined

In [ ]:
ssp1.plot_star_formation_rate()
ssp1.plot_star_formation_rate(fig=6,marker='o',shape=':')

In [ ]:
ssp1.plot_mass_range_contributions(fig=7,specie='H',prodfac=False,rebin=-1,time=-1,label='Total burst',shape='-',marker='o',color='r',markevery=20,extralabel=False,log=False)
ssp1.plot_mass_range_contributions(fig=7,specie='H',prodfac=False,rebin=-1,time=1e8,label='Burst at 1e8',shape='-',marker='o',color='b',markevery=20,extralabel=False,log=False)

write_evol_table


In [ ]:
#s1.write_evol_table(elements=['H','He','C'])
s1.write_evol_table(elements=['H'],isotopes=['H-1'],table_name='gce_table.txt',interact=False)

In [ ]: