Home Download Tutorial 1 Tutorial 2 Tutorial 3 Tutorial 4 Tutorial 5

This page presents the basic usages of ULySS to fit a spectrum against stellar templates, with a model of atmosphere or with stellar population models.
The tutorials are written to follow a smooth progression, from commands requiring minimal understanding of the method (ulyss, <my_spectrum>), to examples demonstrating the flexibility of the package (make composite fits, set constraints on the parameters...).

1. Simple and quite limited examples

Lets first select a spectrum file provided in the package for tests: (the variable uly_root is set in uly_startup.pro to point to ULySS root directory)
GDL> star = uly_root+'/data/cflib_114642.fits'
Analyze this file with default parameters (determine the broadening by comparing to the solar spectrum):
GDL> ulyss, star
Use default model: Solar spectrum
--------------------------------------------------------------------
INPUT PARAMETERS
--------------------------------------------------------------------
The fits file to be analyze is       ./data/cflib_114642.fits
Name of the output file              output.res
Degree of multiplicative polynomial            10
No additive polynomial  
Component1 (cmp1) file:./models/sun.fits 
--------------------------------------------------------------------
--------------------------------------------------------------------
PARAMETERS PASSED TO ULY_FIT
--------------------------------------------------------------------
Wavelength range used                 :       3464.9160       9469.5171
 [Angstrom]
Sampling in log wavelength            :       20.079155 [km/s]
Number of independent pixels in signal:       15011
Number of pixels fitted               :       15011
DOF factor                            :      1.00000
--------------------------------------------------------------------
number of model evaluations:          35
time=       1.5249200
Number of pixels used for the fit       15007

cz             :       7.5581444 +/- 0.96103474 km/s
dispersion     :       75.070373 +/- 0.88710896 km/s
-----------------------------------------------
estimated SNR  :       12.510639
-----------------------------------------------
cmp #0  cmp1
Weight         :    0.0057345585 +/-    5.3433868e-05 [data_unit/cmp_unit]
-----------------------------------------------

Determine the atmospheric parameters of this star with the Elodie.3.1 interpolator. This time we added the keyword /PLOT to produce a graphic of the fit:
GDL> ulyss, star, MODEL_FILE=uly_root+'/models/elodie32_flux_tgm.fits', /PLOT
--------------------------------------------------------------------
INPUT PARAMETERS
--------------------------------------------------------------------
The fits file to be analyze is       ./data/cflib_114642.fits
Name of the output file              output.res
Degree of multiplicative polynomial            10
No additive polynomial  
Component1 (cmp1) model:./models/elodie32_flux_tgm.fits 
  Guess for Teff: 7000.0000 [K], Logg: 2.0000000 [cm/s2], Fe/H: 0.0000000 [dex]
--------------------------------------------------------------------
--------------------------------------------------------------------
PARAMETERS PASSED TO ULY_FIT
--------------------------------------------------------------------
Wavelength range used                 :       3900.2338       6800.1479
 [Angstrom]
Sampling in log wavelength            :       20.079155 [km/s]
Number of independent pixels in signal:        8300
Number of pixels fitted               :        8300
DOF factor                            :      1.00000
--------------------------------------------------------------------
number of model evaluations:          68
time=       2.7778258
Number of pixels used for the fit        8218

cz             :       1.3043659 +/- 0.14290816 km/s
dispersion     :       31.781528 +/- 0.15732457 km/s
-----------------------------------------------
estimated SNR  :       77.287751
-----------------------------------------------
cmp #0  cmp1
Weight         :      0.99005952 +/-      0.010510920 [data_unit/cmp_unit]
Teff           :       6397.5471 +/- 4.0069625 K
Logg           :       4.0506557 +/- 0.0080833872 cm/s2
Fe/H           :     -0.15417556 +/- 0.0049592401 dex
-----------------------------------------------

