-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexe.py
More file actions
63 lines (48 loc) · 1.7 KB
/
exe.py
File metadata and controls
63 lines (48 loc) · 1.7 KB
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
import os
import subprocess
import time
import argparse
"""
Given overdensity evolution deltalin0 and redshfit z,
it will generate corresponding Landau damping rate caused by electron cosmic rays
with k range from 0.995 to 5 times omega_p/c
"""
def create_directory(path):
if not os.path.exists(path):
os.makedirs(path)
def main(args):
time_start = time.time()
z = args.z
deltalin0 = args.deltalin0
timestr = time.strftime("%Y%m%d-%H%M%S")
PATH = f'./results/redshift{z}_density{deltalin0}_{timestr}'
create_directory(PATH)
if not os.path.exists('source_term_Khaire.txt'):
# Run get_source.py
print('executing get_source.py...')
subprocess.run(['python', 'get_source.py'], check=True)
print('finished!')
# Run IGM.py with specified arguments
print('executing IGM.py')
subprocess.run([
'python', 'IGM.py',
'--deltalin0', str(deltalin0),
'--savePATH', PATH
], check=True)
print('finished!')
# Run damp_rate.py with specified arguments
print('executing damp_rate.py')
subprocess.run([
'python', 'damp_rate.py',
'--deltalin0', str(deltalin0),
'--z', str(z),
'--savePATH', PATH,
'--readPATH', PATH
], check=True)
print(f'All process finished! The whole process takes {(time.time-time_start)/60} minutes')
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--deltalin0', type=float, help='overdensity evolution, 0 for mean density, > 0 for overdensity, and < 0 for underdensity', default=0)
parser.add_argument('--z', type=float, help='desired redshift', default=2)
args = parser.parse_args()
main(args)