Next Previous Up Contents
Next: Preparing Model Data
Up: How to fit spectra using Yafit
Previous: How to fit spectra using Yafit

3.1 Preparing Observation Data

Before fitting, you must prepare your observation data in a way that the program can understand. This involves generating a .yobs file which contains spectral information about one or more sources. Typically this will consist of photometric observations at a number of pass bands for each of several sources of interest. Currently the tableobs task is provided to convert observations in a table for which each column represents observations in a given pass band to a .yobs file.

Suppose that you have photometric observations in a table as follows:

   #       RA      DEC   PHOTOZ       J   J_ERR       H   H_ERR       K   K_ERR
      119.608   21.410     2.52   11.94   0.022   12.16   0.024   12.57   0.018
       53.094  -27.839     3.05   12.33   0.022   12.34   0.026   12.67   0.020
      213.870  -46.515     1.65   17.32   0.106   17.57   0.192   17.49   0.176
      204.143  -29.089     0.50   15.93   0.041   16.29   0.071   16.48   0.073
This represents observations of four objects in each of three photometric bands (J, H and K). The fluxes are here represented as magnitude values, and the flux at each of the bands has an associated error value. The fitting program must identify each of these bands with a region of the model spectrum and determine how close the observation is to the model flux in that region to see how well the observation fits the model. The flux error in each case provides a measure of how large deviations are to be tolerated. An additional column (PHOTOZ) gives the known redshift for each object and the sky position is given by the RA and DEC columns.

The tableobs task can be used to generate an observation file from this table, by specifying which columns give flux values and flux errors for each band pass. You can also provide expressions which perform numeric value transformations such as unit conversions if required; recall that the X (wavelength) and Y (flux) values in your observation file must be compatible with those you supply in your model file before the fitting is performed.

To define which columns correspond to which band passes in the table, you must prepare a key file, which lists the flux value and error columns corresponding to each band pass given in the table. For the table above, this file would look something like the following:

   #  yColName     yerrColName        x    xWidth
      J            J_ERR          12400     5000
      H            H_ERR          16600     4000
      K            K_ERR          21600     6000
The format of this file is a four-column ASCII table - the column names (and any other lines starting with a '#' character) are ignored. Each line of it must contain four entries in order:
  1. Name of column giving Y (flux) values
  2. Name of column giving Y (flux) errors
  3. X (wavelength) value of band pass centre for these fluxes
  4. X (wavelength) width of band pass filter for these fluxes
This key file therefore identifies the meanings of six of the columns in the input table above.

When you run tableobs you can also specify information about how the X and Y values should be written out. You can label their names and units and give an expression for how to calculate them from the values in the input table. Note the names and units you give are only annotations and will not cause any conversions to take place apart from those you specify by providing the expressions. Nevertheless it is a good idea to provide these in order to document your data files. You may well wish to convert the X and Y values to more suitable quantities, since they must be in a form which can be meaningfully fitted against the model data to be provided. For instance in the above case, you will probably want to convert the Y values from magnitudes to fluxes. A flexible expression language, described in Section 6, is available to perform these conversions; you will mostly use a few functions such as abToJansky.

Finally, you can specify redshift value if the input table contains one. This may be necessary to determine how model spectra are to be shifted along the X axis prior to attempting a fit.

Here is an example of a tableobs command to prepare a .yobs file from the input table above.

    yafit tableobs in=demo.txt ifmt=ascii
                   key=jhk.key
                   redshift=PHOTOZ
                   xname=Wavelength xunit=Angstrom x=x
                   yname=Flux yunit=Jansky y='abToJansky(y)'
                   out=demo.yobs
In detail, this works as follows:
in=demo.txt ifmt=ascii
The input table is named and its format is given as an ASCII table. The format types here are those permitted by STILTS including VOTable, FITS, CSV and others. See SUN/256.
key=jhk.key
Gives the location of the 4-column 'key file' whose format is described above. This must be in ASCII format.
redshift=PHOTOZ
Defines the column in the input table which gives redshift. This is not required if redshift is not known or not represented in the table. This parameter can only be sensibly used if the X axis is a wavelength measure. The value of the parameter can be an algebraic expression using column names from the table.
xname=Wavelength xunit=Angstrom x=x
Labels the output X values to be Wavelength quantities with units of Angstrom. The x=x is optional, but it means that the output X values will be equal to those supplied in the .key file. You could change the units here by writing, for instance, "xunit=micron x=x*1e-4". The X widths are automatically adjusted to the same scale as the X values (using numerical differentiation).
yname=Flux yunit=Jansky y='abToJansky(y)'
Labels the output Y values to be flux quantities with units of Jansky. Additionally, says that the output Y values are to be calculated from the values in the keyed columns of the input table using the pre-defined "abToJansky()" function, which converts from AB magnitudes to Jansky. The Y errors are automatically adjusted to the same scale as the Y values (using numerical differentiation).
out=demo.yobs
Writes the result to a .yobs file as named. This is in fact a VOTable, and can for instance be viewed in TOPCAT, but it has some special characteristics, and it may be best to think of it as an opaque file format used by Yafit. Note that the output file will contain all the original table information from the input table, and this will be propagated to any output tables, so that for instance information in the RA and DEC columns is not lost.
A full reference for the tableobs task is given in Appendix A.6.

Having prepared your .yobs file, you can view it using the plotobs command if you wish before using it for actual fitting.


Next Previous Up Contents
Next: Preparing Model Data
Up: How to fit spectra using Yafit
Previous: How to fit spectra using Yafit

Yafit - Yet Another Fitting Tool
User Guide