Data Type Classes

TXPipe stage input and output files are all represented by a class which defines their type and various other pieces of information.

Generic data types, such as HDF and Text file types, are inherited from ceci. TXPipe defines more specific types, like ShearCatalog.

The available types are described below.

This file contains TXPipe-specific file types, subclassing the more generic types in ceci.

class txpipe.data_types.BinnedCatalog(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

get_bins(group_name)[source]
required_datasets = []
class txpipe.data_types.CSVFile(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: DataFile

save_file(name, dataframe)[source]
suffix = 'csv'
class txpipe.data_types.ClusteringNoiseMaps(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: MapsFile

number_of_realizations()[source]
read_density_split(realization_index, bin_index)[source]
read_density_split_healpix(realization_index, bin_index)[source]
class txpipe.data_types.FiducialCosmology(path, mode, extra_provenance=None, validate=True, load_mode='full')[source]

Bases: YamlFile

to_ccl(**kwargs)[source]
class txpipe.data_types.LensingNoiseMaps(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: MapsFile

number_of_realizations()[source]
read_rotation(realization_index, bin_index)[source]
read_rotation_healpix(realization_index, bin_index)[source]
required_datasets = []
class txpipe.data_types.MapsFile(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

list_maps()[source]
plot(map_name, **kwargs)[source]
plot_gnomonic(map_name, **kwargs)[source]
plot_healpix(map_name, view='cart', rot180=False, nside=None, reduction='mean', key=None, weight_map=None, **kwargs)[source]

Plots healpix map using healpy tools

The map is read as a HealSparse map, optionally degraded to a target nside, converted to a Healpix array, and plotted with healpy

Parameters:
  • map_name (str) – Name of the map to read and plot.

  • view ({"cart", "moll"}, optional) – Healpy view type: Cartesian (“cart”) or Mollweide (“moll”).

  • rot180 (bool, optional) – If True, rotate the map by 180 degrees in longitude before plotting.

  • nside (int, optional) – Target Healpix nside for visualization. Defaults to the sparse nside of the input map.

  • reduction (str, optional) – Reduction operation used when generating the Healpix map from the HealSparse representation (e.g. “mean”, “sum”).

  • key (str, optional) – Optional key used if healsparse map is a recarray

  • **kwargs – Additional keyword arguments passed directly to the underlying healpy plotting function (e.g. min, max, cmap).

read_gnomonic(map_name)[source]
read_map(map_name)[source]

Read map and return as a healsparse map

Parameters:

map_name (str) – The name of this map

read_map_healpix(map_name, nside=None, reduction='mean', key=None, nest=True)[source]

Read map and return as a healpix array

Parameters:
  • map_name (str) – The name of this map

  • nside (int (healsparse argument)) – Output nside resolution parameter (should be a multiple of 2). If not specified the output resolution will be equal to the parent’s sparsemap nside_sparse

  • reduction (str (healsparse argument)) – If a change in resolution is requested, this controls the method to reduce the map computing the “mean”, “median”, “std”, “max”, “min”, “sum” or “prod” (product) of the neighboring pixels to compute the “degraded” map.

  • key (str (healsparse argument)) – If the parent HealSparseMap contains recarrays, key selects the field that will be transformed into a HEALPix map.

  • nest (bool, optional (healsparse argument)) – Output healpix map should be in nest format?

read_map_info(map_name)[source]
read_mask(mask_name=None, thresh=0.0, degrade_nside=None, returnbool=False)[source]

Read the mask and return as a healsparse map

Parameters:
  • map_name (str or None (optional)) – The name of this mask, if None wil load the default “mask”

  • thresh (float (optional)) – minimum fractional coverage of a pixel (at native nside)

  • degrade_nside (int) – if required, degrade the mask to this nside

  • returnbool (bool) – if True, will return a binary map where any pixel with mask > 0 is True if mask was already boolean, return unchanged

read_mask_healpix(mask_name=None, thresh=0.0, degrade_nside=None)[source]

Read the mask and return as a healpix array

Parameters:
  • map_name (str or None (optional)) – The name of this mask, if None wil load the default “mask”

  • thresh (float (optional)) – minimum fractional coverage of a pixel (at native nside)

  • degrade_nside (int or None (optional)) – degrade the mask to this nside before converting to healpix array

required_datasets = []
write_map(map_name, hsp_map, metadata)[source]

Save an output healsparse map to an HDF5 subgroup in healsparse format

Parameters:
  • map_name (str) – The name of this map, used as the name of a subgroup in the group where the data is stored.

  • pixel (array) – Array of indices of observed pixels

  • value (array) – Array of values of observed pixels

  • metadata (mapping) – Dict or other mapping of metadata to store along with the map

write_map_pixval(map_name, pixel, value, metadata, nside_coverage=32)[source]

Save an array of pixel indices and values to an HDF5 subgroup in healsparse format

The metadata is also saved.

Parameters:
  • map_name (str) – The name of this map, used as the name of a subgroup in the group where the data is stored.

  • pixel (array) – Array of indices of observed pixels

  • value (array) – Array of values of observed pixels

  • metadata (mapping) – Dict or other mapping of metadata to store along with the map

  • nside_coverage (int) – nside of the healsparse coverage map

class txpipe.data_types.PhotometryCatalog(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

get_bands()[source]
class txpipe.data_types.PhotozPDFFile(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

get_z_grid()[source]
required_datasets = []
class txpipe.data_types.QPBaseFile(*args, **kwargs)[source]

Bases: HDFFile

property metadata
class txpipe.data_types.QPMultiFile(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

This type represents and HDF file collecting multiple qp objects together.

We currently use it when multiple realizations of the same n(z) are being generated in the summarize stage.

get_names()[source]
read_ensemble(name)[source]
read_metadata(name)[source]
write_ensemble(ensemble, name)[source]
class txpipe.data_types.QPNOfZFile(*args, **kwargs)[source]

Bases: QPBaseFile

The final ensemble row represents the 2D (non-tomographic) n(z).

In a few places TXPipe assumes that the pdf type is one of the grid types, and will raise an error otherwise; in particular the stacking stage.

get_2d_n_of_z(zmax=3.0, nz=301)[source]
get_bin_n_of_z(bin_index, zmax=3.0, nz=301)[source]
get_nbin()[source]
get_qp_pdf_type()[source]
get_z()[source]

Get the redshift grid for this n(z) file.

If the QP representation used does not have a simple z grid (e.g. if it is a gaussian mixture) then this will raise an error.

read_ensemble()[source]

Read the complete QP object from this file.

write_ensemble(ensemble)[source]
class txpipe.data_types.QPPDFFile(*args, **kwargs)[source]

Bases: QPBaseFile

get_pdf_type()[source]
get_z()[source]
iterate(chunk_rows, rank=0, size=1)[source]
class txpipe.data_types.RandomsCatalog(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

required_datasets = ['randoms/ra', 'randoms/dec']
class txpipe.data_types.SACCFile(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: DataFile

close()[source]
classmethod open(path, mode, **kwargs)[source]

Open a data file. The base implementation of this function just opens and returns a standard python file object.

Subclasses can override to either open files using different openers (like fitsio.FITS), or, for more specific data types, return an instance of the class itself to use as an intermediary for the file.

read_provenance()[source]

Concrete subclasses for which it is possible should override this method and read the provenance information from the file.

Other classes will return this dictionary of UNKNOWNs

suffix = 'sacc'
class txpipe.data_types.ShearCatalog(*args, **kwargs)[source]

Bases: HDFFile

A generic shear catalog

property catalog_type
get_bands()[source]
get_primary_catalog_group()[source]
get_primary_catalog_names(true_shear=False)[source]
get_size()[source]
get_true_redshift_column()[source]
read_catalog_info()[source]
class txpipe.data_types.TomographyCatalog(path, mode, extra_provenance=None, validate=True, **kwargs)[source]

Bases: HDFFile

read_nbin()[source]
read_zbins()[source]

Read saved redshift bin edges from attributes

required_datasets = []
write_nbin(nbin)[source]

Write number of redshift bins to attributes

write_zbins(edges)[source]

Write redshift bin edges to attributes

txpipe.data_types.metacalibration_names(names)[source]

Generate the metacalibrated variants of the inputs names, that is, variants with _1p, _1m, _2p, and _2m on the end of each name.