clusters package

Submodules

clusters.background module

Tools to fit the red sequence and extract background galaxies around a cluster.

clusters.background.color_histo(mags)

Plot color histograms.

clusters.background.color_mag_plot(mags)

Plot color / mag diagrams.

clusters.background.fit_red_sequence(color, mag, **kwargs)

Fit red sequence (RS) band in galaxy color plots, i.e m(i)-m(j) vs. m(k).

Parameters:
  • color (list) – A list of color mag_i - mag_j (ordinate)
  • mag (list) – List of magnitude (abciss)
  • **kwargs
    • minc (float): lower cut on the color axis: color > minc (1.0)
    • maxc (float): upper cut of the color axis: color < maxc (2.0)
    • minm (float): lower cut on the mag axis: mag > minm (20.0)
    • maxm (float): upper cut of the mag axis: mag < maxm (23.5)
    • islope (float): first guess for the red sequence band slope (-0.04)
    • nbins (int): Number of bins used in the fits (40)
    • plot (bool): if True plot stuff
    • verbose (bool): if True print information to screen
Returns:

  • slope of the red sequence band,
  • ordinate at the origin of the red sequence band +/- 1.5 sigma

fitRedSequence is also producing some control plots

clusters.background.get_rs_background(config, data)

Return flag based on RS criterion for galaxy selection.

clusters.background.get_zphot_background(config, zdata, zspec=None, z_config=None, thresh=None, zmin=None, zmax=None, plot=None)

Return flag based on zphot criterion for galaxy selection.

clusters.background.red_sequence_cut(config, data, **kwargs)

Identify RS galaxies using color-magnitude diagram.

First do a radial cut on catalogue and identify the RS from the inner galaxies –> increase the contrast of the RS Then go back and apply the cut on the entire catalogue as some RS galaxies are located far away from the centre

Returns bool array, where False means the object does not pass the cut

List of available kwargs:

Parameters:
  • mag_cut (float) – rband magnitude cut - default is 25
  • plot (float) – if keywords exists, plot stuff for visual inspection
clusters.background.zphot_cut(zclust, zdata, **kwargs)

Redshif selection of the galaxies used for analysis, using both: - hard cut, z_cl+0.1 < z_best < 1.25 (cf WtGIII) - cut from pdz. int_0^z_cl p(z) dz < x%

Parameters:
  • plot (float) – if keywords exists, plot stuff for visual inspection
  • thresh (float) – tolerance x% for the pdz cut method.

Returns bool arrays, where False means the object does not pass the cut

clusters.data module

Data builder and parser for the Clusters package.

class clusters.data.Catalogs(path, load_butler=True)

Bases: object

Load data from a LSST stack butler path.

load_catalogs(catalogs, **kwargs)

Load a list of catalogs.

Parameters:
  • catalogs (str/list) – A catalog name, or a list of catalogs (see below)
  • keys (dict) – A dictionnary of keys to load for each catalog

Available kwargs are:

Parameters:
  • update (bool) – Set to True if you want to update an already loaded catalog
  • show (bool) – Set to True to get all available keys of a (list of) catalog(s)
  • matchid (bool) – Will only keep objects which are in the deepCoad catalogs (to be used when loading the forced_src and deepCoadd catalogs)

Examples of catalogs that you can load:

  • ‘deepCoadd_ref’,
  • ‘deepCoadd_meas’,
  • ‘deepCoadd_forced_src’,
  • ‘deepCoadd_calexp’,
  • ‘forced_src’
  • ‘src’
save_catalogs(output_name, catalog=None, overwrite=False, delete_catalog=False)

Save the catalogs into an hdf5 file.

show_keys(catalogs=None)

Show all the available keys.

clusters.data.get_astropy_table(cat, **kwargs)

Convert an afw data table into a simple astropy table.

Parameters:cat – an afw data table
Returns:the corresponding astropy.table.Table
clusters.data.save_wcs(wcs, output)

Save the wcs dictionnary into a valid astropy Table format.

clusters.data.shorten(doc)

