Ejemplo n.º 1
0
def model_spectrum(model, **kwargs):
    from simqso.sqbase import fixed_R_dispersion
    from simqso.sqrun import buildQsoSpectrum
    from simqso import sqgrids as grids
    wave = fixed_R_dispersion(0.1e4, 10e4, 500)
    m, z = np.array([-25]), np.array([1.0])
    M = grids.AbsMagVar(grids.FixedSampler(m), restWave=1450)
    z = grids.RedshiftVar(grids.FixedSampler(z))
    qsos = grids.QsoSimPoints([M, z],
                              cosmo=ebosscore.dr9cosmo,
                              units='luminosity')
    qsos = ebosscore.runsim(model,
                            None,
                            None,
                            qsos,
                            wave=wave,
                            const=True,
                            nophot=True)
    specFeatures = qsos.getVars(grids.SpectralFeatureVar)
    spec, comp = buildQsoSpectrum(wave,
                                  qsos.cosmo,
                                  specFeatures,
                                  qsos.data[0],
                                  save_components=True)
    spec.wave /= 2.0
    return spec, comp, qsos
Ejemplo n.º 2
0
def model_colorz_tracks(model, forestFile, **kwargs):
    mbins, zbins = get_colorz_bins(**kwargs)
    nm, nz = len(mbins), len(zbins)
    M, z = np.meshgrid(mbins, zbins, indexing='ij')
    M = grids.AbsMagVar(grids.FixedSampler(M.flatten()), restWave=1450)
    z = grids.RedshiftVar(grids.FixedSampler(z.flatten()))
    qsos = grids.QsoSimPoints([M, z],
                              cosmo=ebosscore.dr9cosmo,
                              units='luminosity')
    qsos = ebosscore.runsim(model,
                            None,
                            forestFile,
                            qsos,
                            medianforest=True,
                            const=True,
                            nophot=True)
    synmags = np.array(qsos.data['synMag'].reshape(nm, nz, -1))
    synclrs = -np.diff(synmags, axis=-1)
    synfluxes = np.array(qsos.data['synFlux'].reshape(nm, nz, -1))
    synfratios = synfluxes[..., :-1] / synfluxes[..., 1:]
    return dict(mbins=mbins,
                zbins=zbins,
                synmags=synmags,
                syncolors=synclrs,
                synfluxes=synfluxes,
                synfratios=synfratios,
                qsos=qsos)
Ejemplo n.º 3
0
def run_w4_sim(cosmo):
    wave = sqbase.fixed_R_dispersion(3000, 7e4, 500)
    #
    if False:
        m = sqgrids.AbsMagVar(sqgrids.UniformSampler(-25, -23), 1450)
        units = 'luminosity'
    else:
        m = sqgrids.AppMagVar(sqgrids.UniformSampler(21.4, 22.9), 'CFHT-i')
        units = 'flux'
    z = sqgrids.RedshiftVar(sqgrids.UniformSampler(3.5, 4.5))
    #
    qsoGrid = sqgrids.QsoSimGrid([m, z], (40, 20),
                                 100,
                                 cosmo=cosmo,
                                 units=units)
    #
    tmp_m2M = lambda z: sqbase.mag2lum('SDSS-i', 1450, z, cosmo)
    absMagVals = sqgrids.FixedSampler(qsoGrid.appMag - tmp_m2M(qsoGrid.z))
    qsoGrid.addVar(sqgrids.AbsMagVar(absMagVals, 1450))
    #
    bossDr9model = sqmodels.get_BossDr9_model_vars(qsoGrid, wave, 2000)
    qsoGrid.addVars(bossDr9model)
    #
    qsoGrid.loadPhotoMap([('CFHT', 'CFHTLS_Wide'), ('UKIRT', 'UKIDSS_DXS')])
    #
    _ = sqrun.buildSpectraBySightLine(wave, qsoGrid, maxIter=5, verbose=10)
    #
    photoData = sqphoto.calcObsPhot(qsoGrid.synFlux, qsoGrid.photoMap)
    qsoGrid.addData(photoData)
    #
    qsoGrid.write(simfile)
    return qsoGrid
Ejemplo n.º 4
0
def sample_qlf(qlf, mrange=(17, 22), zrange=(0.9, 4.0), skyArea=3000):
    obsBand = 'SDSS-r'
    kcorr = lambda z: sqbase.continuum_kcorr(obsBand, 1450, z)
    m2M = lambda z: sqbase.mag2lum(obsBand, 1450, z, qlf.cosmo)
    m, z = grids.generateQlfPoints(qlf,
                                   mrange,
                                   zrange,
                                   obsBand,
                                   kcorr=kcorr,
                                   skyArea=skyArea,
                                   fast_sample=True)
    qlfGrid = grids.QsoSimPoints([m, z], cosmo=qlf.cosmo, units='flux')
    qlfGrid.addVar(
        grids.AbsMagVar(grids.FixedSampler(qlfGrid.appMag - m2M(qlfGrid.z))))
    return qlfGrid