Esempio n. 1
0
 def _pspec(self, params):
     cc = ClusterCosmology(paramDict=params,
                           constDict=self.constdict,
                           clTTFixFile=self.clttfile)
     clst = Clustering(self.inifile, self.expname, self.gridname,
                       self.version, cc)
     return clst.fine_ps_bar(self.mus)
Esempio n. 2
0
    def instantiate_grids(self):
        mubins = list_from_config(self.config, 'general', 'mubins')
        self.mus = np.linspace(mubins[0], mubins[1], int(mubins[2]) + 1)

        cc = ClusterCosmology(paramDict=self.params,
                              constDict=self.constdict,
                              clTTFixFile=self.clttfile)
        clst = Clustering(self.inifile, self.expname, self.gridname,
                          self.version, cc)
        self.ks = clst.HMF.kh
        self.ps_fid = clst.fine_ps_bar(self.mus)
        self.veff_fid = clst.V_eff(self.mus)

        self.deltaks = np.gradient(self.ks)
        self.deltamus = np.gradient(self.mus)
Esempio n. 3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-o", "--outfile", help="name for output fisher file", required=True)
    parser.add_argument("-d", "--derivs", help="derivative file for fisher matrix", required=True)
    parser.add_argument("-f", "--factors", help="prefactor file for the fisher matrix", required=True)
    parser.add_argument("-p", "--params", help="parameters file for the fisher matrix", required=True)
    parser.add_argument("--maxkh", help="maximum value of kh to be used, explicitly cutting off the fisher. Note this is slower")
    parser.add_argument("--inifile", help="inifile for reading in a ClusterCosmology to get kh info for cutting off kh. Only needed if maxkh specified.")
    parser.add_argument("--expname", help="experiment name, only needed if maxkh specified")
    parser.add_argument("--gridname", help="name of SZ grid scheme, only needed if maxkh specified")
    args = parser.parse_args()

    DIR = 'userdata/'
    INIFILE = 'input/pipeline.ini'

    ps_derivs = np.load(args.derivs)
    ps_factors = np.load(args.factors)
    ps_params = np.load(args.params).item()
    ps_params = list(ps_params.keys())

    if args.maxkh is not None:
        cc = get_cc(args.inifile)
        clst = Clustering(args.inifile, args.expname, args.gridname, '0.6', cc)

        ps_fisher = _make_fisher_cutks(ps_derivs, ps_factors, clst, maxkh=0.14)
    else:
        ps_fisher = make_fisher(ps_derivs, ps_factors)

    ps_fisher = FisherMatrix(ps_fisher, ps_params)

    ps_fisher.to_pickle(DIR + 'fisher_' + args.outfile + '.pkl')
Esempio n. 4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-i",
                        "--inifile",
                        help="location of inifile",
                        default="input/pipeline.ini")
    parser.add_argument("-e",
                        "--expname",
                        help="name of experiment",
                        default='S4-1.0-CDT')
    parser.add_argument("-g",
                        "--gridname",
                        help="name of grid",
                        default='grid-owl2')
    parser.add_argument("-v",
                        "--version",
                        help="version number",
                        default='0.6')
    parser.add_argument("figname", help="desired figure output filename")
    parser.add_argument("--legendloc",
                        help="location of legend on figure",
                        default="best")
    parser.add_argument("-u", "--upfile", help="up-varied power spectra file")
    parser.add_argument("-d",
                        "--downfile",
                        help="down-varied power spectra file")
    parser.add_argument("-p", "--prefacfile", help="fisher prefactor file")
    parser.add_argument("-par", "--params", help="fisher parameters")
    args = parser.parse_args()

    DIR = 'userdata/figs/'

    params = np.load(args.params).item()
    psups = np.load(args.upfile)
    psdowns = np.load(args.downfile)
    prefacs = np.load(args.prefacfile)

    cc = get_cc(args.inifile)
    clst = Clustering(args.inifile, args.expname, args.gridname, args.version,
                      cc)
    make_plots_upvdown(args.inifile, clst, psups, psdowns, prefacs, params,
                       args.figname, DIR, args.legendloc)
Esempio n. 5
0
File: noise.py Progetto: mntw/szar
clttfile = Config.get('general', 'clttfile')
constDict = dict_from_section(Config, 'constants')

fparams = {}
for (key, val) in Config.items('params'):
    if ',' in val:
        param, step = val.split(',')
        fparams[key] = float(param)
    else:
        fparams[key] = float(val)

expName = 'S4-1.0-CDT'
gridName = 'grid-owl2'
version = '0.6'
cc = ClusterCosmology(fparams, constDict, clTTFixFile=clttfile)
clst = Clustering(INIFILE, expName, gridName, version, cc)

fsky = 1.

ks = clst.HMF.kh
delta_ks = np.gradient(ks)
zs = clst.HMF.zarr[1:-1]
mus = np.linspace(-1, 1, 9)
deltamu = np.gradient(mus)

ps_bars = clst.fine_ps_bar(mus)