Hack to go around an astropy/hdf5 bug. Cut in half words longer than 18 chars.

clusters.extinction module

Converting tools for extinction.

clusters.extinction.from_ebv_sfd_to_megacam_albd(ebv)

Return A(lbd) for the 6 Megacam filters: u, g, r, i, z.

clusters.extinction.from_ebv_sfd_to_sdss_albd(ebv)

Return A(lbd) for the 5 SDSS filters: u, g, r, i, z.

clusters.extinction.from_sdss_albd_to_megacam_albd(sdss)

Return A(lbd) for the 6 Megecam filters: u, g, r, i_old, i_new, z.

clusters.extinction.plots(ra, dec, ebv, albd, title=None, figname='')

Plot the extinction sky-map.

clusters.main module

clusters.shear module

Shear analysis.

clusters.shear.analysis(table, xclust, yclust, e1='ext_shapeHSM_HsmShapeRegauss_e1', e2='ext_shapeHSM_HsmShapeRegauss_e2', config=None, datafile=None, step=200)

Computethe shear.

Parameters:
  • data_file (string) – Name of the hdf5 file to load
  • path (string) – Path (key) of the table to load
Returns:

A dictionnary containing the following keys and values:

  • meas: the ‘deepCoadd_meas’ catalog (an astropy table)
  • forced: the ‘deepCoad_forced_src’ catalog (an astropy table)
  • wcs: the ‘wcs’ of these catalogs (an astropy.wcs.WCS object)

clusters.shear.compare_shear(catalogs, xclust, yclust, qcut=None, param='Tshear')

Compare shear mesured on the coadd and shear measured on indivial ccd.

For now, do: from clusters import data from clusters import shear config = data.load_config(‘MACSJ2243.3-0935.yaml’) catalogs = data.read_hdf5(‘test_data2.hdf5’) xc, yc = shear.xy_clust(config, data.load_wcs(catalogs[‘wcs’])) tables = shear.compare_shear([catalogs[‘deepCoadd_meas’], catalogs[‘forced_src’]], xc, yc)

clusters.shear.compute_shear(e1, e2, distx, disty)

Compute the shear.

clusters.shear.kappa_plot(x, y, e1, e2)
clusters.shear.plot_hist(xs, labels, nbins=200, xarange=(-2, 2))

Plot multiple histograms in subplots.

clusters.shear.plot_scatter(xs, ys, xlabels, ylabels, **kwargs)

Plot multiple scatter plots in subplots.

Parameters:
  • xs (list) – List of arrays for x axis
  • ys (list) – List of arrays for y axis
  • xlabels (str) – List of x labels
  • ylabels (str) – List of y labels

List of available kwargs: :param list yerrs: List of arrays, error on the y axis :param list xarange: Range for x axis (min,max) :param list yarange: Range for y axis (min,max)

clusters.shear.plot_shear(gamt, gamc, dist, drange=(0, 8500), nbins=8)

Plot shear.

clusters.shear.quiver_plot(meas)
clusters.shear.xy_clust(config, wcs)

Return xy coordinate (pixel).

clusters.validation module

Data validation utilisites and plots.

clusters.validation.check_star_elipticities(d, cat='deepCoadd_meas', oid='id')

Compute star elipticities from second momments and check if psf correction is valid.

Also check magnitude vss radius

clusters.validation.compute_elipticities(xx, yy, xy)

Compute star elipticities from second momments.

clusters.validation.define_selection_filter(d, cat)

Define and return a standard quality selection filter.

clusters.validation.get_filter_list(table)

Get the filter list and number of filter in a table.

clusters.validation.load_cluster(cluster='MACSJ2243.3-0935', ifilt='i_new')

Load the data for a given cluster.

clusters.validation.separate_star_gal(d, cat, oid, nfilters, filt=None)

Return two clean tables: one for the stars, the other for the galaxies.

clusters.validation.stellarLocus(d, mag_type='modelfit_CModel_mag_extcorr', ifilt='i_new', cat='deepCoadd_forced_src')

