cleanupSwift.py 690 Bytes
Newer Older
Loic Hausammann's avatar
Loic Hausammann committed
1
#!/usr/bin/env python3
lhausamm's avatar
lhausamm committed
2

Loic Hausammann's avatar
Loic Hausammann committed
3
# ./translate_particles.py filename output_name
lhausamm's avatar
lhausamm committed
4
5
from h5py import File
import sys
Loic Hausammann's avatar
Loic Hausammann committed
6
from shutil import copyfile
lhausamm's avatar
lhausamm committed
7
8

NPartType = 1
Loic Hausammann's avatar
Loic Hausammann committed
9
10
11
12
13
14
filename = sys.argv[-2]
out = sys.argv[-1]

copyfile(filename, out)

f = File(out)
lhausamm's avatar
lhausamm committed
15

Loic Hausammann's avatar
Loic Hausammann committed
16
17
18
19
for i in range(6):
    name = "PartType{}/ElementAbundance".format(i)
    if name in f:
        del f[name]
20

lhausamm's avatar
lhausamm committed
21
22
23
24
25
26
27
28
for i in range(NPartType):
    name = "PartType%i" % i
    if name not in f:
        continue

    grp = f[name + "/SmoothingLength"]
    grp[:] *= 1.823

Loic Hausammann's avatar
Loic Hausammann committed
29
30
31
32
33
34
cosmo = f["Cosmology"].attrs
head = f["Header"].attrs
head["OmegaLambda"] = cosmo["Omega_lambda"]
head["Omega0"] = cosmo["Omega_b"]
head["HubbleParam"] = cosmo["H0 [internal units]"]

lhausamm's avatar
lhausamm committed
35
f.close()