====== Analysis of Photometric Offsets in Astronomical Data using Python ====== === PhotometricOffsetFigures.ipynb === This Jupyter notebook contains a detailed analysis focused on comparing photometric data from the HUGS and ACS surveys, specifically targeting the NGC 2808 cluster. It involves data cleaning, sampling, and visualization using libraries like pandas, matplotlib, and numpy. Furthermore, it applies fiducial line measurement techniques to discern photometric offsets and undertakes isochrone fitting with Bolometric Corrections to study stellar populations. The notebook concludes with a unique assessment of helium mass fraction effects on turn-off points in color-magnitude diagrams, potentially offering insights into stellar evolution. ```python import matplotlib.pyplot as plt import pandas as pd import numpy as np from fidanka.fiducial.fiducial import measure_fiducial_lines from fidanka.fiducial.utils import bin_color_mag_density import pickle as pkl from matplotlib.lines import Line2D from fidanka.fiducial.fiducial import hull_density from scipy.interpolate import splrep, BSpline from scipy.interpolate import interp1d from fidanka.isochrone.MIST import read_iso from fidanka.isochrone.isochrone import interp_isochrone_age from fidanka.bolometric.bctab import BolometricCorrector import re from scipy.optimize import curve_fit from fidanka.isochrone.MIST import read_iso from fidanka.isochrone.isochrone import interp_isochrone_age ``` ```python ACSRoot = "../photometry/hlsp_acsggct_hst_acs-wfc_ngc2808_r.rdviq.cal.adj.zpt" HUGSRoot = "../photometry/HUGS/ngc2808/photometry.pkl" ``` ```python with open(HUGSRoot, 'rb') as f: HUGSdata = pkl.load(f) ``` ```python ACSdata = pd.read_csv(ACSRoot, sep=r'\s+') ACSdata = ACSdata[ACSdata['Vvega'] - ACSdata['Ivega'] > 0.5] ``` ```python n = 20000 ACSSub = ACSdata.sample(n) ACSmag = ACSSub["Vvega"] ACScolor = ACSSub["Vvega"] - ACSSub["Ivega"] HUGSSub = HUGSdata[1].sample(n) HUGSmag = HUGSSub["F606W"] HUGScolor = HUGSSub["F606W"] - HUGSSub["F814W"] ``` ```python ACSdensity = hull_density(ACScolor, ACSmag) HUGSdensity = hull_density(HUGScolor, HUGSmag) ``` ```python with plt.style.context(pubStyle): fig, ax = plt.subplots(1,1,figsize=(10,7)) ax.scatter(HUGScolor, HUGSmag,s=1,c=HUGSdensity, cmap="Reds") ax.scatter(ACScolor, ACSmag, s=1, c=ACSdensity, cmap='Blues', alpha=0.25) ax.set_xlim(0,2) ax.set_ylim(16, 25) ax.invert_yaxis() ax.set_xlabel("F606W - F814W", fontsize=27) ax.set_ylabel("F606W", fontsize=27) legend_elements = [ Line2D([0], [0], marker='o', color='w', label='HUGS', markerfacecolor='r', markersize=15), Line2D([0], [0], marker='o', color='w', label='ACS', markerfacecolor='b', markersize=15), ] ax.legend(handles = legend_elements, frameon=False, fontsize=27) fig.savefig("Figures/photometricOffset.pdf") ``` ![png](media/PhotometricOffsetFigures.ipynb/output_6_0.png) ```python ACSFiducial = measure_fiducial_lines( ACSSub['Vvega'].values, ACSSub['Ivega'].values, ACSSub['err'].values, ACSSub['err.2'].values, binSize='uniformCS', targetStat=100, mcruns=5, convexHullPoints=50, nPops=1) ``` 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:58<00:00, 11.61s/it] ```python HUGSFiducial = measure_fiducial_lines( HUGSSub['F606W'].values, HUGSSub['F814W'].values, HUGSSub['F606W_RMS'].values, HUGSSub['F814W_RMS'].values, binSize='uniformCS', targetStat=100, mcruns=5, convexHullPoints=50, nPops=1) ``` 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:52<00:00, 10.48s/it] ```python from fidanka.misc.utils import measusre_perpendicular_distance ``` ```python with plt.style.context(pubStyle): fig, axs = plt.subplots(1,2,figsize=(20,7)) ax = axs[0] ax.scatter(HUGScolor, HUGSmag,s=1,c=HUGSdensity, cmap="Reds") ax.scatter(ACScolor, ACSmag, s=1,c=ACSdensity, cmap='Blues', alpha=0.1) ax.set_xlim(0,2) ax.set_ylim(17, 22) ax.invert_yaxis() ACSSmoothTCK = splrep(ACSFiducial[0].mean[1], ACSFiducial[0].mean[0], s=0.001) ax.plot(BSpline(*ACSSmoothTCK)(ACSFiducial[0].mean[1]), ACSFiducial[0].mean[1] , color='g') HUGSmoothTCK = splrep(HUGSFiducial[0].mean[1], HUGSFiducial[0].mean[0], s=0.001) ax.plot(BSpline(*HUGSmoothTCK)(HUGSFiducial[0].mean[1]), HUGSFiducial[0].mean[1] , color='orange') ax.set_xlim(0.6, 1) ax.set_xlabel("F606W - F814W", fontsize=27) ax.set_ylabel("F606W", fontsize=27) legend_elements = [ Line2D([0], [0], marker='o', color='w', label='HUGS', markerfacecolor='r', markersize=10), Line2D([0], [0], marker='o', color='w', label='ACS', markerfacecolor='b', markersize=10), ] ax.legend(handles = legend_elements, frameon=False, fontsize=27) ax = axs[1] ax.set_xlabel("F606W", fontsize=27) ax.set_ylabel("HUGS$_{color}$ - ACS$_{color}$", fontsize=27) domain = np.linspace(19.5, 22, 1000) dist = measusre_perpendicular_distance(BSpline(*HUGSmoothTCK), BSpline(*ACSSmoothTCK), domain) ax.plot(domain, dist, color='black') ax.axhline(np.mean(dist), color='black', linestyle='dashed') # ax.axhline(np.median(dist)) fig.savefig("Figures/photometricOffset.pdf") ``` ![png](media/PhotometricOffsetFigures.ipynb/output_10_0.png) ```python plt.plot(np.arange(17, 22, 0.1),measusre_perpendicular_distance(BSpline(*HUGSmoothTCK), BSpline(*ACSSmoothTCK), np.arange(17, 22, 0.1)), 'o') ``` [] ![png](media/PhotometricOffsetFigures.ipynb/output_11_1.png) ```python bc = BolometricCorrector("WFC3", 1.13) ``` ```python rootPath = "../outputs.denseAlpha.fixedLowmass/" ``` ```python import pathlib ``` ```python paths = list() for file in pathlib.Path(rootPath).rglob("alpha-1.901/isochrones.txt"): paths.append(file) ``` ```python isos = list() testIso = read_iso(paths[0]) header = testIso[list(testIso.keys())[0]].columns for path in paths: isos.append(pd.DataFrame(interp_isochrone_age(read_iso(path), 12.3), columns=header)) ``` ```python isos[0] ```
EEP log10_isochrone_age_yr initial_mass star_mass star_mdot he_core_mass c_core_mass log_L log_LH log_LHe ... surface_c12 surface_o16 log_center_T log_center_Rho center_gamma center_h1 center_he4 center_c12 phase age
0 286.0 10.089905 0.235747 0.235747 0.0 0.000000 0.0 -1.989956 -1.989276 -10.0 ... 0.000061 0.000820 6.849942 2.109066 0.0 0.688852 0.309676 0.000061 0.0 1.230187e+10
1 287.0 10.089905 0.260267 0.260267 0.0 0.000000 0.0 -1.904474 -1.903862 -10.0 ... 0.000061 0.000820 6.863070 2.051913 0.0 0.688946 0.309582 0.000061 0.0 1.230187e+10
2 288.0 10.089905 0.262639 0.262639 0.0 0.000000 0.0 -1.897316 -1.896708 -10.0 ... 0.000061 0.000820 6.864233 2.047220 0.0 0.688909 0.309619 0.000061 0.0 1.230187e+10
3 289.0 10.089905 0.265015 0.265015 0.0 0.000000 0.0 -1.890155 -1.889553 -10.0 ... 0.000061 0.000820 6.865400 2.042532 0.0 0.688879 0.309649 0.000061 0.0 1.230187e+10
4 290.0 10.089905 0.267398 0.267398 0.0 0.000000 0.0 -1.882988 -1.882392 -10.0 ... 0.000061 0.000820 6.866570 2.037846 0.0 0.688857 0.309671 0.000061 0.0 1.230187e+10
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
187 601.0 10.089905 0.763934 0.412178 0.0 0.332015 0.0 2.349763 2.347601 -10.0 ... 0.000056 0.000788 7.712642 5.599579 0.0 0.000000 0.998341 0.000004 2.0 1.230187e+10
188 602.0 10.089905 0.763948 0.410825 0.0 0.333765 0.0 2.364422 2.362240 -10.0 ... 0.000056 0.000788 7.715019 5.605118 0.0 0.000000 0.998341 0.000004 2.0 1.230187e+10
189 603.0 10.089905 0.763962 0.409429 0.0 0.335503 0.0 2.379073 2.376870 -10.0 ... 0.000056 0.000788 7.717450 5.610761 0.0 0.000000 0.998342 0.000004 2.0 1.230187e+10
190 604.0 10.089905 0.763978 0.407971 0.0 0.337333 0.0 2.393712 2.391482 -10.0 ... 0.000056 0.000788 7.719974 5.616615 0.0 0.000000 0.998342 0.000004 2.0 1.230187e+10
191 605.0 10.089905 0.764000 0.406203 0.0 0.339454 0.0 2.408234 2.405955 -10.0 ... 0.000056 0.000788 7.722938 5.623576 0.0 0.000000 0.998342 0.000004 3.0 1.230187e+10

