-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmage_2D_intervening.py
80 lines (68 loc) · 3.32 KB
/
mage_2D_intervening.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
''' Looking at 2D spatial profile of interveing absorber. This is a test case, can generalize later
if this works. jrigby, apr 2016.'''
from builtins import str
import os
import jrr
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import fits
def make_one_2D_absline_plot(filename, linewave, linewin, contwave, contwin):
plt.clf()
ax1 = plt.subplot2grid((1,5), (0, 0), colspan=2)
ax2 = plt.subplot2grid((1,5), (0, 2), colspan=1, sharey=ax1)
ax3 = plt.subplot2grid((1,5), (0, 3), colspan=1, sharey=ax1)
ax4 = plt.subplot2grid((1,5), (0, 4), colspan=1, sharey=ax1)
label = str(filename) + "_" + str(thiswave) + "_z" + str(zz)
plt.annotate(label, (0.1,0.96), xycoords="figure fraction")
xx = int(jrr.mage.mage2D_iswave(filename, contwave)) # Show the continuum
cont, header = fits.getdata(filename, header=True)
ccutout = cont[0:18, xx-contwin : xx+contwin]
ax1.imshow(ccutout, cmap='gray', interpolation='none', origin='lower')
cprofile = np.median(ccutout, axis=1)
ax1.annotate("Continuum", (0.1,0.96), xycoords="axes fraction")
ax1.autoscale(False)
xx = int(jrr.mage.mage2D_iswave(filename, thiswave)) # Show the absorption line
data, header = fits.getdata(filename, header=True)
cutout = data[0:18, xx-win : xx+win]
profile = np.median(cutout, axis=1)
ax2.imshow(cutout, cmap='gray', interpolation='none', origin='lower')
ax2.annotate("Line", (0.1,0.96), xycoords="axes fraction")
ax2.autoscale(False)
# show the profiles
ax3.step(profile, np.arange(profile.size))
ax3.step(cprofile, np.arange(cprofile.size))
ax3.annotate("Median", (0.1,0.96), xycoords="axes fraction")
# show the ratio of the profiles
ax4.step( profile / cprofile , np.arange(cprofile.size), color='k')
ax4.step( np.zeros_like(cprofile), np.arange(cprofile.size), color='r')
ax4.step( np.ones_like(cprofile), np.arange(cprofile.size), color='r')
ax4.annotate("Ratio", (0.1,0.96), xycoords="axes fraction")
ax4.set_xlim(-0.5,1.5)
outfile = label + ".png"
plt.savefig(outfile)
plt.show()
if False :
# Let's look at the interveing MgII absorber in S1527
zz = 1.2823
wave = np.array((2796., 2803)) * (1.0+zz)
contwave = np.array((6340.))
win = 10 # window around the wavelength. *KLUDGE
contwin = win *2
filename = ("s1527-2d-278/s1527-2d-278-009sum.fits", "s1527-2d-278/s1527-2d-278-010sum.fits", "s1527-2d-280/s1527-2d-280-009sum.fits", "s1527-2d-280/s1527-2d-280-010sum.fits")
cwd = "/Volumes/Apps_and_Docs/SCIENCE/Lensed-LBGs/Mage/Redux/Mage_July2008/Mage_pipe/Slit2_bin1x2"
os.chdir(cwd)
for thisfile in filename :
for thiswave in wave :
make_one_2D_absline_plot(thisfile, thiswave, win, contwave, contwin) # do all the work here.
# Do it again for the DLA in S1527 that John O'Meara likes
zz = 2.543
wave = np.array((1216.,)) * (1.0+zz)
contwave = np.array((4535,))
win = 50 # window around the wavelength. *KLUDGE
contwin = 50
filename = ("s1527-2d-280/s1527-2d-280-014sum.fits", "s1527-2d-280/s1527-2d-280-015sum.fits")
cwd = "/Volumes/Apps_and_Docs/SCIENCE/Lensed-LBGs/Mage/Redux/Mage_July2008/Mage_pipe/Slit2_bin1x2"
os.chdir(cwd)
for thisfile in filename :
for thiswave in wave :
make_one_2D_absline_plot(thisfile, thiswave, win, contwave, contwin) # do all the work here.