v_effs = clst.V_eff(mus)

noise = np.sqrt(8) * np.pi * np.sqrt(
    1 / (deltamu * v_effs * (ks**2)[..., np.newaxis, np.newaxis] *
Esempio n. 6
0
# If boss, do the fiducial. If odd rank, the minion is doing an "up" job, else doing a "down" job
if rank == 0:
    pass
elif rank % 2 == 1:
    myParam = inParamList[myParamIndex]
    passParams[myParam] = fparams[myParam] + old_div(stepSizes[myParam], 2.)
elif rank % 2 == 0:
    myParam = inParamList[myParamIndex]
    passParams[myParam] = fparams[myParam] - old_div(stepSizes[myParam], 2.)

if rank != 0: print(rank, myParam, fparams[myParam], passParams[myParam])

####FIX THIS

cc = ClusterCosmology(passParams, constDict, clTTFixFile=clttfile)
clst = Clustering(expName, gridName, version, cc)

pbar = clst.fine_ps_bar(mubin_edges)
veff = clst.V_eff(mubin_edges)

fish_fac_err = veff * clst.HMF.kh**2 / pbar**2  # Tegmark 1997

#HMF = Halo_MF(cc,mexp_edges,z_edges)
#HMF.sigN = siggrid.copy()
#SZProf = SZ_Cluster_Model(cc,clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lknee=lknee,alpha=alpha,v3mode=v3mode,fsky=fsky)

#if (YWLcorrflag == 1):
#    dN_dmqz = HMF.N_of_mqz_SZ_corr(lndM*massMultiplier,qbin_edges,SZProf)
#else:
#dN_dmqz = HMF.N_of_mqz_SZ(lndM*massMultiplier,qbin_edges,SZProf)
Esempio n. 7
0
Config.optionxform=str
Config.read(iniFile)
clttfile = Config.get('general','clttfile')
constDict = dict_from_section(Config,'constants')

fparams = {}
for (key, val) in Config.items('params'):
    if ',' in val:
        param, step = val.split(',')
        fparams[key] = float(param)
    else:
        fparams[key] = float(val)

cc = ClusterCosmology(fparams,constDict,clTTFixFile=clttfile)

clst = Clustering(iniFile,expName,gridName,version,cc)
M200temp = np.arange(1,1000,1) * 1e11

print(clst.non_linear_scale(1.95,M200temp))

print()
print(clst.ntilde())
print(clst.b_eff_z())
print(clst.Norm_Sfunc())

zarrs = np.arange(0,4,0.05)
fg = clst.cc.fgrowth(zarrs) #?Is this a calculated growth (as in numerically)?

aarrs = old_div(1.,(1. + zarrs))

g = lambda x: (0.3*(1 + x)**3)**0.55 #?Is this the analytic growth function?
Esempio n. 8
0
def w_v(cc, mu, fsky):
    nbar = cc.ntilde()
    nbar = np.reshape(nbar, (nbar.size, 1))

    ps = cc.ps_bar(mu, fsky)
    npfact = np.multiply(nbar, ps)
    frac = npfact / (1. + npfact)
    return frac


INIFILE = "input/pipeline.ini"

expName = 'S4-1.0-CDT'
gridName = 'grid-owl2'
version = '0.6'
clst = Clustering(INIFILE, expName, gridName, version)

fsky = 1.

ks = clst.HMF.kh
zs = clst.HMF.zarr[1:-1]
mus = np.array([0])

v0s = clst.v0(fsky, 1000)

v_effs = clst.V_eff(mus, fsky, 1000)

plt.plot(zs, v0s, label=r"$V_0$")
plt.plot(zs, v_effs[43, :, :], label=r"$V_{eff}(k\approx 0.001)$")
plt.plot(zs, v_effs[114, :, :], label=r"$V_{eff}(k\approx 0.05)$")
plt.plot(zs, v_effs[127, :, :], label=r"$V_{eff}(k\approx 0.1)$")
Esempio n. 9
0
Config.optionxform = str
Config.read(INIFILE)
clttfile = Config.get('general', 'clttfile')
constDict = dict_from_section(Config, 'constants')

fparams = {}
for (key, val) in Config.items('params'):
    if ',' in val:
        param, step = val.split(',')
        fparams[key] = float(param)
    else:
        fparams[key] = float(val)

cc = ClusterCosmology(fparams, constDict, clTTFixFile=clttfile)

clst = Clustering(INIFILE, expName, gridName, version, cc)


def test_ps_tilde_interpol(cc, paper_plots=False):
    mus = np.linspace(0, 1, 3)
    ks = cc.HMF.kh
    zs = cc.HMF.zarr

    fine_zs = np.linspace(zs[0], zs[-1], 1000)
    ksamp_indices = np.linspace(0, ks.size, 4, dtype=int, endpoint=False)

    try:
        ps_interps = cc.ps_tilde_interpol(fine_zs, mus)
    except Exception as e:
        print("Test of ps_tilde_interpol failed at clustering.tilde_interpol")
        print(e)