From 8b8c6bb3e457b8ac603fe0ac783c901694154d9f Mon Sep 17 00:00:00 2001 From: rstiskalek Date: Fri, 20 Sep 2024 08:54:51 +0100 Subject: [PATCH] Add basic updates --- csiborgtools/flow/flow_model.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/csiborgtools/flow/flow_model.py b/csiborgtools/flow/flow_model.py index 5916de4..c969115 100644 --- a/csiborgtools/flow/flow_model.py +++ b/csiborgtools/flow/flow_model.py @@ -313,13 +313,13 @@ def radial_velocity_los(los_velocity, ra, dec): # JAX Flow model # ############################################################################### -def dist2redshift(dist, Omega_m): +def dist2redshift(dist, Omega_m, h=1.): """ Convert comoving distance to cosmological redshift if the Universe is flat and z << 1. """ eta = 3 * Omega_m / 2 - return 1 / eta * (1 - (1 - 2 * H0 * dist / SPEED_OF_LIGHT * eta)**0.5) + return 1 / eta * (1 - (1 - 2 * 100 * h * dist / SPEED_OF_LIGHT * eta)**0.5) def redshift2dist(z, Omega_m): @@ -902,14 +902,36 @@ class PV_LogLikelihood(BaseFlowValidationModel): else: raise ValueError(f"Unknown kind: `{self.kind}`.") + h = field_calibration_params["h"] # ---------------------------------------------------------------- # 2. Log-likelihood of the true distance and observed redshifts. # The marginalisation of the true distance can be done numerically. # ---------------------------------------------------------------- if self.with_num_dist_marginalisation: + + if field_calibration_params["sample_h"]: + # Rescale the grid to account for the sampled H0. For distance + # modulus going from Mpc / h to Mpc implies larger numerical + # values, so there has to be a minus sign since h < 1. + mu_xrange = self.mu_xrange - 5 * jnp.log(h) + + # The redshift should also be boosted since now the object are + # further away? + + # Actually, the redshift ought to remain the same? + + # TODO: finish this + + r_range = self.r_xrange * h + # Actually no need to do this. + z_range = dist2redshift(r_range, self.Omega_m, h) + else: + mu_xrange = self.mu_xrange + z_range = self.z_xrange + # Calculate p(r) (Malmquist bias). Shape is (ndata, nxrange) log_ptilde = log_ptilde_wo_bias( - self.mu_xrange[None, :], mu[:, None], e2_mu[:, None], + mu_xrange[None, :], mu[:, None], e2_mu[:, None], self.log_r2_xrange[None, :]) # Inhomogeneous Malmquist bias. Shape: (nsims, ndata, nxrange)