Loading src/lsst_inaf_agile/catalog_agn.py +9 −2 Original line number Diff line number Diff line Loading @@ -621,7 +621,14 @@ class CatalogAGN: return log_L_bol def get_MBH( self, sigma_total=0.50, offset=0.00, sigma_intrinsic=False, sigma_observational=None, select=None self, sigma_total=0.50, offset=0.00, sigma_intrinsic=False, sigma_observational=None, select=None, *args, **kwargs, ): """ Return log10 of the supermassive black hole mass in Msun. Loading @@ -631,7 +638,7 @@ class CatalogAGN: """ # Get MBH log_mbh = get_log_mbh_continuity_new2(self["M"], self["Z"]) log_mbh = get_log_mbh_continuity_new2(self["M"], self["Z"], *args, **kwargs) # Add the scatter sigma_tot = np.random.normal(scale=sigma_total, size=log_mbh.size) Loading src/lsst_inaf_agile/mbh.py +7 −6 Original line number Diff line number Diff line Loading @@ -197,10 +197,12 @@ X = None Y = None Z = None SPLINE: dict[float, CubicSpline] = {} FUN_LOG_MBH_CONTINUITY_NEW2 = None FUN_LOG_MBH_CONTINUITY_NEW2 = {} def get_log_mbh_continuity_new2(log_mstar, z): def get_log_mbh_continuity_new2( log_mstar, z, filename="opt/AGILE_Mstar_Mbh/DECODEmeans_Mstar_Mbh_Zou2024cc.dat" ): """ Return logMBH according to the continuity equation with Zou+24 p(lambda). Loading @@ -215,8 +217,7 @@ def get_log_mbh_continuity_new2(log_mstar, z): and logM are clipped to their minimum and maximum values. """ global FUN_LOG_MBH_CONTINUITY_NEW2 if FUN_LOG_MBH_CONTINUITY_NEW2 is None: filename = "opt/AGILE_Mstar_Mbh/DECODEmeans_Mstar_Mbh_Zou2024cc.dat" if filename not in FUN_LOG_MBH_CONTINUITY_NEW2: with open(filename) as f: f.readline() line = f.readline() Loading @@ -227,14 +228,14 @@ def get_log_mbh_continuity_new2(log_mstar, z): from scipy.interpolate import RegularGridInterpolator FUN_LOG_MBH_CONTINUITY_NEW2 = RegularGridInterpolator((mvec, zvec), MBH) FUN_LOG_MBH_CONTINUITY_NEW2[filename] = RegularGridInterpolator((mvec, zvec), MBH) # clip log_mstar = np.atleast_1d(log_mstar) z = np.atleast_1d(z) select = (log_mstar >= 8.5) & (log_mstar < 12.5) & (z >= 0.0) & (z < 5.5) ret = np.full_like(log_mstar, np.nan) ret[select] = FUN_LOG_MBH_CONTINUITY_NEW2((log_mstar[select], z[select])) ret[select] = FUN_LOG_MBH_CONTINUITY_NEW2[filename]((log_mstar[select], z[select])) return np.squeeze(ret) Loading tests/lsst_inaf_agile/test_mbh.py +15 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,21 @@ class TestMBH(unittest.TestCase): util.create_directory(self.dirname) plt.savefig(f"{self.dirname}/graham2023.pdf") def test_continuity_filename(self): log_mstar = np.random.uniform(9.5, 12.0, size=10000) z = np.random.uniform(0.0, 5.5, size=10000) dirname = "opt/AGILE_Mstar_Mbh" def get(f): return mbh.get_log_mbh_continuity_new2( log_mstar, z, filename=f"{dirname}/DECODEmeans_Mstar_Mbh_Zou2024cc.dat" ) mbh1 = get(f"{dirname}/DECODEmeans_Mstar_Mbh_Zou2024cc.dat") mbh2 = get(f"{dirname}/DECODEmeans_Mstar_Mbh_Zou2024c.dat") self.assertTrue(np.all(mbh2 < mbh1)) if __name__ == "__main__": unittest.main() Loading
src/lsst_inaf_agile/catalog_agn.py +9 −2 Original line number Diff line number Diff line Loading @@ -621,7 +621,14 @@ class CatalogAGN: return log_L_bol def get_MBH( self, sigma_total=0.50, offset=0.00, sigma_intrinsic=False, sigma_observational=None, select=None self, sigma_total=0.50, offset=0.00, sigma_intrinsic=False, sigma_observational=None, select=None, *args, **kwargs, ): """ Return log10 of the supermassive black hole mass in Msun. Loading @@ -631,7 +638,7 @@ class CatalogAGN: """ # Get MBH log_mbh = get_log_mbh_continuity_new2(self["M"], self["Z"]) log_mbh = get_log_mbh_continuity_new2(self["M"], self["Z"], *args, **kwargs) # Add the scatter sigma_tot = np.random.normal(scale=sigma_total, size=log_mbh.size) Loading
src/lsst_inaf_agile/mbh.py +7 −6 Original line number Diff line number Diff line Loading @@ -197,10 +197,12 @@ X = None Y = None Z = None SPLINE: dict[float, CubicSpline] = {} FUN_LOG_MBH_CONTINUITY_NEW2 = None FUN_LOG_MBH_CONTINUITY_NEW2 = {} def get_log_mbh_continuity_new2(log_mstar, z): def get_log_mbh_continuity_new2( log_mstar, z, filename="opt/AGILE_Mstar_Mbh/DECODEmeans_Mstar_Mbh_Zou2024cc.dat" ): """ Return logMBH according to the continuity equation with Zou+24 p(lambda). Loading @@ -215,8 +217,7 @@ def get_log_mbh_continuity_new2(log_mstar, z): and logM are clipped to their minimum and maximum values. """ global FUN_LOG_MBH_CONTINUITY_NEW2 if FUN_LOG_MBH_CONTINUITY_NEW2 is None: filename = "opt/AGILE_Mstar_Mbh/DECODEmeans_Mstar_Mbh_Zou2024cc.dat" if filename not in FUN_LOG_MBH_CONTINUITY_NEW2: with open(filename) as f: f.readline() line = f.readline() Loading @@ -227,14 +228,14 @@ def get_log_mbh_continuity_new2(log_mstar, z): from scipy.interpolate import RegularGridInterpolator FUN_LOG_MBH_CONTINUITY_NEW2 = RegularGridInterpolator((mvec, zvec), MBH) FUN_LOG_MBH_CONTINUITY_NEW2[filename] = RegularGridInterpolator((mvec, zvec), MBH) # clip log_mstar = np.atleast_1d(log_mstar) z = np.atleast_1d(z) select = (log_mstar >= 8.5) & (log_mstar < 12.5) & (z >= 0.0) & (z < 5.5) ret = np.full_like(log_mstar, np.nan) ret[select] = FUN_LOG_MBH_CONTINUITY_NEW2((log_mstar[select], z[select])) ret[select] = FUN_LOG_MBH_CONTINUITY_NEW2[filename]((log_mstar[select], z[select])) return np.squeeze(ret) Loading
tests/lsst_inaf_agile/test_mbh.py +15 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,21 @@ class TestMBH(unittest.TestCase): util.create_directory(self.dirname) plt.savefig(f"{self.dirname}/graham2023.pdf") def test_continuity_filename(self): log_mstar = np.random.uniform(9.5, 12.0, size=10000) z = np.random.uniform(0.0, 5.5, size=10000) dirname = "opt/AGILE_Mstar_Mbh" def get(f): return mbh.get_log_mbh_continuity_new2( log_mstar, z, filename=f"{dirname}/DECODEmeans_Mstar_Mbh_Zou2024cc.dat" ) mbh1 = get(f"{dirname}/DECODEmeans_Mstar_Mbh_Zou2024cc.dat") mbh2 = get(f"{dirname}/DECODEmeans_Mstar_Mbh_Zou2024c.dat") self.assertTrue(np.all(mbh2 < mbh1)) if __name__ == "__main__": unittest.main()