Analyze a stellar population with a Pegase_HR/Elodie.3.1 grid of SSPs (this is the default model for a stellar population):
GDL> galaxy = uly_root+'/data/VazMiles_z-0.40t07.94.fits'
GDL> ulyss, galaxy, MODEL_FILE= uly_root+'/models/PHR_Elodie31.fits'
--------------------------------------------------------------------
INPUT PARAMETERS
--------------------------------------------------------------------
The fits file to be analyze is       ./data/VazMiles_z-0.40t07.94.fits
Name of the output file              output.res
Degree of multiplicative polynomial            10
No additive polynomial  
Component1 (cmp1) model:./models/PHR_Elodie31.fits 
  Guess for age: 8000.0000 [Myr], Fe/H: -0.40000000 [dex]
--------------------------------------------------------------------
Read the model ./models/PHR_Elodie31.fits
read the file ./models/PHR_Elodie31.fits
model reading time=       1.7968800
model deriving time=      0.21679497
--------------------------------------------------------------------
PARAMETERS PASSED TO ULY_FIT
--------------------------------------------------------------------
Wavelength range used                 :       3900.5447       6800.7178
 [Angstrom]
Sampling in log wavelength            :       51.501300 [km/s]
Number of independent pixels in signal:        3236
Number of pixels fitted               :        3236
DOF factor                            :      1.00000
--------------------------------------------------------------------
number of model evaluations:          52
time=      0.51620889
Number of pixels used for the fit        3172

cz             :       6.4171465 +/- 0.29640537 km/s
dispersion     :       62.357711 +/- 0.30356847 km/s
-----------------------------------------------
estimated SNR  :       107.19732
-----------------------------------------------
cmp #0  cmp1
Weight         :       1.0981672 +/-    6.8035115e-05 [data_unit/cmp_unit]
age            :       6355.5287 +/- 109.68133 Myr
Fe/H           :     -0.36017315 +/- 0.0065616429 dex
-----------------------------------------------

Analyze a spectrum previously read and convolved (to show some of the several functions of the package), we set the keyword /QUIET to suppress printings, but we save the output in the files tuto_base.res and tuto_base.fits:
GDL> galaxy = uly_root+'/data/VazMiles_z-0.40t07.94.fits'
GDL> spectrum = uly_spect_read(galaxy)
GDL> specConv = uly_spect_losvdconvol(spectrum, 0., 30., 0, 0)
GDL> uly_spect_free, spectrum
GDL> ulyss, specConv, MODEL='models/PHR_Elodie31.fits', /QUIET, FILE_OUT='tuto_base'
We can print the result now, and plot the fit with zooming a detail:
GDL> uly_solut_tprint, 'tuto_base.res'
GDL> uly_solut_splot, 'tuto_base.fits', WAVERANGE=[5000.,5200.]

cz             :       6.3734618 +/- 0.37938520 km/s
dispersion     :       68.989962 +/- 0.38664303 km/s
-----------------------------------------------
estimated SNR  :      113.996
-----------------------------------------------
cmp #0  cmp4
Weight         :       1.1169801 +/-    6.9208513e-05 [data_unit/cmp_unit]
age            :       6497.0194 +/- 130.65446 Myr
Fe/H           :     -0.36589060 +/- 0.0074055300 dex
-----------------------------------------------

2. More advanced usages

In real cases, the model should be defined before calling ULYSS, in order to choose the guesses, add constraints on the parameters, or define a composite model. The model is described by an array of components (cmp in the examples below); when the array has more than one element, the model is composite, like for example a 2-bursts population model. The cmp array also contains the guesses (initial values) and the limits (constraints) on each parameter. This information is passed to the functions creating cmp.
Analyze a 2-bursts stellar population with Pegase_HR/Elodie.3.1:
GDL> galaxy = uly_root+'/data/VazMiles_z-0.40t07.94.fits'
GDL> cmp1 = uly_ssp(AG=[1000.], ZG=[0], AL=[200.,3000.])
GDL> cmp2 = uly_ssp(AG=[10000.], ZG=[0], AL=[3000., 12000.])
GDL> cmp = [cmp1, cmp2]
GDL> ulyss, galaxy, cmp, /PLOT
--------------------------------------------------------------------
INPUT PARAMETERS
--------------------------------------------------------------------
The fits file to be analyze is       ./data/VazMiles_z-0.40t07.94.fits
Name of the output file              output.res
Degree of multiplicative polynomial            10
No additive polynomial  
Component1 (cmp1) model:./models/PHR_Elodie31.fits 
  Guess for age: 1000.0000 [Myr], Fe/H: 0.0000000 [dex]
