Example #1
0
def observed_to_comoving_grid(obins, nurest, cosmo):
    """
    Convert an observed (ang x ang x freq) grid to a comoving grid

    APPROXIMATION: Assume a single (mean) redshift for the entire cube, for converting angle to transverse comoving distance.

    Parameters
    ----------
    obins : tuple or list of arrays, length (M+1, N+1, P+1)
        bin edges of angular and frequency directions

    nurest : float
        observed (redshifted) frequency of mapped line at z=0

    cosmo : 
    """
    
    logging.info("Converting (ang x ang x frq) grid to comoving grid...")

    xa, ya, zf  = obins

    redshift        = nurest/zf - 1.
    redshift_avg    = np.mean(redshift)
    depth_coMpc     = fn.z_to_cmpc(redshift, cosmo)

    xc = fn.arcmin_to_cmpc(xa, redshift_avg, cosmo)
    yc = fn.arcmin_to_cmpc(ya, redshift_avg, cosmo)
    zc = np.linspace(np.min(depth_coMpc), np.max(depth_coMpc), depth_coMpc.size)

    logging.info("  x : (%8.2f to %8.2f arcmin) --> (%8.2f to %8.2f Mpc)" % (np.min(xa), np.max(xa), np.min(xc), np.max(xc)))
    logging.info("  y : (%8.2f to %8.2f arcmin) --> (%8.2f to %8.2f Mpc)" % (np.min(ya), np.max(ya), np.min(yc), np.max(yc)))
    logging.info("  z : (%8.2f to %8.2f GHz   ) --> (%8.2f to %8.2f Mpc)" % (np.min(zf), np.max(zf), np.min(zc), np.max(zc)))
    logging.info("")

    return xc, yc, zc
Example #2
0
def observed_to_covolume_grid(obins, nurest, cosmo):
    """Convert angxangxfreq bins to grid of comoving cell volumes.

    Parameters
    ----------
    obins : 3-tuple of 1d arrays
        arrays of bin edges in (arcmin, arcmin, and [freq]) respectively

    nurest : float
        rest frame frequency of spectral line of interest

    cosmo : 

    Returns
    -------
    vol : 3d array
        3d array of volume elements, in Mpc^3
    """

    xo, yo, zo = obins
    zred_bins = nurest / zo - 1.  # 1d array of redshift bin edges, in depth direction
    zred_mid = _bin_midpoints(
        zred_bins)  # 1d array of redshift bin midpoints, in depth direction

    zcobins = fn.z_to_cmpc(zred_bins,
                           cosmo)  # Bin edges in z-direction [comoving Mpc]
    dzco = _bin_lengths(zcobins)  # Bin lengths in z-direction [comoving Mpc]

    # Check that binning is equal in x and y directions
    assert np.allclose((xo[1] - xo[0]), _bin_lengths(xo))
    assert np.allclose((yo[1] - yo[0]), _bin_lengths(yo))

    dxa = xo[1] - xo[0]  # single bin length, in x[arcmin]
    dya = yo[1] - yo[0]  # single bin length, in y[arcmin]

    dxco = fn.arcmin_to_cmpc(
        dxa, zred_mid, cosmo
    )  # Bin lengths in x-direction, sampled along the z-direction [co-moving Mpc]
    dyco = fn.arcmin_to_cmpc(
        dya, zred_mid, cosmo
    )  # Bin lengths in y-direction, sampled along the z-direction [co-moving Mpc]

    dvco_1d = np.abs(dxco * dyco * dzco)
    vol = np.tile(dvco_1d,
                  (xo.size - 1, yo.size - 1,
                   1))  # Create 3D array of comoving element volumes [Mpc^3]

    return vol
Example #3
0
def observed_to_covolume_grid(obins, nurest, cosmo):
    """Convert angxangxfreq bins to grid of comoving cell volumes.

    Parameters
    ----------
    obins : 3-tuple of 1d arrays
        arrays of bin edges in (arcmin, arcmin, and [freq]) respectively

    nurest : float
        rest frame frequency of spectral line of interest

    cosmo : 

    Returns
    -------
    vol : 3d array
        3d array of volume elements, in Mpc^3
    """

    xo, yo, zo  = obins
    zred_bins   = nurest/zo - 1.            # 1d array of redshift bin edges, in depth direction
    zred_mid    = _bin_midpoints(zred_bins)        # 1d array of redshift bin midpoints, in depth direction

    zcobins = fn.z_to_cmpc(zred_bins, cosmo)    # Bin edges in z-direction [comoving Mpc]
    dzco    = _bin_lengths(zcobins)                # Bin lengths in z-direction [comoving Mpc]

    # Check that binning is equal in x and y directions
    assert np.allclose( (xo[1]-xo[0]), _bin_lengths(xo) )
    assert np.allclose( (yo[1]-yo[0]), _bin_lengths(yo) )

    dxa = xo[1]-xo[0] # single bin length, in x[arcmin]
    dya = yo[1]-yo[0] # single bin length, in y[arcmin]

    dxco = fn.arcmin_to_cmpc(dxa, zred_mid, cosmo)    # Bin lengths in x-direction, sampled along the z-direction [co-moving Mpc]
    dyco = fn.arcmin_to_cmpc(dya, zred_mid, cosmo)    # Bin lengths in y-direction, sampled along the z-direction [co-moving Mpc]

    dvco_1d = np.abs(dxco*dyco*dzco)
    vol = np.tile(dvco_1d, (xo.size-1, yo.size-1, 1)) # Create 3D array of comoving element volumes [Mpc^3]

    return vol
Example #4
0
def observed_to_comoving_grid(obins, nurest, cosmo):
    """
    Convert an observed (ang x ang x freq) grid to a comoving grid

    APPROXIMATION: Assume a single (mean) redshift for the entire cube, for converting angle to transverse comoving distance.

    Parameters
    ----------
    obins : tuple or list of arrays, length (M+1, N+1, P+1)
        bin edges of angular and frequency directions

    nurest : float
        observed (redshifted) frequency of mapped line at z=0

    cosmo : 
    """

    logging.info("Converting (ang x ang x frq) grid to comoving grid...")

    xa, ya, zf = obins

    redshift = nurest / zf - 1.
    redshift_avg = np.mean(redshift)
    depth_coMpc = fn.z_to_cmpc(redshift, cosmo)

    xc = fn.arcmin_to_cmpc(xa, redshift_avg, cosmo)
    yc = fn.arcmin_to_cmpc(ya, redshift_avg, cosmo)
    zc = np.linspace(np.min(depth_coMpc), np.max(depth_coMpc),
                     depth_coMpc.size)

    logging.info("  x : (%8.2f to %8.2f arcmin) --> (%8.2f to %8.2f Mpc)" %
                 (np.min(xa), np.max(xa), np.min(xc), np.max(xc)))
    logging.info("  y : (%8.2f to %8.2f arcmin) --> (%8.2f to %8.2f Mpc)" %
                 (np.min(ya), np.max(ya), np.min(yc), np.max(yc)))
    logging.info("  z : (%8.2f to %8.2f GHz   ) --> (%8.2f to %8.2f Mpc)" %
                 (np.min(zf), np.max(zf), np.min(zc), np.max(zc)))
    logging.info("")

    return xc, yc, zc