-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_runs.py
More file actions
64 lines (52 loc) · 1.85 KB
/
Copy pathcreate_runs.py
File metadata and controls
64 lines (52 loc) · 1.85 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
64
import numpy as np
import os
from glob import glob
import subprocess
def create_directories(dirname):
dataout,dataerr=subprocess.Popen([r"mkdir","-p",dirname],stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
print "creating directory:", dirname
print dataout, dataerr
def copy_files(sourcename, destname):
dataout,dataerr=subprocess.Popen([r"cp",sourcename,destname],stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
print 'copying file:', sourcename, destname
print dataout, dataerr
def modify_input(sourcename, destname, SIGMAFRAC=1.):
writefile = open(destname, 'w')
with open(sourcename, 'r') as f:
for line in f:
if line.rfind('BHSIGMAFRAC')>-1:
writefile.write("BSE_BHSIGMAFRAC=%g\n" %(SIGMAFRAC))
else:
writefile.write("%s" %(line))
writefile.close()
def modify_submit(sourcename, destname, SIGMAFRAC=1.):
writefile = open(destname, 'w')
with open(sourcename, 'r') as f:
for line in f:
if line.rfind("-N n2w5")>-1:
writefile.write("#MSUB -N n8w5r2k%g\n" %(SIGMAFRAC))
else:
writefile.write("%s" %(line))
writefile.close()
#kicks = [0.01, 0.05, 0.1, 0.2, 0.4, 0.6, 0.8, 1.]
kicks = [0.005, 0.02, 0.03, 0.04, 0.06, 0.07, 0.08, 0.09,]
basename = '/projects/b1011/sourav/new_runs/kick_grid'
fitsfilename = 'input_n8e5_f5_m0.08_150_w5_rg8.fits'
exfilename = 'cmc'
inputfilename = 'input.cmc'
submitfilename = 'submit_job.sh'
for i in range(len(kicks)):
dirname = basename+'/kickscale_'+str(kicks[i])
create_directories(dirname)
src = basename+'/'+fitsfilename
dest = dirname+'/'+fitsfilename
copy_files(src, dest)
src = basename+'/'+exfilename
dest = dirname+'/'+exfilename
copy_files(src,dest)
src = basename+'/'+inputfilename
dest = dirname+'/'+inputfilename
modify_input(src, dest,kicks[i])
src = basename+'/'+submitfilename
dest = dirname+'/'+submitfilename
modify_submit(src, dest,kicks[i])