API¶
SPLAT Classes¶
Spectrum¶
-
class
splat.
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
-
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() 115.96374031163553
-
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 ...
-
flamToFnu
()¶ Purpose: Converts flux density from F_lambda to F_nu, the latter in 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.flamToFnu() >>> sp.flux.unit Unit("Jy")
-
fluxCalibrate
(filter, 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)>
-
fnuToFlam
()¶ Purpose: Converts flux density from F_nu to F_lambda, the latter in 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.flamToFnu() >>> sp.flux.unit Unit("Jy") >>> sp.fnuToFlam() >>> sp.flux.unit Unit("erg / (cm2 micron s)")
-
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
(**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)>
-
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
-
smoothToResolution
(resolution, **kwargs)¶ Purpose: Smoothes a spectrum to a constant or resolution (smooth in velocity space). Changes spectrum directly. Note that no smoothing is done if requested resolution is greater than the current resolution
Parameters: - resolution (required) – number giving the desired resolution
- 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.
- overscale (optional, default = 10.) – used for computing number of samples in the window
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.resolution() 120 >>> sp.computeSN() 21.550974 >>> sp.smoothToResolution(50) >>> sp.resolution() 50 >>> sp.computeSN() 49.459522314460855
-
smoothToSlitPixelWidth
(width, **kwargs)¶ Purpose: Smoothes a spectrum to a constant slit pixel width (smooth in pixel space). Changes spectrum directly. Note that no smoothing is done if requested width is greater than the current slit width.
Parameters: - width (required) – number giving the desired smoothing scale in pixels
- 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.
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.slitpixelwidth 3.33 >>> sp.resolution 120 >>> sp.computeSN() 105.41789 >>> sp.smoothToSlitPixelWidth(10) >>> sp.slitpixelwidth 10 >>> sp.resolution 39.96 >>> sp.computeSN() 235.77536310249229
-
smoothToSlitWidth
(width, **kwargs)¶ Purpose: Smoothes a spectrum to a constant slit angular width (smooth in dispersion space). Changes spectrum directly. Note that no smoothing is done if requested width is greater than the current slit width.
Parameters: - width (required) – number giving the desired smoothing scale in arcseconds
- 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.
Output: maximum flux (with units)
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] >>> sp.slitwidth 0.4995 >>> sp.resolution 120 >>> sp.computeSN() 105.41789 >>> sp.smoothToSlitWidth(2.0) >>> sp.slitwidth 2.0 >>> sp.resolution 29.97 >>> sp.computeSN() 258.87135134070593
-
surface
(radius)¶ Purpose: Convert to surface fluxes given a radius, assuming at absolute fluxes Note
Unfinished
-
trim
(range, **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>]
SPLAT Routines¶
Database Access¶
-
splat.
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.
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_db.
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 splat.keySource(10001) SOURCE_KEY NAME DESIGNATION ... NOTE SELECT ---------- ------------------------ ----------------- ... ---- ------ 10001 SDSS J000013.54+255418.6 J00001354+2554180 ... True >>> print splat.keySource([10105, 10623]) SOURCE_KEY NAME DESIGNATION ... NOTE SELECT ---------- ---------------------- ----------------- ... ---- ------ 10105 2MASSI J0103320+193536 J01033203+1935361 ... True 10623 SDSS J09002368+2539343 J09002368+2539343 ... True >>> print splat.keySource(1000001) No sources found with source key 1000001 False
-
splat_db.
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 splat.keySpectrum(10001) DATA_KEY SOURCE_KEY DATA_FILE ... COMPANION COMPANION_NAME NOTE_2 -------- ---------- ---------------- ... --------- -------------- ------ 10001 10443 10001_10443.fits ... >>> print splat.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 splat.keySpectrum(1000001) No spectra found with spectrum key 1000001 False
-
splat_db.
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 = True) – sort results based on Right Ascension
- list (optional, default = False) – if True, return just a list of the data files (can be done with searchLibrary as well)
- 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.
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.
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¶
-
splat.
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) (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.
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.
- sp – required
- sptrange (optional, default = ['M0','T9']) – Set to the spectral type range over which comparisons should be made, can be a two-element array of strings or numbers
- 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
- 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 = True) – Set to True to return the best fit standard type
- average (optional, default = False) – Set to True to return an chi-square weighted type only
- compareto (optional, default = None) – Set to the single standard (string or number) you want to compare to
- 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) – Set to True to give extra feedback
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.
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 136.830522173 SDSS J001608.44-004302.3 L5.5 15468.6209466 274.797693706 2MASSI J0028394+150141 L4.5 63696.1897668 187.266152375 ... 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.
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.
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.
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)
Spectrophotometry¶
-
splat.
filterInfo
()¶ Purpose: Prints out the current list of filters in the SPLAT reference library.
-
splat.
filterMag
(sp, filter, *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 >>> sp = splat.getSpectrum(shortname='1507-1627')[0] >>> sp.fluxCalibrate('2MASS J',14.5) >>> splat.filterMag(sp,'MKO J') (14.345894376898123, 0.027596454828421831)
-
splat.
filterProperties
(filter, **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 ...
Other Spectral Analyses¶
-
splat.
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
-
splat.
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.
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.
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.
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.
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.
typeToTeff
(input, **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, 100.00007874571999) >>> print splat.typeToTeff(20, unc = 0.3, ref = 'golimowski') (2305.7500497902788, 127.62548366132124)
-
splat.
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') (116.36999172188771, 33.124820555524224)
Conversion Routines¶
-
splat.
caldateToDate
(d)¶ Purpose: Convert from numeric date to calendar date, and vice-versa.
Parameters: d – A numeric date of the format ‘20050412’, or a date in the calendar format ‘2005 Jun 12’
Example: >>> import splat >>> caldate = splat.dateToCaldate('20050612') >>> print caldate 2005 Jun 12 >>> date = splat.caldateToDate('2005 June 12') >>> print date 20050612
-
splat.
dateToCaldate
(d)¶ Purpose: Converts numeric date to calendar date Parameters: date – String in the form ‘YYYYMMDD’ Output: Date in format YYYY MMM DD Example: >>> import splat >>> splat.dateToCaldate('19940523') 1994 May 23
-
splat.
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.
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.
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.
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.
properCoordinates
(c)¶ 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.
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
Plotting Routines¶
-
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
- 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
- legend, legends, label or labels:
- 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
- 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:
- 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
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.
test
()¶ Purpose: Tests the SPLAT Code
Checks the following: - If you are online and can see the SPLAT website
- If you have access to unpublished spectra
- If you can search for and load a spectrum
- If
searchLibrary
functions properly - If index measurement routines functions properly
- If classification routines function properly
- If
typeToTeff
functions properly - If flux calibration and normalization function properly
- If
loadModel
functions properly - If
compareSpectra
functions properly - If
plotSpectrum
functions properly
-
splat.
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)
-
splat.
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.
I/O Routines¶
-
splat_db.
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 >>> splat.checkOnline() True # SPLAT's URL was detected. >>> splat.checkOnline() False # SPLAT's URL was not detected. >>> splat.checkOnline('SpectralModels/BTSettl08/parameters.txt') '' # Could not find this online file.
-
splat_db.
checkAccess
(**kwargs)¶ Purpose: Checks if user has access to unpublished spectra in SPLAT library.
Example: >>> import splat >>> print splat.checkAccess() True
Note: Must have the file .splat_access in your home directory with the correct passcode to use.
-
splat_db.
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 splat.checkFile(spectrum1) True >>> spectrum2 = 'fake_name.fits' >>> print splat.checkFile(spectrum2) False
-
splat_db.
checkLocal
(inputfile)¶ Purpose: Checks if a file is present locally or within the SPLAT code directory
Example: >>> import splat >>> splat.checkLocal('splat.py') True # found the code >>> splat.checkLocal('parameters.txt') False # can't find this file >>> splat.checkLocal('SpectralModels/BTSettl08/parameters.txt') True # found it
Modeling Routines¶
Spectral Modeling Routines¶
-
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)
- 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: 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.
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: - 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)
- output – a string containing the base filename for outputs associated with this fitting routine (
file
andfilename
may also be used; default = ‘fit’) - noPlot – 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 >>> sp = splat.Spectrum(shortname='1507-1627')[0] >>> sp.fluxCalibrate('2MASS J',12.32,absolute=True) >>> p = splat.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 Markov chain Monte Carlo method to compare an object with models from a given set. Returns the best estimate of the effective temperature, surface gravity, and metallicity. Can also determine the radius of the object by using these estimates.
Parameters: - spec – Spectrum class object, which should contain wave, flux and noise array elements.
- nsamples (optional, default = 1000) – number of Monte Carlo samples
- initial_cut (optional, default = 0.1) – the fraction of the initial steps to be discarded. (e.g., if
initial_cut = 0.2
, the first 20% of the samples are discarded.) - burn (optional, default = 0.1) – the same as
initial_cut
- set (optional, default = 'BTSettl2008') –
set of models to use; 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)
- model (optional, default = 'BTSettl2008') – the same as
set
- models (optional, default = 'BTSettl2008') – the same as
set
- verbose (optional, default = False) – give lots of feedback
- mask_ranges (optional, default = []) – mask any flux value of
spec
by specifying the wavelength range. Must be in microns. - mask_telluric (optional, default = False) – masks certain wavelengths to avoid effects from telluric absorption
- mask_standard (optional, default = True) – masks wavelengths below 0.8 and above 2.35 microns
- mask (optional, default = [0, ..., 0] for len(sp1.wave)) – mask any flux value of
spec
; has to be an array with length equal asspec
with only 0 (unmask) or 1 (mask). - radius (optional) – calculates and returns radius of object if True
- filename (optional) – filename or filename base for output
- filebase (optional) – the same as
filename
- savestep (optional, default =
nsamples/10
) – indicate when to save data output (e.g.savestep = 10
will save the output every 10 samples) - 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 >>> sp = splat.getSpectrum(shortname='1047+2124')[0] # T6.5 radio emitter >>> spt, spt_e = splat.classifyByStandard(sp,spt=['T2','T8']) >>> teff,teff_e = splat.typeToTeff(spt) >>> sp.fluxCalibrate('MKO J',splat.typeToMag(spt,'MKO J')[0],absolute=True) >>> table = splat.modelFitMCMC(sp, mask_standard=True, initial_guess=[teff, 5.3, 0.], zstep=0.1, nsamples=100, savestep=0, verbose=True) Trouble with model BTSettl2008 T=1031.61, logg=5.27, z=-0.02 At cycle 0: fit = T=1031.61, logg=5.27, z=0.00 with chi2 = 35948.5 Trouble with model BTSettl2008 T=1031.61, logg=5.27, z=-0.13 At cycle 1: fit = T=1031.61, logg=5.27, z=0.00 with chi2 = 35948.5 . . . # Skipped a few lines . . . Trouble with model BTSettl2008 T=973.89, logg=4.95, z=-0.17 At cycle 99: fit = T=973.89, logg=4.95, z=0.00 with chi2 = 30569.6 Number of steps = 170 Best Fit parameters: Lowest chi2 value = 29402.3750247 for 169.0 degrees of freedom Effective Temperature = 1031.608 (K) log Surface Gravity = 5.267 Metallicity = 0.000 Radius (relative to Sun) from surface fluxes = 0.103 Median parameters: Effective Temperature = 1029.322 + 66.535 - 90.360 (K) log Surface Gravity = 5.108 + 0.338 - 0.473 Metallicity = 0.000 + 0.000 - 0.000 Radius (relative to Sun) from surface fluxes = 0.094 + 0.012 - 0.007 fit_J1047+2124_BTSettl2008 Quantiles: [(0.16, 0.087231370556002871), (0.5, 0.09414839610875167), (0.84, 0.10562967101117798)] Quantiles: [(0.16, 4.6366512070621884), (0.5, 5.1077094570511488), (0.84, 5.4459108887603094)] Quantiles: [(0.16, 938.96254520460286), (0.5, 1029.3222563137401), (0.84, 1095.8574021575118)] Total time elapsed = 0:01:46.340169 >>> print table teff logg z radius chisqr ------------- ------------- --- --------------- ------------- 1031.60790828 5.26704520744 0.0 0.103152256465 29402.3750247 1031.60790828 5.26704520744 0.0 0.103152256465 29402.3750247 ... ... ... ... ... # Skipped a few lines 938.962545205 5.43505121711 0.0 0.125429265207 43836.3720496 938.962545205 5.43505121711 0.0 0.129294090544 47650.4267022
-
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.
- nwalkers (optional, default = 20) – number of MCMC walkers, should have at least 20
- nsamples (optional, default = 500) – number of MCMC samples, for model fitting about 500 seems OK
- burn_fraction (optional, default = 0.5) – the fraction of the initial steps to be discarded. (e.g., if
burn_fraction = 0.2
, the first 20% of the samples are discarded.) - initial_guess (optional, default = array of random numbers within allowed ranges) – 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.
- limits (optional, default = depends on model set) – 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.
- prior_scatter (optional, default = [25,0.1,0.1]) – array giving the widths of the normal distributions from which to draw prior parameter values
- 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
-
splat_model.
reportModelFitResults
(spec, t, *arg, **kwargs)¶ Purpose: Reports the result of model fitting parameters. Produces triangle plot, best fit model, statistics of parameters and saves raw data if iterative = True
.Required Inputs:
param spec: Spectrum class object, which should contain wave, flux and noise array elements. param t: Must be an astropy Table with columns containing parameters fit, and one column for chi-square values (‘chisqr’). - Optional Inputs:
param evol: computes the mass, age, temperature, radius, surface gravity, and luminosity by using various evolutionary model sets. See below for the possible set options and the Brown Dwarf Evolutionary Models page for more details (default = True) param emodel: set of evolutionary models to use; see loadEvolModelParameters() (default = ‘Baraffe’)
param weight: set to True to use fitting statistic as a weighting to compute best fit statistics (default = True) param stat: name of the statistics column in input table t
(default = ‘chisqr’)param stats: if True, prints several statistical values, including number of steps, best fit parameters, lowest chi2 value, median parameters and key values along the distribution (default = True) param triangle: creates a triangle plot, plotting the parameters against each other, demonstrating areas of high and low chi squared values. Useful for demonstrating correlations between parameters (default = True) param bestfit: set to True to plot best-fit model compared to spectrum (default=True) param model_set: desired model set of bestfit
; see loadModel() for allowed options (can also use ‘mset’; default = blank)param filebase: a string that is the base filename for output (default = ‘modelfit_results’) param sigma: when printing statistical results ( stats
= True), print the value atsigma
standard deviations away from the mean (default = 1)param iterative: if True, prints quantitative results but does not plot anything (default = False) - Output:
- No formal output, but results are plotted to various files
Example: >>> import splat >>> sp = splat.getSpectrum(shortname='1047+2124')[0] # T6.5 radio emitter >>> spt, spt_e = splat.classifyByStandard(sp,spt=['T2','T8']) >>> teff,teff_e = splat.typeToTeff(spt) >>> sp.fluxCalibrate('MKO J',splat.typeToMag(spt,'MKO J')[0],absolute=True) >>> table = splat.modelFitMCMC(sp, mask_standard=True, initial_guess=[teff, 5.3, 0.], zstep=0.1, nsamples=100, savestep=0, verbose=False) >>> splat.reportModelFitResults(sp, table, evol = True, stats = True, sigma = 2, triangle = False) Number of steps = 169 Best Fit parameters: Lowest chi2 value = 29567.2136599 for 169.0 degrees of freedom Effective Temperature = 918.641 (K) log Surface Gravity = 5.211 Metallicity = 0.000 Radius (relative to Sun) from surface fluxes = 0.096 Median parameters: Effective Temperature = 927.875 + 71.635 - 73.237 (K) log Surface Gravity = 5.210 + 0.283 - 0.927 Metallicity = 0.000 + 0.000 - 0.000 Radius (relative to Sun) from surface fluxes = 0.108 + 0.015 - 0.013
Evolutionary Model Routines¶
-
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:
burrows : Models from Burrows et al. (2001) for 1 Myr < age < 10 Gyr, 0.005 Msol < mass < 0.2 Msol, and solar metallicity
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)
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 500.45609068 2604.99966013 1017.03307609 1774.18267474 1675.12181635 2682.9697321 2512.45223777 346.41152614 2066.19972036 843.28528456 2264.93051445 2767.85660557 348.84214986 922.87030167 2669.27152307] K
-
splat_evolve.
modelParametersSingle
(*args, **kwargs)¶ Purpose: Driver function for modelParameters_, performs actual interpolation of evolutionary models. See SPLAT API for modelParameters() for details.
-
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]
Specialty Packages¶
EUCLID Analysis Routines¶
-
splat_euclid.
spexToEuclid
(sp)¶ Purpose: Convert a SpeX file into EUCLID form, using the resolution and wavelength coverage defined from the Euclid Red Book (Laurijs et al. 2011). This function changes the input Spectrum objects, which can be restored by the Spectrum.reset() method.
Parameters: sp – Spectrum class object, which should contain wave, flux and noise array elements
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] # grab a random file >>> splat.spexToEuclid(sp) >>> min(sp.wave), max(sp.wave) (<Quantity 1.25 micron>, <Quantity 1.8493000000000364 micron>) >>> sp.history [``'Spectrum successfully loaded``', ``'Converted to EUCLID format``'] >>> sp.reset() >>> min(sp.wave), max(sp.wave) (<Quantity 0.6454827785491943 micron>, <Quantity 2.555659770965576 micron>)
-
splat_euclid.
addEuclidNoise
(sp)¶ Purpose: Adds Gaussian noise to a EUCLID-formatted spectrum assuming a constant noise model of 3e-15 erg/s/cm2/micron (as extrapolated from the Euclid Red Book; Laurijs et al. 2011 <http://sci.esa.int/euclid/48983-euclid-definition-study-report-esa-sre-2011-12/>`_). Note that noise is added to both flux and (in quadrature) variance. This function creates a new Spectrum object so as not to corrupt the original data.
Parameters: sp – Spectrum class object, which should contain wave, flux and noise array elements
Output: Spectrum object with Euclid noise added in
Example: >>> import splat >>> sp = splat.getSpectrum(lucky=True)[0] # grab a random file >>> splat.spexToEuclid(sp) >>> sp.normalize() >>> sp.scale(1.e-14) >>> sp.computeSN() 115.96374031163553 >>> sp_noisy = splat.addEculidNoise(sp) >>> sp_noisy.computeSN() 3.0847209519763172
BibTeX Routines¶
-
splat_db.
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
Astroquery-based Data Access¶
-
splat_db.
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 splat.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 >>> from astropy import units as u >>> c = splat.properCoordinates('J053625-064302') >>> v = splat.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_db.
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 splat.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 = splat.properCoordinates('J053625-064302') >>> q = splat.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 ...
Search