CGM Examples (v2.1)

%matplotlib inline
# import
# imports
try:
    import seaborn as sns; sns.set_style("white")
except:
    pass


from bokeh.io import output_notebook, show, hplot, output_file
from bokeh.plotting import figure
from bokeh.models import Range1d
output_notebook()

from linetools import utils as ltu

from pyigm.abssys.igmsys import IGMSystem
from pyigm.field.galaxy import Galaxy
from pyigm.cgm.cgm import CGM, CGMAbsSys
from pyigm.cgm.cos_halos import COSHalos
from pyigm.cgm import cos_halos as pycsh

from pyigm.cgm.cgmsurvey import CGMAbsSurvey
/Users/xavier/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))
BokehJS successfully loaded.

Instantiate CGM

radec = (125*u.deg, 45.2*u.deg)
gal = Galaxy(radec,z=0.3)
cgm = CGM(gal)
cgm
<CGM: 08:20:00 +45:12:00, z=0.3>

Instantiate CGMAbsSys

radec_qso = (125*u.deg, 45.203*u.deg)
igmsys = IGMSystem(radec_qso, gal.z, [-500,500]*u.km/u.s)
cgmabs = CGMAbsSys(gal,igmsys)
cgmabs
/Users/xavier/local/Python/pyigm/pyigm/cgm/cgm.py:125: UserWarning: cgm.CGMAbsSys: Using WMAP9 cosmology
  warnings.warn('cgm.CGMAbsSys: Using WMAP9 cosmology')
<CGMAbsSys: J0820+4512_180_11 Galaxy RA/DEC=08:20:00+45:12:00, zgal=0.3, rho=48.7208 kpc>

Instantiate CGMAbsSurvey

cgmsurvey = CGMAbsSurvey(survey='cos-halos', ref='Tumlinson+13, Werk+13')

COS-Halos

Load

reload(pycsh)
cos_halos = pycsh.COSHalos()
WARNING: UnitsWarning: The unit 'Angstrom' has been deprecated in the FITS standard. Suggested: 10**-1 nm. [astropy.units.format.utils]
WARNING:astropy:UnitsWarning: The unit 'Angstrom' has been deprecated in the FITS standard. Suggested: 10**-1 nm.
Be patient, using /Users/xavier/Dropbox/COS-Halos-Data/cos-halos_systems.v1.1.tar.gz to load COS-Halos
Skipping a likely folder: CGM_JSON
cos_halos.name
array([u'J0226+0015_268_22', u'J0401-0540_67_24', u'J0803+4332_306_20',
       u'J0910+1014_242_34', u'J0910+1014_34_46', u'J0914+2823_41_27',
       u'J0925+4004_196_22', u'J0928+6025_110_35', u'J0935+0204_15_28',
       u'J0943+0531_106_34', u'J0943+0531_216_61', u'J0943+0531_227_19',
       u'J0950+4831_177_27', u'J1009+0713_170_9', u'J1009+0713_204_17',
       u'J1016+4706_274_6', u'J1016+4706_359_16', u'J1112+3539_236_14',
       u'J1133+0327_110_5', u'J1133+0327_164_21', u'J1157-0022_230_7',
       u'J1220+3853_225_38', u'J1233+4758_94_38', u'J1233-0031_168_7',
       u'J1241+5721_199_6', u'J1241+5721_208_27', u'J1245+3356_236_36',
       u'J1322+4645_349_11', u'J1330+2813_289_28', u'J1342-0053_157_10',
       u'J1342-0053_77_10', u'J1419+4207_132_30', u'J1435+3604_126_21',
       u'J1435+3604_68_12', u'J1437+5045_317_38', u'J1445+3428_232_33',
       u'J1514+3619_287_14', u'J1550+4001_197_23', u'J1550+4001_97_33',
       u'J1555+3628_88_11', u'J1617+0638_253_39', u'J1619+3342_113_40',
       u'J2257+1340_270_40', u'J2345-0059_356_12'],
      dtype='<U17')
cos_halos.cgm_abs[4].igm_sys
<IGMSystem: IGMSystem 09:10:29.8 10:14:13.6, 0.142738, NHI=14.7577, Z/H=-0.7>

Simple output

cdict = cos_halos.cgm_abs[10].to_dict()
cdict.keys()
['cosmo',
 'z',
 'Name',
 u'igm_sys',
 'RA',
 'PA',
 'user',
 'rho',
 'ang_sep',
 'DEC',
 u'galaxy',
 'CreationDate']
cdict['igm_sys'].keys()
['vlim',
 'CreationDate',
 'Name',
 'flag_NHI',
 u'components',
 'Refs',
 'NHI',
 'RA',
 'zem',
 'kin',
 'sig_NHI',
 'zabs',
 'DEC',
 'user',
 'abs_type']
# Write
import io, json
newdict = ltu.jsonify(cdict)
newdict['igm_sys']['kin'] = None
with io.open('/u/xavier/Desktop/J0943+0531_216_61.json', 'w', encoding='utf-8') as f:
    f.write(unicode(json.dumps(newdict, sort_keys=True, indent=4,
                               separators=(',', ': '))))

Simple plots

Impact parameter

rho = cos_halos.rho
p = figure(plot_width=400, plot_height=400, title='COS-Halos Impact Parameters')
hist, edges = np.histogram(rho, range=(25., 155), bins=10)
p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], fill_color='blue')#, alpha=0.5)
p.xaxis.axis_label = 'rho (kpc)'
# Show
show(p)

Stellar Mass

Mstar = cos_halos.stellar_mass
p = figure(plot_width=400, plot_height=400, title='COS-Halos Stellar Masses')
hist, edges = np.histogram(Mstar, range=(9,12), bins=10)
p.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], fill_color='blue')#, alpha=0.5)
p.xaxis.axis_label = 'log10 M*'
# Show
show(p)

Metallicity

# coming soon

Load spectra

#
itup = ('J0928+6025','110_35')
cgmabs = cos_halos[itup]
print(cgmabs)
<CGMAbsSys: J0928+6025_110_35 Galaxy RA/DEC=09:28:42.46+60:25:08.7, zgal=0.154, rho=95.2382 kpc>

Galaxy

# Not working right now
spec = cos_halos.load_gal_spec(('J0928+6025','110_35'))
spec.plot()
CGM_examples_files/CGM_examples_32_0.png

QSO

qso_spec = cos_halos.load_bg_cos_spec(itup, 1215.6700*u.AA)
qso_spec.plot()
CGM_examples_files/CGM_examples_35_0.png

Velocity plot

plt.figure(figsize=(18, 11))
cos_halos.stack_plot(itup,ymnx=(-0.1,1.3))
Skipping 977.02 Angstrom. Assuming no coverage
/Users/xavier/local/Python/pyigm/pyigm/cgm/cos_halos.py:549: UserWarning: File /Users/xavier/Dropbox/COS-Halos-Data//Targets/fitting/J0928+6025_110_35_z0.154_CIII977_slice.fits not found
  warnings.warn("File {:s} not found".format(slicedir+slicename))
<matplotlib.figure.Figure at 0x11a434550>
CGM_examples_files/CGM_examples_37_3.png