Ejemplo n.º 1
0
def get_gal(Args, cat, get_seds=False):
    """Returns parametric bulge+dik galaxy (galsim Chromatic object).
    @Args        galaxy parametrs (same for all catsim galaxies)
    @cat         catsim row with galaxy parameters (different for every galaxy)
    @get_seds    if True, returns bulge and disk SEDs (default:False).
    """
    norm_d = cat['fluxnorm_disk']  # * 30  * np.pi * (6.67 * 100 / 2.)**2
    Args.d_SED = get_catsim_SED(cat['sedname_disk'],
                                redshift=cat['redshift'],
                                a_v=cat['av_d'],
                                r_v=cat['rv_d'],
                                model='ccm89') * norm_d
    norm_b = cat['fluxnorm_bulge']  # * 30 * np.pi * (6.67 * 100 / 2.)**2
    Args.b_SED = get_catsim_SED(cat['sedname_bulge'],
                                redshift=cat['redshift'],
                                a_v=cat['av_b'],
                                r_v=cat['rv_b'],
                                model='ccm89') * norm_b
    #  composite SED
    seds = [Args.b_SED * (1 / norm_b), Args.d_SED * (1 / norm_d)]
    Args.c_SED = Args.b_SED + Args.d_SED
    PSF = cg_fn.get_gaussian_PSF(Args)
    gal = cg_fn.get_gal_cg(Args)
    con = galsim.Convolve([gal, PSF])
    if get_seds:
        return gal, PSF, con, seds
    else:
        return gal, PSF, con
