API¶
SPLAT Classes¶
Spectrum¶
-
class
splat.core.
Spectrum
(*args, **kwargs)¶ Description: Primary class for containing spectral and source data for SpeX Prism Library. Optional Inputs:
Parameters: - ismodel – Set to True to specify spectrum as a model (default = False)
- wlabel – label of wavelength (default = ‘Wavelength’)
- wunit – unit in which wavelength is measured (default = u.micron)
- wunit_label – label of the unit of wavelength (default = ‘micron’)
- flabel – label of flux density (default = ‘F_lambda’)
- fscale – string describing how flux density is scaled (default = ‘’)
- funit – unit in which flux density is measured (default = u.erg/(u.cm**2 * u.s * u.micron)
- funit_label – label of the unit of flux density (default = ‘erg cm^-2 s^-1 micron^-1’)
- resolution – Resolution of spectrum (default = 150)
- slitpixelwidth – Width of the slit measured in subpixel values (default = 3.33)
- slitwidth – Actual width of the slit, measured in arcseconds. Default value is the
slitpixelwidth
multiplied an assumed (for SpeX) spectrograph pixel scale of 0.15 arcseconds - header – header info of the spectrum (default = Table())
- filename – a string containing the spectrum’s filename (default = ‘’)
- file – same as filename (default = ‘’)
- idkey – spectrum key of the desired spectrum (default = False)
Example: >>> import splat >>> sp = splat.Spectrum(filename='myspectrum.fits') # read in a file >>> sp = splat.Spectrum('myspectrum.fits') # same >>> sp = splat.Spectrum(10002) # read in spectrum with idkey = 10002 >>> sp = splat.Spectrum(wave=wavearray,flux=fluxarray) # create objects with wavelength & flux arrays
-
brightnessTemperature
()¶ Purpose: Convert to surface fluxes given a radius, assuming at absolute fluxes
-
computeSN
()¶ Purpose: Compute a representative S/N value as the median value of S/N among the top 50% of flux values
Output: the S/N value
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.computeSN()<PHONE_NUMBER>1163553
-
copy
()¶ Purpose: Make a copy of a Spectrum object
-
export
(*args, **kwargs)¶ Purpose: Exports a Spectrum object to either a fits or ascii file, depending on file extension given. If no filename is explicitly given, the Spectrum.filename attribute is used. If the filename does not include the full path, the file is saved in the current directory. Spectrum.export and Spectrum.save function in the same manner. Parameters: filename (optional, default = Spectrum.simplefilename) – String specifying the filename to save
Output: An ascii or fits file with the data
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.export('/Users/adam/myspectrum.txt') >>> from astropy.io import ascii >>> data = ascii.read('/Users/adam/myspectrum.txt',format='tab') >>> data <Table length=564> wavelength flux uncertainty float64 float64 float64 -------------- ----------------- ----------------- 0.645418405533 0.0 nan 0.647664904594 6.71920214475e-16 3.71175052033e-16 0.649897933006 1.26009925777e-15 3.85722895842e-16 0.652118623257 7.23781818374e-16 3.68178778862e-16 0.654327988625 1.94569566622e-15 3.21007116982e-16 ...
-
fluxCalibrate
(filt, mag, **kwargs)¶ Purpose: Flux calibrates a spectrum given a filter and a magnitude. The filter must be one of those listed in splat.FILTERS.keys(). It is possible to specifically set the magnitude to be absolute (by default it is apparent). This function changes the Spectrum object’s flux, noise and variance arrays. Required Inputs:
Parameters: - filter – string specifiying the name of the filter
- mag – number specifying the magnitude to scale to
Optional Inputs:
Parameters: - absolute – set to True to specify that the given magnitude is an absolute magnitude, which sets the
fscale
keyword in the Spectrum object to ‘Absolute’ (default = False) - apparent – set to True to specify that the given magnitude is an apparent magnitude, which sets the
fscale
flag in the Spectrum object to ‘Apparent’ (default = False)
Outputs:
None, Spectrum object is changed to a flux calibrated spectrum
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.fluxCalibrate('2MASS J',15.0) >>> splat.filterMag(sp,'2MASS J') (15.002545668628173, 0.017635234089677564)
-
fluxMax
(**kwargs)¶ Purpose: Reports the maximum flux of a Spectrum object ignoring nan’s.
Parameters: maskTelluric (optional, default = True) – masks telluric regions
Output: maximum flux (with units)
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.normalize() >>> sp.fluxMax() <Quantity 1.0 erg / (cm2 micron s)>
-
fluxUnit
(funit)¶ Purpose: Converts wavelength to microns. This routine changes the underlying Spectrum object.
Example: >>> import splat >>> import astropy.units as u >>> sp = splat.Spectrum(file='somespectrum',wunit=u.Angstrom) >>> sp.wave.unit Unit("Angstrom") >>> sp.toMicron() >>> sp.wave.unit Unit("micron")
-
info
(**kwargs)¶ Purpose: Returns a summary of properties for the Spectrum object
Output: Text summary
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.info() Spectrum of NLTT 184 Observed on 20071012 at an airmass of 1.145 Full source designation is J00054517+0723423 Median S/N = 97.0 SPLAT source key is 10012.0 SPLAT spectrum key is 10857 Data published in Kirkpatrick, J. D. et al. (2010, ApJS, 190, 100-146) History: Spectrum successfully loaded
-
normalize
(*args, **kwargs)¶ Purpose: Normalize a spectrum to a maximum value of 1 (in its current units)
Parameters: waveRange (optional, default = None) – choose the wavelength range to normalize; can be a list specifying minimum and maximum or a single number to normalize around a particular point
Output: maximum flux (with units)
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.normalize() >>> sp.fluxMax() <Quantity 1.0 erg / (cm2 micron s)> >>> sp.normalize(waverange=[2.25,2.3]) >>> sp.fluxMax() <Quantity 1.591310977935791 erg / (cm2 micron s)>
-
plot
(**kwargs)¶ Purpose: calls the plotSpectrum_ function, by default showing the noise spectrum and zeropoints. See the plotSpectrum_ API listing for details. Output: A plot of the Spectrum object
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.plot()
-
reset
()¶ Purpose: Restores a Spectrum to its original read-in state, removing scaling and smoothing. This routine changes the Spectrum object directly and there is no output.
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.fluxMax() <Quantity 4.561630292384622e-15 erg / (cm2 micron s)> >>> sp.normalize() >>> sp.fluxMax() <Quantity 0.9999999403953552 erg / (cm2 micron s)> >>> sp.reset() >>> sp.fluxMax() <Quantity 4.561630292384622e-15 erg / (cm2 micron s)>
-
rvShift
(rv)¶ Purpose: Shifts the wavelength scale by a radial velocity factor. This routine changes the underlying Spectrum object.
Example: >>> import splat >>> import astropy.units as u >>> sp = splat.Spectrum(file='somespectrum',wunit=u.Angstrom) >>> sp.wave.unit Unit("Angstrom") >>> sp.toMicron() >>> sp.wave.unit Unit("micron")
-
save
(*args, **kwargs)¶ Purpose: Exports a Spectrum object to either a fits or ascii file, depending on file extension given. If no filename is explicitly given, the Spectrum.filename attribute is used. If the filename does not include the full path, the file is saved in the current directory. Spectrum.export() and Spectrum.save function in the same manner.
-
scale
(factor, **kwargs)¶ Purpose: Scales a Spectrum object’s flux and noise values by a constant factor. This routine changes the Spectrum object directly.
Parameters: factor (required, default = None) – A floating point number used to scale the Spectrum object
Output: maximum flux (with units)
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.fluxMax() <Quantity 1.0577336634332284e-14 erg / (cm2 micron s)> >>> sp.computeSN() 124.5198 >>> sp.scale(1.e15) >>> sp.fluxMax() <Quantity 1.0577336549758911 erg / (cm2 micron s)> >>> sp.computeSN() 124.51981
-
showHistory
()¶ Purpose: Report history of actions taken on a Spectrum object. This can also be retrieved by printing the attribute Spectrum.history
Output: List of actions taken on spectrum
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.normalize() >>> sp.fluxCalibrate('2MASS J',15.0) >>> sp.showHistory() Spectrum successfully loaded Spectrum normalized Flux calibrated with 2MASS J filter to an apparent magnitude of 15.0
-
smooth
(**kwargs)¶ Purpose: Smoothes a spectrum either by selecting a constant slit width (smooth in spectral dispersion space), pixel width (smooth in pixel space) or resolution (smooth in velocity space). One of these options must be selected for any smoothing to happen. Changes spectrum directly.
Parameters: - method (optional, default = Hanning) – the type of smoothing window to use. See http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.get_window.html for more details.
- resolution (optional, default = None) – Constant resolution to smooth toe(see smoothToResolution)
- slitPixelWidth (optional, default = None) – Number of pixels to smooth in pixel space (see smoothToSlitPixelWidth)
- slitWidth (optional, default = None) – Number of pixels to smooth in angular space (see smoothToPixelWidth)
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.smoothfluxMax() <Quantity 1.0577336634332284e-14 erg / (cm2 micron s)> >>> sp.computeSN() 124.5198 >>> sp.scale(1.e15) >>> sp.fluxMax() <Quantity 1.0577336549758911 erg / (cm2 micron s)> >>> sp.computeSN() 124.51981
-
surface
(radius)¶ Purpose: Convert to surface fluxes given a radius, assuming at absolute fluxes Note
UNTESTED, NEED TO ADD IN UNCERTAINTIES
-
toAngstrom
()¶ Purpose: Converts wavelength to Angstrom. This routine changes the underlying Spectrum object.
Example: >>> import splat >>> import astropy.units as u >>> sp = splat.getSpectrum(lucky=True) >>> sp.wave.unit Unit("micron") >>> sp.toAngstrom() >>> sp.wave.unit Unit("Angstrom")
-
toFlam
()¶ Purpose: Converts flux density to F_lambda in units of erg/s/cm^2/Hz. This routine changes the underlying Spectrum object. There is no change if the spectrum is already in F_lambda units.
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.toFnu() >>> sp.flux.unit Unit("Jy") >>> sp.toFlam() >>> sp.flux.unit Unit("erg / (cm2 micron s)")
-
toFnu
()¶ Purpose: Converts flux density F_nu in units of Jy. This routine changes the underlying Spectrum object. There is no change if the spectrum is already in F_nu units.
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.toFnu() >>> sp.flux.unit Unit("Jy")
-
toMicron
()¶ Purpose: Converts wavelength to microns. This routine changes the underlying Spectrum object.
Example: >>> import splat >>> import astropy.units as u >>> sp = splat.Spectrum(file='somespectrum',wunit=u.Angstrom) >>> sp.wave.unit Unit("Angstrom") >>> sp.toMicron() >>> sp.wave.unit Unit("micron")
-
toSED
()¶ Purpose: Converts flux density in F_lambda to lambda x F_lambda with units of erg/s/cm^2. This routine changes the underlying Spectrum object.
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.toSED() >>> sp.flux.unit Unit("erg / (cm2 s)")
-
trim
(rng, **kwargs)¶ Purpose: Trims a spectrum to be within a certain wavelength range or set of ranges. Data outside of these ranges are excised from the wave, flux and noise arrays. The full spectrum can be restored with the reset() procedure. Parameters: range – the range(s) over which the spectrum is retained - a series of nested 2-element arrays Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.smoothfluxMax() <Quantity 1.0577336634332284e-14 erg / (cm2 micron s)> >>> sp.computeSN() 124.5198 >>> sp.scale(1.e15) >>> sp.fluxMax() <Quantity 1.0577336549758911 erg / (cm2 micron s)> >>> sp.computeSN() 124.51981
-
waveRange
()¶ Purpose: Return the wavelength range of the current Spectrum object.
Output: 2-element array giving minimum and maximum of wavelength range
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.slitwidth [<Quantity 0.6447611451148987 micron>, <Quantity 2.5517737865448 micron>]
-
waveUnit
(wunit)¶ Purpose: Converts wavelength to microns. This routine changes the underlying Spectrum object.
Example: >>> import splat >>> import astropy.units as u >>> sp = splat.Spectrum(file='somespectrum',wunit=u.Angstrom) >>> sp.wave.unit Unit("Angstrom") >>> sp.toMicron() >>> sp.wave.unit Unit("micron")
SPLAT Routines¶
Database Access¶
-
splat.utilities.
checkFile
(filename, **kwargs)¶ Purpose: Checks if a spectrum file exists in the SPLAT’s library.
Parameters: filename – A string containing the spectrum’s filename.
Example: >>> import splat >>> spectrum1 = 'spex_prism_1315+2334_110404.fits' >>> print spl.checkFile(spectrum1) True >>> spectrum2 = 'fake_name.fits' >>> print spl.checkFile(spectrum2) False
-
splat.utilities.
checkAccess
(**kwargs)¶ Purpose: Checks if user has access to unpublished spectra in SPLAT library.
Example: >>> import splat >>> print spl.checkAccess() True
Note: Must have the file .splat_access in your home directory with the correct passcode to use.
-
splat.database.
fetchDatabase
(*args, **kwargs)¶ Purpose: Get the SpeX Database from either online repository or local drive
-
splat.core.
getSpectrum
(*args, **kwargs)¶ Purpose: Gets a spectrum from the SPLAT library using various selection criteria. Calls searchLibrary to select spectra; if any found it routines an array of Spectrum objects, otherwise an empty array. Output: An array of Spectrum objects that satisfy the search criteria Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1507-1627')[0] Retrieving 1 file >>> sparr = splat.getSpectrum(spt='M7') Retrieving 120 files >>> sparr = splat.getSpectrum(spt='T5',young=True) No files match search criteria
-
splat.core.
getStandard
(spt, **kwargs)¶ Purpose: Gets one of the pre-defined spectral standards from the SPLAT library.
Parameters: - spt (required) – Spectral type of standard desired, either string (‘M7’) or numberic (17)
- sd (optional, default = False) – Set to True to get a subdwarf standard
- esd (optional, default = False) – Set to True to get an extreme subdwarf standard
Example: >>> import splat >>> sp = splat.getStandard('M7')[0] Spectrum of VB 8 >>> sparr = splat.getStandard('T5',esd=True) Type esdT5.0 is not in esd standards: try one of the following: ['esdM5.0', 'esdM7.0', 'esdM8.5']
-
splat.core.
initiateStandards
(**kwargs)¶ Purpose: Initiates the spectral standards in the SpeX library. By default this loads the dwarfs standards, but you can also specify loading of subdwarf and extreme subdwarf standards as well. Once loaded, these standards remain in memory.
Parameters: - sd (optional, default = False) – Set equal to True to load subdwarf standards
- esd (optional, default = False) – Set equal to True to load extreme subdwarf standards
Example: >>> import splat >>> splat.initiateStandards() >>> splat.SPEX_STDS['M5.0'] Spectrum of Gl51
-
splat.core.
keySource
(keys, **kwargs)¶ Purpose: Takes a source key and returns a table with the source information Parameters: keys – source key or a list of source keys Example: >>> import splat >>> print spl.keySource(10001) SOURCE_KEY NAME DESIGNATION ... NOTE SELECT ---------- ------------------------ ----------------- ... ---- ------ 10001 SDSS J000013.54+255418.6 J00001354+2554180 ... True >>> print spl.keySource([10105, 10623]) SOURCE_KEY NAME DESIGNATION ... NOTE SELECT ---------- ---------------------- ----------------- ... ---- ------ 10105 2MASSI J0103320+193536 J01033203+1935361 ... True 10623 SDSS J09002368+2539343 J09002368+2539343 ... True >>> print spl.keySource(1000001) No sources found with source key 1000001 False
-
splat.core.
keySpectrum
(keys, **kwargs)¶ Purpose: Takes a spectrum key and returns a table with the spectrum and source information Parameters: keys – spectrum key or a list of source keys Example: >>> import splat >>> print spl.keySpectrum(10001) DATA_KEY SOURCE_KEY DATA_FILE ... COMPANION COMPANION_NAME NOTE_2 -------- ---------- ---------------- ... --------- -------------- ------ 10001 10443 10001_10443.fits ... >>> print spl.keySpectrum([10123, 11298]) DATA_KEY SOURCE_KEY DATA_FILE ... COMPANION COMPANION_NAME NOTE_2 -------- ---------- ---------------- ... --------- -------------- ------ 11298 10118 11298_10118.fits ... 10123 10145 10123_10145.fits ... >>> print spl.keySpectrum(1000001) No spectra found with spectrum key 1000001 False
-
splat.core.
searchLibrary
(*args, **kwargs)¶ Purpose: Search the SpeX database to extract the key reference for that Spectrum
Parameters: - name (optional) – search by source name (e.g.,
name = 'Gliese 570D'
) - shortname (optional) – search be short name (e.g.
shortname = 'J1457-2124'
) - designation (optional) – search by full designation (e.g.,
designation = 'J11040127+1959217'
) - coordinate (optional) – search around a coordinate by a radius specified by radius keyword (e.g.,
coordinate = [180.,+30.], radius = 10.
) - radius (optional, default = 10) – search radius in arcseconds for coordinate search
- spt (optional) – search by SpeX spectral type; single value is exact, two-element array gives range (e.g.,
spt = 'M7'
orspt = [24,39]
) - spex_spt (optional) – same as
spt
- opt_spt (optional) – same as
spt
for literature optical spectral types - nir_spt (optional) – same as
spt
for literature NIR spectral types - jmag, hmag, kmag (optional) – select based on faint limit or range of J, H or Ks magnitudes (e.g.,
jmag = [12,15]
) - snr (optional) – search on minimum or range of S/N ratios (e.g.,
snr = 30.
orsnr = [50.,100.]
) - subdwarf, young, binary, spbinary, red, blue, giant, wd, standard (optional) – classes to search on (e.g.,
young = True
) - logic (optional, default = 'and') – search logic, can be
and
oror
- combine (optional, default = 'and') – same as logic
- date (optional) – search by date (e.g.,
date = '20040322'
) or range of dates (e.g.,date=[20040301,20040330]
) - reference (optional) – search by list of references (bibcodes) (e.g.,
reference = '2011ApJS..197...19K'
) - sort (optional, default = 'DESIGNATION') – by default returned table is sorted by designation; set this parameter to a column name to sort on a different parameter
- reverse (optional, default = False) – set to True to do a reverse sort
- list (optional, default = False) – if True, return just a list of the data files
- lucky (optional, default = False) – if True, return one randomly selected spectrum from the selected sample
- output (optional, default = 'all') – returns desired output of selected results
- logic – search logic, can be and`` or
or
- combine – same as logic
Example: >>> import splat >>> print SearchLibrary(shortname = '2213-2136') DATA_KEY SOURCE_KEY DATA_FILE ... SHORTNAME SELECT_2 -------- ---------- ---------------- ... ---------- -------- 11590 11586 11590_11586.fits ... J2213-2136 1.0 11127 11586 11127_11586.fits ... J2213-2136 1.0 10697 11586 10697_11586.fits ... J2213-2136 1.0 10489 11586 10489_11586.fits ... J2213-2136 1.0 >>> print SearchLibrary(shortname = '2213-2136', output = 'OBSERVATION_DATE') OBSERVATION_DATE ---------------- 20110908 20080829 20060902 20051017
Note
Note that this is currently only and AND search - need to figure out how to a full SQL style search
- name (optional) – search by source name (e.g.,
Spectral Comparison¶
-
splat.core.
compareSpectra
(sp1, sp2, *args, **kwargs)¶ Purpose: Compare two spectra against each other using a pre-selected statistic. Returns the value of the desired statistic as well as the optimal scale factor. Minimum possible value for statistic is 1.e-9.
Parameters: - sp1 (required) – First spectrum class object, which sets the wavelength scale
- sp2 (required) – Second spectrum class object, interpolated onto the wavelength scale of sp1
- statistic (optional, default = 'chisqr') –
string defining which statistic to use in comparison; available options are:
- ‘chisqr’: compare by computing chi squared value (requires spectra with noise values)
- ‘stddev’: compare by computing standard deviation
- ‘stddev_norm’: compare by computing normalized standard deviation
- ‘absdev’: compare by computing absolute deviation
- fit_ranges (optional, default = [0.65,2.45]) – 2-element array or nested array of 2-element arrays specifying the wavelength ranges to be used for the fit, assumed to be measured in microns. This is effectively the opposite of mask_ranges.
- weights (optional, default = [1, ..., 1] for len(sp1.wave)) – Array specifying the weights for individual wavelengths; must be an array with length equal to the wavelength scale of
sp1
; need not be normalized - mask_ranges (optional, default = None) – Multi-vector array setting wavelength boundaries for masking data, assumed to be in microns
- mask (optional, default = [0, ..., 0] for len(sp1.wave)) – Array specifiying which wavelengths to mask; must be an array with length equal to the wavelength scale of
sp1
with only 0 (OK) or 1 (mask). - mask_telluric (optional, default = False) – Set to True to mask pre-defined telluric absorption regions
- mask_standard (optional, default = False) – Like
mask_telluric
, with a slightly tighter cut of 0.80-2.35 micron - novar2 (optional, default = True) – Set to True to compute statistic without considering variance of
sp2
- plot (optional, default = False) – Set to True to plot
sp1
with scaledsp2
and difference spectrum overlaid - verbose (optional, default = False) – Set to True to report things as you’re going along
Example: >>> import splat >>> import numpy >>> sp1 = splat.getSpectrum(shortname = '2346-3153')[0] Retrieving 1 file >>> sp2 = splat.getSpectrum(shortname = '1421+1827')[0] Retrieving 1 file >>> sp1.normalize() >>> sp2.normalize() >>> splat.compareSpectra(sp1, sp2, statistic='chisqr') (<Quantity 19927.74527822856>, 0.94360732593223595) >>> splat.compareSpectra(sp1, sp2, statistic='stddev') (<Quantity 3.0237604611215705 erg2 / (cm4 micron2 s2)>, 0.98180983971456637) >>> splat.compareSpectra(sp1, sp2, statistic='absdev') (<Quantity 32.99816249949072 erg / (cm2 micron s)>, 0.98155779612333172) >>> splat.compareSpectra(sp1, sp2, statistic='chisqr', novar2=False) (<Quantity 17071.690727945213>, 0.94029474635786015)
-
splat.core.
stitch
(s1, s2, rng=[0.8, 0.9], **kwargs)¶ Purpose: Stitches together two spectra covering different wavelength scales.
Output: New spectrum object of stitched spectrum
Example: >>> import splat >>> spopt = splat.Spectrum(file='myopticalspectrum.fits') >>> spnir = splat.Spectrum(file='myopticalspectrum.fits') >>> sp = splat.stitch(spopt,spnir,rng=[0.8,0.9],trim=[0.35,2.4])
-
splat.core.
_generateMask
(wave, **kwargs)¶ Purpose: Generates a mask array based on wavelength vector and optional inputs on what to mask. Output: A mask array, where 0 = OK and 1 = ignore Example:
Spectral Classification and Characterization¶
-
splat.core.
classifyByIndex
(sp, *args, **kwargs)¶ Purpose: Determine the spectral type and uncertainty for a spectrum based on indices. Makes use of published index-SpT relations from Reid et al. (2001); Testi et al. (2001); Allers et al. (2007); and Burgasser (2007). Returns 2-element tuple containing spectral type (numeric or string) and uncertainty.
Required Inputs:
Parameters: sp – Spectrum class object, which should contain wave, flux and noise array elements. Optional Inputs:
Parameters: - set –
named set of indices to measure and compute spectral type
- ‘burgasser’: H2O-J, CH4-J, H2O-H, CH4-H, CH4-K from Burgasser (2007), applicable for types (default)
- ‘allers’: H2O from Allers et al. (2007)
- ‘reid’:H2O-A and H2O-B from Reid et al. (2001)
- ‘testi’: sHJ, sKJ, sH2O_J, sH2O_H1, sH2O_H2, sH2O_K from Testi et al. (2001)
- string – return spectral type as a string using typeToNum (default = False)
- round – rounds off to nearest 0.5 subtypes (default = False)
- allmeasures – Set to True to return all of the index values and individual subtypes (default = False)
- remeasure – force remeasurement of indices (default = True)
- nsamples – number of Monte Carlo samples for error computation (default = 100)
- nloop – number of testing loops to see if spectral type is within a certain range (default = 5)
Example: >>> import splat >>> spc = splat.getSpectrum(shortname='0559-1404')[0] >>> splat.classifyByIndex(spc, string=True, set='burgasser', round=True) ('T4.5', 0.2562934083414341)
- set –
-
splat.core.
classifyByStandard
(sp, *args, **kwargs)¶ Purpose: Determine the spectral type and uncertainty for a spectrum by direct comparison to defined spectral standards. Dwarf standards span M0-T9 and include the standards listed in Burgasser et al. (2006), Kirkpatrick et al. (2010) and Cushing et al. (2011). Comparison to subdwarf and extreme subdwarf standards may also be done. Returns the best match or an F-test weighted mean and uncertainty. There is an option to follow the procedure of Kirkpatrick et al. (2010), fitting only in the 0.9-1.4 micron region.
Output: A tuple listing the best match standard and uncertainty based on F-test weighting and systematic uncertainty of 0.5 subtypes
Parameters: - sp – Spectrum class object, which should contain wave, flux and noise array elements (required)
- sptrange – set to the spectral type range over which comparisons should be made, can be a two-element array of strings or numbers (optional, default = [‘M0’,’T9’])
- statistic –
string defining which statistic to use in comparison; available options are:
- ‘chisqr’: (DEFAULT) compare by computing chi squared value (requires spectra with noise values)
- ‘stddev’: compare by computing standard deviation
- ‘stddev_norm’: compare by computing normalized standard deviation
- ‘absdev’: compare by computing absolute deviation
- method –
set to
'kirkpatrick'
to follow the Kirkpatrick et al. (2010) method, fitting only to the 0.9-1.4 micron band (optional, default = ‘’) - best – set to True to return the best fit standard type (optional, default = True)
- average – set to True to return an chi-square weighted type only (optional, default = False)
- compareto – set to the single standard (string or number) you want to compare to (optional, default = None)
- plot – set to True to generate a plot comparing best fit template to source; can also set keywords associated with plotSpectrum_ routine (optional, default = False)
- string – set to True to return spectral type as a string (optional, default = True)
- return_standard – set to True to return a Spectrum class of the standard properly scaled (optional, default = False)
- return_statistic – set to True to return a best match spectral type and statistic (instead of uncertainty) (optional, default = False)
- verbose – set to True to give extra feedback (optional, default = False)
Users can also set keyword parameters defined in plotSpectrum_ and compareSpectra routine.
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> result = splat.classifyByStandard(sp,verbose=True) Using dwarf standards Type M3.0: statistic = 5763368.10355, scale = 0.000144521824721 Type M2.0: statistic = 5613862.67356, scale = 0.000406992798674 Type T8.0: statistic = 18949835.2087, scale = 9.70960919364 Type T9.0: statistic = 21591485.163, scale = 29.1529786804 Type L8.0: statistic = 3115605.62687, scale = 1.36392504072 Type L9.0: statistic = 2413450.79206, scale = 0.821131769522 ... Best match to L1.0 spectral standard Best spectral type = L1.0+/-0.5 >>> result ('L1.0', 0.5) >>> splat.classifyByStandard(sp,sd=True,average=True) ('sdL0.0:', 1.8630159149200021)
-
splat.core.
classifyByTemplate
(sp, *args, **kwargs)¶ Purpose: Determine the spectral type and uncertainty for a spectrum by direct comparison to a large set of spectra in the library. Returns a dictionary with the best spectral type (F-test weighted mean and uncertainty), and arrays for the N best-matching Spectrum objects, scale factors, spectral types and comparison statistics. There is an option to follow the procedure of Kirkpatrick et al. (2010), fitting only in the 0.9-1.4 micron region. It is strongly encouraged that users winnow down the templates used in the comparison by selecting templates using the searchLibrary options or optionally the
set
parameter.Output: A dictionary containing the following keys:
- result: a tuple containing the spectral type and its uncertainty based on F-test statistic
- statistic: array of N best statistical comparison values
- scale: array of N best optimal scale factors
- spectra: array of N best Spectrum objects
- spt: array of N best spectral types
Parameters: - sp – Spectrum class object, which should contain wave, flux and noise array elements.
- sp – required
- statistic (optional, default = 'chisqr') –
string defining which statistic to use in comparison; available options are:
- ‘chisqr’: compare by computing chi squared value (requires spectra with noise values)
- ‘stddev’: compare by computing standard deviation
- ‘stddev_norm’: compare by computing normalized standard deviation
- ‘absdev’: compare by computing absolute deviation
- select (optional, default = '') –
string defining which spectral template set you want to compare to; several options which can be combined:
- m dwarf: fit to M dwarfs only
- l dwarf: fit to M dwarfs only
- t dwarf: fit to M dwarfs only
- vlm: fit to M7-T9 dwarfs
- optical: only optical classifications
- high sn: median S/N greater than 100
- young: only young/low surface gravity dwarfs
- companion: only companion dwarfs
- subdwarf: only subdwarfs
- single: only dwarfs not indicated a binaries
- spectral binaries: only dwarfs indicated to be spectral binaries
- standard: only spectral standards (Note: use classifyByStandard instead)
- method (optional, default = '') –
set to
'kirkpatrick'
to follow the Kirkpatrick et al. (2010) method, fitting only to the 0.9-1.4 micron band - best (optional, default = False) – Set to True to return only the best fit template type
- nbest (optional, default = 1) – Set to the number of best fitting spectra to return
- maxtemplates (optional, default = 100) – Set to the maximum number of templates that should be fit
- force (optional, default = False) – By default, classifyByTemplate won’t proceed if you have more than 100 templates; set this parameter to True to ignore that constraint
- plot (optional, default = False) – Set to True to generate a plot comparing best fit template to source; can also set keywords associated with plotSpectrum_ routine
- string (optional, default = True) – return spectral type as a string
- verbose (optional, default = False) – give lots of feedback
Users can also set keyword parameters defined in plotSpectrum_ and searchLibrary routines
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1507-1627')[0] >>> result = splat.classifyByTemplate(sp,string=True,spt=[24,26],nbest=5) Too many templates (171) for classifyByTemplate; set force=True to override this >>> result = splat.classifyByTemplate(sp,string=True,spt=[24,26],snr=50,nbest=5) Comparing to 98 templates LHS 102B L5.0 10488.1100432 11.0947838116 2MASSI J0013578-223520 L4.0 7037.37441677<PHONE_NUMBER>73 SDSS J001608.44-004302.3 L5.5 15468.6209466<PHONE_NUMBER>06 2MASSI J0028394+150141 L4.5 63696.1897668<PHONE_NUMBER>75 ... Best match = DENIS-P J153941.96-052042.4 with spectral type L4: Mean spectral type = L4.5+/-0.718078660103 >>> result {'result': ('L4.5', 0.71807866010293797), 'scale': [3.0379089778408642e-14, 96.534933767992072, 3.812718429200959, 2.9878801833735986e-14, 3.0353579048704484e-14], 'spectra': [Spectrum of DENIS-P J153941.96-052042.4, Spectrum of 2MASSI J0443058-320209, Spectrum of SDSSp J053951.99-005902.0, Spectrum of 2MASSI J1104012+195921, Spectrum of 2MASS J17502484-0016151], 'spt': [24.0, 25.0, 25.0, 24.0, 25.5], 'statistic': [<Quantity 2108.997879536768>, <Quantity 2205.640664932956>, <Quantity 2279.316858783139>, <Quantity 2579.0089210846527>, <Quantity 2684.003187310027>]}
-
splat.core.
classifyGravity
(sp, *args, **kwargs)¶ Purpose: Determine the gravity classification of a brown dwarf using the method of Allers & Liu (2013).
Parameters: - sp (required) – Spectrum class object, which should contain wave, flux and noise array elements. Must be between M6.0 and L7.0.
- spt (optional, default = False) – spectral type of
sp
. Must be between M6.0 and L7.0 - indices (optional, default = 'allers') – specify indices set using
measureIndexSet
. - plot (optional, default = False) – Set to True to plot sources against closest dwarf spectral standard
- allscores (optional, default = False) – Set to True to return a dictionary containing the gravity scores from individual indices
- verbose (optional, default = False) – Give feedback while computing
Output: Either a string specifying the gravity classification or a dictionary specifying the gravity scores for each index
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1507-1627')[0] >>> splat.classifyGravity(sp) FLD-G >>> result = splat.classifyGravity(sp, allscores = True, verbose=True) Gravity Classification: SpT = L4.0 VO-z: 1.012+/-0.029 => 0.0 FeH-z: 1.299+/-0.031 => 1.0 H-cont: 0.859+/-0.032 => 0.0 KI-J: 1.114+/-0.038 => 1.0 Gravity Class = FLD-G >>> result {'FeH-z': 1.0, 'H-cont': 0.0, 'KI-J': 1.0, 'VO-z': 0.0, 'gravity_class': 'FLD-G', 'score': 0.5, 'spt': 'L4.0'}
-
splat.core.
metallicity
(sp, **kwargs)¶ Purpose: Metallicity measurement using Na I and Ca I lines and H2O-K2 index as described in Rojas-Ayala et al.(2012)
Parameters: - sp – Spectrum class object, which should contain wave, flux and noise array elements
- nsamples (optional, default = 100) – number of Monte Carlo samples for error computation
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='0559-1404')[0] >>> print splat.metallicity(sp) (-0.50726104530066363, 0.24844773591243882)
-
splat.empirical.
redden
(sp, **kwargs)¶ - Description:
- Redden a spectrum based on an either Mie theory or a standard interstellar profile using Cardelli, Clayton, and Mathis (1989 ApJ. 345, 245)
Usage
>>> import splat >>> sp = splat.Spectrum(10001) # read in a source >>> spr = splat.redden(sp,av=5.,rv=3.2) # redden to equivalent of AV=5
- Note
- This routine is still in beta form; only the CCM89 currently works
Spectrophotometry¶
-
splat.photometry.
checkFilter
(filt, verbose=True, info=True)¶
-
splat.photometry.
filterInfo
(*args, **kwargs)¶ Purpose: Prints out the current list of filters in the SPLAT reference library.
-
splat.photometry.
filterMag
(sp, filt, *args, **kwargs)¶ Purpose: Determine the photometric magnitude of a source based on its spectrum. Spectral fluxes are convolved with the filter profile specified by the
filter
input. By default this filter is also convolved with a model of Vega to extract Vega magnitudes, but the user can also specify AB magnitudes, photon flux or energy flux.Parameters: - sp (required) – Spectrum class object, which should contain wave, flux and noise array elements.
- filter (required) – String giving name of filter, which can either be one of the predefined filters listed in splat.FILTERS.keys() or a custom filter name
- custom (optional, default = None) – A 2 x N vector array specifying the wavelengths and transmissions for a custom filter
- notch (optional, default = None) – A 2 element array that specifies the lower and upper wavelengths for a notch filter (100% transmission within, 0% transmission without)
- vega (optional, default = True) – compute Vega magnitudes
- ab (optional, default = False) – compute AB magnitudes
- energy (optional, default = False) – compute energy flux
- photon (optional, default = False) – compute photon flux
- filterFolder (optional, default = splat.FILTER_FOLDER) – folder containing the filter transmission files
- vegaFile (optional, default = vega_kurucz.txt) – name of file containing Vega flux file, must be within
filterFolder
- nsamples (optional, default = 100) – number of samples to use in Monte Carlo error estimation
- info (optional, default = False) – List the predefined filter names available
Example: >>> import splat >>> import splat.photometry as spphot >>> sp = splat.getSpectrum(shortname='1507-1627')[0] >>> sp.fluxCalibrate('2MASS J',14.5) >>> spphot.filterMag(sp,'MKO J') (14.345894376898123, 0.027596454828421831)
-
splat.photometry.
filterProfile
(filt, **kwargs)¶ Purpose: Retrieve the filter profile for a SPLAT filter. Returns two arrays: the filter wavelength and filter transmission curve.
Parameters: - filter – String giving the name of one of the predefined filters listed in splat.FILTERS.keys() (required)
- filterFolder – folder containing the filter transmission files (optional, default = splat.FILTER_FOLDER)
Example: >>> import splat >>> import splat.photometry as spphot >>> sp = splat.getSpectrum(shortname='1507-1627')[0] >>> sp.fluxCalibrate('2MASS J',14.5) >>> spphot.filterMag(sp,'MKO J') (14.345894376898123, 0.027596454828421831)
-
splat.photometry.
filterProperties
(filt, **kwargs)¶ Purpose: Returns a dictionary containing key parameters for a particular filter.
Parameters: - filter (required) – name of filter, must be one of the specifed filters given by splat.FILTERS.keys()
- verbose (optional, default = True) – print out information about filter to screen
Example: >>> import splat >>> data = splat.filterProperties('2MASS J') Filter 2MASS J: 2MASS J-band Zeropoint = 1594.0 Jy Pivot point: = 1.252 micron FWHM = 0.323 micron Wavelength range = 1.066 to 1.442 micron >>> data = splat.filterProperties('2MASS X') Filter 2MASS X not among the available filters: 2MASS H: 2MASS H-band 2MASS J: 2MASS J-band 2MASS KS: 2MASS Ks-band BESSEL I: Bessel I-band FOURSTAR H: FOURSTAR H-band FOURSTAR H LONG: FOURSTAR H long FOURSTAR H SHORT: FOURSTAR H short ...
-
splat.photometry.
magToFlux
(mag, filt, **kwargs)¶ Purpose: Converts a magnitude into an energy, and vice versa.
Parameters: - mag – magnitude on whatever system is defined for the filter or provided (required)
- filter – name of filter, must be one of the specifed filters given by splat.FILTERS.keys() (required)
- reverse – convert energy into magnitude instead (optional, default = False)
- ab – magnitude is on the AB system (optional, default = filter preference)
- vega – magnitude is on the Vega system (optional, default = filter preference)
- rsr – magnitude is on the Vega system (optional, default = filter preference)
- units – units for energy as an astropy.units variable; if this conversion does not work, the conversion is ignored (optional, default = erg/cm2/s)
- verbose – print out information about filter to screen (optional, default = False)
WARNING: THIS CODE IS ONLY PARTIALLY COMPLETE
-
splat.photometry.
visualizeFilter
(filt, **kwargs)¶ Purpose: Plots a filter profile or set of filter profiles, optionally on top of a spectrum FUTURE CODE, THIS IS A PLACEHOLDER
Other Spectral Analyses¶
-
splat.core.
measureIndex
(sp, *args, **kwargs)¶ Purpose: Measure an index on a spectrum based on defined methodology measure method can be mean, median, integrate index method can be ratio = 1/2, valley = 1-2/3, OTHERS output is index value and uncertainty # NOTE: NOISE FLAG ERROR IS BACKWARDS HERE
-
splat.core.
measureIndexSet
(sp, **kwargs)¶ Purpose: Measures indices of
sp
from specified sets. Returns dictionary of indices.Parameters: - sp – Spectrum class object, which should contain wave, flux and noise array elements
- set (optional, default = 'burgasser') –
string defining which indices set you want to use; options include:
- bardalez: H2O-J, CH4-J, H2O-H, CH4-H, H2O-K, CH4-K, K-J, H-dip, K-slope, J-slope, J-curve, H-bump, H2O-Y from Bardalez Gagliuffi et al. (2014)
- burgasser: H2O-J, CH4-J, H2O-H, CH4-H, H2O-K, CH4-K, K-J from Burgasser et al. (2006)
- tokunaga: K1, K2 from Tokunaga & Kobayashi (1999)
- reid: H2O-A, H2O-B from Reid et al. (2001)
- geballe: H2O-1.2, H2O-1.5, CH4-2.2 from Geballe et al. (2002)
- allers: H2O, FeH-z, VO-z, FeH-J, KI-J, H-cont from Allers et al. (2007), Allers & Liu (2013)
- testi: sHJ, sKJ, sH2O-J, sH2O-H1, sH2O-H2, sH2O-K from Testi et al. (2001)
- slesnick: H2O-1, H2O-2, FeH from Slesnick et al. (2004)
- mclean: H2OD from McLean et al. (2003)
- rojas: H2O-K2 from Rojas-Ayala et al.(2012)
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1555+0954')[0] >>> print splat.measureIndexSet(sp, set = 'reid') {'H2O-B': (1.0531856077273236, 0.0045092074790538221), 'H2O-A': (0.89673318593633422, 0.0031278302105038594)}
-
splat.core.
measureEW
(sp, *args, **kwargs)¶ Purpose: Measures equivalent widths (EWs) of specified lines
Parameters: - sp – Spectrum class object, which should contain wave, flux and noise array elements
- args – wavelength arrays. Needs at least two arrays to measure line and continuum regions.
- nonoise (optional, default = '') –
- line –
-
splat.core.
measureEWSet
(sp, *args, **kwargs)¶ Purpose: Measures equivalent widths (EWs) of lines from specified sets. Returns dictionary of indices.
Parameters: - sp – Spectrum class object, which should contain wave, flux and noise array elements
- set (optional, default = 'rojas') –
string defining which EW measurement set you want to use; options include:
- rojas: EW measures from Rojas-Ayala et al. (2012); uses Na I 2.206/2.209 Ca I 2.26 micron lines.
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1555+0954')[0] >>> print splat.measureEWSet(sp, set = 'rojas') {'Na I 2.206/2.209': (1.7484002652013144, 0.23332441577025356), 'Ca I 2.26': (1.3742491939667159, 0.24867705962337672), 'names': ['Na I 2.206/2.209', 'Ca I 2.26'], 'reference': 'EW measures from Rojas-Ayala et al. (2012)'}
Empirical Relationships¶
-
splat.empirical.
estimateDistance
(*args, **kwargs)¶ Purpose: Takes the apparent magnitude and either takes or determines the absolute magnitude, then uses the magnitude/distance relation to estimate the distance to the object in parsecs. Returns estimated distance and uncertainty in parsecs
Parameters: - sp – Spectrum class object, which should be flux calibrated to its empirical apparent magnitude
- mag (optional, default = False) – apparent magnitude of
sp
- mag_unc (optional, default = 0) – uncertainty of the apparent magnitude
- absmag (optional, default = False) – absolute magnitude of
sp
- absmag_unc (optional, default = 0) – uncertainty of the absolute magnitude
- spt (optional, default = False) – spectral type of
sp
- spt_e (optional, default = 0) – uncertainty of the spectral type
- nsamples (optional, default = 100) – number of samples to use in Monte Carlo error estimation
- filter (optional, default = False) –
Name of filter, must be one of the following:
- ‘2MASS J’, ‘2MASS H’, ‘2MASS Ks’
- ‘MKO J’, ‘MKO H’, ‘MKO K’, MKO Kp’, ‘MKO Ks’
- ‘NICMOS F090M’, ‘NICMOS F095N’, ‘NICMOS F097N’, ‘NICMOS F108N’
- ‘NICMOS F110M’, ‘NICMOS F110W’, ‘NICMOS F113N’, ‘NICMOS F140W’
- ‘NICMOS F145M’, ‘NICMOS F160W’, ‘NICMOS F164N’, ‘NICMOS F165M’
- ‘NICMOS F166N’, ‘NICMOS F170M’, ‘NICMOS F187N’, ‘NICMOS F190N’
- ‘NIRC2 J’, ‘NIRC2 H’, ‘NIRC2 Kp’, ‘NIRC2 Ks’
- ‘WIRC J’, ‘WIRC H’, ‘WIRC K’, ‘WIRC CH4S’, ‘WIRC CH4L’
- ‘WIRC CO’, ‘WIRC PaBeta’, ‘WIRC BrGamma’, ‘WIRC Fe2’
- ‘WISE W1’, ‘WISE W2’
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1555+0954')[0] >>> print splat.estimateDistance(sp) Please specify the filter used to determine the apparent magnitude (nan, nan) >>> print splat.estimateDistance(sp, mag = 12.521, mag_unc = 0.022, absmag = 7.24, absmag_unc = 0.50, spt = 'M3')<PHONE_NUMBER>2188771, 33.124820555524224)
-
splat.empirical.
typeToColor
(spt, color, **kwargs)¶ Purpose: Takes a spectral type and optionally a color (string) and returns the typical color of the source.
Parameters: - spt – string or integer of the spectral type
- color (optional, default = 'J-K') – string indicating color; e.g., color=’i-z’ (note that case does not matter)
- ref (optional, default = 'dupuy') –
Abs Mag/SpT relation used to compute the absolute magnitude. Options are:
- skrzypek (default): Color trends from Skryzpek et al. (2015). Spectral type range is M5 to T8 Colors include i-z, z-Y, Y-J, J-H, H-K, K-W1, W1-W2, and combinations therein.
- nsamples (optional, default = 100) – number of Monte Carlo samples for error computation
- unc (optional, default = 0.) – uncertainty of
spt
; if included, returns a tuple with color and uncertainty - verbose (optional, default = False) – Give feedback while in operation
Example: >>> import splat >>> print splat.typeToColor('L3', 'J-K') (1.46, nan) >>> print splat.typeToColor('M5', 'i-z', ref = 'skrzypek', unc=0.5) (0.91, 0.57797809947624645) >>> print splat.typeToColor('M0', 'i-z', ref = 'skrzypek') Spectral type M0.0 is outside the range for reference set Skrzypek et al. (2015) (nan, nan)
-
splat.empirical.
typeToMag
(spt, filt, **kwargs)¶ Purpose: Takes a spectral type and a filter, and returns absolute magnitude
Parameters: - spt – string or integer of the spectral type
- filter – filter of the absolute magnitude. Options are MKO K, MKO H, MKO J, MKO Y, MKO LP, 2MASS J, 2MASS K, or 2MASS H
- nsamples (optional, default = 100) – number of Monte Carlo samples for error computation
- unc (optional, default = 0.) – uncertainty of
spt
- ref (optional, default = 'dupuy') –
Abs Mag/SpT relation used to compute the absolute magnitude. Options are:
- burgasser: Abs Mag/SpT relation from Burgasser (2007). Allowed spectral type range is L0 to T8, and allowed filters are MKO K.
- faherty: Abs Mag/SpT relation from Faherty et al. (2012). Allowed spectral type range is L0 to T8, and allowed filters are MKO J, MKO H and MKO K.
- dupuy: Abs Mag/SpT relation from Dupuy & Liu (2012). Allowed spectral type range is M6 to T9, and allowed filters are MKO J, MKO Y, MKO H, MKO K, MKO LP, 2MASS J, 2MASS H, and 2MASS K.
- filippazzo: Abs Mag/SpT relation from Filippazzo et al. (2015). Allowed spectral type range is M6 to T9, and allowed filters are 2MASS J and WISE W2.
Example: >>> import splat >>> print splat.typeToMag('L3', '2MASS J') (12.730064813273996, 0.4) >>> print splat.typeToMag(21, 'MKO K', ref = 'burgasser') (10.705292820099999, 0.26) >>> print splat.typeToMag(24, '2MASS J', ref = 'faherty') Invalid filter given for Abs Mag/SpT relation from Faherty et al. (2012) (nan, nan) >>> print splat.typeToMag('M0', '2MASS H', ref = 'dupuy') Spectral Type is out of range for Abs Mag/SpT relation from Dupuy & Liu (2012) Abs Mag/SpT relation (nan, nan)
-
splat.empirical.
typeToTeff
(inp, **kwargs)¶ Purpose: Returns an effective temperature (Teff) and its uncertainty for a given spectral type
Parameters: - input – Spectral type; can be a number or a string from 0 (K0) and 49.0 (Y9).
- uncertainty (optional, default = 0.001) – uncertainty of spectral type
- unc (optional, default = 0.001) – same as
uncertainty
- spt_e (optional, default = 0.001) – same as
uncertainty
- ref (optional, default = 'stephens2009') –
Teff/SpT relation used to compute the effective temperature. Options are:
- golimowski: Teff/SpT relation from Golimowski et al. (2004). Allowed spectral type range is M6 to T8.
- looper: Teff/SpT relation from Looper et al. (2008). Allowed spectral type range is L0 to T8.
- stephens: Teff/SpT relation from Stephens et al. (2009). Allowed spectral type range is M6 to T8 and uses alternate coefficients for L3 to T8.
- marocco: Teff/SpT relation from Marocco et al. (2013). Allowed spectral type range is M7 to T8.
- filippazzo: Teff/SpT relation from Filippazzo et al. (2015). Allowed spectral type range is M6 to T9.
- set (optional, default = 'stephens2009') – same as
ref
- method (optional, default = 'stephens2009') – same as
ref
- nsamples (optional, default = 100) – number of samples to use in Monte Carlo error estimation
Example: >>> import splat >>> print splat.typeToTeff(20) (2233.4796740905499,<PHONE_NUMBER>4571999) >>> print splat.typeToTeff(20, unc = 0.3, ref = 'golimowski') (2305.7500497902788,<PHONE_NUMBER>6132124)
-
splat.empirical.
typeToLuminosity
(spt, **kwargs)¶
-
splat.empirical.
typeToBC
(spt, filter, **kwargs)¶
Conversion Routines¶
-
splat.utilities.
coordinateToDesignation
(c)¶ Purpose: Converts right ascension and declination into a designation string Parameters: c – RA and Dec coordinate to be converted; can be a SkyCoord object with units of degrees, a list with RA and Dec in degrees, or a string with RA measured in hour angles and Dec in degrees Output: Designation string Example: >>> import splat >>> from astropy.coordinates import SkyCoord >>> c = SkyCoord(238.86, 9.90, unit="deg") >>> print splat.coordinateToDesignation(c) J15552640+0954000 >>> print splat.coordinateToDesignation([238.86, 9.90]) J15552640+0954000 >>> print splat.coordinateToDesignation('15:55:26.4 +09:54:00.0') J15552640+0954000
-
splat.utilities.
designationToCoordinate
(value, **kwargs)¶ Purpose: Convert a designation srtring into a RA, Dec tuple or ICRS SkyCoord objects (default)
Parameters: - value (required) – Designation string with RA measured in hour angles and Dec in degrees
- icrs (optional, defualt = True) – returns astropy SkyCoord coordinate in ICRS frame if
True
Output: Coordinate, either as [RA, Dec] or SkyCoord object
Example: >>> import splat >>> splat.designationToCoordinate('J1555264+0954120') <SkyCoord (ICRS): (ra, dec) in deg (238.8585, 9.90333333)>
-
splat.utilities.
designationToShortName
(value)¶ Purpose: Produce a shortened version of designation Parameters: value (required) – Designation string with RA measured in hour angles and Dec in degrees Output: Shorthand designation string Example: >>> import splat >>> print splat.designationToShortName('J1555264+0954120') J1555+0954
-
splat.utilities.
typeToNum
(inp, **kwargs)¶ Purpose: Converts between string and numeric spectral types, and vise versa.
Parameters: - input – Spectral type to convert. Can convert a number or a string from 0 (K0) and 49.0 (Y9).
- error (optional, default = '') – magnitude of uncertainty. ‘:’ for uncertainty > 1 and ‘::’ for uncertainty > 2.
- uncertainty (optional, default = 0) – uncertainty of spectral type
- subclass (optional, default = '') –
subclass of object. Options include:
- sd: object is a subdwarf
- esd: object is an extreme subdwarf
- usd: object is an ultra subdwarf
- lumclass (optional, default = '') – luminosity class of object represented by roman numerals
- ageclass (optional, default = '') – age class of object
- colorclass (optional, default = '') – color class of object
- peculiar (optional, default = False) – if object is peculiar or not
Example: >>> import splat >>> print splat.typeToNum(30) T0.0 >>> print splat.typeToNum('T0.0') 30.0 >>> print splat.typeToNum(27, peculiar = True, uncertainty = 1.2, lumclass = 'II') L7.0IIp: >>> print splat.typeToNum(50) Spectral type number must be between 0 (K0) and 49.0 (Y9) nan
-
splat.utilities.
properCoordinates
(c, **kwargs)¶ Purpose: Converts various coordinate forms to the proper SkyCoord format. Convertible forms include lists and strings. Parameters: c – coordinate to be converted. Can be a list (ra, dec) or a string. Example: >>> import splat >>> print splat.properCoordinates([104.79, 25.06]) <SkyCoord (ICRS): ra=104.79 deg, dec=25.06 deg> >>> print splat.properCoordinates('06:59:09.60 +25:03:36.0') <SkyCoord (ICRS): ra=104.79 deg, dec=25.06 deg> >>> print splat.properCoordinates('J06590960+2503360') <SkyCoord (ICRS): ra=104.79 deg, dec=25.06 deg>
-
splat.utilities.
properDate
(din, **kwargs)¶ Purpose: Converts various date formats into a standardized date of YYYY-MM-DD
Parameters: - d – Date to be converted.
- format (Optional, string) – Optional input format of the following form: * ‘YYYY-MM-DD’: e.g., 2011-04-03 (this is default output) * ‘YYYYMMDD’: e.g., 20110403 * ‘YYMMDD’: e.g., 20110403 * ‘MM/DD/YY’: e.g., 03/04/11 * ‘MM/DD/YYYY’: e.g., 03/04/2011 * ‘YYYY/MM/DD’: e.g., 2011/03/04 * ‘DD/MM/YYYY’: e.g., 04/03/2011 * ‘DD MMM YYYY’: e.g., 04 Mar 2011 * ‘YYYY MMM DD’: e.g., 2011 Mar 04
- output (Optional, string) – Format of the output based on the prior list
Example: >>> import splat >>> splat.properDate('20030502') '2003-05-02' >>> splat.properDate('2003/05/02') '02-2003-05' >>> splat.properDate('2003/05/02',format='YYYY/MM/DD') '2003-05-02' >>> splat.properDate('2003/05/02',format='YYYY/MM/DD',output='YYYY MMM DD') '2003 May 02'
Note that the default output format can be read into an astropy.time quantity >>> import splat >>> from astropy.time import Time >>> t = Time(splat.properDate(‘20030502’)) >>> print(t)
2003-05-02 00:00:00.000
Plotting Routines¶
-
splat.plot.
plotMap
(*args, **kwargs)¶ Purpose: Plot coordinates onto an equatorial map grid :Input One or more coordinates, specified as astropy.coordinates.SkyCoord objects, two-element arrays (RA and declination in decimal degrees), or string coordinate designation; the latter two are converted to SkyCoord variables using splat.properCoordinates()
Parameters: - projection = ‘mollweide’
- projection type; see the Basemap documentation
- reference_declination or rdec
- a single or array of declinations to indicates as references, useful for denoting pointing limits
- galactic = False
- Plot in galactic coordinates (NOT YET IMPLEMENTED)
- ecliptic = False
- Plot in ecliptic coordinates (NOT YET IMPLEMENTED)
- extrgalactic or supergalactic = False
- Plot in supergalactic coordinates (NOT YET IMPLEMENTED)
- marker or markers or symbol or symbols = ‘o’
- symbol type; see the matplotlib documentation
- size or sizes or symsize or symsizes = 10
- symbol size
- color or colors = ‘k’
- color of plot symbols
- alpha or alphas = 0.5
- transparency of plot symbols
- legend, legends, label or labels = None
- list of strings providing legend-style labels for each spectrum plotted
- grid = True:
- add a grid
- file or filename or output:
- filename or filename base for output
- figsize = (8,6)
- set the figure size; set to default size if not indicated
- tight = True:
- makes a ``tight’’ box plot to elimate extra whitespace
Example: >>> import splat >>> import splat.plot as splot >>> s = splat.searchLibrary(young=True) >>> c = [splat.properCoordinates(x) for x in s['DESIGNATION']] >>> splot.plotMap(c)
-
splat.plot.
plotSpectrum
(*args, **kwargs)¶ Purpose: Primary plotting program for Spectrum objects.
:Input Spectrum objects, either sequentially, in list, or in list of lists
- Spec1, Spec2, ...: plot multiple spectra together, or separately if multiplot = True
- [Spec1, Spec2, ...]: plot multiple spectra together, or separately if multiplot = True
- [[Spec1, Spec2], [Spec3, Spec4], ..]: plot multiple sets of spectra (multiplot forced to be True)
Parameters: - title = ‘’
- string giving plot title - NOTE: THIS IS NOT WORKING
- xrange = [0.85,2.42]:
- plot range for wavelength axis
- yrange = [-0.02,1.2]*fluxMax:
- plot range for wavelength axis
- xlabel:
- wavelength axis label; by default set by wlabel and wunit keywords in first spectrum object
- ylabel:
- flux axis label; by default set by fscale, flabel and funit keywords in first spectrum object
- xlog = False:
- set the x (wavelength) axis to plot as a log scale
- ylog = False:
- set the y (flux) axis to plot as a log scale
- features:
- a list of strings indicating chemical features to label on the spectra options include H2O, CH4, CO, TiO, VO, FeH, H2, HI, KI, NaI, SB (for spectral binary)
- mdwarf, ldwarf, tdwarf, young, binary = False:
- add in features characteristic of these classes
- telluric = False:
- mark telluric absorption features
- band(s) = []
- a single or array of 2-element arrays that indicate bands that you want to specifically shade in
- bandcolor(s) = []
- a single or array of colors to shade the bands (default = ‘k’)
- bandalpha(s) = []
- a single or array of alphas to shade the bands (default = 0.2)
- bandlabel(s) = []
- a single or array of labels to annotate the bands (default = ‘’)
- bandlabelposition(s) = []
- a single or array of strings indicating the position of the labels; can be ‘bottom’, ‘middle’, or ‘top’ (default = ‘bottom’)
- legend(s) or label(s):
- list of strings providing legend-style labels for each spectrum plotted
- legendLocation or labelLocation = ‘upper right’:
- place of legend; options are ‘upper left’, ‘center middle’, ‘lower right’ (variations thereof) and ‘outside’
- legendfontscale = 1:
- sets the scale factor for the legend fontsize (defaults to fontscale)
- grid = False:
- add a grid
- stack = 0:
- set to a numerical offset to stack spectra on top of each other
- zeropoint = [0,...]:
- list of offsets for each spectrum, giving finer control than stack
- showZero = True:
- plot the zeropoint(s) of the spectra
- comparison:
- a comparison Spectrum to compare in each plot, useful for common reference standard
- noise, showNoise or uncertainty = False:
- plot the uncertainty for each spectrum
- residual = False:
- plots the residual between two spectra
- colorComparison:
- color of comparison source plot lines; by default all grey
- color or colors:
- color of plot lines; by default all black
- colorUnc or colorsUnc:
- color of uncertainty lines; by default same as line color but reduced opacity
- colorScheme or colorMap:
- color map to apply based on matplotlib colormaps; see http://matplotlib.org/api/pyplot_summary.html?highlight=colormaps#matplotlib.pyplot.colormaps
- linestyle or linestyles:
- line style of plot lines; by default all solid
- fontscale = 1:
- sets a scale factor for the fontsize
- inset = False:
- place an inset panel showing a close up region of the spectral data
- inset_xrange = False:
- wavelength range for inset panel
- inset_position = [0.65,0.60,0.20,0.20]
- position of inset planet in normalized units, in order left, bottom, width, height
- inset_features = False
- list of features to label in inset plot
- file or filename or output:
- filename or filename base for output
- filetype = ‘pdf’:
- output filetype, generally determined from filename
- multiplot = False:
- creates multiple plots, depending on format of input (optional)
- multipage = False:
- spreads plots across multiple pages; output file format must be PDF if not set and plots span multiple pages, these pages are output sequentially as separate files
- layout or multilayout = [1,1]:
- defines how multiple plots are laid out on a page
- figsize:
- set the figure size; set to default size if not indicated
- interactive = False:
- if plotting to window, set this to make window interactive
- tight = True:
- makes a ``tight’’ box plot to elimate extra whitespace
Example 1: A simple view of a random spectrum >>> import splat >>> spc = splat.getSpectrum(spt = ‘T5’, lucky=True)[0] >>> spc.plot() # this automatically generates a “quicklook” plot >>> splat.plotSpectrum(spc) # does the same thing >>> splat.plotSpectrum(spc,uncertainty=True,tdwarf=True) # show the spectrum uncertainty and T dwarf absorption features
Example 2: - Viewing a set of spectra for a given object
In this case we’ll look at all of the spectra of TWA 30B in the library, sorted by year and compared to the first epoch data This is an example of using multiplot and multipage
>>> splist = splat.getSpectrum(name = 'TWA 30B') # get all spectra of TWA 30B >>> junk = [sp.normalize() for sp in splist] # normalize the spectra >>> dates = [sp.date for sp in splist] # observation dates >>> spsort = [s for (s,d) in sorted(zip(dates,splis))] # sort spectra by dates >>> dates.sort() # don't forget to sort dates! >>> splat.plotSpectrum(spsort,multiplot=True,layout=[2,2],multipage=True,\ # here's our plot statement comparison=spsort[0],uncertainty=True,mdwarf=True,telluric=True,legends=dates, legendLocation='lower left',output='TWA30B.pdf')
Example 3: - Display the spectra sequence of L dwarfs
This example uses the list of standard files contained in SPLAT, and illustrates the stack feature
>>> spt = [splat.typeToNum(i+20) for i in range(10)] # generate list of L spectral types >>> splat.initiateStandards() # initiate standards >>> splist = [splat.SPEX_STDS[s] for s in spt] # extact just L dwarfs >>> junk = [sp.normalize() for sp in splist] # normalize the spectra >>> labels = [sp.shortname for sp in splist] # set labels to be names >>> splat.plotSpectrum(splist,figsize=[10,20],labels=labels,stack=0.5,\ # here's our plot statement colorScheme='copper',legendLocation='outside',telluric=True,output='lstandards.pdf')
-
splat.plot.
plotBatch
(*args, **kwargs)¶ Purpose: Plots a batch of spectra into a 2x2 set of PDF files, with options of overplotting comparison spectra, including best-match spectral standards.
Parameters: - input (required) – A single or list of Spectrum objects or filenames, or the glob search string for a set of files (e.g., ‘/Data/myspectra/*.fits’).
- output (optional, default = 'spectra_plot.pdf') – Filename for PDF file output; full path should be include if not saving to current directory
- comparisons (optional, default = None) – list of Spectrum objects or filenames for comparison spectra. If comparisons list is shorter than source list, then last comparison source will be repeated. If the comparisons list is longer, the list will be truncated.
- classify (optional, default = False) –
Set to True to classify sources based on comparison to MLT spectral standards following the method of Kirkpatrick et al. (2010). This option normalizes the spectra by default
- normalize (optional, default = False) – Set to True to normalize source and (if passed) comparison spectra.
- legend (optional, default = displays file name for source and object name for comparison (if passed)) – Set to list of legends for plots. The number of legends should equal the number of sources and comparisons (if passed) in an alternating sequence. T
Relevant parameters for plotSpectrum may also be passed
Example: >>> import glob, splat >>> files = glob.glob('/home/mydata/*.fits') >>> sp = splat.plotBatch(files,classify=True,output='comparison.pdf') >>> sp = splat.plotBatch('/home/mydata/*.fits',classify=True,output='comparison.pdf') >>> sp = splat.plotBatch([splat.Spectrum(file=f) for f in files],classify=True,output='comparison.pdf') All three of these commands produce the same result
-
splat.plot.
plotSequence
(*args, **kwargs)¶ Purpose: Compares a spectrum to a sequence of standards a batch of spectra into a 2x2 set of PDF files, with options of overplotting comparison spectra, including best-match spectral standards.
Parameters: - input (required) – A single or list of Spectrum objects or filenames, or the glob search string for a set of files (e.g., ‘/Data/myspectra/*.fits’).
- type_range (optional, default = 2) – Number of subtypes to consider above and below best-fit spectral type
- spt (optional, default = None) – Default spectral type for source; this input skips classifyByStandard
- output (optional, default = None (screen display)) – Filename for output; full path should be include if not saving to current directory. If blank, plot is shown on screen
Relevant parameters for plotSpectrum may also be passed
Example: >>> import glob, splat >>> files = glob.glob('/home/mydata/*.fits') >>> sp = splat.plotBatch(files,classify=True,output='comparison.pdf') >>> sp = splat.plotBatch('/home/mydata/*.fits',classify=True,output='comparison.pdf') >>> sp = splat.plotBatch([splat.Spectrum(file=f) for f in files],classify=True,output='comparison.pdf') All three of these commands produce the same result
-
splat.plot.
plotSED
(*args, **kwargs)¶ Purpose: Plot SED photometry with SpeX spectrum.
Not currently implemented
-
splat.plot.
plotIndices
(*args, **kwargs)¶ Purpose: Plot index-index plots.
Not currently implemented
Utility Routines¶
-
splat.utilities.
checkInstrument
(instrument)¶ - Purpose:
- Checks that an instrument name is one of the available instruments, including a check of alternate names
- Required Inputs:
param: instrument: A string containing the instrument name to be checked. This should be one of the instruments in the global parameter splat.initialize.INSTRUMENTS - Optional Inputs:
- None
- Output:
- A string containing SPLAT’s default name for a given model set, or False if that model set is not present
Example:
>>> import splat >>> print(splat._checkModelName('burrows')) burrows06 >>> print(splat._checkModelName('allard')) BTSettl2008 >>> print(splat._checkModelName('somethingelse')) False
-
splat.utilities.
checkKeys
(input, parameters, **kwargs)¶ Purpose: Checks the input kwargs keys against the expected parameters of a function to make sure the right parameters are passed.
Parameters: - input – input dictionary to a function (i.e., kwargs).
- parameters – allowed parameters for the function
- forcekey – (optional, default = False) if True, raises a Value Error if an incorrect parameter is passed
-
splat.utilities.
distributionStats
(x, q=[0.16, 0.5, 0.84], weights=None, sigma=None, **kwargs)¶ Purpose: Find key values along distributions based on quantile steps. This code is derived almost entirely from triangle.py.
-
splat.utilities.
isNumber
(s)¶ Purpose: Checks if something is a number. Parameters: s (required) – object to be checked Output: True or False Example: >>> import splat >>> print splat.isNumber(3) True >>> print splat.isNumber('hello') False
-
splat.core.
readSpectrum
(*args, **kwargs)¶
-
splat.utilities.
weightedMeanVar
(vals, winp, *args, **kwargs)¶ Purpose: Computes weighted mean of an array of values through various methods. Returns weighted mean and weighted uncertainty.
Parameters: - vals – array of values
- winp – array of weights associated with
vals
- method (optional, default = '') –
input type of weights. Default is where
winp
is the actual weights ofvals
. Options include:- uncertainty: uncertainty weighting, where
winp
is the uncertainties ofvals
- ftest: ftest weighting, where
winp
is the chi squared values ofvals
- uncertainty: uncertainty weighting, where
- weight_minimum (optional, default = 0.) – minimum possible weight value
- dof (optional, default = len(vals) - 1) – effective degrees of freedom
Note
When using
ftest
method, extradof
value is requiredExample: >>> import splat >>> print splat.weightedMeanVar([3.52, 5.88, 9.03], [0.65, 0.23, 0.19]) (5.0057009345794379, 4.3809422657000594) >>> print splat.weightedMeanVar([3.52, 5.88, 9.03], [1.24, 2.09, 2.29], method = 'uncertainty') (5.0069199363443841, 4.3914329968409946)
I/O Routines¶
-
splat.utilities.
checkOnline
(*args)¶ Purpose: Checks if SPLAT’s URL is accessible from your machine– that is, checks if you and the host are online. Alternately checks if a given filename is present locally or online
Example: >>> import splat >>> spl.checkOnline() True # SPLAT's URL was detected. >>> spl.checkOnline() False # SPLAT's URL was not detected. >>> spl.checkOnline('SpectralModels/BTSettl08/parameters.txt') '' # Could not find this online file.
-
splat.utilities.
checkOnlineFile
(*args)¶ Purpose: Checks if SPLAT’s URL is accessible from your machine– that is, checks if you and the host are online. Alternately checks if a given filename is present locally or online
Example: >>> import splat >>> spl.checkOnlineFile('SpectralModels/BTSettl08/parameters.txt') '' # Could not find this online file. >>> spl.checkOnlineFile() '' # SPLAT's URL was not detected; you are not online.
-
splat.utilities.
checkAccess
(**kwargs) Purpose: Checks if user has access to unpublished spectra in SPLAT library.
Example: >>> import splat >>> print spl.checkAccess() True
Note: Must have the file .splat_access in your home directory with the correct passcode to use.
-
splat.utilities.
checkFile
(filename, **kwargs) Purpose: Checks if a spectrum file exists in the SPLAT’s library.
Parameters: filename – A string containing the spectrum’s filename.
Example: >>> import splat >>> spectrum1 = 'spex_prism_1315+2334_110404.fits' >>> print spl.checkFile(spectrum1) True >>> spectrum2 = 'fake_name.fits' >>> print spl.checkFile(spectrum2) False
-
splat.utilities.
checkLocal
(inputfile)¶ Purpose: Checks if a file is present locally or within the SPLAT code directory
Example: >>> import splat >>> spl.checkLocal('spl.py') True # found the code >>> spl.checkLocal('parameters.txt') False # can't find this file >>> spl.checkLocal('SpectralModels/BTSettl08/parameters.txt') True # found it
Modeling Routines¶
Spectral Modeling Routines¶
-
splat.utilities.
checkSpectralModelName
(model)¶ - Purpose:
- Checks that an input model name is one of the available spectral models, including a check of alternate names
- Required Inputs:
param: model: A string containing the spectral model to be checked. This should be one of the models listed in loadModel()
- Optional Inputs:
- None
- Output:
- A string containing SPLAT’s default name for a given model set, or False if that model set is not present
Example:
>>> import splat >>> print(splat.checkSpectralModelName('burrows')) burrows06 >>> print(splat.checkSpectralModelName('allard')) BTSettl2008 >>> print(splat.checkSpectralModelName('somethingelse')) False
-
splat.model.
loadModel
(*args, **kwargs)¶ - Purpose:
- Loads up a model spectrum based on a set of input parameters. The models may be any one of the following listed below. For parameters between the model grid points, loadModel calls the function loadInterpolatedModel().
- Required Inputs:
param: model: The model set to use; may be one of the following:
- BTSettl2008: (default) model set from Allard et al. (2012) with effective temperatures of 400 to 2900 K (steps of 100 K); surface gravities of 3.5 to 5.5 in units of cm/s^2 (steps of 0.5 dex); and metallicity of -3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.3, and 0.5 for temperatures greater than 2000 K only; cloud opacity is fixed in this model, and equilibrium chemistry is assumed. Note that this grid is not completely filled and some gaps have been interpolated (alternate designations: btsettled, btsettl, allard, allard12)
- burrows06: model set from Burrows et al. (2006) with effective temperatures of 700 to 2000 K (steps of 50 K); surface gravities of 4.5 to 5.5 in units of cm/s^2 (steps of 0.1 dex); metallicity of -0.5, 0.0 and 0.5; and either no clouds or grain size 100 microns (fsed = ‘nc’ or ‘f100’). equilibrium chemistry is assumed. Note that this grid is not completely filled and some gaps have been interpolated (alternate designations: burrows, burrows2006)
- morley12: model set from Morley et al. (2012) with effective temperatures of 400 to 1300 K (steps of 50 K); surface gravities of 4.0 to 5.5 in units of cm/s^2 (steps of 0.5 dex); and sedimentation efficiency (fsed) of 2, 3, 4 or 5; metallicity is fixed to solar, equilibrium chemistry is assumed, and there are no clouds associated with this model (alternate designations: morley2012)
- morley14: model set from Morley et al. (2014) with effective temperatures of 200 to 450 K (steps of 25 K) and surface gravities of 3.0 to 5.0 in units of cm/s^2 (steps of 0.5 dex); metallicity is fixed to solar, equilibrium chemistry is assumed, sedimentation efficiency is fixed at fsed = 5, and cloud coverage fixed at 50% (alternate designations: morley2014)
- saumon12: model set from Saumon et al. (2012) with effective temperatures of 400 to 1500 K (steps of 50 K); and surface gravities of 3.0 to 5.5 in units of cm/s^2 (steps of 0.5 dex); metallicity is fixed to solar, equilibrium chemistry is assumed, and no clouds are associated with these models (alternate designations: saumon, saumon2012)
- drift: model set from Witte et al. (2011) with effective temperatures of 1700 to 3000 K (steps of 50 K); surface gravities of 5.0 and 5.5 in units of cm/s^2; and metallicities of -3.0 to 0.0 (in steps of 0.5 dex); cloud opacity is fixed in this model, equilibrium chemistry is assumed (alternate designations: witte, witte2011, helling)
- madhusudhan: model set from Madhusudhan et al. (2011) with effective temperatures of 600 K to 1700 K (steps of 50-100 K); surface gravities of 3.5 and 5.0 in units of cm/s^2; and metallicities of 0.0 to 1.0 (in steps of 0.5 dex); there are multiple cloud prescriptions for this model, equilibrium chemistry is assumed (alternate designations: madhusudhan)
- Optional Inputs:
param: teff: effective temperature of the model in K (e.g. teff = 1000) param: logg: log10 of the surface gravity of the model in cm/s^2 units (e.g. logg = 5.0) param: z: log10 of metallicity of the model relative to solar metallicity (e.g. z = -0.5) param: fsed: sedimentation efficiency of the model (e.g. fsed = ‘f2’) param: cld: cloud shape function of the model (e.g. cld = ‘f50’) param: kzz: vertical eddy diffusion coefficient of the model (e.g. kzz = 2) param: slit: slit weight of the model in arcseconds (e.g. slit = 0.3) param: sed: if set to True, returns a broad-band spectrum spanning 0.3-30 micron (applies only for BTSettl2008 models with Teff < 2000 K) param: local: set to True to force program to read in local models (default = True) param: online: set to True to force program to read in models from SPLAT webpage (default = False) param: folder: string of the folder name containing the model set (default = ‘’) param: filename: string of the filename of the desired model; should be a space-delimited file containing columns for wavelength (units of microns) and surface flux (F_lambda units of erg/cm^2/s/micron) (default = ‘’) param: force: force the filename to be exactly as specified param: fast: set to True to do a fast interpolation if needed, only for Teff and logg (default = False) param: url: string of the url to the SPLAT website (default = ‘http://www.browndwarfs.org/splat/‘) - Output:
- A SPLAT Spectrum object of the interpolated model with wavelength in microns and surface fluxes in F_lambda units of erg/cm^2/s/micron.
Example:
>>> import splat >>> mdl = splat.loadModel(teff=1000,logg=5.0) >>> mdl.info() BTSettl2008 model with the following parmeters: Teff = 1000 K logg = 5.0 cm/s2 z = 0.0 fsed = nc cld = nc kzz = eq Smoothed to slit width 0.5 arcseconds >>> mdl = splat.loadModel(teff=2500,logg=5.0,model='burrows') Input value for teff = 2500 out of range for model set burrows06 Warning: Creating an empty Spectrum object
-
splat.model.
getModel
(*args, **kwargs)¶ - Purpose:
- Redundant routine with loadModel() to match syntax of getSpectrum()
-
splat.model.
loadInterpolatedModel
(*args, **kwargs)¶ - Purpose:
- Generates as spectral model with is interpolated between model parameter grid points. This routine is called by loadModel(), or it can be called on its own.
- Required Inputs:
param model: set of models to use; see options in loadModel() - Optional Inputs:
param: The parameters for loadModel() can also be used here. - Output:
- A SPLAT Spectrum object of the interpolated model with wavelength in microns and surfae fluxes in F_lambda units of erg/cm^2/s/micron.
Example:
>>> import splat >>> mdl = splat.loadModel(teff=1000,logg=5.0) >>> mdl.info() morley12 model with the following parmeters: Teff = 540 K logg = 4.7 cm/s2 z = 0.0 fsed = f3 cld = nc kzz = eq Smoothed to slit width 0.5 arcseconds
-
splat.model.
blackbody
(temperature, **kwargs)¶ This program is still in development
-
splat.model.
modelFitGrid
(spec, **kwargs)¶ Purpose: Fits a spectrum to a grid of atmosphere models, reports the best-fit and weighted average parameters, and returns either a dictionary with the best-fit model parameters or the model itself scaled to the optimal scaling factor. If spectrum is absolutely flux calibrated with the fluxcalibrate() method, the routine will also calculate the equivalent radii of the source.
Required inputs:
Parameters: spec – a Spectrum class object, which should contain wave, flux and noise array elements. Optional inputs:
Parameters: model – set of models to use ( set
andmodel_set
may also be used), from the available models given by loadModel().Parameters: stat – the statistic to use for comparing models to spectrum; can be any one of the statistics allowed in compareSpectra() routine (default = chisqr) Parameters: - nbest – sets the number of best-fit models to return (default = 1)
- weights – an array of the same length as the spectrum flux array, specifying the weight for each pixel (default: equal weighting)
- mask – an array of the same length as the spectrum flux array, specifying which data to include in comparison statistic as coded by 0 = good data, 1 = bad (masked). The routine generateMask() is called to create a mask, so parameters from that routine may be specified (default: no masking)
Parameters: - compute_radius – if set to True, force the computation of the radius based on the model scaling factor. This is automatically set to True if the input spectrum is absolutely flux calibrated (default = False)
- teff_range – set to the range of temperatures over which model fitting will be done (
temperature_range
andt_range
may also be used; default = full range of model temperatures) - logg_range – set to the range of surface gravities over which model fitting will be done (
gravity_range
andg_range
may also be used; default = full range of model temperatures) - z_range – set to the range of metallicities over which model fitting will be done (
metallicity_range
may also be used; default = full range of model temperatures) - return_model – set to True to return a Spectrum class of the best-fit model instead of a dictionary of parameters (default = False)
- return_mean_parameters – set to True a dictionary of mean parameters (default = False)
- return_all_parameters – set to True to return all of the parameter sets and fitting values (default = False)
- summary – set to True to report a summary of results (default = True)
- output – a string containing the base filename for outputs associated with this fitting routine (
file
andfilename
may also be used; default = ‘fit’) - plot – set to True to suppress plotting outputs (default = False)
- plot_format – specifes the file format for output plots (default = pdf)
- file_best_comparison – filename to use for plotting spectrum vs. best-fit model (default = ‘
OUTPUT
_best_comparison.``PLOT_FORMAT``’) - file_mean_comparison – filename to use for plotting spectrum vs. mean parameter model (default = ‘
OUTPUT
_mean_comparison.``PLOT_FORMAT``’)
In addition, the parameters for compareSpectra() , generateMask() and plotSpectrum() may be used; see SPLAT API for details.
Output:
Default output is a dictionary containing the best-fit model parameters: model name, teff, logg, z, fsed, kzz, cloud and slit, as well as the scaling factor for the model and comparison statistic. If the input spectrum is absolutely flux calibrated, radius is also returned. Alternate outputs include:
- a dictionary of the statistic-weighted mean parameters (
return_mean_parameters
= True) - a list of dictionaries containing all parameters and fit statistics (
return_all_parameters
= True) - a Spectrum class of the best-fit model scaled to the best-fit scaling (
return_model
= True)
Example: >>> import splat >>> import splat.model as spmod >>> sp = splat.Spectrum(shortname='1507-1627')[0] >>> sp.fluxCalibrate('2MASS J',12.32,absolute=True) >>> p = spmod.modelFitGrid(sp,teff_range=[1200,2500],model='Saumon',file='fit1507') Best Parameters to fit to BT-Settl (2008) models: $T_{eff}$=1800.0 K $log\ g$=5.0 dex(cm / s2) $[M/H]$=-0.0 dex $f_{sed}$=nc $cld$=nc $log\ \kappa_{zz}$=eq dex(cm2 / s) R=0.143324498969 solRad chi=4500.24997585 Mean Parameters: $T_{eff}$: 1800.0+/-0.0 K $log\ g$: 5.0+/-0.0 dex(cm / s2) Radius: 0.143324498969+/-0.0 solRad $[M/H]$: 0.0+/-0.0 dex
-
splat.model.
modelFitMCMC
(spec, **kwargs)¶ Purpose: Uses Metropolis-Hastings Markov Chain Monte Carlo method to compare a spectrum to atmosphere models. Returns the best estimate of whatever parameters are allowed to vary; can also compute the radius based on the scaling factor.
Parameters: - spec – Spectrum class object, which should contain wave, flux and noise array elements (required)
- nsamples – number of MCMC samples (optional, default = 1000)
- burn – the decimal fraction (0 to 1) of the initial steps to be discarded (optional; default = 0.1; alternate keywords
initial_cut
) - set – set of models to use; see loadModel for list (optional; default = ‘BTSettl2008’; alternate keywords
model
,models
) - verbose – give lots of feedback (optional; default = False)
- showRadius – set to True so evaluate radius (optional; default = False unless spec is absolute flux calibrated)
Also takes commands for compareSpectra
Parameters: - output – filename or filename base for output files (optional; alternate keywords
filename
,filebase
) - savestep – indicate when to save data output; e.g.
savestep = 10
will save the output every 10 samples (optional, default =nsamples
/10) - dataformat (optional, default = 'ascii.csv') – output data format type
- initial_guess (optional, default = array of random numbers within allowed ranges) – array including initial guess of the effective temperature, surface gravity and metallicity of
spec
. Can also set individual guesses of spectral parameters by using initial_temperature or initial_teff, initial_gravity or initial_logg, and initial_metallicity or initial_z. - ranges (optional, default = depends on model set) – array of arrays indicating ranges of the effective temperature, surface gravity and metallicity of the model set. Can also set individual ranges of spectral parameters by using temperature_range or teff_range, gravity_range or logg_range, and metallicity_range or z_range.
- step_sizes (optional, default = [50, 0.25, 0.1]) – an array specifying step sizes of spectral parameters. Can also set individual step sizes by using temperature_step or teff_step, gravity_step or logg_step, and metallicity_step or z_step.
- nonmetallicity (optional, default = False) – if True, sets metallicity = 0
- addon (optional, default = False) – reads in prior calculation and starts from there. Allowed object types are tables, dictionaries and strings.
- evolutionary_model (optional, default = 'Baraffe') –
set of evolutionary models to use. See Brown Dwarf Evolutionary Models page for more details. Options include:
- ‘baraffe’: Evolutionary models from Baraffe et al. (2003).
- ‘burrows’: Evolutionary models from Burrows et al. (1997).
- ‘saumon’: Evolutionary models from Saumon & Marley (2008).
- emodel (optional, default = 'Baraffe') – the same as
evolutionary_model
Example: >>> import splat >>> import splat.model as spmod >>> sp = splat.getSpectrum(shortname='1047+2124')[0] # T6.5 radio emitter >>> parameters = spmod.modelFitMCMC(sp,initial_guess=[900,5.0,0.0],nsamples=1000)
-
splat.model.
modelFitEMCEE
(spec, **kwargs)¶ Purpose: Uses the
emcee
package by Dan Foreman-Mackey et al. to perform Goodman & Weare’s Affine Invariant Markov chain Monte Carlo (MCMC) Ensemble sampler to fit a spectrum to a set of atmosphere models. Returns the best estimate of the effective temperature, surface gravity, and (if selected) metallicity. Includes an estimate of the time required to run, prompts user if they want to proceed, and shows progress with iterative saving of outcomesParameters: - spec – Spectrum class object, which should contain wave, flux and noise array elements (required)
- nwalkers – number of MCMC walkers, should be at least 20 (optional, default = 20)
- nsamples – number of MCMC samples (optional, default = 500)
- threads – number of threads to run on a multiprocessing machine (optional, default = 1)
- burn_fraction – the fraction of the initial steps to be discarded; e.g., if
burn_fraction = 0.2
, the first 20% of the samples are discarded. (optional, default = 0.5) - initial_guess – array including initial guess of the model parameters. Can also set individual guesses of spectral parameters by using initial_temperature, initial_teff, or t0; initial_gravity, initial_logg or g0; and initial_metallicity, initial_z or z0 (optional, default = array of random numbers within allowed ranges)
- limits – list of 2-element arrays indicating ranges of the model parameters to limit the parameter space. Can also set individual ranges of spectral parameters by using temperature_range, teff_range or t_range; gravity_range, logg_range or g_range; and metallicity_range or z_range (optional, default = depends on model set)
- prior_scatter – array giving the widths of the normal distributions from which to draw prior parameter values (optional, default = [25,0.1,0.1])
- model (optional, default = 'BTSettl2008') –
set of models to use (
set
andmodel_set
do the same); options include:- ‘BTSettl2008’: model set with effective temperature of 400 to 2900 K, surface gravity of 3.5 to 5.5 and metallicity of -3.0 to 0.5 from Allard et al. (2012)
- ‘burrows06’: model set with effective temperature of 700 to 2000 K, surface gravity of 4.5 to 5.5, metallicity of -0.5 to 0.5, and sedimentation efficiency of either 0 or 100 from Burrows et al. (2006)
- ‘morley12’: model set with effective temperature of 400 to 1300 K, surface gravity of 4.0 to 5.5, metallicity of 0.0 and sedimentation efficiency of 2 to 5 from Morley et al. (2012)
- ‘morley14’: model set with effective temperature of 200 to 450 K, surface gravity of 3.0 to 5.0, metallicity of 0.0 and sedimentation efficiency of 5 from Morley et al. (2014)
- ‘saumon12’: model set with effective temperature of 400 to 1500 K, surface gravity of 3.0 to 5.5 and metallicity of 0.0 from Saumon et al. (2012)
- ‘drift’: model set with effective temperature of 1700 to 3000 K, surface gravity of 5.0 to 5.5 and metallicity of -3.0 to 0.0 from Witte et al. (2011)
- radius (optional, default = False) – set to True to calculate and returns radius of object [NOT CURRENT IMPLEMENTED]
- save (optional, default = True) – save interim results to a .dat file based on output filename
- output (optional, default = None) – base filename for output (
filename
andoutfile
do the same); outputs will include (each can be set individually with associated keywords): -filename_iterative.dat
: interative saved data -filename_summary.txt
: summary of results -filename_corner.eps
: corner plot of parameters -filename_comparison.eps
: plot spectrum compared to best fit model - plot_format – file type for diagnostic plots
- noprompt (optional, default = False) – don’t prompt user to continue of emcee run will be > 10 minutes
- verbose (optional, default = False) – give lots of feedback
In addition, the parameters for compareSpectra, generateMask_, plotSpectrum_; see SPLAT API for details.
- Note: modelfitEMCEE requires external packages:
Example: >>> import splat >>> sp = splat.Spectrum(shortname='1507-1627')[0] >>> spt,spt_e = splat.classifyByStandard(sp) >>> teff,teff_e = splat.typeToTeff(spt) >>> result = modelFitEMCEE(sp,t0=teff,g0=5.0,fit_metallicity=False, >>> nwalkers=50,nsamples=500,output='/Users/adam/test_modelfitEMCEE') Estimated time to compute = 9228 seconds = 153.8 minutes = 2.56 hours = 0.11 days Do you want to continue? [Y/n]: Progress: [**************************************************]
Results are saved in test_modelfitEMCEE_interative.dat, *_chains.pdf, *_comparison.pdf, *_corner.pdf, and *_summary.txt
Evolutionary Model Routines¶
-
splat.utilities.
checkEvolutionaryModelName
(model)¶ - Purpose:
- Checks that an input model name is one of the available evolutionary models, including a check of alternate names
- Required Inputs:
param: model: A string containing the evolutionary model to be checked. This should be one of the models listed in splat.EVOLUTIONARY_MODELS.keys() - Optional Inputs:
- None
- Output:
- A string containing SPLAT’s default name for a given model set, or False if that model set is not present
Example:
>>> import splat >>> print(splat.checkEvolutionaryModelName('burrows')) burrows01 >>> print(splat.checkEvolutionaryModelName('allard')) False
-
splat.evolve.
loadEvolModel
(*model, **kwargs)¶ Purpose: Reads in the evolutionary model parameters for the models listed below, which are used to interpolate parameters in modelParameters(). Available models are:
baraffe : Models from Baraffe et al. (2003) for 1 Myr < age < 10 Gyr, 0.005 Msol < mass < 0.1 Msol, and solar metallicity (COND dust prescription)
baraffe15 : Models from Baraffe et al. (2015) for 1 Myr < age < 10 Gyr, 0.01 Msol < mass < 1.4 Msol, and solar metallicity
burrows : Models from Burrows et al. (2001) for 1 Myr < age < 10 Gyr, 0.005 Msol < mass < 0.2 Msol, and solar metallicity
saumon : Models from Saumon et al. (2003) for 3 Myr < age < 10 Gyr, 0.002 Msol < mass < 0.085 Msol, although mass and age ranges vary as the maximum temperature for the models is 2500 K. For these models there are additional options:
- metallicity = solar, +0.3, or -0.3
- cloud = cloud-free, hybrid, f2 (sub- and super-solar metallicities are only cloud-free)
Parameter units (in astropy convention) are:
- masses: Solar masses
- ages: Gyr
- temperature: K
- gravity: log10 of cm/s/s
- luminosity: log10 of Solar luminosities
- radius: Solar radii
Models are contained in SPLAT’s reference/EvolutionaryModels folder.
Required Inputs:
Param: model: string of the name of the evolutionary model set to be used; can be baraffe (default), burrows, or saumon Optional Inputs:
Param: metallicity: for Saumon models, this is the metallicity assumed, and can be a string or integer. Allowed values are 0 (or solar = default), -0.3 (or subsolar) or 0.3 (or supersolar)
Param: cloud: for Saumon models, this is the desired cloud prescription, and is a string:
- no clouds: cloud = nocloud, cloud-free or nc (default)
- hybrid cloud prescription: cloud = hybrid
- f2 cloud prescription: cloud = f2
Output:
Dictionary containing keywords mass, age, temperature, luminosity, gravity, and radius, each linked to the evolutionary parameters retrieved.
Example: >>> import splat >>> p = splat.loadEvolModel('saumon',metallicity=-0.3,cloud='nc') You are using saumon's models. >>> for k in list(p.keys()): print('{}: {}'.format(k, p[k][12])) age: 0.15 mass: [ 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01 0.011 0.012 0.013 0.014 0.015 0.016 0.017 0.018 0.019 0.02 0.022 0.024 0.026 0.028 0.03 0.033 0.035 0.038 0.04 0.043 0.045 0.048 0.05 0.053] temperature: [ 353. 418. 471. 523. 585. 642. 695. 748. 806. 893. 1146. 1228. 1114. 1113. 1148. 1183. 1227. 1270. 1316. 1402. 1489. 1572. 1654. 1739. 1853. 1930. 2030. 2096. 2187. 2240. 2316. 2362. 2426.] gravity: [ 3.576 3.746 3.871 3.972 4.056 4.128 4.191 4.246 4.296 4.335 4.337 4.368 4.437 4.479 4.512 4.543 4.571 4.597 4.621 4.665 4.704 4.74 4.772 4.8 4.839 4.861 4.892 4.909 4.931 4.947 4.966 4.978 4.996] luminosity: [-6.691 -6.393 -6.185 -6.006 -5.815 -5.658 -5.527 -5.404 -5.277 -5.098 -4.628 -4.505 -4.709 -4.724 -4.675 -4.627 -4.568 -4.51 -4.45 -4.342 -4.24 -4.146 -4.058 -3.969 -3.856 -3.781 -3.69 -3.628 -3.546 -3.5 -3.432 -3.393 -3.34 ] radius: [ 0.1206 0.1214 0.1214 0.1209 0.1202 0.1195 0.1189 0.1182 0.1178 0.1181 0.123 0.1235 0.1184 0.1167 0.1161 0.1154 0.1151 0.1148 0.1146 0.1142 0.1139 0.1139 0.1138 0.1141 0.1144 0.115 0.1155 0.1163 0.1174 0.118 0.1193 0.12 0.121 ]
-
splat.evolve.
modelParameters
(*model, **kwargs)¶ Purpose: Retrieves the evolutionary model parameters given two of the following parameters: mass, age, temperature, luminosity, gravity, or radius. The inputs can be individual values or arrays. Using the input parameters, the associated evolutionary model parameters are computed through log-linear interpolation of the original model grid. Parameters that fall outside the grid return nan. Required Inputs:
Param: model: Either a string of the name of the evolutionary model set, which can be one of baraffe (default), burrows, or saumon; or a dictionary output from loadEvolModel() containing model parameters. and two (2) of the following:
Param: mass: input value of list of values for mass (can also be masses or m) Param: age: input value of list of values for age (can also be ages, time or a) Param: temperature: input value of list of values for temperature (can also be temperatures, teff, temp or t) Param: gravity: input value of list of values for gravity (can also be gravities, grav, logg or g) Param: luminosity: input value of list of values for luminosity (can also be luminosities, lum, lbol or l) Param: radius: input value of list of values for radius (can also be radii, rad and r) Optional Inputs:
Param: Parameters for loadEvolModel() may also be used. Output:
Dictionary containing keywords mass, age, temperature, luminosity, gravity, and radius, each linked to the evolutionary parameters retrieved.
Example: >>> import splat, numpy >>> masses = numpy.random.uniform(0.01,0.1,20) >>> ages = numpy.random.uniform(0.01,10,20) >>> p = splat.modelParameters('baraffe',mass=masses,age=ages) You are using baraffe's models. >>> print(p.temperature) [ 2502.90132332 2818.85920306 1002.64227134 1330.37273021 1192.86976417<PHONE_NUMBER>8 2604.99966013 1017.03307609 1774.18267474 1675.12181635 2682.9697321 2512.45223777<PHONE_NUMBER>4 2066.19972036<PHONE_NUMBER>6 2264.93051445 2767.85660557<PHONE_NUMBER>6<PHONE_NUMBER>7 2669.27152307] K
-
splat.evolve.
plotModelParameters
(parameters, xparam, yparam, **kwargs)¶ Purpose: Plots pairs of physical star parameters and optionally compares to evolutionary model tracks. Required Inputs:
Param: parameters: dictionary or nested set of two arrays containing parameters to be plotted. For dictionary, keywords should include the xparameter and yparameter strings to be plotted. Values associated with keywords can be single numbers or arrays Param: xparam: string corresponding to the key in the parameters dictionary to be plot as the x (independent) variable. Param: yparam: string corresponding to the key in the parameters dictionary to be plot as the y (dependent) variable. Optional Inputs:
Param: showmodel: set to True to overplot evolutionary model tracks from model (default = True) Param: model: either a string of the name of the evolutionary model set, one of baraffe (default), burrows, or saumon; or a dictionary output from loadEvolModel() containing model parameters. Param: tracks: string indicating what model tracks to show; can either be mass (default) or age Param: file: name of file to output plot (output can also be used) Param: show: set to True to show the plot onscreen (default = True) Param: figsize: a two-element array defining the figure size (default = [8,6]) Param: color: color of data symbols (default = ‘blue’) Param: marker: matplotlib marker type for data symbols (default = ‘o’) Param: xlabel: string overriding the x-axis label (default = parameter name and unit) Param: ylabel: string overriding the y-axis label (default = parameter name and unit) Param: title: string specifying plot title (no title by default) Param: tight: set to True to tighten plot to focus on the data points (default = True) Output:
A matplotlib plot object. Optionally, can also show plot on screen or output plot to a file.
Example: >>> import splat, numpy >>> age_samp = 10.**numpy.random.normal(numpy.log10(1.),0.3,50) >>> mass_samp = numpy.random.uniform(0.001,0.1,50) >>> p = splat.modelParameters('baraffe',age=age_samp,mass=mass_samp) >>> splat.plotModelParameters(p,'age','temperature',showmodels=True,model='baraffe',show=True) [plot of temperature vs age for 50 data points with baraffe models overplotted]
-
splat.evolve.
simulatePopulation
(**kwargs)¶
-
splat.evolve.
simulateAges
(num, **kwargs)¶ Purpose: Generates a distribution of ages based on the defined input distribution. Required Inputs:
Param: num: number of ages to generate Optional Inputs:
Param: age_range: range of ages to draw from (default = [0.1,10.]); can also specify range, minage or min, and maxage or max Param: distribution: either a string set to one of the following to define the type of age distribution (or reverse star formation rate) desired: * uniform: uniform distribution (default) * exponential: exponential age distribution, P(t) ~ e^(beta x t). You can specify the parameters beta or tau = 1/beta, or set distribution
to aumer or miller * double_exponential: double exponential age distribution, P(t) ~ Ae^(lambda x t) + e^(beta x t). You can specify the parameters beta, lambda and a or setdistribution
to aumer_double (default parameters) * cosmic or rujopakarn: cosmic age distribution with P(t) ~ (1+z(t))^alpha, where z is the redshift, which is converted to time using the Planck 2015 cosmology. You can specify the parameter alpha or setdistribution
to rujopakarn (default parameters) * peaked: age distribution that peaks at some early time, written in the form P(t) ~ (t-t0)/(t^2+t1^2)^2. You can specify the parameters t0 and t1 or setdistribution
to aumer_peaked or just_peaked * aumer or aumer_exponential: exponential age distribution with parameters from Aumer & Binney (2009): beta = 0.117 * aumer_double: double exponential age distribution with parameters from Aumer & Binney (2009): beta = 0.348, lambda = 2.0, a = 1.e-8 * aumer_peaked: peaked age distribution with parameters from Aumer & Binney (2009): t0 = XXX, t1 = XXX * just or just_exponential: exponential age distribution with parameters from Just & Jahriess (2010): beta = 0.125 * `just_peaked_a: peaked age distribution with parameters from Just & Jahriess (2010) Model A: t0 = 5.6, t1 = 8.2 * just_peaked or just_peaked_b: peaked age distribution with parameters from Just & Jahriess (2010) Model B: t0 = 1.13, t1 = 7.8 * miller: exponential age distribution with parameters from Miller & Scalo (1979): beta = max age / 2 * rujopakarn: cosmic age distribution with parameters from Rujopakarn et al. (2010): beta = max age / 2 * input: user specified age distribution or star formation history;input
must be set to a 2 x N array specifying age and distributionParam: distribution can also be set to a 2 x N array specifying an age distribution or star formation history; the first vector should be the ages for the function and the second vector the distribution function Param: parameters: dictionary containing the parameters for the age distribution/star formation model being used; options include: * alpha: power law factor for cosmic age distribution * beta: power factor in exponential age distribution; positive beta implies a star formation rate that decreases with time * lambda: second power factor in double exponential age distribution; positive lambda implies a star formation rate that decreases with time * a: relative scale factor for second exponential in double exponential age distribution * tau: 1/beta scale factor in exponential age distribution * t0 and t1: parameters for peaked age distribution Param: sfh: set to True if distribution is a star formation history rather than an age distribution (default = False) Param: verbose: Give feedback (default = False) Output:
An array of ages drawn from the desired distribution in units of Gyr
Example: >>> import splat >>> import matplotlib.pyplot as plt >>> ages = splat.simulateAges(10000,distribution='aumer',age_range=[0.3,8.0]) >>> plt.hist(ages) [histogram of ages in range 0.3-8.0 Gyr]
-
splat.evolve.
simulateMasses
(num, **kwargs)¶ Purpose: Generates a distribution of masses based on the defined input distribution. Required Inputs:
Param: num: number of masses to generate Optional Inputs:
Param: mass_range: range of masses to draw from (default = [0.01,0.1]); can also specify range
,minmass
ormin
, andmaxmass
ormax
Param: distribution: can be a string set to one of the following to define the type of mass distribution to sample: * uniform: uniform distribution (default) * powerlaw or power-law: single power-law distribution, P(M) ~ M^-alpha. You must specify the parameter alpha or set distribution
to TBD * broken-powerlaw’ or `broken-power-law: a broken power-law distribution; segments are specified by the parameters `alpha (N array of numbers) for the slopes and ranges (N array of 2-element arrays) for the ranges over which these slopes occur; if the scales parameter is also included, the power-law segments are scaled by these factors; otherwise, the segments are forced to be continuous. You can also setdistribution
to kroupa * ‘lognormal` or log-normal: log normal distribution, P(M) ~ exp(-0.5*(M-M0)^2/sigmaM^2). You must specify the parameters M0 and sigmaM or setdistribution
to chabrier (default parameters) * kroupa: broken power-law distribution with parameters from Kroupa (2001): `http://adsabs.harvard.edu/abs/2001MNRAS.322..231K`_ * chabrier: lognormal distribution with parameters from Chabrier (2003): `http://adsabs.harvard.edu/abs/2003PASP..115..763C`_Param: distribution can also be set to a 2 x N array specifying the mass distribution; the first vector should be the masses for the distribution function and the second vector the distribution function itself Param: parameters: dictionary containing the parameters for the age distribution/star formation model being used; options include: * alpha: exponent for power-law distribution, or array of numbers giving power-law factors for broken power-law distribution * range: array of 2-element arrays specifying the masses (in units of solar masses) over which the broken-law slopes are defined * scales: array of numbers specifying relative scaling between the segments in the broken-law distribution * M0 and `sigmaM: parameters for lognormal distribution in units of solar masses Param: verbose: Give feedback (default = False) Output:
An array of masses drawn from the desired distribution in units of solar masses
Example: >>> import splat >>> import matplotlib.pyplot as plt >>> masses = splat.simulateMasses(10000,distribution='power-law',parameters={'alpha': 0.5},mass_range=[0.01,0.08]) } >>> plt.hist(masses) [histogram of masses in range 0.01-0.08 solar masses]
-
splat.evolve.
simulateMassRatios
(num, **kwargs)¶ Purpose: Generates a distribution of mass ratios (q = M2/M1) based on the defined input distribution. It is assumed that q <= 1 Required Inputs:
param: num: number of masses to generate Optional Inputs:
param: q_range: range of masses to draw from (default = [0.1,1.0]); can also specify range
,minq
ormin
, andmaxq
ormax
param: distribution: can be a string set to one of the following to define the type of mass distribution to sample: * uniform: uniform distribution (default) * powerlaw or power-law: single power-law distribution, P(M) ~ M^-alpha. You must specify the parameter alpha or set distribution
to TBD * allen: power-law distribution with gamma = -1.8 based on Allen (2007), ApJ 668, 492 * burgasser: power-law distribution with gamma = -4.2 based on Burgasser et al (2006), ApJS 166, 585param: parameters: dictionary containing the parameters for the age distribution/star formation model being used; options include: * gamma: exponent for power-law distribution param: verbose: Give feedback (default = False) Output:
An array of mass ratios drawn from the desired distribution
Example: >>> import splat >>> import matplotlib.pyplot as plt >>> q = splat.simulateMassRatios(100,distribution='allen'),q_range=[0.2,1.0]) } >>> plt.hist(q) [histogram of mass ratios in the range 0.2-1.0 solar masses]
-
splat.evolve.
simulateSpatialDistribution
(**kwargs)¶
-
splat.evolve.
simulateBinaryOrbits
(**kwargs)¶
-
splat.evolve.
simulateGalacticOrbits
(**kwargs)¶
-
splat.evolve.
simulateKinematics
(**kwargs)¶
-
splat.evolve.
simulatePhotometry
(**kwargs)¶
Specialty Packages¶
EUCLID Analysis Routines¶
BibTeX Routines¶
-
splat.citations.
bibTexParser
(bib_tex, **kwargs)¶ Purpose: Parses a bibtex segment and returns a dictionary of parameter fields
Required parameters: param bib_tex: String containing bibtex data in standard format Optional parameters: None
Output: A dictionary containing the parsed bibtex information
-
splat.citations.
citeURL
(bib_dict, **kwargs)¶ Purpose: Generate the URL corresponding to a citation, based on the bibcode and NASA ADS syntax
Required parameters: param bib_tex: Dictionary output from bibTexParser, else a bibcode that is fed into bibTexParser Optional parameters: None
Output: A string of the format
Burgasser, A. J., Cruz, K. L., Cushing, M., et al. SpeX Spectroscopy of Unresolved Very Low Mass Binaries. I. Identification of 17 Candidate Binaries Straddling the L Dwarf/T Dwarf Transition. ApJ 710, 1142 (2010)
-
splat.citations.
getBibTex
(bibcode, **kwargs)¶ - Purpose
- Takes a bibcode and returns a dictionary containing the bibtex information; looks either in internal SPLAT
- or user-supplied bibfile, or seeks online. If nothing found, gives a soft warning and returns False
Note: Currently not functional
Required parameters: param bibcode: Bibcode string to look up (e.g., ‘2014ApJ...787..126L’) Optional parameters: param biblibrary: Filename for biblibrary to use in place of SPLAT internal one type string: optional, default = ‘’ param online: If True, go directly online; if False, do not try to go online type logical: optional, default = null Output: - A dictionary containing the bibtex fields, or False if not found
-
splat.citations.
getBibTexOnline
(bibcode)¶ - Purpose
- Takes a bibcode and searches for the bibtex information online through NASA ADS; requires user to be online.
- If successful, returns full bibtex string block; otherwise False.
Required parameters: param bibcode: Bibcode string to look up (e.g., ‘2014ApJ...787..126L’) Optional parameters: param bibfile: Filename for bibfile to use in place of SPLAT internal one type string: optional, default = ‘’ param online: If True, go directly online; if False, do not try to go online type logical: optional, default = null Output: - A string block of the basic bibtex information
-
splat.citations.
veryShortRef
(bib_dict, **kwargs)¶ Purpose: Takes a bibtex dictionary and returns a short (in-line) version of the citation
Required parameters: param bib_tex: Dictionary output from bibTexParser, else a bibcode that is fed into bibTexParser Optional parameters: None
Output: A string of the format
Burgasser et al. (2006)
-
splat.citations.
shortRef
(bib_dict, **kwargs)¶ Purpose: Takes a bibtex dictionary and returns a short (in-line) version of the citation
Required parameters: param bib_tex: Dictionary output from bibTexParser, else a bibcode that is fed into bibTexParser Optional parameters: None
Output: A string of the format
Burgasser, A. J., et al. (2006, ApJ, 710, 1142)
-
splat.citations.
longRef
(bib_dict, **kwargs)¶ Purpose: Takes a bibtex dictionary and returns a long (in-line) version of the citation
Required parameters: param bib_tex: Dictionary output from bibTexParser, else a bibcode that is fed into bibTexParser Optional parameters: None
Output: A string of the format
Burgasser, A. J., Cruz, K. L., Cushing, M., et al. SpeX Spectroscopy of Unresolved Very Low Mass Binaries. I. Identification of 17 Candidate Binaries Straddling the L Dwarf/T Dwarf Transition. ApJ 710, 1142 (2010)
Astroquery-based Data Access¶
-
splat.database.
getPhotometry
(coordinate, **kwargs)¶ - Purpose
- Downloads photometry for a source by coordinate using astroquery
- Required Inputs:
param: coordinate: Either an astropy SkyCoord or a variable that can be converted into a SkyCoord using properCoordinates()
- Optional Inputs:
param radius: Search radius, nominally in arcseconds although this can be changed by passing an astropy.unit quantity (default = 30 arcseconds) param catalog: Catalog to query, which can be set to the Vizier catalog identifier code or to one of the following preset catalogs: * ‘2MASS’ (or set ``2MASS``=True): the 2MASS All-Sky Catalog of Point Sources (Cutri et al. 2003), Vizier id II/246 * ‘SDSS’ (or set ``SDSS``=True): the The SDSS Photometric Catalog, Release 9 (Adelman-McCarthy et al. 2012), Vizier id V/139 * ‘WISE’ (or set ``WISE``=True): the WISE All-Sky Data Release (Cutri et al. 2012), Vizier id II/311 * ‘ALLWISE’ (or set ``ALLWISE``=True): the AllWISE Data Release (Cutri et al. 2014), Vizier id II/328 * ‘VISTA’ (or set ``VISTA``=True): the VIKING catalogue data release 1 (Edge et al. 2013), Vizier id II/329 * ‘CFHTLAS’ (or set ``CFHTLAS``=True): the CFHTLS Survey (T0007 release) by (Hudelot et al. 2012), Vizier id II/317 * ‘DENIS’ (or set ``DENIS``=True): the DENIS DR3 (DENIS Consortium 2005), Vizier id B/denis/denis * ‘UKIDSS’ (or set ``UKIDSS``=True): the UKIDSS-DR8 LAS, GCS and DXS Surveys (Lawrence et al. 2012), Vizier id II/314 * ‘LEHPM’ (or set ``LEHPM``=True): the Liverpool-Edinburgh High Proper Motion Catalogue (Pokorny et al. 2004), Vizier id J/A+A/421/763 * ‘SIPS’ (or set ``SIPS``=True): the Southern Infrared Proper Motion Survey (Deacon et al 2005), Vizier id J/A+A/435/363 * ‘UCAC4’ (or set ``UCAC4``=True): the UCAC4 Catalogue (Zacharias et al. 2012), Vizier id I/322A * ‘USNOB’ (or set ``USNO``=True): the USNO-B1.0 Catalog (Monet et al. 2003), Vizier id I/284 * ‘LSPM’ (or set ``LSPM``=True): the LSPM-North Catalog (Lepine et al. 2005), Vizier id I/298 * ‘GAIA’ (or set ``GAIA``=True): the GAIA DR1 Catalog (Gaia Collaboration et al. 2016), Vizier id I/337 param: sort: String specifying the parameter to sort the returned SIMBAD table by; by default this is the offset from the input coordinate (default = ‘sep’) param: nearest: Set to True to return on the single nearest source to coordinate (default = False) param: verbose: Give feedback (default = False) - Output:
- An astropy Table instance that contains data from the Vizier query, or a blank Table if no sources are found
Example:
>>> import splat >>> import splat.database as spd >>> from astropy import units as u >>> c = splat.properCoordinates('J053625-064302') >>> v = spd.querySimbad(c,catalog='SDSS',radius=15.*u.arcsec) >>> print(v) _r _RAJ2000 _DEJ2000 mode q_mode cl ... r_E_ g_J_ r_F_ i_N_ sep arcs deg deg ... mag mag mag mag arcs ------ ---------- ---------- ---- ------ --- ... ---- ---- ---- ---- ------ 7.860 84.105967 -6.715966 1 3 ... -- -- -- -- 7.860 14.088 84.108113 -6.717206 1 6 ... -- -- -- -- 14.088 14.283 84.102528 -6.720843 1 + 6 ... -- -- -- -- 14.283 16.784 84.099524 -6.717878 1 3 ... -- -- -- -- 16.784 22.309 84.097988 -6.718049 1 + 6 ... -- -- -- -- 22.309 23.843 84.100079 -6.711999 1 + 6 ... -- -- -- -- 23.843 27.022 84.107504 -6.723965 1 + 3 ... -- -- -- -- 27.022
-
splat.database.
querySimbad
(variable, **kwargs)¶ - Purpose
- Queries Simbad using astroquery to grab information about a source
- Required Inputs:
param: variable: Either an astropy SkyCoord object containing position of a source, a variable that can be converted into a SkyCoord using spl.properCoordinates(), or a string name for a source.
- Optional Inputs:
param: radius: Search radius, nominally in arcseconds although can be set by assigning and astropy.unit value (default = 30 arcseconds) param: sort: String specifying the parameter to sort the returned SIMBAD table by; by default this is the offset from the input coordinate (default = ‘sep’) param: reject_type: Set to string or list of strings to filter out object types not desired. Useful for crowded fields (default = None) param: nearest: Set to True to return on the single nearest source to coordinate (default = False) param: iscoordinate: Specifies that input is a coordinate of some kind (default = False) param: isname: Specifies that input is a name of some kind (default = False) param: clean: Set to True to clean the SIMBAD output and reassign to a predefined set of parameters (default = True) param: verbose: Give lots of feedback (default = False) - Output:
- An astropy Table instance that contains data from the SIMBAD search, or a blank Table if no sources found
Example:
>>> import splat >>> from astropy import units as u >>> c = spl.properCoordinates('J053625-064302') >>> q = spl.querySimbad(c,radius=15.*u.arcsec,reject_type='**') >>> print(q) NAME OBJECT_TYPE OFFSET ... K_2MASS K_2MASS_E ----------------------- ----------- ------------- ... ------- --------- BD-06 1253B Star 4.8443894429 ... [SST2010] 3 Star 5.74624887682 ... 18.36 0.1 BD-06 1253 Ae* 7.74205447776 ... 5.947 0.024 BD-06 1253A ** 7.75783861347 ... 2MASS J05362590-0643020 brownD* 13.4818185612 ... 12.772 0.026 2MASS J05362577-0642541 Star 13.983717577 ...
-
splat.database.
queryVizier
(coordinate, **kwargs)¶
Search