In [1]:
from mingle.utilities import masking
from spectrum_overload import Spectrum
from astropy.io import fits
import matplotlib.pyplot as plt
import os
% matplotlib inline
In [2]:
observations = [{"star": "HD4747", "obsnum": "1", "chip": "1"},
{"star": "HD4747", "obsnum": "1", "chip": "2"},
{"star": "HD4747", "obsnum": "1", "chip": "3"},
{"star": "HD4747", "obsnum": "1", "chip": "4"},
{"star": "HD30501", "obsnum": "2a", "chip": "1"},
{"star": "HD30501", "obsnum": "2a", "chip": "2"},
{"star": "HD30501", "obsnum": "2a", "chip": "3"},
{"star": "HD30501", "obsnum": "2a", "chip": "4"},
{"star": "HD30501", "obsnum": "2b", "chip": "1"},
{"star": "HD30501", "obsnum": "2b", "chip": "2"},
{"star": "HD30501", "obsnum": "2b", "chip": "3"},
{"star": "HD30501", "obsnum": "2b", "chip": "4"},
{"star": "HD30501", "obsnum": "3", "chip": "1"},
{"star": "HD30501", "obsnum": "3", "chip": "2"},
{"star": "HD30501", "obsnum": "3", "chip": "3"},
{"star": "HD30501", "obsnum": "3", "chip": "4"},
{"star": "HD211847", "obsnum": "1", "chip": "1"},
{"star": "HD211847", "obsnum": "1", "chip": "2"},
{"star": "HD211847", "obsnum": "1", "chip": "3"},
{"star": "HD211847", "obsnum": "1", "chip": "4"},
{"star": "HD211847", "obsnum": "2", "chip": "1"},
{"star": "HD211847", "obsnum": "2", "chip": "2"},
{"star": "HD211847", "obsnum": "2", "chip": "3"},
{"star": "HD211847", "obsnum": "2", "chip": "4"},]
for obs in observations:
# Load in masking data
masks = masking.get_maskinfo(obs["star"], obs["obsnum"], obs["chip"])
print("masks", masks)
# Load in a spectrum
name = "{0}-{1}-mixavg-tellcorr_{2}.fits".format(obs["star"], obs["obsnum"], obs["chip"])
data, hdr = fits.getdata(os.path.join("/home/jneal/.handy_spectra/", name), header=True)
spec = Spectrum(xaxis=data["wavelength"], flux=data["flux"], header=hdr)
spec2 = spec.copy()
for mask_limits in masks:
if len(mask_limits) is not 2:
raise ValueError("Mask limits in mask file is incorrect for {0}-{1}_{2}".format(obs["star"], obs["obsnum"], obs["chip"]))
spec2.wav_select(*mask_limits) # Wavelengths to include
plt.plot(spec.xaxis, spec.flux)
plt.plot(spec2.xaxis, spec2.flux)
if obs["chip"] == "4":
plt.axvline(x=spec.xaxis[50], label="50 pixels")
plt.legend()
plt.show()
In [ ]:
In [3]:
obser_4 = [{"star": "HD4747", "obsnum": "1", "chip": "4"},
{"star": "HD30501", "obsnum": "2a", "chip": "4"},
{"star": "HD30501", "obsnum": "2b", "chip": "4"},
{"star": "HD30501", "obsnum": "3", "chip": "4"},
{"star": "HD211847", "obsnum": "1", "chip": "4"},
{"star": "HD211847", "obsnum": "2", "chip": "4"},]
In [4]:
for obs in obser_4:
masks = masking.get_maskinfo(obs["star"], obs["obsnum"], obs["chip"])
print("masks", masks)
# Load in a spectrum
name = "{0}-{1}-mixavg-tellcorr_{2}.fits".format(obs["star"], obs["obsnum"], obs["chip"])
data, hdr = fits.getdata(os.path.join("/home/jneal/.handy_spectra/", name), header=True)
spec = Spectrum(xaxis=data["wavelength"], flux=data["flux"], header=hdr)
spec2 = spec.copy()
for mask_limits in masks:
if len(mask_limits) is not 2:
raise ValueError("Mask limits in mask file is incorrect for {0}-{1}_{2}".format(obs["star"], obs["obsnum"], obs["chip"]))
spec2.wav_select(*mask_limits) # Wavelengths to include
plt.plot(spec.xaxis, spec.flux)
plt.plot(spec2.xaxis, spec2.flux+0.1, label="spec2")
plt.show()
In [5]:
for obs in obser_4:
name = "{0}-{1}-mixavg-tellcorr_{2}.fits".format(obs["star"], obs["obsnum"], obs["chip"])
data, hdr = fits.getdata(os.path.join("/home/jneal/.handy_spectra/", name), header=True)
spec = Spectrum(xaxis=data["wavelength"], flux=data["flux"], header=hdr)
plt.plot(spec.xaxis, spec.flux)
plt.show()
In [ ]:
In [6]:
for obs in obser_4:
name = "{0}-{1}-mixavg-tellcorr_{2}.fits".format(obs["star"], obs["obsnum"], obs["chip"])
data, hdr = fits.getdata(os.path.join("/home/jneal/.handy_spectra/", name), header=True)
spec = Spectrum(xaxis=data["wavelength"], flux=data["flux"], header=hdr)
plt.plot(spec.flux)
plt.axvline(x=55)
plt.show()
In [ ]: