VPFIT  Example : Interactive fit to a single feature:

If you have copied the Hubble Deep Field quasar spectrum there, then you might like to try using it as in the following example (lines you type are shown with > at the beginning, a prompt from the program, or by <-- at the end, maybe followed by a comment, and are coloured; additional comments are shown in this colour, the rest is a running commentary from the program -- note that program developments have changed the output slightly, so these may not be completely consistent with each other, or the version you are running):



>> vpfit <-- or whatever you've called it
 

 VPFIT 2.02DR

 maximum file size      :   100000
 maximum chunk size     :   10000
 maximum no. parameters :   528
 maximum no. chunks     :   16
 exceeding above will corrupt results probably without warning
 

  options:   <CR> for previous value
  I - interactive setup and fit
  F - run from an input file
  D - display profiles from input file
  ? for help
  option (key) (key)...
> I
  lower case characters following values are treated as labels.  if the same
  upper case character follows another value then it will be tied to the lower
  case label.  isolated (un-paired) upper case characters fix values.

  setup: ? help, <CR> defaults, n,z,b,cs,sf,il,w,me,p,d,v to change
>

 Column density (n), logN (l) or emission (e), scalefactor
>
  Filename   1 or ? (lam,n) [     ]:
> q2233
  IRAF v2.10 wavelength coefficients
  Data is subset of larger one, wavelengths
   shifted by LTV1 =  -9624 channels
  sigma scale (midpoint value) :    1.00000
 Plot? [y]
>
 at co   co   3
 at er   co   2
 at ti   co   5
 plot parameter? (type he for options list)
 [format is cc.. a..a b..b ...
 sc # - set scale; lo # - low chan; hi # - high chan
 sn # - scale range min chan; sx # - max; ln #; lx #
 ym # - min y; yx # - max y; yb - default baseline
 qu(it); al(l); co(ntinuum); er(ror); re(sidual)
 wl # - low wavelength; wh # - high wavelength (wn #, wx # scale ranges also)
 nu(ll), nx # - nx/page, ny # - ny/page
 la(bel) 'xstr','ystr','capstr'; ca(ption) 'capstr'; te(xt); ch(aracter) size
 sp - suppress error, ov # - overplot (bias=#)
 at - set attributes (type at for help);
 tf - tick marks from file; {sl - scrunch lims}
 gk - greek symbols over ticks; ng - numbers
 ns - no symbols, tl # # - tick top, len (fract)
 ve # # - velocity limits; wc # - central wavelength
 rz # - reference redshift for velocity plots
 as - ASCII to fort.17 (toggles back to PGPLOT)
 zs - suppress zero lines; zx - x-axis only; zb - draw both
 <CR> - plot on last device used]
> wm 3800
 wm 3800
  Channel  12344
 plot parameter? (type he for options list)
> wx 3840
 wx 3840
  Channel  14165
 plot parameter? (type he for options list)
>

 PGPLOT device? (? for list)
> xw !! xwindows, goes into cursor mode
 Expand plot if needed:
 Cursor ("e" to mark edges, "q" when OK) [used e e]
     Channel  13086
 right edge..
  Channel  13902
[type ? in graphics window to get command list
 Left mouse button, or "e", expands plot
 Center button, or "r" replots
 Right button, or "q" to exit
 "." shift range up
 "," shift range down
 "a" plot whole array
 "d" demagnify by factor 2
 "y" max y from cursor
 "Q" abandon this region
  .. any other lower case letter for command line prompt]
 Cursor ("e" to mark edges, "q" when OK)  [used left mouse button twice]
 Cursor ("e" to mark edges, "q" when OK)  [used right mouse button]
 Mark region in which data is to be fitted:
 left limit (space when ready) [or left mouse button]
   right limit     [space or left mouse button]
 Region limits:  3809.082A (channel 12758) -   3814.022A ( 12982)
  Channels   12758  12982
  Vacuum wavelength for start of chunk is     3809.10
 FWHM : 0.073A
  Line   1 :ion, lamda0, N,b,z? <CR> to end
  .. in the graphics window <------ THIS IS IMPORTANT
HI 1215
 Wavelength used:    1215.67
 set cursor x- wavelength, y- base of feature [and click on left mouse button]
  .. and now half width at half (optical) depth  [and click on left mouse button]
  Estimated vac wavelength & z are    3811.42    2.13525
     13.4025    24.0985    2.13525
  Line   2 :ion, lamda0, N,b,z? <CR> to end
  .. in the graphics window

  Include other data? y, n (def),
   (or sf for more from the same file)