Ejemplo n.º 2
0
def get_CRG(in_p, SNRs, row, rng):
    """Create CRG for a given input galaxy parametrs.
    Bulge + Disk galaxy is created, convolved with HST PSF, drawn in HST V and
    I bands for 1 second exposure. Correlated noise (from AEGIS images)
    is added to each image. SNR in a gaussian elliptical aperture is computed.
    cgr1: The galaxy +psf images + noise correlation function is provided as
    input to CRG with default polynomial SEDs. The input galaxy images are
    padded with noise. This enables us to to draw the CRG image larger than
    the input image, and not have boundary edges.
    crg2: same as crg1 except the true SEDS of bulge and disk are provided
    as input to CRG.
    """
    #  HST scale
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    PSF = cg_fn.get_gaussian_PSF(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    con = galsim.Convolve([gal, PSF])
    images, bands = get_HST_im(con)
    psf_v = cg_fn.get_eff_psf(PSF, in_p.c_SED, bands[0])
    psf_i = cg_fn.get_eff_psf(PSF, in_p.c_SED, bands[1])
    eff_PSFs = [psf_v, psf_i]
    images, cfs = get_HST_im_noise(images, SNRs, row, rng)
    crg1 = galsim.ChromaticRealGalaxy.makeFromImages(images=images,
                                                     bands=bands,
                                                     xis=cfs,
                                                     PSFs=eff_PSFs)
    return crg1
Ejemplo n.º 3
0
def cg_other_est():
    """Test all HSM shear estimators give same value as REGAUSS (default)"""
    in_p = cg_fn.LSST_Args()
    filt = galsim.Bandpass('data/baseline/total_r.dat',
                           wave_type='nm').thin(rel_err=1e-4)
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    psf_args = cg_fn.psf_params()
    meas_args = cg_fn.meas_args(shear_est='KSB')
    meas_args.bp = filt
    gcg, gnocg = cg_fn.calc_cg_crg(gal, meas_args, psf_args)
    # Previously measured value at default galaxy parameters
    np.testing.assert_array_almost_equal((gcg / gnocg - 1).T[0],
                                         [0.00106263, 0.00106594],
                                         decimal=5)
    meas_args.shear_est = 'BJ'
    gcg, gnocg = cg_fn.calc_cg_crg(gal, meas_args, psf_args)
    # Previously measured value at default galaxy parameters
    np.testing.assert_array_almost_equal((gcg / gnocg - 1).T[0],
                                         [0.00106263, 0.00106594],
                                         decimal=5)
    meas_args.shear_est = 'LINEAR'
    gcg, gnocg = cg_fn.calc_cg_crg(gal, meas_args, psf_args)
    # Previously measured value at default galaxy parameters
    np.testing.assert_array_almost_equal((gcg / gnocg - 1).T[0],
                                         [0.00106263, 0.00106594],
                                         decimal=5)
Ejemplo n.º 4
0
def same_sed():
    """bulge and disk have same sed, cg bias must be zero"""
    in_p = cg_fn.LSST_Args(disk_SED_name='E')
    filt = galsim.Bandpass('data/baseline/total_r.dat',
                           wave_type='nm').thin(rel_err=1e-4)
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    meas_args = cg_fn.meas_args()
    meas_args.bp = filt
    psf_args = cg_fn.psf_params()
    gcg, gnocg = cg_fn.calc_cg_crg(gal, meas_args, psf_args)
    np.testing.assert_array_almost_equal((gcg / gnocg - 1).T[0], [0, 0],
                                         decimal=5)
Ejemplo n.º 5
0
def achr_psf():
    """LSST PSF is chromatic, CG bias must be 0"""
    in_p = cg_fn.LSST_Args()
    filt = galsim.Bandpass('data/baseline/total_r.dat',
                           wave_type='nm').thin(rel_err=1e-4)
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    meas_args = cg_fn.meas_args()
    meas_args.bp = filt
    psf_args = cg_fn.psf_params(alpha=0)
    gcg, gnocg = cg_fn.calc_cg_crg(gal, meas_args, psf_args)
    np.testing.assert_array_almost_equal((gcg / gnocg - 1).T[0],
                                         [0, 0],
                                         decimal=5)
Ejemplo n.º 6
0
def with_cg():
    """Raise error if no cg bias in default setting"""
    in_p = cg_fn.LSST_Args()
    filt = galsim.Bandpass('data/baseline/total_r.dat',
                           wave_type='nm').thin(rel_err=1e-4)
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    meas_args = cg_fn.meas_args()
    meas_args.bp = filt
    psf_args = cg_fn.psf_params()
    gcg, gnocg = cg_fn.calc_cg_crg(gal, meas_args, psf_args)
    np.testing.assert_raises(AssertionError,
                             np.testing.assert_array_almost_equal,
                             (gcg / gnocg - 1).T[0], [0, 0], decimal=5)
    # Previously measured value at default galaxy parameters
    np.testing.assert_array_almost_equal((gcg / gnocg - 1).T[0],
                                         [0.00106263, 0.00106594],
                                         decimal=5)
Ejemplo n.º 7
0
def with_CRG():
    """Raise error if no cg bias in default setting"""
    in_p = cg_fn.LSST_Args()
    filt = galsim.Bandpass('data/baseline/total_r.dat',
                           wave_type='nm').thin(rel_err=1e-4)
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    meas_args = cg_fn.meas_args()
    meas_args.bp = filt
    psf_args = cg_fn.psf_params()
    CRG1, CRG2 = cg_fn.get_CRG_basic(gal, in_p)
    gcg1, gnocg1 = cg_fn.calc_cg_crg(CRG1, meas_args, psf_args)
    gcg2, gnocg2 = cg_fn.calc_cg_crg(CRG2, meas_args, psf_args)
    # Previously measured value at default galaxy parameters
    np.testing.assert_array_almost_equal((gcg1 / gnocg1 - 1).T[0],
                                         [0.00128506, 0.0012862],
                                         decimal=5)
    np.testing.assert_array_almost_equal((gcg2 / gnocg2 - 1).T[0],
                                         [0.00106303, 0.00106446],
                                         decimal=5)
Ejemplo n.º 8
0
def get_lsst_para(in_p):
    """Create parametric bulge+disk galaxy for input parametrs."""
    in_p.b_SED, in_p.d_SED, in_p.c_SED = cg_fn.get_template_seds(in_p)
    gal = cg_fn.get_gal_cg(in_p)
    return gal