LRT Fortran77 Functions
Here is a description of all functions included with the LRT
libraries. For all cases, the following definitions apply:
 nchan = Total
number of filters used.
 nspec =
Number of templates your are using (3 or 4).
 real*8 function
bol_lum(comp)
 Parameters

real*8 comp(nspec) 
INPUT. Specific luminosities of each template
component. This is vector is typically an output of the kca subroutine. 
 Description
Given the output vector of KCA with the specific bolometric
luminosities, returns the bolometric luminosity of the galaxy in
units of 10^{10} solar luminosities. In practice, it
just adds the components of vector comp.
 Requisites
 call kcinit
 call kca (Recommended)
 subroutine
get_mags(comp,z,jymodtot)
 Parameters

real*8 comp(nspec) 
INPUT. Specific luminosities of each template
component. This is vector is typically an output of the kca subroutine. 

real*8 z 
INPUT. Redshift of the object. 

real*8 jymodtot(nchan)

OUTPUT. Vector that holds the expected fluxes in each
filter. 
 Description
Subroutine that given specific luminosities for each component
and a redshift, returns the associated fluxes in the set of
filters of the Photometry Description File. This Subroutine can
be used to
 Requisites
 call kcinit or call pzinit
 real*8 function
DL(z)
 Parameters

real*8 z 
INPUT. Redshift of the object. 
 Description
Returns the luminosity distance to redshift z.
 Requisites
 subroutine
fitzero(filename, niter, chifrac, corr, op)
 Parameters

character*100 filename 
INPUT. Name of the training set file. See below for the
description of the file format. 

integer niter 
INPUT. Number of iterations for estimating the
corrections. Convergence is somewhat slow, but 10 or 15
iterations are usually good enough. 

real*8 chifrac 
INPUT.Fraction of objects to use, arranged by chisquared.


real*8 corr(nchan) 
OUTPUT. Array of size nchan with the zero point
corrections, such that zeropoint/corr is the corrected zero
point. 

integer op 
INPUT. 0 if input is in fluxes (in Jy) and 1 if in
magnitudes. 
 Description
Subroutine that estimates corrections to the input photometric
zero points using a usersupplied training set. This corrections
can significantly improve photometric redshifts and
Kcorrections. The format of the training set file must be:
redshift, flux (Jy) or magnitude in each band, flux (Jy) or
magnitude error in each band, and flags for each band (1 if its
to be used and 0 if not). Lines starting with # are considered
comments. Click here for an example. Once
the corrections have been estimated, they are automatically
incorporated to the pza and kca functions.
 Requisites
 subroutine
kca(mag,emag,maguse,z,z0,magmod,magcorr,comp,op)
 Parameters

real*8 mag(nchan) 
INPUT. Array of size nchan with the
Magnitudes or Fluxes (in Jy) in each band arranged in the same
order as in the photometry description file. 

real*8 emag(nchan) 
INPUT. Array of size nchan with the
magnitude or fluxes (in Jy) errors in each band 

integer maguse(nchan) 
INPUT. Array of size nchan with the
use flags. If maguse(j)=1, the jth band
will be used for estimating photometric redshifts. If
maguse(j)=0, it will not. Still, a modeled magnitude
or flux will be returned for this filter. 

real*8 z 
INPUT. Redshift of the object. 

real*8 z0 
INPUT. Redshift of the Kcorrection (typically 0.d0).


real*8 magmod(nchan)

OUTPUT. Array of size nchan in which
the best fit model fluxes or magnitudes are returned. 

real*8 magcorr(nchan) 
OUTPUT. Array of size nchan in which
the Kcorrections will be returned. mag  magcorr = Kcorrected
magnitude. Flux/Flux_corr= Kcorrected flux. 

real*8 comp(nspec) 
OUTPUT. Array of size nspec in
which the best fit specific luminosities of each component are
returned 

integer op 
INPUT. 0 if input is in Fluxes (in Jy) and 1 if in
magnitudes. 
 Description
Subroutine that calculates KCorrections. For a thorough
explanation of how this is done, please refer to Assef et
al. (2008).
 Requisites
 subroutine kcinit(filtname,nspec,verbose)
 Parameters

string filtname 
INPUT. The name of the photometry description file ('bandmag.dat' in the test programs for
example.) 

integer verbose 
INPUT. If 1, information will be print to the STDOUT. If 0,
nothing will be printed except for possible errors. 
 Description
Function that initializes the KCorrection subroutine kca and most other functions.
 Requisites
 subroutine
pza(mag,emag,maguse,zphot,chigal,chinop,op,chi2zop)
 Parameters

real*8 mag(nchan) 
INPUT. Array of size nchan with the
Magnitudes or Fluxes (in Jy) in each band arranged in the same
order as in the photometry description file. 

real*8 emag(nchan) 
INPUT. Array of size nchan with the
magnitude or fluxes (in Jy) errors in each band 

integer maguse(nchan) 
INPUT. Array of size nchan with the
use flags. If maguse(j)=1, the band will be used for
estimating photometric redshifts. If maguse(j) = 0, it
will not. Still, a modeled magnitude or flux will be returned
for this filter. 

real*8 zphot 
OUTPUT. Photometric redshift output variable. 

real*8 chigal 
OUTPUT. χ^{2} + Prior of the best fit 

real*8 chinop 
OUTPUT. χ^{2} of the best fit. 

integer op 
INPUT. 0 if input is in Fluxes (in Jy) and 1 if in
magnitudes. 

integer chi2zop 
INPUT. If >0, the χ^{2} distribution of the
object for which a photometric redshift is calculated will be
written to the fort.90 file. The first line has two columns, the
chi2zop flag value (should be the galaxy ID for easier
recognition) and the number of lines in the redshift grid,
N. The following N lines show the distribution
and have three columns: redshift, χ^{2},
χ^{2}+prior. Following objects on the same run are
appended to the file. 
 Description
Subroutine that calculates Photometric Redshifts. For a thorough
explanation of how this is done, please refer to Assef et
al. (2008).
 Requisites
 subroutine pzinit(filtname,nspec,zmin,zmax,dz,verbose)
 Parameters

string filtname 
INPUT. The name of the photometry description file ('bandmag.dat' in the test programs for
example.) 

real*8 zmin 
INPUT. Lower limit to search for best fit photometric
redshift. 

real*8 zmax 
INPUT. Upper limit to search for best fit photometric
redshift. 

real*8 dz 
INPUT. Redshift grid separation. 

integer verbose 
INPUT. If 1, information will be print to the STDOUT. If 0,
nothing will be printed except for possible errors. 
 Description
Function that initializes the photometric redshift subroutine pza and most other functions. This function will
create the photoz_grid.dat file. This file is used
internally by the pza function.
 Requisites
 real*8 function
vc(z)
 Parameters

real*8 z 
INPUT. Redshift. 
 Description
Returns the comoving volume from redshift 0
to redshift z.
 Requisites
 real*8 function
vmax(comp,jchan,mlim,zlim,area)
 Parameters

real*8 comp(nspec) 
INPUT. Specific luminosities of each template
component. This vector is an output of kca. 

integer jchan 
INPUT .Band in which the magnitude limits applies. 

real*8 mlim 
INPUT. Faint apparent magnitude limit. 

real*8 zlim 
OUTPUT. Maximum redshift to which galaxy can be found. 

real*8 area 
INPUT. Area of the survey in square degrees. 
 Description
Function that returns the comoving volume on which a galaxy
could have been detected given the magnitude limit of the survey
and the area in square degrees. This function will also return
the maximum redshift to which the galaxy could have been
observed.
 Requisites
 call kcinit
 call kca
(Recommended)
