CGM Examples (v2.1) =================== .. code:: python %matplotlib inline .. code:: python # 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 .. parsed-literal:: /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)) .. raw:: html
BokehJS successfully loaded.
Instantiate CGM --------------- .. code:: python radec = (125*u.deg, 45.2*u.deg) gal = Galaxy(radec,z=0.3) cgm = CGM(gal) cgm .. parsed-literal:: Instantiate CGMAbsSys --------------------- .. code:: python radec_qso = (125*u.deg, 45.203*u.deg) igmsys = IGMSystem(radec_qso, gal.z, [-500,500]*u.km/u.s) .. code:: python cgmabs = CGMAbsSys(gal,igmsys) cgmabs .. parsed-literal:: /Users/xavier/local/Python/pyigm/pyigm/cgm/cgm.py:125: UserWarning: cgm.CGMAbsSys: Using WMAP9 cosmology warnings.warn('cgm.CGMAbsSys: Using WMAP9 cosmology') .. parsed-literal:: Instantiate CGMAbsSurvey ------------------------ .. code:: python cgmsurvey = CGMAbsSurvey(survey='cos-halos', ref='Tumlinson+13, Werk+13') COS-Halos --------- Load ~~~~ .. code:: python reload(pycsh) cos_halos = pycsh.COSHalos() .. parsed-literal:: 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. .. parsed-literal:: 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 .. code:: python cos_halos.name .. parsed-literal:: 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=' Simple output ~~~~~~~~~~~~~ .. code:: python cdict = cos_halos.cgm_abs[10].to_dict() cdict.keys() .. parsed-literal:: ['cosmo', 'z', 'Name', u'igm_sys', 'RA', 'PA', 'user', 'rho', 'ang_sep', 'DEC', u'galaxy', 'CreationDate'] .. code:: python cdict['igm_sys'].keys() .. parsed-literal:: ['vlim', 'CreationDate', 'Name', 'flag_NHI', u'components', 'Refs', 'NHI', 'RA', 'zem', 'kin', 'sig_NHI', 'zabs', 'DEC', 'user', 'abs_type'] .. code:: python # 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 ^^^^^^^^^^^^^^^^ .. code:: python rho = cos_halos.rho .. code:: python 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) .. raw:: html
Stellar Mass ^^^^^^^^^^^^ .. code:: python Mstar = cos_halos.stellar_mass .. code:: python 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) .. raw:: html
Metallicity ~~~~~~~~~~~ .. code:: python # coming soon Load spectra ~~~~~~~~~~~~ .. code:: python # itup = ('J0928+6025','110_35') cgmabs = cos_halos[itup] print(cgmabs) .. parsed-literal:: Galaxy ^^^^^^ .. code:: python # Not working right now spec = cos_halos.load_gal_spec(('J0928+6025','110_35')) .. code:: python spec.plot() .. image:: CGM_examples_files/CGM_examples_32_0.png QSO ^^^ .. code:: python qso_spec = cos_halos.load_bg_cos_spec(itup, 1215.6700*u.AA) .. code:: python qso_spec.plot() .. image:: CGM_examples_files/CGM_examples_35_0.png Velocity plot ^^^^^^^^^^^^^ .. code:: python plt.figure(figsize=(18, 11)) cos_halos.stack_plot(itup,ymnx=(-0.1,1.3)) .. parsed-literal:: Skipping 977.02 Angstrom. Assuming no coverage .. parsed-literal:: /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)) .. parsed-literal:: .. image:: CGM_examples_files/CGM_examples_37_3.png