#!/usr/bin/env python3
# Author: Akke Viitanen
# Email: akke.viitanen@helsinki.fi
# Date: 2025-09-23 16:04:03
"""Implement wrapper for Shen+2020 data."""
from functools import cache
import astropy.units as u
import numpy as np
from quasarlf.pubtools.load_observations import get_data
[docs]
def get_phi_shen2020(z):
"""
Return Shen+2020 luminosity function dataset for the given redshift.
Parameters
----------
z: float
redshift of interest
Returns
-------
4-element list of luminosity function datasets corresponding to the
wavelength 15um, 4400angstrom, 1450angstrom and 2-10 keV, respectively.
Refer to Shen+2020 quasarlf library for the details.
"""
@cache
def get(dataid: int, lam: u.Quantity, z: float):
"""Return a single dataset corresponding to dataid, wavelength and redshift."""
# Return the Shen luminosity function for a single dataid
x, y, dy, dx = get_data(dataid, z)
if dataid == -4:
L_solar_in_cgs = np.log10(u.L_sun.cgs.scale)
x += L_solar_in_cgs
if dataid in (-2, -1):
# Convert from Lsun / dex to ABmag / mag
x = 10**x * u.L_sun / lam.to(u.Hz, equivalencies=u.spectral())
L_AB = 3631.0 * u.Jy * 4 * np.pi * (10 * u.pc) ** 2
x = -2.5 * np.log10((x / L_AB).cgs)
y -= np.log10(2.5)
return x, dx, y, dy
dataset = [(-2, 15.0 * u.um), (-1, 4400 * u.angstrom), (-5, 1450 * u.angstrom), (-4, None)]
return [get(dataid, lam, z) for dataid, lam in dataset]