Check colors by plotting stellar loci and comparing with analytical fits.

First a few color-color (and one mag-color) plots are plotted based on the input magnitudes. Since analytical fits are based on SDSS data, the given magnitudes are then converted to SDSS mags. Fits are overplotted with the derived SDSS magnitudes, and then residuals are calculated and plotted. The analytical plots are plotted as an intermediary as well.

Three plots are saved. Nothing is returned.

clusters.zphot module

Photometric redshift analysis. Includes a wrapper to LEPHARE and BPZ.

class clusters.zphot.BPZ(magnitudes, errors, zpara=None, spectro_file=None, **kwargs)

Bases: object

Wrapper to the BPZ photometric redshift code.

http://www.stsci.edu/~dcoe/BPZ

build_columns_file(prefix='CFHT_megacam_', sufix='p', filters=None, ref='i', z_s=False)

Build and write the ‘columns’ file.

Hardcoded for test purpose.

run()

Run BPZ.

Configuration file must exist in the current directory.

Todo

Build the configuration file on the fly (the .columns)

write_input()

Create and write files needed to run BPZ.

  • the input data file for BPZ
  • a similar file containing the sources ID along with their RA DEC.
class clusters.zphot.LEPHARE(magnitudes, errors, zpara=None, spectro_file=None, **kwargs)

Bases: object

Wrapper to the LEPHARE photometric redshift code.

http://www.cfht.hawaii.edu/~arnouts/LEPHARE/lephare.html

check_config(config=None)

Check that the SED and filters requested for the LePhare run do exist.

If not: explains where the problem is and aborts.

run(config=None)

Run LEPHARE.

Default config file is $LEPHAREDIR/config/zphot_megacam.para. Can be overwritten with the config argument

write_input()

Create and write files needed to run LEPHARE.

  • the input data file for LEPHARE
  • a similar file containing the sources ID along with their RA DEC.
class clusters.zphot.ZPHOTO(zphot_output, zphot_pdz_output, zcode_name=None, all_input=None, **kwargs)

Bases: object

Read photoz code (LePhare, BPZ) output file and creates/saves astropy tables.

hist(param, **kwargs)

Plot histograms.

Possible kwargs

Params float minv:
 Lower value of the histogram
Params float maxv:
 Upper value of the histogram
Params int nbins:
 Number of bins. Default is 10.
Params string xlabel:
 An xlbal for the figure
Params string title:
 A title for the figure
Params float zclust:
 Redshift of the studies cluster
plot(px, py, **kwargs)

Plot x vs. y.

Possible kwargs are: :params float minx: lower limit of the x axis :params float maxx: upper limit of the x axis :params float miny: lower limit of the y axis :params float maxy: upper limit of the y axis :params string xlabel: label of the x axis :params string ylabel: label of the y axis :params string title: title of the figure

plot_map(title=None, zmin=0, zmax=999)

Plot the redshift sky-map.

read()

Read the output.

read_input()

Read the input.

save_zphot(file_out, path_output, overwrite=False)

Save the output of photoz code (z_best, chi^2, pdz) into astropy table.

class clusters.zphot.ZSPEC(sfile, names, unit='deg')

Bases: object

Compare spectroscopic and photometric redshifts.

load_zphot(ra, dec, zphot, unit='deg')

Load the photometric informations and match them to the spectro ones.

Parameters:
  • ra (list) – List of RA coordinates
  • dec (list) – List of DEC coordinates
  • zphot (list) – List of photometric redshift
  • unit (list) – List of RA coordinates

All lists must have the same length.

plot(cut=300, path_to_png=None)

Plot a sky-map of the matches.

scatter(zclust, cluster=None, cut=0.1, stability=False)

Redshift scatter in the cluster.

Plot the spectroscopic redshift distribution and apply a gaussian fit.

clusters.zphot.dict_to_array(d, filters='ugriz')

Transform a dictionnary into a list of arrays.

clusters.zphot.gauss(x, *p)

Model function to be used to fit a gaussian distribution.

Module contents

Cluster analysis on the LSST DM stack.