-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.py
67 lines (55 loc) · 1.39 KB
/
converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Program to convert the SNANA format HD outputs to cosmoMC HD format
# Ayan Mitra @ 2022
import sys
import pandas as pd
import numpy as np
col = [
"#name",
"zcmb",
"zhel",
"dz",
"mb",
"dmb",
"x1",
"dx1",
"color",
"dcolor",
"3rdvar",
"d3rdvar",
"cov_m_s",
"cov_m_c",
"cov_s_c",
"set",
"ra",
"dec",
"biascor",
]
input = sys.argv[1]
# /scratch/midway2/rkessler/PIPPIN_OUTPUT/PLASTICC_COMBINED/7_CREATE_COV/LSST_BINNED_COV_BBC_SIMDATA_PHOTOZ_11/output/hubble_diagram.txt
h = pd.read_csv(input, sep="\s+", comment="#")
h = h.iloc[:, 1:-1]
h.MU -= 19.36 # (h.MU[0]-d.mb[0])
h.insert(3, "dz", np.zeros(np.shape(h)[0]))
row = np.shape(h)[0]
# (np.zeros(np.shape(h)[0]))
colu = 13
# np.shape(d)[1] - np.shape(h)[1]
# join = pd.DataFrame(np.array([row,colu]))
join = np.zeros((row, colu))
hh = pd.DataFrame(np.concatenate([h, join], axis=1))
hh.columns = col
h = hh
h["#name"] = np.linspace(0, np.shape(h)[0] - 1, np.shape(h)[0]).astype(int)
h.to_csv("data.txt", sep=" ", index=None)
def conversion(h):
h = h.iloc[:, 1:-1]
h.MU -= 19.36
h.insert(3, "dz", np.zeros(np.shape(h)[0]))
row = np.shape(h)[0]
colu = 13
join = np.zeros((row, colu))
hh = pd.DataFrame(np.concatenate([h, join], axis=1))
hh.columns = col
h = hh
h["#name"] = np.linspace(0, np.shape(h)[0] - 1, np.shape(h)[0]).astype(int)
return h