>

  Continue (c), fit (f), or stop (s)? [f]
>

  no. of ions for fitting is   1
 

   ion          N           z           b         bturb   temp

 iteration   :   0 ( 1 )
 chi-squared :        0.739 (   163.9874,  222 )

   H I       13.4025    2.135245      24.10       0.00   0.00E+00  0    !  1

 iteration   :   1 ( 1 )
 chi-squared :        0.469 (   104.1750,  222 )

   H I       13.5485    2.135208      29.96       0.00   0.00E+00  0    !  1

 iteration   :   2 ( 1 )
 chi-squared :        0.467 (   103.7634,  222 )

   H I       13.5513    2.135201      30.49       0.00   0.00E+00  0    !  1

 iteration   :   3 ( 1 )
 chi-squared :        0.467 (   103.7621,  222 )

   H I       13.5515    2.135201      30.52       0.00   0.00E+00  0    !  1

 parameter errors:
   H I        0.0140    0.000008       1.02                             !  1

 statistics for whole fit:
  Runs test  K-S test Chi-squared  Chans ndf   APr   Xp(.68) Xp(.95) Xp(.99)
   0.00000   0.00026    103.76     225  222   1.000  231.50  257.48  273.26

 statistics for each region :
    Start      End    Chi-squared  Chans df?
   3808.88   3814.24    103.76     225  222   1.000 < Prob < 1.000 g= 1.000   1
   3808.86   maxdev       1.4652              0.027   0.956   1.358   1.627

  Plot? y,n, or c=change device [y]
>
  Line, system number: (* for internal guesses)
> *
 at co   co   3
 at er   co   2
 at ti   co   5
 plot parameter? (type he for options list)
>

  Plot? y,n, or c=change device [y]
> n
  Restore continuum? [n]
>
  Fit more lines? [n]
>
 Note: IEEE floating-point exception traps enabled:
    overflow;  division by zero;  invalid operation;
 Nonstandard floating-point mode enabled
 See the Numerical Computation Guide, ieee_handler(3M), ieee_sun(3M)
 
 

Note that if you try to type the line parameters or ID's in the VPFIT command window, as opposed to the PGPLOT window, the program will ignore them as line ID's and try to save them as commands. This is not useful, and can be confusing. It was done this way so that you don't have to oscillate between windows, as well as keyboard/mouse, when entering in a number of lines. What you type is reflected in the command window so you can see what you are typing. The backspace or del keys can be used to correct mistakes, though if you do use these then the ID line being typed goes on to a new line in the command window .. so the last line you see there is the one which is being entered as the line ID, preceded by a history of your mistakes which are ignored!
 




 
 
 

The fit you will have seen before you looks something like this:
 
 
 
 
 

After all this you will have a number of new files:

fort.18: essentially a summary of the fit, containing the information given above but without the questions.

fort.13: the starting guesses in case you have to restart. You can edit this to have closer values if you want, or to put another line in. In this case it looks like:
   *
 q2233   1    3809.08    3814.04
  *
   H I    1.340E+01    2.135245      24.10       0.00   0.00E+00
 

fort.26: summary of the final results

You will notice that the fit probability is amazingly high, and (equivalently) that the (normalized) chi-squared is amazingly low, at 0.467 when it should be near unity. This is because the error estimate array is too large by about a factor 1.5, so the whole array should be divided by 1.5 (use IRAF, or, alternatively, create a file called 'vp_setup.dat' in the same directory as you are running the program from, containing the line  'sigscalemult 1.5', which will cause VPFIT to do it for you for any incoming error array). When you do this you find that the normalized chi-squared is 1.049, and the fit probability 0.294.

This may seem to be a totally arbitrary thing to do, and as presented here, it is. However, the chi-squared statistic assumes that the data bins are independent, and the data have been rebinned in this example, so there is a correlation between neighboring channels -- effectively a smoothing on a scale of up to two channels  if the rebinning is to a uniform binsize which is an average from the (usually not completely linear) raw data. As a consequence the fluctuations in the rebinned data are smaller than in the raw data, and it is the raw data which is generally used to estimate the 1-sigma error array. Thus the chi-squared values, which are the sum of [(data-fit)/sigma]^2, will be underestimated because sigma is an overextimate given the fluctuations. A way of determining the appropriate scalefactor is to measure the rms about the mean using IRAF (in splot) and comparing that with the sigma value for the same region.
 

Last update: 24 October 2000