In [1]:
# Plot all spectra in .handy_spectra"

In [2]:
import glob 
from astropy.io import fits
import matplotlib.pyplot as plt

In [3]:
path = "/home/jneal/.handy_spectra/*{}.fits"
chips = range(1, 5)
fits_files = [glob.glob(path.format(chip)) for chip in chips]
# print(fits_files)

In [4]:
for i, chip in enumerate(chips):
    plt.figure(figsize=(10,7))
    for f_file in fits_files[i]:
        
        data = fits.getdata(f_file)
        if "TEST" in f_file or "SIM" in f_file:
            plt.plot(data["wavelength"], data["flux"], "-.", label=f_file)
        else:
            plt.plot(data["wavelength"], data["flux"], label=f_file)
    plt.title("All handy spectra, chip {}".format(chip))
    plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
    plt.show()



In [5]:
for i, chip in enumerate(chips):
    plt.figure(figsize=(10,7))
    for f_file in fits_files[i]:
        
        data = fits.getdata(f_file)
        if "TEST" in f_file.upper() or "SIM" in f_file.upper():
            pass
        else:
            plt.plot(data["wavelength"], data["flux"], label=f_file)
    plt.title("All handy spectra, chip {}".format(chip))
    plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
    
    plt.show()



In [6]:
for i, chip in enumerate(chips):
    plt.figure(figsize=(10,7))
    for f_file in fits_files[i]:
        
        data = fits.getdata(f_file)
        
        if "TEST" in f_file.upper() or "SIM" in f_file.upper():
            plt.plot(data["wavelength"], data["flux"], label=f_file)
        else:
            pass
    plt.title("All handy spectra, chip {}".format(chip))
    plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
    
    plt.show()



In [7]:
from mingle.utilities.phoenix_utils import load_starfish_spectrum

load_starfish_spectrum?


/home/jneal/anaconda3/envs/sims/lib/python3.6/site-packages/matplotlib/__init__.py:1405: UserWarning: 
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)

In [8]:
stars = ["HD30501", "HD211847", "HD4747"]
teff_host =  [5200, 5700, 5300]


def test_plot(star, host_temp):
    phoenix_spec = load_starfish_spectrum([host_temp, 4.5, 0.0], limits=[2100, 2180], normalize=True)
    
    for i, chip in enumerate(chips):
        plt.figure(figsize=(10,7))
        for f_file in fits_files[i]:
            if star in f_file:
                data = fits.getdata(f_file)
                plt.plot(data["wavelength"], data["flux"], label=f_file)
      
        plt.plot(phoenix_spec.xaxis, phoenix_spec.flux, label="host phoenix")
        plt.xlim([data["wavelength"][0] - 0.5, data["wavelength"][-1] + 0.5])
        plt.title("{}, chip {}".format(star, chip))
        plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))    
        plt.show()

In [9]:
test_plot(stars[0], teff_host[0])



In [10]:
test_plot(stars[1], teff_host[1])



In [11]:
test_plot(stars[2], teff_host[2])



In [ ]: