/
ch3cn_110_synthspec.py
59 lines (44 loc) · 1.57 KB
/
ch3cn_110_synthspec.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Example:
Plot the relative intensities of the 3mm CH3CN (methyl cyanide) lines at 110 GHz
"""
import pyradex
import pylab as pl
from astropy import units as u
import numpy as np
import matplotlib as mpl
R = pyradex.Radex(species='ch3cn',abundance=1e-11,column=None)
# There are 5 lines of interest in this band
nlines = 6
fluxes = {ii:[] for ii in xrange(nlines)}
# Temperature range: 20-500 K is allowed (by CH3CN data file)
temperatures = np.linspace(20,500)
# set up figure
pl.figure(1)
pl.clf()
for ii,temperature in enumerate(temperatures):
R.temperature = temperature
R.run_radex()
S = pyradex.synthspec.SyntheticSpectrum(110.326*u.GHz,110.388*u.GHz,R.get_table())
# spectral colors
color = mpl.cm.spectral(float(ii)/len(temperatures))
S.plot(label='%i K' % temperature,color=color)
for ii in xrange(nlines):
fluxes[ii].append(S.table[ii]['flux'])
pl.savefig("CH3CN_6-5_synthetic_spectra.pdf",bbox_inches='tight')
linenames = {ii:S.table[ii]['upperlevel']+" - "+S.table[ii]['lowerlevel'] for ii in xrange(nlines)}
pl.figure(2)
pl.clf()
pl.subplot(1,2,1)
for ii in xrange(nlines):
pl.plot(temperatures,fluxes[ii],label=linenames[ii])
# Line #4 is the "reference line" at lowest energy
pl.subplot(1,2,2)
for ii in xrange(nlines):
pl.plot(temperatures,np.array(fluxes[ii])/np.array(fluxes[4]),label=linenames[ii])
pl.savefig("CH3CN_6-5_flux_ratios.pdf",bbox_inches='tight')
pl.figure(3)
pl.clf()
for ii in xrange(nlines):
pl.plot(temperatures,np.array(fluxes[4])/np.array(fluxes[ii]),label=linenames[ii])
pl.legend(loc='best')