In [22]:
%matplotlib notebook
In [2]:
# imports
from matplotlib import pyplot as plt
from astropy.coordinates import SkyCoord, match_coordinates_sky
from astropy import units as u
from specdb.specdb import IgmSpec
from pyigm.surveys.dlasurvey import DLASurvey
In [3]:
sdssdr5 = DLASurvey.load_SDSS_DR5(sample='all')
In [48]:
min_NHI = np.min(sdssdr5.NHI)
min_NHI
Out[48]:
In [4]:
sdssdr5.sightlines[0:4]
Out[4]:
In [5]:
dla_coord = sdssdr5.coord
In [6]:
sl_coord = SkyCoord(ra=sdssdr5.sightlines['RA'], dec=sdssdr5.sightlines['DEC'])
In [7]:
idx, d2d, d3d = match_coordinates_sky(sl_coord, dla_coord, nthneighbor=1)
In [8]:
clear = d2d > 1*u.arcsec
In [9]:
nclear = np.sum(clear)
nclear
Out[9]:
In [10]:
keep = clear
In [11]:
np.max(sdssdr5.sightlines['FLG_BAL'])
Out[11]:
In [23]:
plt.clf()
ax = plt.gca()
ax.hist(sdssdr5.sightlines['S2N'][keep], bins=50, color='grey')
ax.set_xlim(0., 40.)
plt.show()
In [13]:
s2n_cut = 5.
In [14]:
gd_s2n = sdssdr5.sightlines['S2N'] > s2n_cut
In [15]:
keep = clear & gd_s2n
np.sum(keep)
Out[15]:
In [24]:
plt.clf()
ax = plt.gca()
ax.hist(sdssdr5.sightlines['DX'][keep], bins=50, color='orange')
#ax.set_xlim(0., 40.)
plt.show()
In [25]:
plt.clf()
ax = plt.gca()
ax.scatter(sdssdr5.sightlines['ZEM'][keep], sdssdr5.sightlines['DX'][keep], color='orange')
ax.set_xlabel(r'$z_{\rm em}$')
ax.set_ylabel(r'$\Delta X$')
plt.show()
In [18]:
nsight = np.sum(keep)
print("We have {:d} sightlines for the training set".format(nsight))
In [51]:
plt.clf()
ax = plt.gca()
ax.hist(sdssdr5.sightlines['ZEM'][keep], bins=50)
#ax.set_xlim(0., 40.)
ax.set_xlabel(r'$z_{\rm em}$')
plt.show()
In [52]:
plt.clf()
ax = plt.gca()
ax.hist(sdssdr5.sightlines['MAG'][keep], bins=50, color='green')
ax.set_xlabel(r'$i$ (mag)')
plt.show()
In [30]:
igmsp = IgmSpec()
In [21]:
kidx = np.where(keep)[0]
In [31]:
k0 = kidx[0]
s0 = sdssdr5.sightlines[k0]
s0
Out[31]:
In [35]:
spec, meta = igmsp.spec_from_coord((s0['RA'], s0['DEC']), isurvey=['SDSS_DR7'])
spec[0]
Out[35]:
In [36]:
spec[0].plot()
In [37]:
k100 = kidx[100]
s100 = sdssdr5.sightlines[k100]
s100
Out[37]:
In [38]:
spec100, meta = igmsp.spec_from_coord((s100['RA'], s100['DEC']), isurvey=['SDSS_DR7'])
spec100[0].plot()
In [41]:
i3 = np.argmin(np.abs(sdssdr5.sightlines['ZEM'][keep]-3.))
k3 = kidx[i3]
s3 = sdssdr5.sightlines[k3]
s3
Out[41]:
In [44]:
spec3, meta = igmsp.spec_from_coord((s3['RA'], s3['DEC']), isurvey=['SDSS_DR7'])
spec3[0].plot()
In [45]:
i4 = np.argmin(np.abs(sdssdr5.sightlines['ZEM'][keep]-4.))
k4 = kidx[i4]
s4 = sdssdr5.sightlines[k4]
s4
Out[45]:
In [46]:
spec4, meta = igmsp.spec_from_coord((s4['RA'], s4['DEC']), isurvey=['SDSS_DR7'])
spec4[0].plot()
In [ ]: