In [1]:
%matplotlib
import matplotlib.pyplot as plt
import numpy as np

from StellarSpectra.grid_tools import HDF5Interface
import h5py


Using matplotlib backend: Qt4Agg

Loading M dwarf spectra


In [5]:
hdf5 = h5py.File("../../data/Gl51/Gl51.hdf5", "r")

fl = hdf5["fls"][:]
#ind = (fl >= 0)

wl = hdf5["wls"][:]
sigma = hdf5["sigmas"][:]
masks = hdf5["masks"][:]

#low = fl - sigma
#high = fl + sigma
hdf5.close()

In [4]:
masks


Out[4]:
array([1, 1, 1, ..., 1, 1, 1], dtype=int8)

In [15]:
plt.fill_between(wl, low, high)
#plt.plot(wl,fl)

plt.show()

Loading M dwarf with DataSpectrum


In [2]:
from StellarSpectra.spectrum import DataSpectrum

In [14]:
myDataSpectrum = DataSpectrum.open("../../data/Gl51/Gl51.hdf5")

In [15]:
print(myDataSpectrum.wls)
print(myDataSpectrum.masks)

myDataSpectrum.wls[myDataSpectrum.masks]


[[  8051.96   8053.99   8056.01 ...,  24986.38  24991.42  24996.46]]
[[ True  True  True ...,  True  True  True]]
Out[15]:
array([  8051.96,   8053.99,   8056.01, ...,  24986.38,  24991.42,
        24996.46])

In [16]:
plt.plot(myDataSpectrum.wls[0], myDataSpectrum.fls[0])
#plt.ylim(0, 2e-13)
plt.show()

Plotting synthetic M dwarf spectra


In [76]:
myInterface = HDF5Interface("../../libraries/PHOENIX_SPEX_2300.hdf5")

wl = myInterface.wl
fl = myInterface.load_flux({"temp":2300, "logg":4.5, "Z":-0.5, "alpha":0.0})

In [77]:
plt.plot(wl, fl)
plt.show()

In [ ]:

Playing with model


In [ ]:
HDF5InterfaceLA = HDF5Interface("../../libraries/PHOENIX_SPEX_2300.hdf5")
fullModelLA = Model(myDataSpectrum, myInstrument, HDF5InterfaceLA, stellar_tuple=("temp",
            "logg", "Z", "vsini", "vz", "logOmega"), cheb_tuple=("c1", "c2", "c3"), cov_tuple=("sigAmp",
            "logAmp", "l"), region_tuple=("loga", "mu", "sigma"))
modelLA = fullModelLA.OrderModels[0]

wl = myDataSpectrum.wls[0]
print(wl[3118:3125])
print(base[3118:3125])

In [ ]:
params = {"temp":3000, "logg":4.5, "Z":-0.5, "vsini":0., "vz":0, "logOmega":0.}
fullModelLA.update_Model(params)

base = modelLA.get_spectrum()

In [ ]:
fl = HDF5InterfaceLA.load_flux({"temp":3000, "logg":4.5, "Z":-0.5, "alpha":0.0})
wl_inter = HDF5InterfaceLA.wl
plt.plot(wl_inter, fl)
plt.show()