SPLAT: The SpeX Prism Library Analysis Toolkit¶
SPLAT is a python-based spectral access and analysis package designed to interface with the SpeX Prism Library (SPL), an online repository of over 2000 low-resolution, near-infrared spectra of low-temperature stars and brown dwarfs. It is built on common python packages such as astropy, emcee, matplotlib, numpy, pandas, scipy, and others.
- SPLAT tools allow you to:
- search the SPL for spectral data and source information;
- access the publically-available (published) spectra contained in it;
- compare your own near-infrared spectrum to these data;
- make use of published empirical trends in absolute magnitudes, luminosity, effective temperatures, and others;
- perform basic spectral analyses such as spectral classification, gravity classification, index measurement, spectrophotometry, reddening, blended light analysis, and basic math operations;
- access atmosphere models and perform fits to spectral data;
- transform observable to physical parameters using evolutionary models;
- simulate very low mass star and brown dwarf populations; and
- plot, tabulate and publish your results.
Note that many of these features are currently under development.
Installation and Dependencies¶
Once you’ve downloaded the code and data, you will need to copy the file
.splat_access into your home directory (this is your access key) and add the SPLAT top-level directory to the environment variables
PYTHONPATH or your system
PATH. More detailed instructions are on the installation page.
- SPLAT has core dependencies on the following packages:
SPLAT has not yet reached v1.0, so bugs are common. Please help us squish them by sending bug reports to email@example.com or start an issue on the github site.
- SPLAT is organized into a series of modules based on core functionalities:
- splat.core: core functionalities, including index measurement, database access and classification
- splat.citations: biblographic/bibtex routines
- splat.database: access the spectral and source databases, as well as online resources through astroquery
- splat.empirical: empirical conversion relations
- splat.evolve: access to evolutionary models
- splat.model: access to spectral models and model-fitting routines
- splat.photometry: spectrophotometry routines and filter access
- splat.plot: plotting and visualization routines
- splat.simulate: population simulation routines
- splat.utilities: additional routines for general analysis
- splat.web: SPLAT’s web interface
SPLAT has been tested on both Python 2.7 and 3.5, and is best used in the ipython or ipython notebook; all of the necessary data is included in the github package, so you don’t need to be online to run most programs.
Here are some examples:
- The best way to read in a spectrum is to use getSpectrum(), which takes a number of search keywords and
returns a list of Spectrum objects:
>>> import splat >>> splist = splat.getSpectrum(shortname='0415-0935') >>> splist = splat.getSpectrum(young=True) >>> splist = splat.getSpectrum(spt=['M7','L5'],jmag=[14.,99.])
In each case, splist is a list of Spectrum objects, each a container of various aspects of each spectrum and its source properties. For example, selecting the first spectrum,
>>> sp = splist
sp.wave gives the wavelengths of this spectrum,
sp.flux the flux values, and
flux uncertainty. A summary of the Spectrum object can be accessed using
You can also read in your own spectrum by passing a filename
>>> sp = splat.Spectrum(filename='PATH_TO/myspectrum.fits')
Both fits and ascii (tab or csv) data formats are supported, but files must conform to the data format standard:
- column 1: wavelength, assumed in microns
- column 2: flux in f_lambda units
- column 3: (optional) flux uncertainty in f_lambda units.
>>> sp = splat.getSpectrum(shortname='0415-0935') >>> sp.fluxCalibrate('2MASS J',14.0)
- To display the spectrum, use the Spectrum object’s plot() function
or the splat.plot routine plotSpectrum() :
>>> import splat.plot as splot >>> splot.plotSpectrum(sp)
You can save your spectrum by adding a filename:
You can also compare multiple spectra:
>>> sp1 = splat.getSpectrum(shortname='0415-0935') >>> sp2 = splat.getSpectrum(shortname='1217-0311') >>> splot.plotSpectrum(sp1,sp2,colors=['black','red'])
plotSpectrum() and related routines have many extras to label features, plot uncertainties, indicate telluric absorption regions, make multi-panel and multi-page plots of lists of spectra, plot batches of spectra, etc. Be sure to look through the splat.plot subpackage for more details.
SPLAT’s primary purpose is to allow the analysis of ultracool dwarf spectra.
>>> sp = splat.getSpectrum(shortname='0415-0935') >>> value, error = splat.measureIndex(sp,[1.14,1.165],[1.21,1.235],method='integrate') >>> indices = splat.measureIndexSet(sp,set='testi')
The last line returns a dictionary, whose value,error pair can be accessed by the name of the index:
>>> print(indices['sH2O-J']) # returns value, error
- You can also determine the gravity classification of a source following Allers & Liu (2013) using classifyGravity():
>>> sp = splat.getSpectrum(young=True, lucky=True) >>> print(splat.classifyGravity(sp)) # returned 'VL-G'
- To classify a spectrum, use the various classifyByXXX methods:
>>> sp = splat.getSpectrum(shortname='0415-0935') >>> spt,unc = splat.classifyByIndex(sp,set='burgasser') >>> spt,unc = splat.classifyByStandard(sp,spt=['T5','T9']) >>> result = splat.classifyByTemplate(sp,spt=['T6','T9'],nbest=5)
The last line returns a dictionary containing the best 5 template matches to the Spectrum
- To compare a spectrum to another spectrum or a model, use compareSpectra() :
>>> import splat.model as spmod >>> mdl = spmod.loadModel(teff=720,logg=4.8,set='btsettl') # loads a BTSettl08 model >>> sp = splat.getSpectrum(shortname='0415-0935') >>> chi,scale = splat.compareSpectra(sp,mdl) >>> mdl.scale(scale) >>> splat.plotSpectrum(sp,mdl,colors=['black','red'],legend=[sp.name,mdl.name])
You can shortcut the last three lines using the
>>> chi,scale = splat.compareSpectra(sp,mdl,plot=True)
>>> import splat.model as spmod >>> sp = splat.getSpectrum(shortname='0415-0935') >>> sp.fluxCalibrate('2MASS J',14.49,absolute=True) >>> nbest = 5 >>> result1 = splat.modelFitGrid(sp,set='btsettl') >>> result2 = splat.modelFitMCMC(sp,set='btsettl',initial_guess=[800,5.0,0.],nsamples=300,step_sizes=[50.,0.5,0.]) >>> result3 = splat.modelFitEMCEE(sp,set='btsettl',initial_guess=[800,5.0,0.],nwalkers=12,nsamples=500)
The outputs of all of these fitting functions is a dictionary or list of dictionaries containing the parameters of the best-fitting models; there are also several diagnostic plots produced depending on the routine. View the model fitting page for more details.
All of these routines have many options worth exploring, and which are (increasingly) documented on this website. If there are capabilities you need, please suggest them to firstname.lastname@example.org, or note it in the “Issues” link on our github site.
SPLAT is an experimental, collaborative project of research students in the UCSD Cool Star Lab, aimed at teaching students how to do research by building their own analysis tools. Contributors to SPLAT have included Christian Aganze, Jessica Birky, Daniella Bardalez Gagliuffi, Adam Burgasser (PI), Caleb Choban, Andrew Davis, Ivanna Escala, Joshua Hazlett, Carolina Herrara Hernandez, Elizabeth Moreno Hilario, Aishwarya Iyer, Yuhui Jin, Mike Lopez, Dorsa Majidi, Diego Octavio Talavera Maya, Alex Mendez, Gretel Mercado, Niana Mohammed, Johnny Parra, Maitrayee Sahi, Adrian Suarez, Melisa Tallis, Tomoki Tamiya, Chris Theissen, and Russell van Linge.
This project is supported by the National Aeronautics and Space Administration under Grant No. NNX15AI75G.
- Installation and Dependencies
- Main SPLAT module
- Empirical Relations
- SPLAT Plotting Routines
- SPLAT Spectral Modeling
- Brown Dwarf Evolutionary Models
- Population Simulation Routines
- SPLAT Classes
- SPLAT Routines
- Modeling and Simulation Routines
- Specialty Packages