-
Notifications
You must be signed in to change notification settings - Fork 0
/
HbandLbol.py
76 lines (64 loc) · 3.23 KB
/
HbandLbol.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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# ------------------------------------------------------------------------------------
# ------------------- Read in Spectra and Photometry files ---------------------------
# ------------------------------------------------------------------------------------
# Read all in as pandas dataframes
df_1256 = pd.read_csv('Data/correctpi1256-0224 (L3.5sd) SED.txt', sep=" ", comment='#', header=None,
names=["w", "f", "err"])
# -------------- Comparison objects of the same Lbol ----------------------------------
df_young = pd.read_csv('Data/lbol0223-5815 (L0gamma) SED.txt', sep=" ", comment='#', header=None,
names=["w", "f", "err"])
df_field = pd.read_csv('Data/lbol1048-3956 (M9) SED.txt', sep=" ", comment='#', header=None, names=["w", "f", "err"])
# -------- Remove lines from when trimming with SEDkit for 1256
df_1256h = df_1256[(df_1256['w'] >= 1.49786) & (df_1256['w'] <= 1.79593)]
# -------------------------------------------------------------------------------------
# ------------------------- Normalize the spectra -------------------------------------
# -------------------------------------------------------------------------------------
# Determine region good for all spectra to take the average flux over
norm_region = df_1256h[(df_1256h['w'] >= 1.5) & (df_1256h['w'] <= 1.52)]
norm_df_1256 = df_1256h['f']/(np.average(norm_region['f']))
norm_region2 = df_young[(df_young['w'] >= 1.5) & (df_young['w'] <= 1.52)]
norm_df_young = df_young['f']/(np.average(norm_region2['f']))
norm_region3 = df_field[(df_field['w'] >= 1.5) & (df_field['w'] <= 1.52)]
norm_df_field = df_field['f']/(np.average(norm_region3['f']))
# -------------------------------------------------------------------------------------
# ------------------- Plotting: H band comparison -------------------------------
# -------------------------------------------------------------------------------------
# ------ Set up figure layout --------
fig = plt.figure()
ax1 = fig.add_subplot(111)
fig.set_size_inches(10, 8)
plt.gcf().subplots_adjust(bottom=0.15, left=0.15)
plt.xlim([1.42, 1.80])
plt.ylim([0, 3.5])
# ------Tick size and Axes Labels --------
plt.yticks(fontsize=20)
plt.xticks(fontsize=20)
plt.xlabel('Wavelength ($\mu m$)', fontsize=25)
plt.ylabel('Normalized Flux (F$_\lambda$)', fontsize=25)
# -------- Add data -----------
ax1.plot(df_1256h['w'], norm_df_1256, c='blue')
ax1.plot(df_field['w'], norm_df_field + 0.5, c='#7C7D70')
ax1.plot(df_young['w'], norm_df_young + 1, c='#D01810')
# ------- Label Features --------------------------
FeH = pd.DataFrame()
FeH['x'] = [1.581, 1.66]
FeH['y'] = [2.6, 2.6]
plt.plot(FeH['x'], FeH['y'], color='k')
ax1.text(0.5, 0.75, 'FeH', transform=ax1.transAxes, color='k', fontsize=15)
FeHd = pd.DataFrame()
FeHd['x'] = [1.581, 1.581]
FeHd['y'] = [2.45, 2.6]
plt.plot(FeHd['x'], FeHd['y'], color='k')
CH4 = pd.DataFrame()
CH4['x'] = [1.67, 1.75]
CH4['y'] = [2.75, 2.75]
plt.plot(CH4['x'], CH4['y'], color='k')
ax1.text(0.74, 0.8, 'CH$_\mathrm{4}$', transform=ax1.transAxes, color='k', fontsize=15)
CH4d = pd.DataFrame()
CH4d['x'] = [1.67, 1.67]
CH4d['y'] = [2.6, 2.75]
plt.plot(CH4d['x'], CH4d['y'], color='k')
plt.savefig('Plots/HbandLbol.pdf')