Example #1
0
def test_get_max_z():
    gwcosmo = GWCosmo(default_cosmology.get_cosmology_from_string('Planck15'))
    f_low = 10
    f_high = 4096
    df = 0.1
    waveform = 'IMRPhenomPv2'
    snr = 8
    m1 = np.asarray([50.0])
    m2 = np.asarray([30.0, 50.0])
    x1 = np.asarray([-1.0, 0.0, 1.0])
    x2 = np.asarray([-1.0, -0.5, 0.5, 1.0])

    psd = lal.CreateREAL8FrequencySeries('', 0, f_low, df,
                                         lal.DimensionlessUnit,
                                         int((f_high - f_low) // df))
    lalsimulation.SimNoisePSDaLIGODesignSensitivityP1200087(psd, f_low)

    result = gwcosmo.get_max_z([psd], waveform, f_low, snr, m1, m2, x1, x2)
    # Check that shape matches
    assert result.shape == (1, 2, 3, 4)
    # Spot check some individual cells
    for im1, m1_ in enumerate(m1):
        for im2, m2_ in enumerate(m2):
            for ix1, x1_ in enumerate(x1):
                for ix2, x2_ in enumerate(x2):
                    expected = gwcosmo.z_at_snr([psd], waveform, f_low, snr,
                                                m1_, m2_, x1_, x2_)
                    assert result[im1, im2, ix1, ix2] == expected
Example #2
0
    def set_cosmology(self, cosmology):
        """
        Compute the L**p distance between two arrays.

        Parameters
        ----------
        x : astropy.cosmology.core.FLRW subclass or string
            class that provides methods to compute the number of arcseconds
            per kpc (comoving), or a string specifing a predefined cosmology
            in astropy.

        Examples
        --------
        >>> get_angle = fastDang2Angle()
        >>> get_angle.set_cosmology("WMAP7")
        >>> get_angle.cosmology
        FlatLambdaCDM(name="WMAP7", H0=70.4 km / (Mpc s), Om0=0.272,
        Tcmb0=2.725 K, Neff=3.04, m_nu=[0. 0. 0.] eV, Ob0=0.0455)

        """
        if type(cosmology) is str:
            self.cosmology = \
                default_cosmology.get_cosmology_from_string(cosmology)
        elif not issubclass(type(cosmology), FLRW):
            raise TypeError("cosmology must be subclass of type %s" %
                            str(FLRW))
        else:
            self.cosmology = cosmology
        self._fit_spline()
Example #3
0
def test_sensitive_volume(z):
    """Test that the sensitive volume has the correct derivative with z."""
    gwcosmo = GWCosmo(default_cosmology.get_cosmology_from_string('Planck15'))
    dVC_dz = gwcosmo.cosmo.differential_comoving_volume(z)
    expected = (dVC_dz / (1 + z) * 4 * np.pi * u.sr).to_value(u.Mpc**3)
    actual = derivative(gwcosmo.sensitive_volume, x0=z,
                        dx=1e-6 * z).to_value(u.Mpc**3)
    assert expected == pytest.approx(actual)
Example #4
0
def test_z_at_snr(mtotal, z):
    gwcosmo = GWCosmo(default_cosmology.get_cosmology_from_string('Planck15'))
    f_low = 10
    f_high = 4096
    df = 0.1
    mass1 = mass2 = 0.5 * mtotal

    psd = lal.CreateREAL8FrequencySeries('', 0, f_low, df,
                                         lal.DimensionlessUnit,
                                         int((f_high - f_low) // df))
    lalsimulation.SimNoisePSDaLIGODesignSensitivityP1200087(psd, f_low)

    snr = get_snr_at_z_lalsimulation(gwcosmo.cosmo, z, mass1, mass2, f_low,
                                     f_high, psd)
    z_solution = gwcosmo.z_at_snr([psd], 'IMRPhenomPv2', f_low, snr, mass1,
                                  mass2, 0, 0)

    assert z_solution == pytest.approx(z, rel=1e-2)
Example #5
0
def test_sensitive_volume_0():
    gwcosmo = GWCosmo(default_cosmology.get_cosmology_from_string('Planck15'))
    assert gwcosmo.sensitive_volume(0) == 0
Example #6
0
def test_sensitive_distance(z):
    gwcosmo = GWCosmo(default_cosmology.get_cosmology_from_string('Planck15'))
    expected = gwcosmo.sensitive_volume(z).to_value(u.Mpc**3)
    actual = (4 / 3 * np.pi * gwcosmo.sensitive_distance(z)**3).to_value(
        u.Mpc**3)
    assert expected == pytest.approx(actual)
Example #7
0
def test_sensitive_volume_0():
    cosmo = default_cosmology.get_cosmology_from_string('Planck15')
    assert sensitive_volume(cosmo, 0) == 0