def main(argv): if len(sys.argv)!=2: print "usage : %s parfile\n copy input_clik to output_clik, change lmin and lmax of output_clik.\n lmin and lmax can be set to -1 to keep the input_clik values.\n input_clik, must be a plik or commander file.\n if input_clik is a binned plik file, the effective lmin and lmax will be the set to the closest bins.\n Here is an example parfile\n #input and output clik files\n input_clik = plik_dx11dr2_HM_v18_TT.clik\n\n output_clik = plik_dx11dr2_HM_v18_TT_no143x143.clik\n\n #set to -1 to use default value\n #set to anything else to change lmin\n lmin = -1 -1 -1 &\n -1 -1 -1 &\n -1 -1 -1 \n\n \n #set to -1 to use default value\n #set to anything else to change lmax\n #set any non negative value inferior than lmin (0 is a good example) ro remove a cross spectra\n lmax = -1 -1 -1 &\n -1 0 -1 &\n -1 -1 -1 \n\n "%osp.basename(sys.argv[0]) sys.exit(0) pars = clik.miniparse(argv[1]) lklfile = pars.str.input_clik lmin = pars.int_array.lmin lmax = pars.int_array.lmax if "beg_notch" in pars: beg = pars.int_array.beg_notch nd = pars.int_array.end_notch else: beg = [-1]*len(lmin) nd = [-1]*len(lmin) outfile = pars.str.output_clik inhf = hpy.File(lklfile) ty = inhf["clik/lkl_0/lkl_type"] if ty not in ("smica"): print "can only change lmin and lmax for plik likelihoods" sys.exit(-1) assert ty in ["smica"],"Cannot change lrange for likelihood type %s"%ty fnc = globals()["change_%s"%ty] fnc(inhf,lklfile,outfile,lmin,lmax,beg,nd)
def main(argv): pars = clik.miniparse(argv[1]) outhf, lkl_grp = php.copy_and_get_0(pars) php.add_free_calib(lkl_grp, pars.str.parname) php.remove_selfcheck(root_grp=outhf["clik"]) outhf.close()
def main(argv): pars = clik.miniparse(argv[1]) #test_cl = nm.loadtxt(osp.join(pars.wmap_data,"data/v2a1s_best_lcdm_6000.txt")) #mcl = nm.zeros((4,1201),dtype=nm.double) #llp1s2pi = nm.arange(1201)*nm.arange(1,1202)/2./nm.pi #mcl[:,2:] = (test_cl[:1201-2,1:].T)/llp1s2pi[2:] lmin11 = max(2, pars.int(default=1000).lmin11) lmin12 = max(2, pars.int(default=1500).lmin12) lmin22 = max(2, pars.int(default=1500).lmin22) lmax11 = min(10000, pars.int(default=10000).lmax11) lmax12 = min(10000, pars.int(default=10000).lmax12) lmax22 = min(10000, pars.int(default=10000).lmax22) tt_lmax_mc = min(10000, pars.int(default=5000).tt_lmax_mc) lmin = min(2, lmin11, lmin12, lmin22) lmax = min(tt_lmax_mc, max(3300, lmax11, lmax12, lmax22, 10000)) root_grp, hf = php.baseCreateParobject(pars.res_object) hascl = [0] * 6 hascl[0] = 1 hascl = nm.array(hascl, dtype=nm.int) lkl_grp = php.add_lkl_generic(root_grp, "actspt", 1, hascl, lmax, lmin) print("lmin11 = ", lmin11) print("lmin12 = ", lmin12) print("lmin22 = ", lmin22) print("lmax11 = ", lmax11) print("lmax12 = ", lmax12) print("lmax22 = ", lmax22) print("tt_lmax_mc = ", tt_lmax_mc) lkl_grp.attrs["lmin11"] = lmin11 lkl_grp.attrs["lmin12"] = lmin12 lkl_grp.attrs["lmin22"] = lmin22 lkl_grp.attrs["lmax11"] = lmax11 lkl_grp.attrs["lmax12"] = lmax12 lkl_grp.attrs["lmax22"] = lmax22 lkl_grp.attrs["tt_lmax_mc"] = tt_lmax_mc lkl_grp.attrs["use_act_south"] = pars.int(default=1).use_act_south lkl_grp.attrs["use_act_equa"] = pars.int(default=1).use_act_equa lkl_grp.attrs["use_spt_highell"] = pars.int(default=1).use_spt_highell php.add_external_data(osp.realpath(pars.actspt_data), lkl_grp, tar=bool(pars.int(default=1).include)) #lkl_grp.attrs["external_dir"] = osp.realpath(pars.actspt_data) hf.close()
def main(argv): pars = clik.miniparse(argv[1]) cl = nm.loadtxt(pars.initdata) lkl = clik.clik(pars.input_object) offset = nm.sum(nm.array(lkl.lmax) + 1) offset += lkl.extra_parameter_names.index(pars.parameter) ps = nm.linspace(pars.float.beg, pars.float.end, pars.float.step) res = ps * 0. for i, v in enumerate(ps): cl[offset] = v res[i] = lkl(cl) res = nm.array([ps, res]).T res.tofile(pars.res, sep="\n")
def main(argv): pars = clik.miniparse(argv[1]) inhf = hpy.File(pars.input_object) if "external_dir" in inhf["clik/lkl_%d" % pars.int( default=0).lkl_id].attrs and inhf["clik/lkl_%d" % pars.int( default=0).lkl_id].attrs["external_dir"] == ".": import shutil shutil.copytree( pars.input_object + "/clik/lkl_%d/_external" % pars.int(default=0).lkl_id, pars.install_path) else: dts = inhf["clik/lkl_%d/external_data" % pars.int(default=0).lkl_id][:] inhf.close() if not osp.exists(pars.install_path): os.mkdir(pars.install_path) f = open(osp.join(pars.install_path, "data.tar"), "w") f.write(dts.tostring()) f.close() assert os.system("cd %s;tar xvf data.tar" % pars.install_path) == 0 assert os.system("cd %s;rm -f data.tar" % pars.install_path) == 0 if "res_object" in pars: hpy.copyfile(pars.input_object, pars.res_object) outhf = hpy.File(pars.res_object, "r+") try: del outhf["clik/lkl_%d/external_data" % pars.int(default=0).lkl_id] except Exception as e: pass try: rmtree(pars.input_object + "/clik/lkl_%d/_external" % pars.int(default=0).lkl_id) except Exception as e: pass outhf["clik/lkl_%d" % pars.int( default=0).lkl_id].attrs["external_dir"] = pars.install_path outhf.close()
def main(argv): pars = clik.miniparse(argv[1]) try: test_cl = nm.loadtxt(osp.join(pars.wmap_data, "data/test_cls_v4.dat")) except IOError as e: test_cl = nm.loadtxt(osp.join(pars.wmap_data, "data/test_cls_v5.dat")) mcl = nm.zeros((4, 1201), dtype=nm.double) llp1s2pi = nm.arange(1201) * nm.arange(1, 1202) / 2. / nm.pi mcl[:, 2:] = (test_cl[:1201 - 2, 1:5].T) / llp1s2pi[2:] ttmin = max(2, pars.int.ttmin) ttmax = min(1200, pars.int.ttmax) temin = max(2, pars.int.temin) temax = min(800, pars.int.temax) has_tt = True has_te = True if pars.int.ttmin > pars.int.ttmax: ttmin = 1201 ttmax = 2 has_tt = False if pars.int.temin > pars.int.temax: temin = 801 temax = 2 has_te = False # print has_tt,has_te,ttmin,ttmax,temin,temax root_grp, hf = php.baseCreateParobject(pars.res_object) hascl = [0] * 6 hascl[0] = has_tt hascl[1:4] = [has_te] * 3 hascl = nm.array(hascl, dtype=nm.int) # print hascl lmin = 0 lmax = min(1200, max(pars.int.ttmax, pars.int.temax)) mcl = (nm.compress(hascl[:4], mcl[:, :lmax + 1], 0)).flat[:] lkl_grp = php.add_lkl_generic(root_grp, "wmap", 1, hascl, lmax, lmin) lkl_grp.attrs["ttmin"] = ttmin lkl_grp.attrs["temin"] = temin lkl_grp.attrs["ttmax"] = ttmax lkl_grp.attrs["temax"] = temax lkl_grp.attrs["use_gibbs"] = pars.int.use_gibbs lkl_grp.attrs["use_lowl_pol"] = pars.int.use_lowl_pol #lkl_grp.attrs["external_dir"] = osp.realpath(pars.wmap_data) php.add_external_data(osp.realpath(pars.wmap_data), lkl_grp, tar=bool(pars.int(default=1).include)) hf.close() if hasattr(clik, "clik"): res = php.add_selfcheck(pars.res_object, mcl) print("lkl for init cl %g" % res) if "cl_save" in pars: f = open(pars.cl_save, "w") for ci in mcl: print(ci, file=f) f.close()
def main(argv): pars = clik.miniparse(argv[1]) try: test_cl = nm.loadtxt(osp.join(pars.wmap_data,"data/test_cls_v4.dat")) except IOError,e: test_cl = nm.loadtxt(osp.join(pars.wmap_data,"data/test_cls_v5.dat"))