Closed raphaelshirley closed 1 year ago
I think the qp demo.ipynb notebook https://github.com/LSSTDESC/qp/blob/main/nb/demo.ipynb already has a very simple example of this in the qp interpolated parameterization
section, the gist of it is that if you have a linear grid of N values called xgrid
and an MxN array of PDF values called pdfvals
you can create an ensemble with ens = qp.Ensemble(qp.interp, data=dict(xvals=xgrid, yvals=pdfvals))
As another quick example, the following should make an ensemble of 10 PDFs on a grid of 31 x values filled with random numbers:
import numpy as np
import qp
x = np.linspace(0,3,31)
pdfs = np.random.random(310).reshape(10,31)
ens = qp.Ensemble(qp.interp, data=dict(xvals=x, yvals=pdfs))
You can also save the ensemble to hdf5 with ens.write_to("myensemble.hdf5")
, and then read that directly into qp and/or RAIL later with ens = qp.read("myensemble.hdf5")
.
And for calculating PIT values and metrics with RAIL, there's a demo notebook here: https://github.com/LSSTDESC/rail/blob/main/examples/evaluation_examples/demo.ipynb
Ok great thank you that is very useful. Sorry for missing it already being there.
I am working on creating a rail wrapper for the LePhare template fitting code.
https://gitlab.lam.fr/Galaxies/LEPHARE/
As part of our early testing we would like to look at some PIT plots and other rail metrics for example PDFs produced by LePHARE. These come in simple files of linear redshift grids with probability density values. Is it possible to create a simple example notebook taking such a file and creating a qp ensemble from it?
Many thanks,
Raphael.