photoz

class txpipe.photoz.TXRandomPhotozPDF(*args: Any, **kwargs: Any)[source]

Bases: ceci.

This is a placeholder for an actual photoz pipeline!

At the moment it just randomly generates a log-normal PDF for each object.

The pipeline loops through input photometry data, “calculating” (at random!) a PDF and a point-estimate for each row. It must generate the point estimates for the five different metacal variants (which each have different shears applied).

It can do this in parallel if needed.

We might want to move some of the functionality here (e.g. the I/O) into a general parent class.

calculate_photozs(data, z)[source]

Generate random photo-zs.

This is a mock method that instead of actually running any photo-z analysis just spits out some random PDFs.

This method is run on chunks of data, not the whole thing at once.

It does however generate outputs in the right format to be saved later, and generates point estimates, used for binning and assumed to be a mean or similar statistic from each bin, for each of the five metacalibrated variants of the magnitudes.

Parameters
  • data (dict of arrays) – Chunk of input photometry catalog containing object magnitudes

  • z (array) – The redshift values at which to “compute” P(z) values

Returns

  • pdfs (array of shape (n_chunk, n_z)) – The output PDF values

  • point_estimates (array of shape (5, n_chunk)) – Point-estimated photo-zs for each of the 5 metacalibrated variants

prepare_output(nobj, z)[source]

Prepare the output HDF5 file for writing.

Note that this is done by all the processes if running in parallel; that is part of the design of HDF5.

Parameters
  • nobj (int) – Number of objects in the catalog

  • z (array) – Points on the redshift axis that the PDF will be evaluated at.

Returns

f – The output file, opened for writing.

Return type

h5py.File object

run()[source]

Run the analysis for this stage.

  • prepares the output HDF5 file

  • loads in chunks of input data, one at a time

  • computes mock photo-z PDFs for each chunk

  • writes each chunk to output

  • closes the output file

write_output(output_file, start, end, pdfs, point_estimates)[source]

Write out a chunk of the computed PZ data.

Parameters
  • output_file (h5py.File) – The object we are writing out to

  • start (int) – The index into the full range of data that this chunk starts at

  • end (int) – The index into the full range of data that this chunk ends at

  • pdfs (array of shape (n_chunk, n_z)) – The output PDF values

  • point_estimates (array of shape (5, n_chunk)) – Point-estimated photo-zs for each of the 5 metacalibrated variants