Component2 (cmp2) model:./models/PHR_Elodie31.fits 
  Guess for age: 10000.000 [Myr], Fe/H: 0.0000000 [dex]
--------------------------------------------------------------------
Read the model ./models/PHR_Elodie31.fits
read the file ./models/PHR_Elodie31.fits
model reading time=       1.7573318
model deriving time=      0.21527600
Read the model ./models/PHR_Elodie31.fits
read the file ./models/PHR_Elodie31.fits
model reading time=       1.7630351
model deriving time=      0.21560097
--------------------------------------------------------------------
PARAMETERS PASSED TO ULY_FIT
--------------------------------------------------------------------
Wavelength range used                 :       3900.5447       6800.7178
 [Angstrom]
Sampling in log wavelength            :       51.501300 [km/s]
Number of independent pixels in signal:        3236
Number of pixels fitted               :        3236
DOF factor                            :      1.00000
--------------------------------------------------------------------
number of model evaluations:          45
time=      0.73431396
Number of pixels used for the fit        3172

cz             :       6.4343579 +/- 0.30888007 km/s
dispersion     :       62.408533 +/- 0.31547613 km/s
-----------------------------------------------
estimated SNR  :       104.62244
-----------------------------------------------
cmp #0  cmp1
Light fraction :       3.3730552 +/-      0.066524257 %
Weight         :     0.014335284 +/-    0.00028272413 [data_unit/cmp_unit]
age            :       2374.2576 +/- 77896.473 Myr
Fe/H           :     -0.52676316 +/- 31.854347 dex
-----------------------------------------------
cmp #1  cmp2
Light fraction :       96.626945 +/-      0.066056484 %
Weight         :       1.0035757 +/-    0.00068606830 [data_unit/cmp_unit]
age            :       5940.4404 +/- 206.11379 Myr
Fe/H           :     -0.36143326 +/- 0.0083828031 dex
-----------------------------------------------

Analyze and use the proper line-spread function:
Another important aspect of this method is to properly take into account the actual line-spread function (LSF) of the observation being analyzed. The LSF is the equivalent in spectroscopy of the PSF for images, it describes the instrumental broadening of the spectral lines (ie. the resolution). The LSF generally changes with the wavelength and is not necessary a Gaussian.
In the example below we first analyze the LSF using a star and then inject this LSF in the model to analyze a stellar population. (In practice the star must be observed with the same set-up as the stellar population -- it is not the case in this example where we are simply using the spectra included in ULySS for the purpose of illustrations).
First, to determine the LSF using a standard star, we use the TGM model to find its atmospheric parameters (see above). Then, we synthetize a spectrum with those parameters and use it to determine the LSF:
GDL> star = uly_root+'/data/cflib_114642.fits'
GDL> model = uly_tgm_extr(star,[6400.,4.,0.]) ;  Teff=6400K log(g)=4 [Fe/H]=0
GDL> cmp = uly_star(model)
GDL> uly_lsf, star, cmp, 600, 300, FILE='tuto_lsf.txt', /QUIET
GDL> plotsym,0,1,/FILL
GDL> uly_lsf_plot, 'tuto_lsf.txt', YST=3, PSYM=8, CONNECT='Red'


We smooth this LSF (it is likely a smooth function of the wavelength):
GDL> uly_lsf_smooth, 'tuto_lsf.txt', 'tuto_lsf_s.txt'
And we analyse the galaxy using this LSF.
GDL> galaxy = uly_root+'/data/VazMiles_z-0.40t07.94.fits'
GDL> cmp = uly_ssp(LSF='tuto_lsf_s.txt')
GDL> ulyss, galaxy, cmp, /QUIET

Several more options and tools exist to improve the fit, add constraints, define composite models, study the space of parameters with Monte-Carlo simulations or chi2 maps... They are described in the more specialized tutorials.
Contact: ulyss at obs.univ-lyon1.fr Last modified: Thu Jul 31 13:57:09 2008.