192 rows × 26 columns

```python mags = list() for iso in isos: mags.append(bc.apparent_mags( 10**iso['log_Teff'], iso['log_g'], iso['log_L'], filters=("WFC3_UVIS_F606W", "WFC3_UVIS_F814W") ) ) ``` ```python turnOffs = list() for mag, path in zip(mags, paths): color = mag["WFC3_UVIS_F606W"]-mag["WFC3_UVIS_F814W"] idStr = re.findall('Pop[A|E]\+0\.\d+', str(path))[0] pop = idStr[3] Y = float(idStr[5:]) turnOffColor = min(mag["WFC3_UVIS_F606W"] - mag["WFC3_UVIS_F814W"]) turnOffMag = mag[color==turnOffColor]["WFC3_UVIS_F606W"] if turnOffColor < 0.48: turnOffs.append((turnOffColor, turnOffMag.values[0], pop, Y)) meanTurnOffColorA = sum([x[0] for x in turnOffs if x[2] == 'A'])/(len(turnOffs)/2) meanTurnOffMagA = sum([x[1] for x in turnOffs if x[2] == 'A'])/(len(turnOffs)/2) meanTurnOffColorE = sum([x[0] for x in turnOffs if x[2] == 'E'])/(len(turnOffs)/2) meanTurnOffMagE = sum([x[1] for x in turnOffs if x[2] == 'E'])/(len(turnOffs)/2) ``` ```python hevolve = list() for mag, path, turnOff in zip(mags, paths, turnOffs): formater = {'A': 'ko', 'E': 'kx'} if turnOff[2] == 'A': dist = np.sqrt((turnOff[0]-turnOffs[0][0])**2 + (turnOff[1]-turnOffs[0][1])**2) hevolve.append((turnOff[3]-turnOffs[0][3], dist)) hevolve = np.array(hevolve) ``` ```python with plt.style.context(pubStyle): fig, ax = plt.subplots(1,1,figsize=(10,7)) for h in hevolve: ax.plot(h[0], h[1], 'ko') line = lambda x, m, b: m*x + b fit, covar = curve_fit(line, hevolve[:, 0], hevolve[:, 1]) X = np.linspace(hevolve[:, 0].min(), hevolve[:, 0].max()) ax.plot(X, line(X, *fit), 'k--') ax.set_xlabel("$\Delta$ Helium Mass Fraction", fontsize=20) ax.set_ylabel("Turn off offset from mean [mag]", fontsize=20) ax.annotate(f'$O(Y)={fit[0]:0.2f}Y+{fit[1]:0.2f}$', xy=(-0.04, 0.30), color='black', fontsize=20) fig.savefig("Figures/HeliumMeanOffset.pdf") ``` ![png](media/PhotometricOffsetFigures.ipynb/output_21_0.png) ```python with open("BestFit.pkl", 'rb') as f: mags = pkl.load(f) ``` ```python def correct_iso_set(path, age, mu, Av): print(os.path.exists(path)) isoAtAge = interp_isochrone_age(iso, age) isoAMags = bc.apparent_mags( 10**isoAtAge[:, 10], isoAtAge[:, 12], isoAtAge[:, 7], mu = mu, Av = Av, filters = ("WFC3_UVIS_F275W", "WFC3_UVIS_F606W", "WFC3_UVIS_F814W") ) return isoAMags ``` ```python testPath = "/mnt/Astronomy/GraduateSchool/Thesis/GCConsistency/NGC2808/justIso.denseAlpha.fixedLowmass/PopA+0.39/alpha-1.750/isochrones.txt" ``` ```python isoMags = correct_iso_set(testPath, 17, 1.491e+01, 5.414e-01) ``` True ```python fig, ax = plt.subplots(1,1,figsize=(10,10)) ax.scatter(HUGScolor, HUGSmag,s=1,c=HUGSdensity, cmap="Reds") ax.scatter(ACScolor, ACSmag, s=1,c=ACSdensity, cmap='Blues', alpha=0.1) ax.set_ylim(17, 22) ax.invert_yaxis() ACSSmoothTCK = splrep(ACSFiducial[0].mean[1], ACSFiducial[0].mean[0], s=0.001) ax.plot(BSpline(*ACSSmoothTCK)(ACSFiducial[0].mean[1]), ACSFiducial[0].mean[1] , color='C0') HUGSmoothTCK = splrep(HUGSFiducial[0].mean[1], HUGSFiducial[0].mean[0], s=0.001) ax.plot(BSpline(*HUGSmoothTCK)(HUGSFiducial[0].mean[1]), HUGSFiducial[0].mean[1] , color='C1') ax.set_xlim(0.6, 1) ax.set_xlabel("F606W - F814W", fontsize=27) ax.set_ylabel("F606W", fontsize=27) Color = isoMags['WFC3_UVIS_F606W'].values - isoMags["WFC3_UVIS_F814W"].values Mag = isoMags['WFC3_UVIS_F606W'].values turnOffColor = min(Color) turnOffMag = Mag[Color==turnOffColor][0] print(turnOffMag, turnOffColor) ax.plot(Color, Mag, color='C2', linewidth=10) ``` 19.73960461108486 0.652611121597868 [] ![png](media/PhotometricOffsetFigures.ipynb/output_26_2.png) ```python ```
WFC3_UVIS_F275W WFC3_UVIS_F606W WFC3_UVIS_F814W
0 33.753726 26.699337 24.461482
1 33.737848 26.683081 24.448594
2 33.722102 26.666965 24.435789
3 33.706476 26.650976 24.423060
4 33.690944 26.635087 24.410393
... ... ... ...
313 23.471173 14.562014 13.486965
314 23.445802 14.533347 13.452625
315 23.420594 14.504854 13.418372
316 23.395397 14.476370 13.384128
317 23.370260 14.447949 13.349919

318 rows × 3 columns

```python ```