Documentation

advertisement
*************************************************************************
***
CORRFIT -- CROSS-CORRELATION ROUTINES
T. Statler, Dec. 1994
Documentation modified Jan. 1996
Public version Aug. 1996
*************************************************************************
***
CORRFIT is a set of routines that use the updated cross-correlation
method
(Statler 1995, AJ, 109, 1371) to extract parameters of the line-of-sight
velocity distribution from galactic spectra and stellar templates
observed
on the same system. CORRFIT works best when the broadening function is
well sampled at the spectral resolution used (e.g. 200 km/s dispersion at
2 Angstrom resolution). If the broadening function is not well sampled
then
the results will become increasingly sensitive to the spectral match
between
galaxy and template. CORRFIT can be expected to fail miserably for
dispersions
less than the velocity sampling interval ('delta' in the code) unless the
template is perfect.
CORRFIT was written to run under the PV-Wave/CL data analysis and
graphics
software package, produced by VNI, Inc. In many ways PV-Wave resembles
the
more widely distributed IDL. To the best of the author's knowledge
CORRFIT
will run under IDL and produce the same results.
DISCLAIMER: This software is provided free of charge as a service to the
astronomical community. While reasonably careful tests of the code have
been
done, there is no certainty that it will produce correct results on all
possible inputs. The author makes no guarantees that this code will work
on
your computer or on your particular data, and accepts no responsibility
for
the consequences of its use. The user is responsible for verifying the
results.
If you have a problem using CORRFIT contact Tom Statler at
tss@helios.phy.ohiou.edu.
----------CONTENTS
The file 'corrfit.pro' contains the PV-Wave/IDL procedures for doing
cross-
correlation on galaxy spectra. The routines are:
corrfit
Main program. Feed it a galaxy and template spectrum and
you get back velocity profile parameters, chi-square, and
a covariance matrix. This calls everything else.
makeb
Makes the current model line profile, b, from the parameters
in the vector pp
correval
Evaluates the chi-square value for the model fit to the
cross-correlation peak
corramoeba Minimizes chi-square using the multidimensional simplex
method from Numerical Recipes, with multiple restarts.
corrpeak
Calculates the cross-correlation function from the data and
assigns a window around the primary peak in which the fit is
made.
corrauto
Calculates the template autocorrelation function. Actually
what is returned is the conjugate of the FT of this function.
filter
spectra
Use this to filter low-frequency stuff out of your
before running corrfit. This is not called by any of the
above routines.
avg, sum
Standard PV-Wave procedures that don't exist in IDL.
HOW TO USE CORRFIT
1. Data
Get your spectra continuum-divided and logarithmically binned. You will
probably want to taper the ends in the wavelength (ie not in the Fouriertransformed) domain. Put them in one-dimensional PVWave/IDL vectors. Pad
them out to some convenient length, which need not be a power of 2.
(How far? A couple thousand km/s worth; see below.)
Use filter if you want to remove residual low-frequency (in the Fourier
sense) components of the spectra. Galaxy and template must be identically
filtered. The filter procedure takes the FT of the padded spectrum, which
is, say, N pixels long, then multiplies it by a window function that is
also
N pixels long (that is, inverse pixels, in the frequency domain), which
is
unity in the middle and tapers to zero over the last M pixels at either
end.
By convention FFTs are folded so that points near the left end correspond
to positive low frequencies and points near the right end to negative low
frequencies, hence the shape of the window function. You have to pick
what
M is; this is the 'taperwidth' parameter. Tests using several different
values are strongly encouraged. Usually you find a range of values over
which
the results are fairly repeatable. You want to remove all trace of misfitted
continuum, while not eating into the structure of the line profile. At 2
angstrom resolution and spectra around 1000 pixels long, 'taperwidth'
will
probably be somewhere in the vicinity of 10 to 20.
2. Editing the code
There are a few things that you have to set in the source. This may be
a little clumsy, but mostly improves execution speed, and anyway only has
to be done once for a given dataset. Search for exclamation marks (!!!)
in the source to find the items you may want to edit. Note that...
1. The value of delta has to be set in TWO places. This is the number
of
km/s corresponding to 1 pixel in your (log-binned) spectra.
2. In makeb, there's a line that says 'n=1300'. Set that to the length
of
your padded spectra.
3. You can fit Gaussians or Gauss-Hermite profiles including terms up
to h4. Comment out the lines you don't want. This also has to be
done in TWO spots.
4. The corrpeak routine defines the window around the primary XC peak
to be bounded by the first minima on either side of the peak. If the
data are noisy, however, these might be washed out and you could get
a window that's way too big (or, for that matter, too small) to be
sensible. As written, the code forces the window edges to be between
5
and 20 pixels of the peak; you may want to change this.
5. Near the top of the 'corrfit' there is a line that sets the error in
the
galaxy spectrum to be the RMS difference between the spectrum and a
smoothed version of itself. Change this if you want a different
error
prescription.
6. As a time-saver, I have assumed that the redshift of the galaxy is
large
enough that the broadening function is zero at negative velocities.
So
if you have a nearby galaxy, you have to tell CORRFIT, when you call
it,
to shift the whole spectrum by several times the velocity dispersion
away
from zero before cross-correlating. (See sec. 4 below.) Be sure that
you
have padded the spectra enough that one end of the template spectrum
won't
wrap around onto the other end of the galaxy spectrum when they are
cross-correlated with that much relative shift. The velocities
returned
will be corrected for the shift, so you don't have to worry about
that.
However, in the routine 'corrpeak', it is assumed for speed that the
primary correlation peak is somwhere between pixels 60 and 100. If
your
galaxy has a radial velocity somewhere around 80*delta, or if you're
going
to manually shift it this far, you can leave this part of the code
alone;
if you have a higher-redshift object you can either shift it back to
pixel
80 or change the code accordingly. [Author's apology: in the next
version
this will be transparent.]
4. Running
The parameters of corrfit are:
Input:
seed
nshift
be
Seed for the random number generator. This is used only for
restarts of the amoeba method, to randomize the initial
direction of the search. Use anything undefined.
The number of pixels that the galactic spectrum should
shifted so that the cross-correlation peak will come out
near pixel 80. For instance, if delta = 40 km/s and your
galaxy is at 1500 km/s, nshift should be 80 - 1500/40 = 43.
galaxy
template
Output:
param
chisq
The galaxy spectrum (filtered as appropriate)
The template spectrum (filtered as appropriate)
Velocity profile parameters, in one vector. The order is
V, sigma, linestrength, h3, h4. If you've commented out the
'fit up to h4' lines in the source, then param will be
only 3 elements long.
The reduced chi-square of the fit.
covariance The covariance matrix for the returned parameters, either
5x5 or 3x3, depending on what you're doing. Unless you have
strange data, the off-diagonal elements will be fairly
small and the errors in the parameters will be the square
roots of the diagonal terms.
Download