«  Data module   ::   Contents   ::   Plotting  »

Utils

This is the utils_mlz module in some detail, this class contains some useful routines used by MLZ.

Module author: Matias Carrasco Kind

class utils_mlz.Stopwatch(verb='yes')

Stopwatch and some time procedures

Parameters:verb (str) – ‘yes’ or ‘no’ (verbose?)
elapsed(only_sec=False, verbose=True)

Prints and saves elapsed time

Parameters:
  • only_sec (bool) – set this to True for the elapsed time prints in seconds only
  • verbose (bool) – Prints on screen
restart(verb='Restart', verbose=True)

Set the counter to zero, keeps tracking of starting time

Parameters:verb (str) – ‘Start’ (default) or ‘Restart’ (set the counter to zero and the starting

time to current time, keeps the initial starting in self.start0)

class utils_mlz.bias(zs, zb, name, zmin, zmax, nbins, mode=1, d_z=<function <lambda> at 0x10cf1d0c8>, verb=True)

Creates a instance to compute some metrics for the photo-z calculation for quick analysis

Parameters:
  • zs (float) – Spectrocopic redshift array
  • zb (float) – Photometric redshift
  • name (str) – name for identification
  • zmin (float) – Minimum redshift for binning
  • zmax (float) – Maximum redshift for binning
  • nbins (int) – Number of bins used
  • mode (int) – 0 (binning in spec-z) or 1 (binning in photo-z)
  • d_z (function) – function to be applied on z_phot and z_spec, default (z_phot-z_spec)
  • verb (bool) – verbose?
utils_mlz.compute_error(z, pdf, zv)

Computes the error in the PDF calculation using a reference values from PDF it computes the 68% percentile limit around this value

Parameters:
  • z (float) – redshift
  • pdf (float) – photo-z PDF
  • zv (float) – Reference value from PDF (can be mean, mode, median, etc.)
Returns:

error associated to reference value

Return type:

float

utils_mlz.compute_zConf(z, pdf, zv, sigma)

Computes the confidence level of the pdf with respect a reference value as the area between zv-sigma(1+zv) and zv+sigma(1+zv)

Parameters:
  • z (float) – redshift
  • pdf (float) – photo-z PDF
  • zv (float) – reference value
  • sigma (float) – extent of confidence
Returns:

zConf

Return type:

float

class utils_mlz.conf(zconf, zb, zmin, zmax, nbins)

Computes confidence level (zConf) as a function of photometric redshift

Parameters:
  • zconf (float) – zConf array for galaxies
  • zb (float) – Photometric redshifts
  • zmin (float) – Minimum redshift for binning
  • zmax (float) – Maximum redshift for binning
  • nbins (int) – Number of bins used
utils_mlz.get_area(z, pdf, z1, z2)

Compute area under photo-z Pdf between z1 and z2, PDF must add to 1

Parameters:
  • z (float) – redshift
  • pdf (float) – photo-z PDF
  • z1 (float) – Lower boundary
  • z2 (float) – Upper boundary
Returns:

area between z1 and z2

Return type:

float

utils_mlz.get_limits(ntot, Nproc, rank)

Get limits for farming an array to multiple processors

Parameters:
  • ntot (int) – Number of objects in array
  • Nproc (int) – number of processor
  • rank (int) – current processor id
Returns:

L1,L2 the limits of the array for given processor

Return type:

int, int

utils_mlz.percentile(Nvals, percent)

Find the percentile of a list of values. :param float Nvals: list of values :param float percent: a percentile value between 0 and 1. :return: percentile value :rtype: float

utils_mlz.print_dtpars(DTpars, outfile, system=False)

Prints the values from class Pars to a file

Parameters:
  • DTpars (class) – class Pars from input file
  • outfile (str) – output filename
utils_mlz.read_dt_pars(filein, verbose=True, myrank=0)

Read parameters to be used by the program and convert them into integers/float if necessary, returning a class

Parameters:
  • filein (str) – name of inputs file, check format here Input file template
  • verbose (bool) – True or False
  • myrank (int) – processor id for multi-core capabilities
utils_mlz.zconf_dist(conf, nbins)

Computes the distribution of Zconf for different bins between 0 and 1

Parameters:
  • conf (float) – zConf values
  • nbins (int) – number of bins
Returns:

zConf dist, bins

Return type:

float,float

«  Data module   ::   Contents   ::   Plotting  »